Timer Probblem
#1

I have a TextDraw When a player connects it sas EXAMPLE: "Park4Bmx Joined The Server"
And then a Timer that closes it.
But the probblem is when 2 players join the server at the same time
The Timer Doesnt work for two of the players ?

CODE
pawn Код:
//on player conn..
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "~y~%s ~w~has joined the server", pname);
Textdraw30 = TextDrawCreate(22.000000, 111.000000, string);
//So on with the TextDraw.....
SetTimer("HideTextdraw",4000,false);

//then
forward HideTextdraw();
public HideTextdraw()
{
    TextDrawHideForAll(Textdraw30);
    TextDrawDestroy(Textdraw30);
    return 1;
}
Reply
#2

Hi there again,

I have a better way to do this:

At TOP:
pawn Код:
new Text:Textdraw30;
new TDHideTimer = -1;
OnGameModeInit:
pawn Код:
Textdraw30 = TextDrawCreate(22.000000, 111.000000, " ");
//So on with the TextDraw.....
OnPlayerConnect:
pawn Код:
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "~y~%s ~w~has joined the server", pname);
TextDrawSetString(Textdraw30, string);
TextDrawShowForAll(Textdraw30);
if(TDHideTimer != -1) KillTimer(TDHideTimer);
TDHideTimer = SetTimer("HideTextdraw",4000,false);
The function:
pawn Код:
forward HideTextdraw();
public HideTextdraw()
{
    TextDrawHideForAll(Textdraw30);
    TextDrawSetString(Textdraw30, " ");
    return 1;
}
Thats a better usage, because you do not destroy and create the TD always.

If you have any questions or find any bugs you don't know how to fix, feel free to ask.


Jeffry
Reply
#3

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
Hi there again,

I have a better way to do this:

At TOP:
pawn Код:
new Text:Textdraw30;
new TDHideTimer = -1;
OnGameModeInit:
pawn Код:
Textdraw30 = TextDrawCreate(22.000000, 111.000000, " ");
//So on with the TextDraw.....
OnPlayerConnect:
pawn Код:
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "~y~%s ~w~has joined the server", pname);
TextDrawSetString(Textdraw30, string);
TextDrawShowForAll(Textdraw30);
if(TDHideTimer != -1) KillTimer(TDHideTimer);
TDHideTimer = SetTimer("HideTextdraw",4000,false);
The function:
pawn Код:
forward HideTextdraw();
public HideTextdraw()
{
    TextDrawHideForAll(Textdraw30);
    TextDrawSetString(Textdraw30, " ");
    return 1;
}
Thats a better usage, because you do not destroy and create the TD always.

If you have any questions or find any bugs you don't know how to fix, feel free to ask.


Jeffry
OMG THANKS AGAIN
See what i tell u my here XD
Reply
#4

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
OMG THANKS AGAIN
See what i tell u my here XD
Nice that I could help you again.
Have fun.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)