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

How to counted 2 minutes from time left


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 02-26-2011 , 05:08   How to counted 2 minutes from time left
Reply With Quote #1

Hey, guys. I tried to counted 2 minutes from time left, but without results.. So I hope someone will help me to do it.

I tried this:

PHP Code:
public func(id)
{
    new 
tl get_timeleft()
    
    if(
tl == 180.0)
    {
        
// code
    
}


Last edited by dark_style; 02-26-2011 at 05:35.
dark_style is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-26-2011 , 05:37   Re: How to counted 2 minutes from time left
Reply With Quote #2

Two minutes isn't 180 seconds. The returned value is integer, so faster to compare to the same type. You should probably check if the time equals or is less for more general usage of the function. You don't really need to cache the value if you don't use it otherwise. Is the id needed to be passed to the function, it doesn't seem anyhow proper?
SnoW is offline
Send a message via MSN to SnoW
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 02-26-2011 , 05:58   Re: How to counted 2 minutes from time left
Reply With Quote #3

Oops, my error. You mean I should do:

PHP Code:
public func(id)
{
    new 
tl get_timeleft()
    
    if(
tl >= 120)
    {
        
// code
    
}

?

Last edited by dark_style; 02-26-2011 at 06:01.
dark_style is offline
am_amx
Senior Member
Join Date: Jul 2010
Location: here
Old 02-26-2011 , 08:32   Re: How to counted 2 minutes from time left
Reply With Quote #4

may be this can help you
Code:
set_task ( Float:time, const function[], id = 0, parameter[]="", len = 0, flags[]="", repeat = 0 )
Quote:
flag= "d" - do task on time before a map timeleft
__________________
am_amx is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 02-26-2011 , 08:35   Re: How to counted 2 minutes from time left
Reply With Quote #5

What I believe is that you use wrong comparison operator, though I'm not exactly sure what you are wanting to do ( When do you call the function? ). Following would return true if there is equal or less of 2 minutes time left.
Code:
( get_timeleft( ) <= 120 )
SnoW is offline
Send a message via MSN to SnoW
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 02-26-2011 , 09:00   Re: How to counted 2 minutes from time left
Reply With Quote #6

I tried to counted 2 minutes and appear a hud message. I do it on task. ;)
dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-26-2011 , 09:26   Re: How to counted 2 minutes from time left
Reply With Quote #7

Show your code.
Say what you want to do.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 02-26-2011 , 09:45   Re: How to counted 2 minutes from time left
Reply With Quote #8

PHP Code:
#include <amxmodx>

new const Version[] = "0.1"

public plugin_init()
{
    
register_plugin"Test"Version"Dark_Style" )
}

public 
client_putinserverid )
{
    
set_task10.0"show_func"id )
}

public 
show_funcid )
{
    if( 
is_user_connectedid ) )
    {
        if( 
get_timeleft( ) <= 120 )
        {
            
set_hudmessage8542255, -1.0, -1.006.012.0 )
            
show_hudmessageid"Test" )
        }
    }

dark_style is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-26-2011 , 10:21   Re: How to counted 2 minutes from time left
Reply With Quote #9

PHP Code:
#include <amxmodx>

new const Version[] = "0.1"

public plugin_init()
{
    
register_plugin"Test"Version"Dark_Style" )
    
set_task(120.0"show_func", .flags="d")
}

public 
show_func( )
{
    
set_hudmessage8542255, .channel=-)
    
show_hudmessage(0"Timeleft is 120" )

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 02-26-2011 , 14:16   Re: How to counted 2 minutes from time left
Reply With Quote #10

Thank you.
dark_style is offline
Reply


Thread Tools
Display Modes

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 13:33.


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