AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Map Time elapsed ? (https://forums.alliedmods.net/showthread.php?t=292988)

Awesome_man 01-19-2017 23:32

Map Time elapsed ?
 
How to get time elapsed after starting of any new map

EFFx 01-20-2017 00:06

Re: Map Time elapsed ?
 
https://www.amxmodx.org/api/amxmodx/get_gametime

Awesome_man 01-20-2017 00:53

Re: Map Time elapsed ?
 
Quote:

Originally Posted by EFFx (Post 2488234)

Thanks :)

Awesome_man 01-20-2017 01:48

Re: Map Time elapsed ?
 
How to reduce decimal place like this is my output : 34.220508 Minutes

How to make it 34:22 minutes also when i'm using integer it's showing very big value like 1256456744 etc

EFFx 01-20-2017 02:04

Re: Map Time elapsed ?
 
What are u trying to do? Show the remaining time for map change?

Awesome_man 01-20-2017 02:48

Re: Map Time elapsed ?
 
Quote:

Originally Posted by EFFx (Post 2488252)
What are u trying to do? Show the remaining time for map change?

get_gametime()/60;


I'm trying to get the time elapsed since map change and it's working fine except it's changing to minutes after 0.99 instead of 0.60 for eg: time should change to 2 min after 1:59 but it's changing after 1:99 why so ?

Craxor 01-20-2017 03:34

Re: Map Time elapsed ?
 
Edit: i would do something like that:
PHP Code:

client_printid print_chat"Minutes passed from map start: %i" ,  floatround get_gametime( ) / 60.0 ) ); 

But is not weel because the zecimals wont be calculated until .60 , more than 100.

So a minute will mean 100 seconds based on my tests.

You can trick people like that or you can make your own Count with a variable.

Btw , another trick to calculate the TIMELEFT - Current time passed.

OciXCrom 01-20-2017 08:38

Re: Map Time elapsed ?
 
Quote:

Originally Posted by Awesome_man (Post 2488249)
How to reduce decimal place like this is my output : 34.220508 Minutes

How to make it 34:22 minutes also when i'm using integer it's showing very big value like 1256456744 etc

.220508 doesn't mean 22 seconds. That's basic math:

PHP Code:

34.220508 100 60 57.03418 seconds
floatround
(57.03418) = 57 seconds 

Make your code according to that formula.

edon1337 01-20-2017 18:29

Re: Map Time elapsed ?
 
Quote:

Originally Posted by Awesome_man (Post 2488249)
How to make it 34:22 minutes also when i'm using integer it's showing very big value like 1256456744 etc

34:22 is a string.

Craxor 01-21-2017 04:00

Re: Map Time elapsed ?
 
Code:
#include <amxmodx> static iMinutes, iSeconds; public plugin_init( ) {     register_clcmd( "say /test" , "test" )     set_task( 1.0 , "UpTime" ); } public UpTime( ) {     new iGetGameTime = floatround( get_gametime( ) );     iMinutes = iGetGameTime / 60;     iSeconds = iGetGameTime % 60;     set_task( 1.0 , "UpTime" ); } public test( id ) {     client_print( id , print_chat, "Time passed: %d:%d ", iMinutes, iSeconds );     return PLUGIN_HANDLED;  }


All times are GMT -4. The time now is 20:47.

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