Day started
#1

How can i check if a day has passed ?
Reply
#2

Check the calendar
Reply
#3

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

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

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

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.
Reply
#7

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
Reply
#8

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.
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)