[ISSUE] playerid's are switching inside a function -
PKRanger - 08.08.2009
[22:11:21] [DBUG] In een checkpoint!
[22:11:21] [DBUG] Natrixz CountDown, met id: 1
[22:11:22] [DBUG] Hanno CountDown, met id: 0
[22:11:23] [DBUG] Hanno CountDown, met id: 0
[22:11:24] [DBUG] Hanno CountDown, met id: 0
[22:11:25] [DBUG] Hanno CountDown, met id: 0
[22:11:26] [DBUG] Hanno CountDown, met id: 0
As seen above, Natrixz (id 1) starts a time challenge race for him self.
Somehow the ID in the countdown gets reversed in my id (0)..
How can i solve this ' strange ' problem ?
because im unable to see any common sense in this problem.
The most important part where the crap gets messed up :
Код:
public TimeCounter(playerid)
{
if(timecounter[playerid] > timechallange)
{
new debugg[128];
format(debugg, sizeof debugg, "[DBUG] %s Failed the time challange\n", PlayerName(playerid));
print(debugg);
GameTextForPlayer(playerid,"~r~ You failed to beat the time challange!", 5000, 5);
KillTimer(timecountertimer[playerid]);
timecounter[playerid] = 0;
racecheckpoint[playerid] = 0;
currentstate[playerid] = 0;
timeminitimer[playerid] = 0;
timerealtime[playerid] = 0;
}
else
{
if (timeminitimer[playerid] >= 10)
{
timeminitimer[playerid] = 0;
timecounter[playerid]++;
if (timecounter[playerid] != 0)
{
new str[128];
format(str, sizeof str, "~w~ %d", timecounter[playerid]);
GameTextForPlayer(playerid, str, 500, 5);
}
new debugg[128];
format(debugg, sizeof debugg, "[DBUG] %s Started a race against the timer\n", PlayerName(playerid));
print(debugg);
}
timecountertimer[playerid] = SetTimer("TimeCounter", 100, 0);
timeminitimer[playerid]++;
timerealtime[playerid]++;
}
return 1;
}
Edit: It works when im allone in the server, and it works if anyone joins later.
Its somehow in the countdown when it changes the playerid :/
Re: [ISSUE] playerid's are switching inside a function -
Weirdosport - 08.08.2009
The problem is that you're using SetTimer instead of SetTimerEx. E.g:
SetTimerEx("TimeCounter", 100, 0, "i", playerid);
See
HERE for more information.
Re: [ISSUE] playerid's are switching inside a function -
PKRanger - 08.08.2009
Thnx, going to test it right away!