Raised This Month: $51 Target: $400
 12% 

How can I get a specific time of the map?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 07-03-2011 , 08:32   How can I get a specific time of the map?
Reply With Quote #1

As the title.
For example, I want to get last 30sec of the map by using the get_timeleft().
I watched the mapchooser but I cant understand it.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-03-2011 , 14:36   Re: How can I get a specific time of the map?
Reply With Quote #2

"mapchooser" plugin sets a task every 15 seconds and checks for possible win conditions:
Code:
public voteNextmap()
{
    new winlimit = get_cvar_num("mp_winlimit") // plugin is old, you use pointers !
    new maxrounds = get_cvar_num("mp_maxrounds")
    
    if (winlimit) // this one checks if a team is nearing mp_winlimit
    {
        new c = winlimit - 2
        
        if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
        {
            g_selected = false
            return
        }
    }
    else if (maxrounds) // this one checks if the round is nearing mp_maxrounds
    {
        if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
        {
            g_selected = false
            return
        }
    } else { // and this one checks if it's near the time limit
        new timeleft = get_timeleft()
        
        if (timeleft < 1 || timeleft > 129)
        {
            g_selected = false
            return
        }
    }

    //...
}

Still, set_task() has a flag, "d - do task on time before a map timeleft", but I never tested it and I dunno what effect the time has on it... it may be negative, like, if you specify 30.0 and flag "d" it *could* trigger 30 seconds before timelimit... or you could try -30.0... just experiment with that since it would be a far better method than checking each X seconds.
__________________
Hunter-Digital is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-03-2011 , 16:49   Re: How can I get a specific time of the map?
Reply With Quote #3

I wonder why mapchooser uses a repeating task instead of that then. Nevermind, I know why.

Also, it does work but will only trigger once (for instances like extending the map, it does not trigger again when there is the specified time left; unless I did something wrong during testing).
__________________

Last edited by fysiks; 07-03-2011 at 17:28.
fysiks 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 12:53.


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