AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   PlayTime (https://forums.alliedmods.net/showthread.php?t=162266)

Xalus 07-16-2011 21:16

PlayTime
 
I wanted to make a stock that says how much hours, mins, when U give seconds;

PHP Code:

stock PlayTimeSecondsMinutesHours ) {
    if( 
Seconds == )
        return 
0;

    
Calc_Time:
    
    if( (
Seconds 3600) > ) {
        
Hours++;
        
Seconds /= 3600;
        goto 
Calc_Time;
    }
    else if( (
Seconds 60) > ) {
        
Minutes++;
        
Seconds /= 60;
        goto 
Calc_Time;
    }
    return 
1;


For some reason Seconds / .. don't do anything
Please help / fix!

Thanks

Aykay 07-16-2011 21:21

Re: PlayTime
 
I think you have to do:
PHP Code:

timeHoursMinutesSeconds 

to register them.

fysiks 07-16-2011 21:23

Re: PlayTime
 
Here ya go:

PHP Code:

new iTotalSeconds 1233435
new iHours iTotalSeconds 3600
new iMinutes = (iTotalSeconds 3600) / 60
new iSeconds iTotalSeconds 60 

Also, "PlayTime" is a misleading name for a function that just converts total seconds into hours minutes seconds.

Exolent[jNr] 07-16-2011 21:35

Re: PlayTime
 
You need to make your parameters by-ref.

Xalus 07-17-2011 05:34

Re: PlayTime
 
For somereason this doesn't work..

PHP Code:

new const g_iBanTime[8] = {
    
300,
    
3600,
    
360,
    
1440,
    
360,
    
604800,
    
604800,
    
0
};

new 
SecsMinsHours;

Secs g_iBanTime[i];

convert_secondsSecsMinsHours );
formatex(szTimecharsmax(szTime), "\d(%ih %imins %is)"HoursMinsSecs);

stock convert_seconds( &seconds, &minutes, &hours ) {
    
hours seconds 3600
    minutes 
= (hours 3600) / 60
    seconds 
%= 60



SpeeDeeR 07-17-2011 05:44

Re: PlayTime
 
There is already a native for that ? Inspect time.inc

Xalus 07-17-2011 09:38

Re: PlayTime
 
Quote:

Originally Posted by SpeeDeeR (Post 1512352)
There is already a native for that ? Inspect time.inc

It just gives the time in secs/mins/..

It doesnt calc how much mins/secs/..

SpeeDeeR 07-17-2011 10:08

Re: PlayTime
 
I didnt understand at all.

Bugsy 07-17-2011 10:44

Re: PlayTime
 
Try
PHP Code:

stock convert_seconds( &seconds , &minutes , &hours , &days 
{
    
days seconds 86400;
    
hours = ( seconds 3600 ) % 24;
    
minutes = ( seconds 60 ) % 60;
    
seconds seconds 60;



fysiks 07-17-2011 14:22

Re: PlayTime
 
Quote:

Originally Posted by Xalus (Post 1512344)
For somereason this doesn't work..

PHP Code:

new const g_iBanTime[8] = {
    
300,
    
3600,
    
360,
    
1440,
    
360,
    
604800,
    
604800,
    
0
};

new 
SecsMinsHours;

Secs g_iBanTime[i];

convert_secondsSecsMinsHours );
formatex(szTimecharsmax(szTime), "\d(%ih %imins %is)"HoursMinsSecs);

stock convert_seconds( &seconds, &minutes, &hours ) {
    
hours seconds 3600
    minutes 
= (hours 3600) / 60
    seconds 
%= 60



That's because you didn't do what I showed. The hours variable should never be used, only assigned. See my example again.

Quote:

Originally Posted by SpeeDeeR (Post 1512352)
There is already a native for that ? Inspect time.inc

1. There are not natives in time.inc
2. The stock converts to a string.


All times are GMT -4. The time now is 01:09.

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