PDA

View Full Version : Helper Script



GhettoTrucker
10-05-2006, 05:32 PM
OK, so using the new comands "disable" i made a quick little scipt thing that you can just paste onto the top of your script. I think i may have added a few extra "{}"'s and "return"'s. So do help me modify it! ...please.

How to use it:
Once run it will prompt you to set values for int(s). If you place the value of it at "1" it will dissable the said action. (ie. define int eat. 1. disable eat)



void main(int eat, int use, int buy, int drink)
{
if(eat = 1)
{
cli_execute("disable eat");
return;
}
if(use = 1)
{
cli_execute("disable use");
return;
}
if(buy = 1)
cli_execute("disable buy");
return;
}
if(drink = 1)
{
cli_execute("disable drink");
return;
}
}

Have fun![hr]I keep getting an error that states

")" expected at line 3.

Or something of the sort. Any ideas?

Also is it possible to define variables with letters? (ie. "y" and "n")

Also i modified the code to


void main(int eat, int use, int buy, int drink)
{
if( eat => 0 );
{
cli_execute("disable eat");
}
if( use => 0 );
{
cli_execute("disable use");
}
if( buy => 1 );
cli_execute("disable buy");
}
if( drink => 1 );
{
cli_execute("disable drink");
return;
}
}

holatuwol
10-05-2006, 07:45 PM
Remove the semicolons after the if ( )

GhettoTrucker
10-05-2006, 08:22 PM
void main(int eat, int use, int buy, int drink)
{
if( eat => 0 )
{
cli_execute("disable eat");
}
if( use => 0 )
{
cli_execute("disable use");
}
if( buy => 1 )
cli_execute("disable buy");
}
if( drink => 1 )
{
cli_execute("disable drink");
return;
}
}

Better?

Nightmist
10-06-2006, 12:44 AM
You sort of need to use "==" when your trying to use a "=" (Debug says it expects a ")" but its really since "=" doesn't actually work.)

And when your using "=> 0", that means we need to insert a negative number to not disable it? Why not make it also "=> 1" so its just a simple 0 to keep it enabled?

PS. Your missing a "{" after the if buy.

GhettoTrucker
10-06-2006, 12:51 AM
void main(int eat, int use, int buy, int drink)
{
if( eat == 0 )
{
cli_execute("disable eat");
}
if( use == 0 )
{
cli_execute("disable use");
}
if( buy == 1 )
{
cli_execute("disable buy");
}
if( drink == 1 )
{
cli_execute("disable drink");
return;
}
}

Better now?

Nightmist
10-06-2006, 12:57 AM
If your going to use == then change the number to needs to equal to the same for each disable. Easier to remember "All 1 to disable all and all 0 to enable" rather than "The first 2 are 0 to disable and then the next 2 are 1 to disable".

GhettoTrucker
10-06-2006, 01:05 AM
void main(int eat, int use, int buy, int drink)
{
if( eat == 0 )
{
cli_execute("disable eat");
else
cli_execute("enable eat");
}
if( use == 0 )
{
cli_execute("disable use");
else
cli_execute("enable use");
}
if( buy == 0 )
{
cli_execute("disable buy");
else
cli_execute("enable buy");
}
if( drink == 0 )
{
cli_execute("disable drink");
else
cli_execute("enable drink");
return;
}
}

Now?

This time it is setup to if it =0 it is disabled if it is anything else it is enabled!

Nightmist
10-06-2006, 01:16 AM
If your going to use "else" while using "{" and "}"

if( condition)
{
}
else
{
}

Edit: But if your sticking it in void main, doesn't that make it automatically assume enabled unless told otherwise? Or do the disable settings carry on even after the scripts ended?

GhettoTrucker
10-06-2006, 01:44 AM
I'm not sure i'm understanding what you are saying...how would you go about making this work?

Nightmist
10-06-2006, 02:29 AM
Uhh in the last example, by your "else" stick a "}" before it and a "{" after it.

PS. Whats the return for? (in the drink one)

GhettoTrucker
10-06-2006, 03:58 AM
NOW? ;D



void main(int eat, int use, int buy, int drink)
{
if( eat == 0 )
{
cli_execute("disable eat");
}
else
{
cli_execute("enable eat");
}
if( use == 0 )
{
cli_execute("disable use");
}
else
{
cli_execute("enable use");
}
if( buy == 0 )
{
cli_execute("disable buy");
}
else
{
cli_execute("enable buy");
}
if( drink == 0 )
{
cli_execute("disable drink");
}
else
{
cli_execute("enable drink");
}
}

efilnikufecin
10-06-2006, 04:01 AM
You got it.

It does make me wonder though will the settings remain after the script ends?

GhettoTrucker
10-06-2006, 11:35 PM
Not sure... I think that the settings stay until the session is closed (just like if you manually type into the gCli disable ___)

Nightmist
10-07-2006, 12:16 AM
Hmm true if it can be used directly from the GCLI it's probably session based (I doubt it would be "permanent setting until enabled manually" since that would end up with a heap of bug reports saying "x function" isn't working when they happened to disable it a few days ago and forgot... but then thats just a guess.)

GhettoTrucker
10-07-2006, 12:19 AM
Yeah... I think that option stays until you a) log out or b)close window