SA-MP Forums Archive
Can anyone help me? please. - 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: Can anyone help me? please. (/showthread.php?tid=337211)



Can anyone help me? please. - Rudy_ - 25.04.2012

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?


Re: Can anyone help me? please. - Rudy_ - 25.04.2012

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


Re: Can anyone help me? please. - Pinguinn - 25.04.2012

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;
}



Re: Can anyone help me? please. - Rudy_ - 25.04.2012

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;
}



Re: Can anyone help me? please. - SuperViper - 25.04.2012

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);
}



Re: Can anyone help me? please. - Rudy_ - 25.04.2012

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;
}



Re: Can anyone help me? please. - SuperViper - 25.04.2012

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


Re: Can anyone help me? please. - Rudy_ - 25.04.2012

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


Re: Can anyone help me? please. - SuperViper - 25.04.2012

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.


Re: Can anyone help me? please. - Rudy_ - 25.04.2012

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