SA-MP Forums Archive
Timer Probblem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer Probblem (/showthread.php?tid=231416)



Timer Probblem - park4bmx - 25.02.2011

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;
}



Re: Timer Probblem - Jeffry - 25.02.2011

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


Re: Timer Probblem - park4bmx - 25.02.2011

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


Re: Timer Probblem - Jeffry - 25.02.2011

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.