Help with OnPlayerUpdate
#1

Hey guys.. I need your lil' help. I'm trying to make a system that will Show player Textdraw with Distance if He is in 10m of range from object. But If He leaves that range then the Textdraw will hide. I tried to use Else Statement in onPlayerUpdate. it was something like if Distance>10 then Hide Player object. But Instead of doing what I thought. It was not even showing the Textdraws. So, Please Help me to Make a system that will show TextDraw if player is in 10m of range and will hide if player leaves that 10m range.

Код:
public OnPlayerUpdate(playerid)
{
    for(new i=1;i<MAX_TREASURE;i++){
	 new Float:x,Float:y,Float:z;
     GetObjectPos(treasure[i],x,y,z);
	if(IsPlayerInRangeOfPoint(playerid,11,x,y,z)){
	new Float: Distance = GetPlayerDistanceFromPoint(playerid, x, y, z),Dis[44];
        format(Dis, sizeof(Dis), "%.2f", Distance);
		PlayerTextDrawSetString(playerid, Textdraw1[playerid], Dis);
		PlayerTextDrawShow(playerid, Textdraw0[playerid]);
		PlayerTextDrawShow(playerid, Textdraw1[playerid]);
	}
	}
	
    return 1; 
}
Reply
#2

That's a terrible way of trying to define a point/area. Use streamer and its dynamic area feature ---> https://sampforum.blast.hk/showthread.php?tid=102865 <---. It will behave differently from a range-point, but it's way better than having a bunch of bulky/inefficient code that is called a lot of times per second.
Reply
#3

uhmm.. But what about Removing textdraw when player leaves the 10m range?
Reply
#4

Quote:
Originally Posted by TheRaGeLord
Посмотреть сообщение
uhmm.. But what about Removing textdraw when player leaves the 10m range?
The following function and callbacks are self-explanatory:

pawn Код:
native CreateDynamicCircle(Float:x, Float:y, Float:size, worldid = -1, interiorid = -1, playerid = -1);

forward OnPlayerEnterDynamicArea(playerid, areaid);
forward OnPlayerLeaveDynamicArea(playerid, areaid);
https://sampforum.blast.hk/showthread.php?tid=102865
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)