SA-MP Forums Archive
Enable/Disable megajump - 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: Enable/Disable megajump (/showthread.php?tid=336099)



Enable/Disable megajump - newbienoob - 21.04.2012

Hi all. I've created a megajump command. But I don't know how to enable or disable it. Like if someone type /mjump, he will enable/disable megajump.
Here's the code

pawn Код:
OnPlayerKeyStateChange

    if(PRESSED(KEY_JUMP))
    {
    new Float:P[3];
    GetPlayerPos(playerid,P[0],P[1],P[2]);
    GetPlayerVelocity(playerid,P[0],P[1],P[2]);
    SetPlayerVelocity(playerid,P[0],P[1],P[2]+5.0);
    }

zcmd

    new Float:P[3];
    GetPlayerPos(playerid,P[0],P[1],P[2]);
    GetPlayerVelocity(playerid,P[0],P[1],P[2]);
    SetPlayerVelocity(playerid,P[0],P[1],P[2]+5.0);
    return 1;



Re: Enable/Disable megajump - RollTi - 21.04.2012

use a global variable

something like

pawn Код:
new MegaJump[MAX_PLAYERS];
pawn Код:
CMD:megajump(playerid, params[])
{
    if(MegaJump[playerid] == 0)
    {
         new Float:P[3];
         GetPlayerPos(playerid,P[0],P[1],P[2]);
         GetPlayerVelocity(playerid,P[0],P[1],P[2]);
         SetPlayerVelocity(playerid,P[0],P[1],P[2]+5.0);
         MegaJump[playerid] = 1;
    } else if(MegaJump[playerid] == 1) {
         MegaJump[playerid] = 0;
    }
    return 1;
}

    if(PRESSED(KEY_JUMP))
    {
         if(MegaJump[playerid] == 0) return 0;
         new Float:P[3];
         GetPlayerPos(playerid,P[0],P[1],P[2]);
         GetPlayerVelocity(playerid,P[0],P[1],P[2]);
         SetPlayerVelocity(playerid,P[0],P[1],P[2]+5.0);
    }
Not sure if it works