Raised This Month: $51 Target: $400
 12% 

PlayTime


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 07-16-2011 , 21:16   PlayTime
Reply With Quote #1

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
__________________
Retired.
Xalus is offline
Aykay
Senior Member
Join Date: Jul 2009
Location: Australia
Old 07-16-2011 , 21:21   Re: PlayTime
Reply With Quote #2

I think you have to do:
PHP Code:
timeHoursMinutesSeconds 
to register them.
__________________

Aykay is offline
Send a message via MSN to Aykay
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-16-2011 , 21:23   Re: PlayTime
Reply With Quote #3

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.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-16-2011 , 21:35   Re: PlayTime
Reply With Quote #4

You need to make your parameters by-ref.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 07-17-2011 , 05:34   Re: PlayTime
Reply With Quote #5

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

__________________
Retired.

Last edited by Xalus; 07-17-2011 at 05:36.
Xalus is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 07-17-2011 , 05:44   Re: PlayTime
Reply With Quote #6

There is already a native for that ? Inspect time.inc
SpeeDeeR is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 07-17-2011 , 09:38   Re: PlayTime
Reply With Quote #7

Quote:
Originally Posted by SpeeDeeR View Post
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/..
__________________
Retired.
Xalus is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 07-17-2011 , 10:08   Re: PlayTime
Reply With Quote #8

I didnt understand at all.
SpeeDeeR is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-17-2011 , 10:44   Re: PlayTime
Reply With Quote #9

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

__________________

Last edited by Bugsy; 07-17-2011 at 10:46.
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-17-2011 , 14:22   Re: PlayTime
Reply With Quote #10

Quote:
Originally Posted by Xalus View Post
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 View Post
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.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:02.


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