SA-MP Forums Archive
Keystate Help - 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: Keystate Help (/showthread.php?tid=398354)



Keystate Help - zohartrejx - 09.12.2012

Hello

I Have one keystate, which makes super jump on foot. How can i make it like so i need to type first /EnableKeystate then i can super jump?
pawn Код:
if (PRESSED(KEY_JUMP))
    {
        new
            Float:x,
            Float:y,
            Float:z;
        GetPlayerPos(playerid, x, y, z);
        SetPlayerPos(playerid, x, y, z + 5.0);
            }
Thats how i have it!
I Rep every comment


Re: Keystate Help - [HK]Ryder[AN] - 09.12.2012

top of script
pawn Код:
new wannajump[MAX_PLAYERS];
the command(i am assuming you are using ZCMD, i can change that later if you want)
pawn Код:
CMD:togglekeystate(playerid, params[])
{
    if(wannajump[playerid] == 0)
    {
        wannajump[playerid] = 1;
    }
    else if(wannajump[playerid] == 1)
    {
        wannajump[playerid] = 0;
    }
    return 1;
}
In the keystate
pawn Код:
if (PRESSED(KEY_JUMP))
    {
     if(wannajump[playerid] == 1) {
        new
            Float:x,
            Float:y,
            Float:z;
        GetPlayerPos(playerid, x, y, z);
        SetPlayerPos(playerid, x, y, z + 5.0);
    }
            }



Re: Keystate Help - RenovanZ - 09.12.2012

Try This
pawn Код:
new EnabledKey[MAX_PLAYERS]; //Add this on top your script
And Use this:
pawn Код:
if (PRESSED(KEY_JUMP))
    {
        if(EnabledKey[playerid] == 1)
        {
            new
                Float:x,
                Float:y,
                Float:z;
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x, y, z + 5.0);
        }
                    }
And the command
pawn Код:
CMD:enabledkey(playerid, params[])
{
    if(EnabledKey[playerid] == 0)
    {
        EnabledKey[playerid] = 1;
    }
    else if(EnabledKey[playerid] == 1)
    {
        EnabledKey[playerid] = 0;
    }
    return 1;
}
Just Try


Re: Keystate Help - [HK]Ryder[AN] - 09.12.2012

i have already given it :P


Re: Keystate Help - RenovanZ - 09.12.2012

Look at the time, it's just a few sec, ahaha


Re: Keystate Help - zohartrejx - 09.12.2012

Both thanks! I'll be using both (at more cmds)! Repped both !


Re: Keystate Help - zohartrejx - 09.12.2012

One question, can you guys give me cmd in normal? not with DCMD/SSCANF or whats called :S?


Re: Keystate Help - RenovanZ - 09.12.2012

Add this under the OnPlayerTextCommand
pawn Код:
if(!strcmp(cmdtext, "/enabledkeys"))
    {
        if(EnabledKeys[playerid] == 0)
        {
            EnabledKeys[playerid] = 1;
        }
        else if(EnabledKeys[playerid] == 1)
        {
            EnabledKeys[playerid] = 0;
        }
        return 1;
    }
    return 0;



Re: Keystate Help - zohartrejx - 09.12.2012

Thanks, you two are really best


Re: Keystate Help - zohartrejx - 09.12.2012

I Did all what you guys said, but now i get errors

pawn Код:
D:\Server\gamemodes\BSJ.pwn(1831) : warning 217: loose indentation
D:\Server\gamemodes\BSJ.pwn(2414) : error 017: undefined symbol "EnabledKeys"
D:\Server\gamemodes\BSJ.pwn(2414) : warning 215: expression has no effect
D:\Server\gamemodes\BSJ.pwn(2414) : error 001: expected token: ";", but found "]"
D:\Server\gamemodes\BSJ.pwn(2414) : error 029: invalid expression, assumed zero
D:\Server\gamemodes\BSJ.pwn(2414) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.