SA-MP Forums Archive
Requesting help regarding simple gate - 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)
+--- Thread: Requesting help regarding simple gate (/showthread.php?tid=458670)



Requesting help regarding simple gate - Arg - 17.08.2013

I am looking for assistance on how to script a gate (I am an somewhat unfamiliar with scripting but trying to learn) which opens and closes with the same command - for example - /gate to open AND /gate to close. I have managed to learn enough to get gates to work with an open and close command but I have seen gate toggles with only one command on servers and I want to learn the method.

If anyone is willing to assist me I would appreciate it a lot. Thanks.


AW: Requesting help regarding simple gate - Nero_3D - 18.08.2013

It isn't complicated, they just used a flag to see if the gate is opened or closed and executed the right code
pawn Код:
if(strcmp(cmdtext, "/gate", true) == 0) {
    static // local static variables hold their value after the function finished
        bool: gateOpened = false
    ;
    if(gateOpened) {
        // if its opened execute the closing code
        gateOpened = false;
    } else {
        // if it isn't opend execute the opening code
        gateOpened = true;
    }
}



Re: Requesting help regarding simple gate - Arg - 18.08.2013

Thank you Nero_3D.