Keystate Help
#1

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
Reply
#2

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);
    }
            }
Reply
#3

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
Reply
#4

i have already given it :P
Reply
#5

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

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

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

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;
Reply
#9

Thanks, you two are really best
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)