Is it possible to change [day/night]
#1

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

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

if you mean to set world time using real time clock you can use something like that.

PHP код:
forward public OnWorldTimeUpdate();
public 
OnWorldTimeUpdate()
{
      new 
hms;
      
gettime(hms);
      if(
&& 5SetWorldTime(0);
      else 
SetWorldTime(12);
      return 
true;

// OnGamemodeinit
PHP код:
SetTimer("OnWorldTimeUpdate"30*60*1000true); 
Reply
#4

Yes, but I'do it more short

PHP код:
forward ServerTime();
public 
ServerTime()
{
      new 
hms;
      
gettime(hms);
      foreach(
Playerk)SetPlayerTime(khm);
      return 
1;

PHP код:
SetTimer("ServerTime"300000true); // 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.
Reply
#5

Quote:
Originally Posted by kAn3
Посмотреть сообщение
Yes, but I'do it more short

PHP код:
forward ServerTime();
public 
ServerTime()
{
      new 
hms;
      
gettime(hms);
      foreach(
Playerk)SetPlayerTime(khm);
      return 
1;

PHP код:
SetTimer("ServerTime"300000true); // 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.
Reply
#6

Didnt read the part where he only wants 4 dark hours
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?
Reply
#7

Actually it's 20 hours night and 4 hours day, but thanks for the help, +repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)