need some help.. - 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: need some help.. (
/showthread.php?tid=85302)
need some help.. -
Virtual1ty - 06.07.2009
i have this bit of code :
Код:
public FallingChecker()
{
new Float:x,Float:y,Float:z,Float:d;
for(new i =0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(i,x,y,z);
d = floatsqroot((x-LastX[i] * x-LastX[i]) + (y-LastY[i] * y-LastY[i]));
if(d < 10 && (LastZ[i] - z) > 5)
{
OnPlayerFall(i);
}
LastX[i] = x;
LastY[i] = y;
LastZ[i] = z;
}
}
return 1;
}
public OnPlayerFall(playerid)
{
SendClientMessage(playerid,0x000000FF,"You are falling! A parachute has been equipped.");
SendClientMessage(playerid,0x000000FF,"Open your parachute NOW!!!");
GivePlayerWeapon(playerid,46,1);
return 1;
}
the problem is: i dont get a parachute whilst im in air and the messages dont appear at all.. so please if you could help me , and explain allitle more on how to exactly do this
Re: need some help.. -
yom - 06.07.2009
Do you run a timer for FallingChecker() ?
Re: need some help.. -
Virtual1ty - 06.07.2009
no , no timer , do i have to?
Re: need some help.. -
yom - 06.07.2009
Obviously.
Put under OnGameModeInit:
pawn Код:
SetTimer("FallingChecker", 500, true);
Note that 500 may not be the correct delay for your calculation (if(d < 10 && (LastZ[ i] - z) > 5)). I mean, if you set the delay to 10 milliseconds, the player won't fall 5 units during this time and thus your code will not work.
Re: need some help.. -
Virtual1ty - 06.07.2009
yep but its not my code its backwards man , anyway il give it a try
Re: need some help.. -
Virtual1ty - 07.07.2009
Yep its working PERFECTLY, thanks a MIL man !!