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

How to check if a player's position has been drastically changed without the use of timer?
Reply
#2

onplayerupdate?
Reply
#3

Quote:
Originally Posted by fordawinzz
Посмотреть сообщение
onplayerupdate?
How?
Reply
#4

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.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)