18.04.2009, 18:52
Actually I just made this real quick and tested it. It seems to work fine.
Obviously not 100% accurate but it gets the job done. :P It works by seeing if the player has moved less then 10 units and fallen more then 5. You can change those values.
pawn Code:
forward FallingChecker();
forward OnPlayerFall(playerid);
new Float:LastX[MAX_PLAYERS],Float:LastY[MAX_PLAYERS],Float:LastZ[MAX_PLAYERS];
//OnGameModeInit
SetTimer("FallingChecker",500,1);
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!");
return 1;
}