SA-MP Forums Archive
Day started - 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: Day started (/showthread.php?tid=660710)



Day started - Cezar98 - 11.11.2018

How can i check if a day has passed ?


Re: Day started - v1k1nG - 11.11.2018

Check the calendar


Re: Day started - IdonTmiss - 11.11.2018

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Check the calendar
AHHAAHHAHAHAHAHAHAHAHAHAHAH


Re: Day started - DIRTYBYT3 - 11.11.2018

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Check the calendar
WTF!!! Hahaha!


Re: Day started - Cezar98 - 11.11.2018

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
WTF!!! Hahaha!
There's no any function like OnDayPassed() or something to what happen when a day has passed


Re: Day started - RogueDrifter - 11.11.2018

Check https://sampwiki.blast.hk/wiki/Gettime
And https://sampwiki.blast.hk/wiki/Getdate

Saving them to a variable and checking days should do it.


Re: Day started - Cezar98 - 11.11.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Check https://sampwiki.blast.hk/wiki/Gettime
And https://sampwiki.blast.hk/wiki/Getdate

Saving them to a variable and checking days should do it.
I don't know how


Re: Day started - ItsRobinson - 12.11.2018

1 in-game hour is 1 minute in real life according to the GTA Wiki so a timer that loops every 24 minutes would be what you're looking for.

PHP код:
forward NewDay();
public 
NewDay()
{
    
SendClientMessageToAll(-1"Rise and Shine, It's a new day!");
    return 
1;
}
public 
OnGameModeInit()
{
    
SetWorldTime(0);
    
SetTimer("NewDay"1440000true);
    return 
1;

That example above will set the servers time to midnight when you first startup the server, this will then sync up with the timer which will loop continuously and send a message to all the players on the server every time the in-game clock strikes midnight.


Re: Day started - Gammix - 12.11.2018

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;
    }
}