Timer problem [REP ++]
#1

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 ?
Reply
#2

Instead of public variable use player variable so new stick; to new stick[MAX_PLAYERS];
and when using the variable use stick[playerid];
Reply
#3

new TIMER_COUNT[MAX_PLAYERS];

TIMER_COUNT[playerid] = SetTimerEx("messagecount", 1000, 1, "i", playerid);

Wrote it really quick. Should fix the player issue.
Reply
#4

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 ?
Reply
#5

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
Reply
#6

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)
Reply
#7

I did the next :
pawn Код:
TIMER_COUNT[playerid] = SetTimerEx("message", 7000, 1, "i", playerid);
new TIMER_COUNT[MAX_PLAYERS];
Reply
#8

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]);
Reply
#9

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;
}
Reply
#10


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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)