[HELP]TextDraw
#1

Hello all. I have one problem with my textdraw.All works good when i am on feet, textdraw show when i am near bizz, when i gone from bizz after 6 sec textdraw disappear, thats ok...but when i enter car that textdraw refreshes every 1-2 sec and start blink...Whats the problem?
BTW:
Gamemode what i use: GTARP

There is the code:
on the top gamemode
Код:
new Text:OwnerShip1;
new Text:OwnerShip2;
public OnPlayerConnect(playerid):
Код:
TextDrawHideForPlayer(playerid,Text:OwnerShip1);
    TextDrawHideForPlayer(playerid,Text:OwnerShip2);
public GameModeExitFunc():
Код:
TextDrawDestroy(Text:OwnerShip1);
    TextDrawDestroy(Text:OwnerShip2);
public OnGameModeInit():
Код:
//**********************************
	OwnerShip1 = TextDrawCreate(235.000000, 141.000000, "~g~We~r~Be~g~r"); TextDrawBackgroundColor(OwnerShip1, 255); TextDrawFont(OwnerShip1, 0); TextDrawLetterSize(OwnerShip1, 0.769999, 2.100000); TextDrawColor(OwnerShip1, 16711935); TextDrawSetProportional(OwnerShip1, 1);
    OwnerShip2 = TextDrawCreate(234.000000, 164.000000, "New Textdraw"); TextDrawBackgroundColor(OwnerShip2, 255); TextDrawFont(OwnerShip2, 2); TextDrawLetterSize(OwnerShip2, 0.230000, 1.000000); TextDrawColor(OwnerShip2, -1); TextDrawSetProportional(OwnerShip2, 1); TextDrawUseBox(OwnerShip2, 1); TextDrawBoxColor(OwnerShip2, 90); TextDrawTextSize(OwnerShip2, 420.000000, 0.000000);
timer for destroy TD after 6 seconds:
Код:
public UnistiTDKuce(playerid)
{
    TextDrawHideForPlayer(playerid,Text:OwnerShip1);
    TextDrawHideForPlayer(playerid,Text:OwnerShip2);
}
and there is where gamemode show TD when i am near bizz:
Код:
			else if(GetPlayerState(i) == 1 && PlayerToPoint(2,i,1531.0088,-1738.5283,13.5469))
			{
                    format(string,sizeof(string),"~g~For buy type~n~~w~/kiosk.");
					TextDrawSetString(OwnerShip2,string);
					TextDrawShowForPlayer(i,OwnerShip1);
					TextDrawShowForPlayer(i,OwnerShip2);
					SetTimerEx("UnistiTDKuce",6000,0,"d",i);
			}
Pictures:
1.this is textdraw


2.and this is textdraw when i enter car, it start blink every 1-2 sec
Reply
#2

First of all, when you're passing the variable into a function you don't need to specify a tag every single time, you should simply be doing:

pawn Код:
TextDrawDestroy(OwnerShip1);
The only time you should be specifying a tag like "Text:" is when you're actually initializing the variable.

As far as the issue goes, is this piece of code being run in a timer?

pawn Код:
else if(GetPlayerState(i) == 1 && PlayerToPoint(2,i,1531.0088,-1738.5283,13.5469))
            {
                    format(string,sizeof(string),"~g~For buy type~n~~w~/kiosk.");
                    TextDrawSetString(OwnerShip2,string);
                    TextDrawShowForPlayer(i,OwnerShip1);
                    TextDrawShowForPlayer(i,OwnerShip2);
                    SetTimerEx("UnistiTDKuce",6000,0,"d",i);
            }
If it is, you need to consider the fact that it will probably be called multiple times, therefore that SetTimerEx at the will be called multiple times, creating multiple, unnecessary timers.

Instead, why not consider adding a simple else to your current statement to hide the textdraws?

pawn Код:
else if(GetPlayerState(i) == 1 && PlayerToPoint(2,i,1531.0088,-1738.5283,13.5469))
{
    format(string,sizeof(string),"~g~For buy type~n~~w~/kiosk.");
    TextDrawSetString(OwnerShip2,string);
    TextDrawShowForPlayer(i,OwnerShip1);
    TextDrawShowForPlayer(i,OwnerShip2);
}
else
{
    // Hide the textdraws!
}
Then it will hide the textdraws once you go out of range of those co-ordinates, or when your player state changes from that (don't know why you didn't use the definition PLAYER_STATE_ONFOOT).

No need for another timer then!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)