OnPlayerUpdate (Get X,Y,Z,A) Question - 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: OnPlayerUpdate (Get X,Y,Z,A) Question (
/showthread.php?tid=630724)
OnPlayerUpdate (Get X,Y,Z,A) Question -
Killa[DGZ] - 18.03.2017
Is it better to declare global float variables for players and simply grab the information to fill them in OnPlayerUpdate, instead of having bajillions of 'GetPlayerPos & GetPlayerFacingAngle' happening all over the place all the time in lengthy gamemodes?, I do realise that it's bad practice to put 'lenthy or strenious' code within OnPlayerUpdate.. but I don't think 'GetPlayerPos & GetPlayerFacingAngle' is either of those do you?
eg
PHP код:
new Float:LivePos_x[MAX_PLAYERS],Float:LivePos_y[MAX_PLAYERS],Float:LivePos_z[MAX_PLAYERS],Float:LivePos_a[MAX_PLAYERS];
//OnPlayerUpdate
GetPlayerPos(playerid, LivePos_x[playerid], LivePos_y[playerid], LivePos_z[playerid]);
GetPlayerFacingAngle(playerid, LivePos_a[playerid]);
Then just use the LivePos positions where required throughout the gamemode.. yes or no?
Re: OnPlayerUpdate (Get X,Y,Z,A) Question -
Type-R - 18.03.2017
I think you are fine. Also if you want to reduce the frequency of the position getting, you can use a timestamp to do that. I am writing from my phone, so cannot give you an example..
Re: OnPlayerUpdate (Get X,Y,Z,A) Question -
DRIFT_HUNTER - 18.03.2017
Hell no