23.04.2013, 12:27
Well, I scripted an online time script yesterday, while I was testing in the server with 2 players, different time connected...
Example of situation:
First, I joined at 7:30 PM, so the timer started to count. And another player joined at 8:00 PM.
But after 1 hour, which is 8:30PM, I received an hour bonus, but player 2 received it too. And after 30 minutes, 9:00 PM, I received another again.. So how to fix it? Here's the code!
OnPlayerConnect:
forward/public OneHourBonus:
How to fix it? :/
Example of situation:
First, I joined at 7:30 PM, so the timer started to count. And another player joined at 8:00 PM.
But after 1 hour, which is 8:30PM, I received an hour bonus, but player 2 received it too. And after 30 minutes, 9:00 PM, I received another again.. So how to fix it? Here's the code!
OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
//Lots of code...
SetTimer("OneHourBonus", 1000*60*60, 1);
return 1;
}
pawn Код:
forward OneHourBonus();
public OneHourBonus()
{
for (new i, slots = GetMaxPlayers(); i < slots; i ++)
{
GivePlayerMoney(i, 5000);
SetPlayerScore(i,GetPlayerScore(i)+5);
SendClientMessage(i, -1, "Thanks for playing on our server for 1 hour! As a bonus, $5000 and 5 scores have been given you.");
pInfo[i][Hours]++;
}
return 1;
}