please help me with jump - 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: please help me with jump (
/showthread.php?tid=575185)
please help me with jump -
Barnwell - 24.05.2015
Hello All i want to set when the player jump no -hp plesae how
+ rep who is help me
Re : please help me with jump -
KillerDVX - 24.05.2015
All what i can advice you, is to set player health into 99999 Once he connects.
Re: please help me with jump -
Gammix - 25.05.2015
Pretty simple using a timer whenever the player presses the JUMP key.
NOTE, the timer interval must be set accordingly. I prefer a 2 seconds timer but each jump differs.
pawn Код:
new nohptimer[MAX_PLAYERS] = -1;
public OnPlayerConnect(playerid)
{
nohptimer[playerid] = -1;
return 1;
}
forward OnPlayerReachGround(playerid, Float:health);
public OnPlayerReachGround(playerid, Float:health)
{
nohptimer[playerid] = -1;
SetPlayerHealth(playerid, health);
return 1;
}
//just to make sure player updating and taking damage is not effected by the timer
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
nohptimer[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
nohptimer[playerid] = -1;
return 1;
}
public OnPlayerSpawn(playerid)
{
if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
nohptimer[playerid] = -1;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
nohptimer[playerid] = -1;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_JUMP)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(nohptimer[playerid] != -1) KillTimer(nohptimer[playerid]);
nohptimer[playerid] = SetTimerEx("OnPlayerReachGround", 2 * 1000, false, "if", playerid, health);
}
return 1;
}
Those extra checks done in the callbacks are there so that no player updating is affected by the timer.