Can anyone help me? please.
#1

Hey guys i'm trying to make it work but it won't work
it's superjump
here's the code
pawn Код:
new
    SuperJumpEnabled[MAX_PLAYERS],
    Float:pX,
    Float:pY,
    Float:pZ,
    IsJumping[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP && IsJumping[playerid])
    {
        IsJumping[playerid] = 0;
        GetPlayerVelocity(playerid, pX, pY, pZ);
        SetPlayerVelocity(playerid, pX, pY, pZ +0.4);
    }
    return 1;
}
and you have to activate it first so you can use it.. here's the code to activate
pawn Код:
command(jump, playerid, params[])
{
    if(SuperJumpEnabled[playerid] == 0)
    {
    SuperJumpEnabled[playerid] = 1;
    SendClientMessage(playerid, COLOR_USE, "Super Jump is now enabled.");
    }
    else if(SuperJumpEnabled[playerid] == 1)
    {
    SuperJumpEnabled[playerid] = 0;
    SendClientMessage(playerid, COLOR_USE, "Super Jump is now Disabled");
    }
    return 1;
}
No errors or anything but in game when i enable /jump and press jump key it don't jumps high it's like old jump can anyone help me figure the problem out?
Reply
#2

Comeon guys... 4 Days and no help? O.o please?
Reply
#3

You were checking for "IsJumping" (under OnPlayerKeyStateChange), instead of "SuperJumpEnabled" (command)

pawn Код:
new
    SuperJumpEnabled[MAX_PLAYERS],
    Float:pX,
    Float:pY,
    Float:pZ;

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_JUMP && SuperJumpingEnabled[playerid] == 1)
    {
        SuperJumpingEnabled[playerid] = 0;
        GetPlayerVelocity(playerid, pX, pY, pZ);
        SetPlayerVelocity(playerid, pX, pY, pZ +0.4);
    }
    return 1;
}
Reply
#4

thanks but after every jump it(SuperJumpEnabled) set's to 0 again... and we have to /jump again to set it enabled... how can i fix it?
pawn Код:
command(jump, playerid, params[])
{
    if(SuperJumpEnabled[playerid] == 0)
    {
        SuperJumpEnabled[playerid] = 1;
        SendClientMessage(playerid, -1, "Super Jump is now enabled.");
    }
    else
    {
        SuperJumpEnabled[playerid] = 0;
        SendClientMessage(playerid, -1, "Super jump is now disabled.");
    }
    return 1;
}
pawn Код:
new
    SuperJumpEnabled[MAX_PLAYERS], // you had a ; here, which is wrong, unless if you want to define just one variable, here you are defining 5 variables (so if you use ;, then you need to type "new (var)" again.
    Float:pX,
    Float:pY,
    Float:pZ,
    IsJumping[MAX_PLAYERS];

forward ResetJumping(playerid);
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(SuperJumpEnabled[playerid] == 1)
    {
        if(newkeys == KEY_JUMP && SuperJumpEnabled[playerid] == 1)
        {
            SuperJumpEnabled[playerid] = 0;
            GetPlayerVelocity(playerid, pX, pY, pZ);
            SetPlayerVelocity(playerid, pX,pY, pZ+5);
            SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
        }

    }
    return 1;
}

public ResetJumping(playerid)
{
    IsJumping[playerid] = 0;
    return true;
}
Reply
#5

pawn Код:
if(SuperJumpEnabled[playerid] == 1)
    {
        if(newkeys == KEY_JUMP && SuperJumpEnabled[playerid] == 1)
        {
            SuperJumpEnabled[playerid] = 0;
            GetPlayerVelocity(playerid, pX, pY, pZ);
            SetPlayerVelocity(playerid, pX,pY, pZ+5);
            SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
        }

    }
should be

pawn Код:
if(newkeys & KEY_JUMP && SuperJumpEnabled[playerid])
{
    SuperJumpEnabled[playerid] = 0;
    GetPlayerVelocity(playerid, pX, pY, pZ);
    SetPlayerVelocity(playerid, pX,pY, pZ+5);
    SetTimerEx("ResetJumping", 2500, false, "d" , playerid);
}
Reply
#6

When i press Jump_Key it jumps but when i do it again and again it does again and again. the timer is not working i guess..
pawn Код:
new
    SuperJumpEnabled[MAX_PLAYERS],
    Float:pX,
    Float:pY,
    Float:pZ,
    IsJumping[MAX_PLAYERS];

forward ResetJumping(playerid);
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(SuperJumpEnabled[playerid] == 1)
    {
        if(newkeys & KEY_JUMP && SuperJumpEnabled[playerid])
        {
            SuperJumpEnabled[playerid] = 1;
            GetPlayerVelocity(playerid, pX, pY, pZ);
            SetPlayerVelocity(playerid, pX,pY, pZ+0.5);
            SetTimerEx("ResetJumping", 2500, true, "d" , playerid);
        }
        return 1;
    }
    return 0;
}

public ResetJumping(playerid)
{
    IsJumping[playerid] = 1;
    return true;
}
Reply
#7

You check for SuperJumpEnabled twice, I suggest removing one of the checks. In your timer, you should be setting SuperJumpEnabled[playerid] to 1.
Reply
#8

pawn Код:
new
    SuperJumpEnabled[MAX_PLAYERS],
    Float:pX,
    Float:pY,
    Float:pZ,
    IsJumping[MAX_PLAYERS];

forward ResetJumping(playerid);
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(SuperJumpEnabled[playerid] == 1)
    {
        if(newkeys & KEY_JUMP && SuperJumpEnabled[playerid])
        {
            GetPlayerVelocity(playerid, pX, pY, pZ);
            SetPlayerVelocity(playerid, pX,pY, pZ+0.5);
            SendClientMessage(playerid, COLOR_USE, "Super Jump De-Acticated");
            SetTimerEx("ResetJumping", 2500, true, "d" , playerid);
        }
        return 1;
    }
    return 0;
}
Still it jumps again and again when you press Jump_Key twice or more
Reply
#9

Put

pawn Код:
SuperJumpEnabled[playerid] = 0;
before setting the timer. Remove

pawn Код:
if(SuperJumpEnabled[playerid] == 1)
{
and the closing bracket for it.

I need to leave right now so if you need more help, just private message me.
Reply
#10

i don't understand... can you give me the full code?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)