TextDraw not showing
#1

Hey guys, i created something like infobox for myself, which is basically stock, which i am showing in certain parts of gamemode, but the thing is, that when i showed it, i did not see it, code:

This is the stock for the box:
Код:
stock Box(playerid, text[], time)
{
	if(Showing[playerid] == 0)
	{
	    Show[playerid] = SetTimerEx("Hide", time*1000, false, "i", playerid);
		PlayerTextDrawSetString(playerid, infoBox[playerid], text);
		PlayerTextDrawShow(playerid, infoBox[playerid]);
		Showing[playerid] = 1;
	}
	if(Showing[playerid] == 1)
	{
	    PlayerTextDrawHide(playerid, infoBox[playerid]);
	    Showing[playerid] = 0;
	    KillTimer(Show[playerid]);
	}
}
Now this is, where i am showing it:
Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 2.0, 217.7364,1877.2621,13.1406))
	{
	    Box(playerid, "Stlac LALT pre otvorenie brany.", 5);
	}
	if(IsPlayerInRangeOfPoint(playerid, 2.0, 217.8487,1874.2979,13.1406))
	{
	    Box(playerid, "Stlac LALT pre otvorenie brany.", 5);
	}
	return 1;
}
But when i am in the coords, nothing is showing up. I am sure, that i am on the good coords, because on the same coords i am using OnPlayerKeyStateChange, and it is working, only the textdraw is not showing.
Reply
#2

The problem is that OnPlayerUpdate is constantly being called, so when the box is shown, the box will also be hidden on the next update if the player is still in range.

Adding checks solves this problem.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!Showing[playerid])
    {
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 217.7364,1877.2621,13.1406))
    {
        Box(playerid, "Stlac LALT pre otvorenie brany.", 5);
    }
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 217.8487,1874.2979,13.1406))
    {
        Box(playerid, "Stlac LALT pre otvorenie brany.", 5);
    }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)