how to check if a player's position has been drastically changed?
#5

Quote:
Originally Posted by Babul
Посмотреть сообщение
1 word: delta.
pawn Код:
new Float:PlayerPosOld[MAX_PLAYERS][3];
OnPlayerUpdate:
pawn Код:
new Float:PosNew[3];
new Float:PosDelta[3];
GetPlayerPos(playerid,PosNew[playerid][0],PosNew[playerid][1],PosNew[playerid][2]);

PosDelta[0]=PosNew[0]-PlayerPosOld[playerid][0];
PosDelta[1]=PosNew[0]-PlayerPosOld[playerid][0];
PosDelta[2]=PosNew[0]-PlayerPosOld[playerid][0];

PlayerPosOld[MAX_PLAYERS][0]=PosNew[0];
PlayerPosOld[MAX_PLAYERS][1]=PosNew[1];
PlayerPosOld[MAX_PLAYERS][2]=PosNew[2];
after this, the PosDelta will have stored the difference betwen each position change. ignoring the [2] can be, i doubt that any player teleports into the sky (or below ground)...

oh, maybe adding this in another callback can help to avoid lag. the OnPlayerKeyStateChange fits better imo - no player can move without pressing at least 1 key.
It's really embarrassing for me to forget it. You deserve reputation from me.
Reply


Messages In This Thread
how to check if a player's position has been drastically changed? - by T0pAz - 11.02.2012, 15:00
Re: how to check if a player's position has been drastically changed? - by fordawinzz - 11.02.2012, 15:02
Re: how to check if a player's position has been drastically changed? - by T0pAz - 11.02.2012, 15:03
Re: how to check if a player's position has been drastically changed? - by Babul - 11.02.2012, 15:34
Re: how to check if a player's position has been drastically changed? - by T0pAz - 11.02.2012, 15:42

Forum Jump:


Users browsing this thread: 2 Guest(s)