Raised This Month: $32 Target: $400
 8% 

time print


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-13-2020 , 05:11   time print
Reply With Quote #1

How can I print Hours after 60min crossed
Currently its showing in mins and seconds but i want it to change to hours if it crossed 60min 00Seconds

PHP Code:
public ElapsedTime(id)
{
    new 
iGetGameTime floatroundget_gametime( ) );

    
iMinutes iGetGameTime 60;
    
iSeconds iGetGameTime 60;
    
//iHours = iMinutes / 60;

    
client_print_color(id "^3Time ^4Elapsed : ^4%d ^3Min ^4%d ^3Sec."iMinutesiSeconds );

__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-13-2020 , 09:10   Re: time print
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=1700371

Don't mind looking at the XPMode.sma, but there's a time.inc attached at the topic that might be usefull for you. I'm not certain though.

Also this could be usefull: https://forums.alliedmods.net/showpo...88&postcount=2

PHP Code:
iHours = ((iGetGameTime 60) / 60
__________________

Last edited by Napoleon_be; 01-13-2020 at 09:15.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-14-2020 , 06:01   Re: time print
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
https://forums.alliedmods.net/showthread.php?p=1700371

Don't mind looking at the XPMode.sma, but there's a time.inc attached at the topic that might be usefull for you. I'm not certain though.

Also this could be usefull: https://forums.alliedmods.net/showpo...88&postcount=2

PHP Code:
iHours = ((iGetGameTime 60) / 60
I want to print in hrs and min if it crossed 60mins.

According this code it will print hours but min will keep increasing.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-14-2020 , 08:30   Re: time print
Reply With Quote #4

Try using clamp(), not sure if it will work though.

Alternatively, i would suggest using a check if iMunites reached 60 and reset it. This probably isn't the proper way though.
__________________

Last edited by Napoleon_be; 01-14-2020 at 08:32.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-14-2020 , 10:42   Re: time print
Reply With Quote #5

When dividing an odd number always use floats AKA double variables then round the number to get an integer.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-14-2020 at 10:42.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-15-2020 , 20:47   Re: time print
Reply With Quote #6

Quote:
Originally Posted by Sanjay Singh View Post
I want to print in hrs and min if it crossed 60mins.

According this code it will print hours but min will keep increasing.
Use the following code for calculating hours, minutes, and seconds:
Code:
iSeconds = 12345 // your time source in seconds
iHours = iSeconds / 3600
iMinutes = iSeconds % 3600 / 60
iSeconds = iSeconds % 60


Quote:
Originally Posted by Natsheh View Post
When dividing an odd number always use floats AKA double variables then round the number to get an integer.
Uh . . no. In this case, we are not trying to get fractional values.
__________________

Last edited by fysiks; 01-15-2020 at 20:53.
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-16-2020 , 01:19   Re: time print
Reply With Quote #7

Me neither just for the integer division problem.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 05:42.


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