Posts: 277
Threads: 24
Joined: Apr 2017
Reputation:
0
Is it possible to change the length of the day/night? I wan't to make it so from 24 hours, 4 hours to be sunny and the other 20 hours to be dark. If it's possible, what do i need to change or add? Thanks in advance.
EDIT: With the real time i meant.
Posts: 457
Threads: 7
Joined: Jul 2017
if you mean to set world time using real time clock you can use something like that.
PHP код:
forward public OnWorldTimeUpdate();
public OnWorldTimeUpdate()
{
new h, m, s;
gettime(h, m, s);
if(h > 0 && h < 5) SetWorldTime(0);
else SetWorldTime(12);
return true;
}
// OnGamemodeinit
PHP код:
SetTimer("OnWorldTimeUpdate", 30*60*1000, true);
Posts: 457
Threads: 7
Joined: Jul 2017
Quote:
Originally Posted by kAn3
Yes, but I'do it more short
PHP код:
forward ServerTime();
public ServerTime()
{
new h, m, s;
gettime(h, m, s);
foreach(Player, k)SetPlayerTime(k, h, m);
return 1;
}
PHP код:
SetTimer("ServerTime", 300000, true); // Check every 5 mins
Also, I'd suggest you to create an enum to store server variables just like server hour,minute and seconds, so you can create a clock with textdraws and add the current server time to it.
|
do you know what are you doing?
he want 4 hours of dark and 20 hours of morning
and instand of setting each player time you can set the whole server time by using SetWorldTime
your version is not optimized at all but it gonna work.
Posts: 277
Threads: 24
Joined: Apr 2017
Reputation:
0
Actually it's 20 hours night and 4 hours day, but thanks for the help, +repped.