For best scripters
#1

Hello guys, I have problem with my clock. My host is in another country and the time there is different. I need to add 1 hour 3 minutes and 16 seconds to fix it. How can I add to my clock? Can you give me.
Reply
#2

(3600 + 3 * 60 + 16) + gettime()) = your unix timestamp.
Reply
#3

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
(3600 + 3 * 60 + 16) + gettime()) = your unix timestamp.
Can you enter it here?
Quote:

new string[256],year,month,day,hours,minutes,seconds;
getdate(year, month, day), gettime(hours, minutes, seconds);
format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
TextDrawSetString(Date, string);
format(string, sizeof string, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (minutes < 10) ? ("0") : (""), minutes, (seconds < 10) ? ("0") : (""), seconds);
TextDrawSetString(Time, string);

Reply
#4

Oh, I don't like the replies on my earlier topic so I'll just post it again without taking in any information.
Reply
#5

I'm so sorry, but I could do nothing... I'm very disappointed!
Reply
#6

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
I'm so sorry, but I could do nothing... I'm very disappointed!
That he actually did answer your question?

It's doing all the work for you.
Maybe its time to learn to code yourself or not code at all.


Its not that hard either, its actually just entering pluses and few numbers, not to mention Vince already gave you an explanatory.

Nevertheless, the fact that you said that you're disappointed in Vince, who actually spend his time (Which I guess can be called "wasted his time on you" by now) is very rude of you and you are the one to be disappointed in yourself.


Don't ask for help if you're not willing to learn and looking for people to waste their time doing job for you.
Reply
#7

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)));

Reply
#8

This won't do the work.

He'd want you to show this in a textdraw.
You don't have a textdraw code.

Code one.
Reply
#9

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
This won't do the work.

He'd want you to show this in a textdraw.
You don't have a textdraw code.

Code one.
How about you give me some chocolate
Reply
#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


Forum Jump:


Users browsing this thread: 4 Guest(s)