AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding days, hours, seconds (https://forums.alliedmods.net/showthread.php?t=188382)

OnePL 06-25-2012 17:37

Adding days, hours, seconds
 
Hello

Can somebody add to showed the days, hours, minutes and eventually seconds?
And to save the database in the same form (days, hours, minutes and eventually seconds)

Spoiler

Liverwiz 06-25-2012 18:24

Re: Adding days, hours, seconds
 
seconds = get_systime()
Minutes = seconds / 60
hours = Minutes / 60
days = hours / 24

if that doesn't help you. go to request.

fysiks 06-25-2012 19:15

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by Liverwiz (Post 1736080)
seconds = get_systime()
Minutes = seconds / 60
hours = Minutes / 60
days = hours / 24

if that doesn't help you. go to request.

You will want to rethink that . . .

I do it this way:

PHP Code:

new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 


Liverwiz 06-25-2012 19:40

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by fysiks (Post 1736125)
PHP Code:

new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 


I'd rethink that too.....

OnePL 06-25-2012 20:34

Re: Adding days, hours, seconds
 
I know, but I want to save in form D: H: M: S in SQL
Add someone?

Liverwiz 06-25-2012 21:22

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by Liverwiz (Post 1736080)
if that doesn't help you. go to request.


fysiks 06-25-2012 23:42

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by Liverwiz (Post 1736146)
I'd rethink that too.....

LOL. Oh really? Why do you say that? Do I have to prove you wrong? I will if you want.

EDIT: I won't wait for your response:

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
set_task(5.0"runProof")
}

public 
runProof()
{
    new 
iTestTest 4687987
    
    
// Liverwiz's Method
    
new seconds iTestTest
    
new minutes seconds 60
    
new hours minutes 60
    
new days hours 24

    server_print
("^nLiverwiz's Method:")
    
server_print("%d Days %d Hours %d Minutes and %d Seconds"dayshoursminutesseconds)

    
// Fysiks' Method
    
new iDays iTestTest 86400
    
new iHours iTestTest 86400 3600
    
new iMinutes iTestTest 3600 60
    
new iSeconds iTestTest 60

    server_print
("^nFysiks' Method:")
    
server_print("%d Days %d Hours %d Minutes and %d Seconds"iDaysiHoursiMinutesiSeconds)


Yields:

Code:

Liverwiz's Method:
54 Days 1302 Hours 78133 Minutes and 4687987 Seconds

Fysiks' Method:
54 Days 6 Hours 13 Minutes and 7 Seconds

I'll let you decide which is correct.

Liverwiz 06-26-2012 00:04

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by fysiks (Post 1736125)
You will want to rethink that . . .

I do it this way:

PHP Code:

new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 


and


Quote:

Originally Posted by fysiks (Post 1736274)
LOL. Oh really? Why do you say that? Do I have to prove you wrong? I will if you want.

EDIT: I won't wait for your response:

PHP Code:

    // Fysiks' Method
    
new iDays iTestTest 86400
    
new iHours iTestTest 86400 3600
    
new iMinutes iTestTest 3600 60
    
new iSeconds iTestTest 60 

.


are different.

You really go through a lot of effort in proving someone wrong, rather than actually helping anyone. When did i sleep with your wife?

fysiks 06-26-2012 00:07

Re: Adding days, hours, seconds
 
Quote:

Originally Posted by Liverwiz (Post 1736280)
are different.

You really go through a lot of effort in proving someone wrong, rather than actually helping anyone. When did i sleep with your wife?

They are the same. I just added an extra "new" because I got it from an old post.

I don't have a wife so you can sleep with her all you want.

Liverwiz 06-26-2012 00:08

Re: Adding days, hours, seconds
 
go compile the first one and tell me if you're still right.


All times are GMT -4. The time now is 06:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.