AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Some timeleft calculations.. (https://forums.alliedmods.net/showthread.php?t=215894)

alonelive 05-13-2013 15:44

Some timeleft calculations..
 
Hello.
I need a calculation of elapsed map time (float vaule). There are no timelimit (mp_timelimit "0") on server (gungame), we can't use [mp_timelimit - timeleft]. How i can get him?

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new Float:ElTime

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /elapsed"elapsed)
}

public 
elapsed (id)
{
    ...
    ..
    
cleint_print(idprint_chat"%f elapsed from map bedinning",ElTime)



Arkshine 05-13-2013 15:48

Re: Some timeleft calculations..
 
This should help : http://forums.alliedmods.net/showpos...26&postcount=5

EDIT: Title is misleading. This below should be correct.

YamiKaitou 05-13-2013 15:48

Re: Some timeleft calculations..
 
get_gametime I believe

alonelive 05-14-2013 07:12

Re: Some timeleft calculations..
 
Quote:

Originally Posted by Arkshine (Post 1951337)
This should help : http://forums.alliedmods.net/showpos...26&postcount=5

EDIT: Title is misleading. This below should be correct.

PHP Code:

    register_event("TextMsg""eRestart""a""2&#Game_C""2&#Game_w")
    
register_logevent("eRoundEnd"2"1=Round_End")
    
register_event("HLTV""eNewRound""a""1=0""2=0")
    
register_logevent("eRoundStart"2"1=Round_Start")
    
register_event("SendAudio","eSendAudio","a","2=%!MRAD_BOMBPL"

Sorry. I forgot to say: i use infinite round (orphey) and a code which removes objectives (C4, etc).
Registering of evens and logevents is useless in my case. :cry:

jimaway 05-14-2013 07:28

Re: Some timeleft calculations..
 
Quote:

Originally Posted by YamiKaitou (Post 1951338)
get_gametime I believe

use this

alonelive 05-14-2013 07:40

Re: Some timeleft calculations..
 
I want to initiate map voting & map change process in the end of map (gun game mod). Votemap process initializes when a timeleft value is 00-30 (seconds left).
This is a way: when a mapchenge is needed, we get elapsed map time (ex.: 15 mins and 14 secs) and summ him with 31 seconds = 15:45, then we set timeleft to 15:45. After 1 second votemap is in process..

Quote:

use this
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "asdf"
#define VERSION "1.0"
#define AUTHOR "asdf"

new Float:g_time

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("/elapsed","elapsed")

    
g_time get_gametime()
}


public 
elapsed()
{
    new 
Float:elapsed_time get_gametime() - g_time
    server_print
("elapsed time: %.2f",elapsed_time)


Is this way true?

jimaway 05-14-2013 09:47

Re: Some timeleft calculations..
 
server_print("elapsed time: %.2f", get_gametime())
no need for any global variables or calculations, this will return game time

alonelive 05-15-2013 12:02

Re: Some timeleft calculations..
 
Thanks to all!

ConnorMcLeod 05-15-2013 12:11

Re: Some timeleft calculations..
 
PHP Code:

public elapsed()
{
    
server_print("elapsed time: %s"convert_timeget_gametime() )
}  

convert_timeFloat:flTime )
{
    new 
szTime[32];
    new 
iTime floatroundflTimefloatround_floor );

    new 
szDecimals[5];
    
formatex(szDecimalscharsmax(szDecimals), "%.2f"flTime iTime);
    if( 
iTime 3600 )
    {
        new 
iTime2 iTime 3600;
        
formatex(szTimecharsmax(szTime), "%d:%02d:%02d.%s"iTime/3600iTime2/60iTime2%60szDecimals[2]);
    }
    else
    {
        
formatex(szTimecharsmax(szTime), "%d:%02d.%s"iTime/60iTime%60szDecimals[2]);
    }
    return 
szTime;



alonelive 05-16-2013 04:58

Re: Some timeleft calculations..
 
Thank! This is very useful code!


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

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