AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Easy way to get round time? (https://forums.alliedmods.net/showthread.php?t=93315)

TitANious 05-27-2009 12:16

Easy way to get round time?
 
Is there a way to do it? Like get_gametime, there is no get_roundtime :(

padilha007 05-27-2009 12:26

Re: Easy way to get round time?
 
http://forums.alliedmods.net/showthr...t=mp_roundtime

Starsailor 05-27-2009 12:39

Re: Easy way to get round time?
 
like this ?
PHP Code:


#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Get Roundtime"
#define VERSION "1.0"
#define AUTHOR "Starsailor"

#define TASKID 1337


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("Event_roundend"2"1=Round_End"
    
register_event("HLTV","Event_newround","a","1=0","2=0")
    
register_event("TextMsg""Event_roundend""a""2&#Game_C""2&#Game_w")
}

public 
Event_newround()
    
set_task(get_cvar_float("mp_freezetime"),"StartCount",TASKID)

new 
Time

public StartCount(task){
    
Time++
    
set_task(0.9,"StartCount",TASKID)
    
}

public 
Event_roundend(){
            
    if(
task_exists(TASKID))
        
remove_task(TASKID)
            
    
client_print(0,print_chat,"The round has lasted: %d",Time)
    
    
Time 0


The result is the time that players has played in each round

ot_207 05-27-2009 12:59

Re: Easy way to get round time?
 
Not tested!
PHP Code:

//global
new Float:round_start_gametime

// plugin init
register_event("HLTV","event_newround","a","1=0","2=0")

public 
event_newround()
{
 
round_start_gametime get_gametime()
 return 
PLUGIN_CONTINUE
}

stock get_roundtime()
{
 return 
get_gametime() - round_start_gametime



TitANious 05-27-2009 13:05

Re: Easy way to get round time?
 
OT Gametime-Gametime = 0.
Well, it would be good for a stock, i'll use it for a command which only can be used in the 10 secs of start of a round.

AntiBots 05-27-2009 13:06

Re: Easy way to get round time?
 
PHP Code:

stock Float:get_roundtime() 

 return 
get_gametime() - round_start_gametime 


</SPAN>

TitANious 05-27-2009 13:08

Re: Easy way to get round time?
 
Quote:

Originally Posted by AntiBots (Post 835824)
PHP Code:

stock Float:get_roundtime() 

 return 
get_gametime() - round_start_gametime 


</SPAN>

Well round_start_gametime is get_gametime, so it would be get_gametime-get_gametime

SnoW 05-27-2009 13:09

Re: Easy way to get round time?
 
Quote:

Originally Posted by TitANious (Post 835823)
OT Gametime-Gametime = 0

You don't get it. :| Ofc if you use it at the round start it's hows correctly zero. Still when the gametime increases, the round start time is the same all the time.
Edit:
Quote:

Originally Posted by TitANious (Post 835828)
Well round_start_gametime is get_gametime, so it would be get_gametime-get_gametime

Antibots just corrected that the stock must be Float, you must use Ot's code, but Antibot's stock.

TitANious 05-27-2009 13:10

Re: Easy way to get round time?
 
Oh, the round_start_gametime resets every round?

SnoW 05-27-2009 13:12

Re: Easy way to get round time?
 
Quote:

Originally Posted by TitANious (Post 835832)
Oh, the round_start_gametime resets every round?

PHP Code:

 // plugin init 
register_event("HLTV","event_newround","a","1=0","2=0"

public 
event_newround() 

 
round_start_gametime get_gametime() 
 return 
PLUGIN_CONTINUE 


You can try to read the event function's name.


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

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