AlliedModders

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

Sanjay Singh 01-13-2020 05:11

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



Napoleon_be 01-13-2020 09:10

Re: time print
 
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


Sanjay Singh 01-14-2020 06:01

Re: time print
 
Quote:

Originally Posted by Napoleon_be (Post 2680048)
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.

Napoleon_be 01-14-2020 08:30

Re: time print
 
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.

Natsheh 01-14-2020 10:42

Re: time print
 
When dividing an odd number always use floats AKA double variables then round the number to get an integer.

fysiks 01-15-2020 20:47

Re: time print
 
Quote:

Originally Posted by Sanjay Singh (Post 2680177)
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 (Post 2680230)
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.

Natsheh 01-16-2020 01:19

Re: time print
 
Me neither just for the integer division problem.


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

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