Score Timer - 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: Score Timer (
/showthread.php?tid=479271)
Score Timer -
TheSnaKe - 04.12.2013
Hey guys,i want a script that give +1 score every 1 hour.
I watched the tutorials about the score timer like +1 score every 1 hour but i didn't understood, can someone do
it for me or explain it to me please?
Re: Score Timer -
eblood1 - 04.12.2013
Here you go, have a look at this I've just created:
pawn Код:
new pTimeOnline[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("Timer_Second", 1000, true);
}
forward Timer_Second();
public Timer_Second()
{
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pTimeOnline[i] == 3600)
{
pTimeOnline[i] = 0;
SetPlayerScore(i, GetPlayerScore(i) + 1);
} else
pTimeOnline[i]++;
}
}
}
public OnPlayerConnect(playerid)
{
pTimeOnline[playerid] = 0;
return 1;
}
Re: Score Timer -
Loot - 04.12.2013
Why not just:
pawn Код:
#define AddScore(%0) SetPlayerScore(%0, GetPlayerScore(%0) + 1)
public OnGameModeInit()
{
SetTimer("Timer", 3_600_000, true); // 1 hour
}
forward Timer();
public Timer()
{
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
AddScore(i);
}
}
Re: Score Timer -
eblood1 - 04.12.2013
Because if someone joined a few seconds before the interval was about to tick 60 minutes, they would also get +1 score.
Re: Score Timer -
TheSnaKe - 04.12.2013
Okay guys thanks, +Rep
Re: Score Timer -
Loot - 04.12.2013
Quote:
Originally Posted by eblood1
Because if someone joined a few seconds before the interval was about to tick 60 minutes, they would also get +1 score.
|
Yes, but that's not what he asked for.
He wanted a simple timer (1 hour) that adds the players 1 score, not by checking if they were online for 1 hour.