28.12.2015, 12:55
I personally would put this in a global task rather than an individual timer. The code underneath is using foreach:
Alternatively (and I actually recommend it), you can check whether the player is logged in or not. If your script makes use of this, of course.
PHP код:
public OnGameModeInit() {
HourTimer();
return 1;
}
task HourTimer[3600000]() {
foreach(new i : Player) {
// Coin draw
SendClientMessage(i, COLOR_GREEN, "LUCKY DRAW: You've got 1 coin that can be used in /luckydraw!");
DataPlayer[i][pcoin] ++;
new INI:File = INI_Open(LDPath(i));
INI_SetTag(File, "DataPlayer");
INI_WriteInt(File, "Coins", DataPlayer[i][pcoin]);
INI_Close(File);
}
}
PHP код:
task HourTimer[3600000]() {
foreach(new i : Player) {
if(!DataPlayer[i][ploggedin]) {
continue;
}
// Coin draw
SendClientMessage(i, COLOR_GREEN, "LUCKY DRAW: You've got 1 coin that can be used in /luckydraw!");
DataPlayer[i][pcoin] ++;
new INI:File = INI_Open(LDPath(i));
INI_SetTag(File, "DataPlayer");
INI_WriteInt(File, "Coins", DataPlayer[i][pcoin]);
INI_Close(File);
}
}