Is it possible to change [day/night] -
Escobabe - 22.10.2017
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.
Re: Is it possible to change [day/night] -
Puff - 22.10.2017
It depends on the time.. so.. what you can do is create something that will change the time after 4 hours to night.. time.. and then back to daytime after 20 hours.. using
https://sampwiki.blast.hk/wiki/SetWorldTime
Re: Is it possible to change [day/night] -
Xeon™ - 22.10.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);
Re: Is it possible to change [day/night] -
kAn3 - 22.10.2017
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.
Re: Is it possible to change [day/night] -
Xeon™ - 22.10.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.
Re: Is it possible to change [day/night] -
kAn3 - 22.10.2017
Didnt read the part where he only wants 4 dark hours
![Cheesy](images/smilies/biggrin.png)
Tho SetWorldTime only sets the hour, not minutes. To me it is way better to set minutes aswell, idk really if SA world time changes suddently from hour to hour, but if there is a function setting minutes too, I guess it doesn't.
EDIT: Also your code only sets time to 12 either to 0, where is sunset/dawn?
Re: Is it possible to change [day/night] -
Escobabe - 22.10.2017
Actually it's 20 hours night and 4 hours day, but thanks for the help, +repped.