TimerEx -
Jack_Leslie - 31.10.2013
Hi guys.
I've got a bit of a problem with a Timer. I need the timer to be seperate for each player. So I have:
pawn Код:
new WelcomeTimer[MAX_PLAYERS];
I set the timer to nothing when the player connects.
pawn Код:
WelcomeTimer[playerid] = 0;
I then call the timer whenever I need to:
pawn Код:
WelcomeTimer[playerid] = SetTimerEx(...);
At the end of the timer function, I kill it:
pawn Код:
KillTimer(WelcomeTimer[playerid]);
I also kill the timer when the player disconnects.
I first call the timer when the player connects, as I have a welcome screen. In the timer function, I hide the welcome screen and spawn the player. How ever, the problem is that the player has to disconnect and re-connect before the timer function will actually work. So the player connects for the first time, and the timer gets called but the function doesn't work, the player then disconnects and re-connects and the function decides to work.
Any ideas?
Re: TimerEx -
Mattakil - 31.10.2013
there is no KillTimerEx, just use KillTimer.
pawn Код:
KillTimer(WelcomeTimer[playerid]);
Re: TimerEx -
Jack_Leslie - 31.10.2013
Quote:
Originally Posted by Mattakil
there is no KillTimerEx, just use KillTimer.
|
Yeah I didn't mean to put KillTimerEx, I just re-typed what I had instead of copying and pasting, I didn't actually have that in the script but I just fixed it in the post.
Re: TimerEx -
Mattakil - 31.10.2013
Okay, if I read this correctly, it shows a message, and when the timer is killed, the message should stop. What are you using to show the message? A textdraw or GameTextForPlayer?
Re: TimerEx -
Jack_Leslie - 31.10.2013
Yeah. That's pretty much how it works.
The timer gets called and a bunch of TextDraws show, showing a welcome message, when the timer finishes it's meant to call the function to hide the TextDraws and do other things. How ever, the timer doesn't finish and call the function unless the player disconnects and re-connects
Re: TimerEx -
Pottus - 31.10.2013
There is no need to do this. WelcomeTimer[playerid] = 0; and you didn't not provide enough information on your problem, we need code, screenshots and a better description. What you have provided so far is very vague you need to be a lot more specific if you expect anyone to help. There is a lot of good scripters here whom would know your solution instantly however you must provide adequate information that pertains to the problem.
Re: TimerEx -
Mattakil - 31.10.2013
hmmm, what does KillTimer do here?
It should work something like this:
pawn Код:
//whatever to show the textdraws
SetTimerEx(WelcomeMessage, 5000, 0, i, playerid);
//somewhere else
forward WelcomeMessage(playerid);
public WelcomeMessage(playerid)
{
//textdrawhide here
}
That should be all you need to make that work
Re: TimerEx -
Jack_Leslie - 31.10.2013
Quote:
Originally Posted by Mattakil
hmmm, what does KillTimer do here?
It should work something like this:
pawn Код:
//whatever to show the textdraws SetTimerEx(WelcomeMessage, 5000, 0, i, playerid);
//somewhere else forward WelcomeMessage(playerid); public WelcomeMessage(playerid) { //textdrawhide here }
That should be all you need to make that work
|
I removed all the WelcomeTimerEx and KillTimerEx, and done what you suggested, and it still didn't work; I still need to re-connect for the message to disappear. This is what I have:
pawn Код:
forward WelcomeTimer(playerid);
public WelcomeTimer(playerid)
{
print("1");
print("2");
TextDrawHideForPlayer(playerid, WelcomeScreen0);
print("3");
TextDrawHideForPlayer(playerid, WelcomeScreen1);
print("4");
TextDrawHideForPlayer(playerid, WelcomeScreen2);
print("5");
TextDrawHideForPlayer(playerid, WelcomeScreen3);
print("6");
}
And then I call it like this when the player spawns
pawn Код:
SetTimerEx("WelcomeTimer", 2500, false, "i", playerid);
Re: TimerEx -
Mattakil - 31.10.2013
why does it have all the "print" in it?
Re: TimerEx -
Jack_Leslie - 01.11.2013
Quote:
Originally Posted by Mattakil
why does it have all the "print" in it?
|
To debug the code and try and catch where the code stops.