Timer problem [REP ++] -
buburuzu19 - 04.12.2014
I tried to do something like this:
(A countdown timer)
Everything works very good if only one player types /test123
pawn Код:
CMD:test123(playerid,params[])
{
stick = 5;
SetTimerEx("messagecount", 1000, 1, "i", playerid);
}
pawn Код:
new stick;
forward messagecount(playerid);
pawn Код:
public messagecount(playerid)
{
stick--;
switch(stick)
{
case 0:
{
SCM(playerid,COLOR_PURPLE,"Timer ended!");
}
case 1: SCM(playerid,COLOR_PURPLE,"Test 1");
case 2: SCM(playerid,COLOR_PURPLE," Test 2");
case 3: SCM(playerid,COLOR_PURPLE,"Test 3");
case 4: SCM(playerid,COLOR_PURPLE,"Test 4");
}
return 1;
}
But, if 2 players type at the same time /test123 everything is going f*cked up ... what is wrong ?
Re: Timer problem [REP ++] -
Capua - 04.12.2014
Instead of public variable use player variable so new stick; to new stick[MAX_PLAYERS];
and when using the variable use stick[playerid];
Re: Timer problem [REP ++] -
rangerxxll - 04.12.2014
new TIMER_COUNT[MAX_PLAYERS];
TIMER_COUNT[playerid] = SetTimerEx("messagecount", 1000, 1, "i", playerid);
Wrote it really quick. Should fix the player issue.
Re: Timer problem [REP ++] -
buburuzu19 - 04.12.2014
Quote:
Originally Posted by rangerxxll
new TIMER_COUNT[MAX_PLAYERS];
TIMER_COUNT[playerid] = SetTimerEx("messagecount", 1000, 1, "i", playerid);
Wrote it really quick. Should fix the player issue.
|
And it don't need to be killed ?
Re: Timer problem [REP ++] -
M4D - 04.12.2014
1.your "stick" variable is global !! Change it ! new stick[MAX_PLAYERS];
2.you have to kill timer in case 0 so you have to define timer id
Note: define timer variable id for players not global
new ContTimer[MAX_PLAYERS];
Good luck
Re: Timer problem [REP ++] -
buburuzu19 - 04.12.2014
Quote:
Originally Posted by M4D
1.your "stick" variable is global !! Change it ! new stick[MAX_PLAYERS];
2.you have to kill timer in case 0 so you have to define timer id
Note: define timer variable id for players not global
new ContTimer[MAX_PLAYERS];
Good luck
|
And after new ContTimer[MAX_PLAYERS] what to add at my timer ? (SetTimerEx("messagecount", 1000, 1, "i", playerid)
Re: Timer problem [REP ++] -
buburuzu19 - 04.12.2014
I did the next :
pawn Код:
TIMER_COUNT[playerid] = SetTimerEx("message", 7000, 1, "i", playerid);
new TIMER_COUNT[MAX_PLAYERS];
Re: Timer problem [REP ++] -
M4D - 04.12.2014
In command where you set timer you have to do :
CountTimer[playerid] = SetTimerEx(…………
And in case 0 that stick[playerid] value is 0 kill timer
KillTimer(CountTimer[playerid]);
Re: Timer problem [REP ++] -
buburuzu19 - 04.12.2014
Quote:
Originally Posted by M4D
In command where you set timer you have to do :
And in case 0 that stick[playerid] value is 0 kill timer
|
I didn't get it , like this :
case 0:
{
SCM(playerid,COLOR_PURPLE,"Timer ended!");
KillTimer(TIMER_COUNT[playerid]);
stick[playerid] = 0;
}
Re: Timer problem [REP ++] -
M4D - 04.12.2014

Case 0 mean seconds passed
I told when variable value is 0 kill timer
This mean case 0 that you maked !
Kill timer in case 0 after sending message that countdown finished
But this (stick[playerid] = 0

won't effect on your contdown system at all
Because timer killed and your countdown has finished