OnPlayerUpdate - 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 (
/showthread.php?tid=623474)
OnPlayerUpdate -
Th3N0oB - 01.12.2016
Hi, I tried to do this function to show a textdraw if a player is within a distance of 7.0 of a vehicle, but, if it moves away from that particular range, hide the textdraw, but when executed, it is only displayed when I get on the vehicle.
PHP код:
public OnPlayerUpdate(playerid)
{
new Float:v_Pos[3], Modelo;
Modelo = GetPlayerVehicleID(playerid);
GetVehiclePos(Modelo, v_Pos[0], v_Pos[1], v_Pos[2]);
GetPlayerPos(playerid, Mostrar[playerid][CercaPos][0], Mostrar[playerid][CercaPos][1], Mostrar[playerid][CercaPos][2]);
Mostrar[playerid][CercaPos][0] = v_Pos[0];
Mostrar[playerid][CercaPos][1] = v_Pos[1];
Mostrar[playerid][CercaPos][2] = v_Pos[2];
if(IsPlayerInRangeOfPoint(playerid, 7.0, v_Pos[0], v_Pos[1], v_Pos[2]))
{
TextDrawShowForPlayer(playerid, AutoCerca[playerid]);
} else {
TextDrawHideForPlayer(playerid, AutoCerca[playerid]);
return true;
}
}
Re: OnPlayerUpdate -
Vince - 01.12.2016
Better to use the streamer plugin so you can attach a dynamic circular area to a vehicle. You can then use the enter and leave callbacks so you don't have to rely on OnPlayerUpdate.