Toggle commands - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Toggle commands (
/showthread.php?tid=112982)
Toggle commands -
[XST]O_x - 11.12.2009
Hey.
I'm in the middle of my script making,and i was wondering...
Is it possible to toggle commands?
For example if i type /Elevator once it goes upstairs on and then i type /Elevator again and it gets downstairs..
Re: Toggle commands -
DeathOnaStick - 11.12.2009
Top of script:
pawn Код:
new bool:IsElevatorUp=true;
(if its up, when gamemode starts. Else just turn the true into false)
Elevator command:
pawn Код:
//.......
{
if(IsElevatorUp==false)
{
//....MoveObjectUp.... lol XD
IsElevatorUp=true;
}
else
{
//....MoveObjectDown :P
IsElevatorUp=false;
}
}
Is it like you want it?!
#edit#: fixed
Cheers.
Re: Toggle commands -
Zamaroht - 11.12.2009
Actually, the variable declaration (new bool:IsElevatorUp=true) has to be done at the top of the script, outside any callback, and the return mustn't be written.
Re: Toggle commands -
[XST]O_x - 11.12.2009
Quote:
Originally Posted by DeathOnaStick
Top of script:
pawn Код:
new bool:IsElevatorUp=true;
(if its up, when gamemode starts. Else just turn the true into false)
Elevator command:
pawn Код:
//....... { if(IsElevatorUp==false) { //....MoveObjectUp.... lol XD IsElevatorUp=true; } else { //....MoveObjectDown :P IsElevatorUp=false; } }
Is it like you want it?!
#edit#: fixed
Cheers.
|
Thanks for helping