SA-MP Forums Archive
Help with my anti bunny jump script - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with my anti bunny jump script (/showthread.php?tid=179787)



Help with my anti bunny jump script - JulietaZ - 28.09.2010

I just maded up this thing to prevent ppl jumping all the time (a bit from scratch and a bit modifying other's scripts)

If u jump more than 3 times in 4.5 seconds it plays a "tired" animation.... it works perfectly, but only if you are ID= 0, ot herwise it ALLWAYS forces the animation whenever you jump, and also the animation never stops...its like the playerdata is not changing for other players, only for player 1...Anyone could help? D=...ALso if this script get fixed would be useful for anyone =O

public OnFilterScriptInit()
{
SetTimer("saltitos",4500,1);
}

enum PlayerData
{
saltos,
}

forward saltitos(playerid);
public saltitos(playerid)
{
if (PlayerInfo[playerid][saltos] <= 0)
{
ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
}
PlayerInfo[playerid][saltos] = 2;
return 1;
}


public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][saltos] = 2;
IsKeyJustDown(key, newkeys, oldkeys)
{
if((newkeys & key) && !(oldkeys & key)) return 1;
return 0;
}
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
if(IsKeyJustDown(KEY_JUMP,newkeys,oldkeys))
{

if(PlayerInfo[playerid][saltos] >= 0)
{
PlayerInfo[playerid][saltos] = PlayerInfo[playerid][saltos] -1;
}

if( PlayerInfo[playerid][saltos] <= 0)
{
ApplyAnimation(playerid,"PED","IDLE_tired",4.0,1,0 ,0,1,5500);
}
}
}


Re: Help with my anti bunny jump script - Zamaroht - 28.09.2010

The problem is that you aren't defining what playerid is in the saltitos function, because you can't send any parameter by using SetTimer(). You would need to use SetTimerEx(), but you don't have any playerid in OnFilterScriptInit.

Therefore, the best option I think is looping trough all the players in saltitos.
Something like this should do:

pawn Код:
forward saltitos();
public saltitos()
{
    for(new i; i < MAX_PLAYERS; i ++) if(IsPlayerConnected(i))
    {
        if (PlayerInfo[i][saltos] <= 0)
        {
            ApplyAnimation(i, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
        }
        PlayerInfo[i][saltos] = 2;
    }

    return 1;
}



Re: Help with my anti bunny jump script - JulietaZ - 28.09.2010

it worked thanks =DDD!!