Raised This Month: $ Target: $400
 0% 

Some timeleft calculations..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-13-2013 , 15:44   Some timeleft calculations..
Reply With Quote #1

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)

__________________
sorry my bad english...

Last edited by alonelive; 05-13-2013 at 15:45.
alonelive is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-13-2013 , 15:48   Re: Some timeleft calculations..
Reply With Quote #2

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

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

Last edited by Arkshine; 05-13-2013 at 15:50.
Arkshine is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-14-2013 , 07:12   Re: Some timeleft calculations..
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
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.
__________________
sorry my bad english...
alonelive is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-13-2013 , 15:48   Re: Some timeleft calculations..
Reply With Quote #4

get_gametime I believe
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-14-2013 , 07:28   Re: Some timeleft calculations..
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
get_gametime I believe
use this
jimaway is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-14-2013 , 07:40   Re: Some timeleft calculations..
Reply With Quote #6

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?
__________________
sorry my bad english...

Last edited by alonelive; 05-14-2013 at 07:41.
alonelive is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-14-2013 , 09:47   Re: Some timeleft calculations..
Reply With Quote #7

server_print("elapsed time: %.2f", get_gametime())
no need for any global variables or calculations, this will return game time
jimaway is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-15-2013 , 12:02   Re: Some timeleft calculations..
Reply With Quote #8

Thanks to all!
__________________
sorry my bad english...
alonelive is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-15-2013 , 12:11   Re: Some timeleft calculations..
Reply With Quote #9

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;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 05-16-2013 , 04:58   Re: Some timeleft calculations..
Reply With Quote #10

Thank! This is very useful code!
__________________
sorry my bad english...
alonelive is offline
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 16:16.


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