For best scripters
#10

Quote:
Originally Posted by Paulice
Посмотреть сообщение
This should work ** /me copies others with their emoji **:
PHP код:
main()
{
    
printf("%s"GetDateAndTime());
    
printf("%s"GetDateAndTime(3796)); // 3796 seconds = 1 hour, 3 minutes and 16 seconds
}
GetDateAndTime(second_diff 0)
{
    new 
string[21], yearmonthdayhourminutesecond;
    
getdate(yearmonthday), gettime(hourminutesecond);
    
second += second_diff;
    while(
second >= 60)
    {
        
second -= 60;
        
minute += 1;
        if(
minute >= 60)
        {
            
minute -= 60;
            
hour += 1;
            if(
hour >= 24)
            {
                
hour -= 24;
                switch(
month)
                {
                    case 
135781012// January, March, May, July, August, October and December
                    
{
                        if(
day 31)
                        {
                            
day ++;
                        }
                        else
                        {
                            
day 1;
                            
month ++;
                        }
                    }
                    case 
2// February
                    
{
                        if(
IsLeapYear(year))
                        {
                            if(
day 29)
                            {
                                
day ++;
                            }
                            else
                            {
                                
day 1;
                                
month ++;
                            }
                        }
                        else
                        {
                            if(
day 28)
                            {
                                
day ++;
                            }
                            else
                            {
                                
day 1;
                                
month ++;
                            }
                        }
                    }
                    case 
46911// April, June, September and November
                    
{
                        if(
day 30)
                        {
                            
day ++;
                        }
                        else
                        {
                            
day 1;
                            
month ++;
                        }
                    }
                }
                if(
month 12)
                {
                    
month 1;
                    
year ++;
                }
            }
        }
    }
    
format(stringsizeof(string), "%02d-%02d-%04d, %02d:%02d:%02d"monthdayyearhourminutesecond);
    return 
string;
}
IsLeapYear(year)
{
    return (((!(
year 4)) && (year 100)) || (!(year 400)));

Okay, It works perfect, but can you help me with hour to /ban command? (give me an example)
Reply


Messages In This Thread
For best scripters - by Kraeror - 22.07.2017, 19:00
Re: For best scripters - by Kaperstone - 22.07.2017, 19:06
Re: For best scripters - by Kraeror - 22.07.2017, 19:35
Re: For best scripters - by Vince - 22.07.2017, 19:44
Re: For best scripters - by Kraeror - 22.07.2017, 19:46
Re: For best scripters - by Kaperstone - 22.07.2017, 20:20
Re: For best scripters - by Paulice - 22.07.2017, 21:08
Re: For best scripters - by Kaperstone - 22.07.2017, 22:53
Re: For best scripters - by Paulice - 22.07.2017, 23:00
Re: For best scripters - by Kraeror - 23.07.2017, 08:58

Forum Jump:


Users browsing this thread: 3 Guest(s)