ScoreTimer only works for ID 0 (or the first player connects) - 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)
+--- Thread: ScoreTimer only works for ID 0 (or the first player connects) (
/showthread.php?tid=369642)
ScoreTimer only works for ID 0 (or the first player connects) -
kbalor - 17.08.2012
Well my score timer works nice for me. But when my friend join my server after waiting almost 10 minutes still he got 0 score. But I've got 3 score added on my stats.
Info: It will basically add 1 score every 3 minutes...
pawn Код:
SetTimerEx("ScoreTimer", 1000, 0, "d", playerid);
pawn Код:
forward ScoreTimer(playerid);
public ScoreTimer(playerid)
{
if(!IsPlayerConnected(playerid)) return 1;
AccInfo[playerid][pSecondScore] += 1;
if(AccInfo[playerid][pSecondScore] >= SCORE_TIME)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
AccInfo[playerid][pSecondScore] = 0;
}
SetTimerEx("ScoreTimer", 1000, 0, "d", playerid);
return 1;
}
Re: ScoreTimer only works for ID 0 (or the first player connects) -
Dan. - 17.08.2012
pawn Код:
SetTimerEx("ScoreTimer", 1000, true, "d", playerid);
pawn Код:
forward ScoreTimer(playerid);
public ScoreTimer(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
AccInfo[playerid][pSecondScore] += 1;
if(AccInfo[playerid][pSecondScore] >= SCORE_TIME)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
AccInfo[playerid][pSecondScore] = 0;
}
return 1;
}
Re: ScoreTimer only works for ID 0 (or the first player connects) -
leonardo1434 - 17.08.2012
just loop through connected players.
pawn Код:
porward ScoreTimer(playerid);
public ScoreTimer(playerid)
{
for(new l = GetMaxPlayers(); playerid < l; ++playerid) {
if(IsPlayerConnected(playerid)) {
AccInfo[playerid][pSecondScore] += 1;
if(AccInfo[playerid][pSecondScore] >= SCORE_TIME) {
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
AccInfo[playerid][pSecondScore] = 0;
}
}
}
return 1;
}
Re: ScoreTimer only works for ID 0 (or the first player connects) -
kbalor - 17.08.2012
Okay thanks! +rep both, but i still didn't try i yet.