[Help] Server Day & Night
#4

This is from my script, it changes day/night automatically according to time:

On top:
PHP код:
new Text:Time;
new 
Tsec;
new 
THrs
Under OnGameModeInit
PHP код:
Time TextDrawCreate(578.00000014.000000"00:00");
    
TextDrawAlignment(Time2);
    
TextDrawFont(Time3);
    
TextDrawLetterSize(Time0.6099993.299998);
    
TextDrawColor(Time, -1);
    
TextDrawSetOutline(Time1);
    
TextDrawSetProportional(Time0);
    
TextDrawSetSelectable(Time0);
    
Tsec0;
    
THrs0;
    
SetTimer("TimeU",60000,true); 
And the callback of timer:
PHP код:
forward TimeU();
public 
TimeU()
{
    new 
string[7];
    
Tsec+=1;
    if(
Tsec==60)
    {
        
Tsec=0;
        
THrs+=1;
    }
    if(
THrs==24)
    {
        
Tsec=0;
        
THrs=0;
    }
    if(
THrs>10)
    {
        if(
Tsec<10)
        {
            
format(string,sizeof(string),"%d:0%d",THrs,Tsec);
        }
        if(
Tsec>9)
        {
               
format(string,sizeof(string),"%d:%d",THrs,Tsec);
        }
    }
    if(
THrs<10)
    {
        if(
Tsec<10)
        {
            
format(string,sizeof(string),"0%d:0%d",THrs,Tsec);
        }
        if(
Tsec>9)
        {
               
format(string,sizeof(string),"0%d:%d",THrs,Tsec);
        }
    }
    for(new 
ii<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
SetPlayerTime(i,THrs,Tsec);
        }
    }
    
TextDrawSetString(Time,string);

It does everything.
Reply


Messages In This Thread
[Help] Server Day & Night - by Arxalan - 16.01.2015, 08:29
Re: [Help] Server Day & Night - by Ironboy - 16.01.2015, 08:35
Re: [Help] Server Day & Night - by Airman123 - 16.01.2015, 08:35
Re: [Help] Server Day & Night - by ATGOggy - 16.01.2015, 08:57
Re: [Help] Server Day & Night - by Arxalan - 16.01.2015, 14:41
Re: [Help] Server Day & Night - by ATGOggy - 17.01.2015, 05:31
Re: [Help] Server Day & Night - by Arxalan - 17.01.2015, 09:29
Re: [Help] Server Day & Night - by HY - 17.01.2015, 10:36

Forum Jump:


Users browsing this thread: 2 Guest(s)