12.11.2018, 22:29
https://sampwiki.blast.hk/wiki/Gettime
pawn Код:
#define HOURS_TO_SECONDS(%0) (%0 * 3600) // hour to seconds convertor
new serverTimestamp;
new serverUpdateTimer;
public OnGameModeInit() {
serverTimestamp = gettime(); // when your server starts, store the timestamp into your global variable
serverUpdateTimer = SetTimer("OnServerUpdate", 1000, true); // a timer which will iterate every 1 second
}
forward OnServerUpdate();
public OnServerUpdate() {
new currentTimestamp = gettime(); // get the current timestamp
if (serverTimestamp - currentTimestamp >= HOURS_TO_SECONDS(1)) { // 1 hour has passed in your server
// do your code here
// reset our variable so we keep track for next hour pass
currentTimestamp = serverTimestamp;
}
}