AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to counted 2 minutes from time left (https://forums.alliedmods.net/showthread.php?t=151639)

dark_style 02-26-2011 05:08

How to counted 2 minutes from time left
 
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
    
}



SnoW 02-26-2011 05:37

Re: How to counted 2 minutes from time left
 
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?

dark_style 02-26-2011 05:58

Re: How to counted 2 minutes from time left
 
Oops, my error. You mean I should do:

PHP Code:

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


?

am_amx 02-26-2011 08:32

Re: How to counted 2 minutes from time left
 
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

SnoW 02-26-2011 08:35

Re: How to counted 2 minutes from time left
 
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 )

dark_style 02-26-2011 09:00

Re: How to counted 2 minutes from time left
 
I tried to counted 2 minutes and appear a hud message. I do it on task. ;)

ConnorMcLeod 02-26-2011 09:26

Re: How to counted 2 minutes from time left
 
Show your code.
Say what you want to do.

dark_style 02-26-2011 09:45

Re: How to counted 2 minutes from time left
 
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" )
        }
    }



ConnorMcLeod 02-26-2011 10:21

Re: How to counted 2 minutes from time left
 
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" )



dark_style 02-26-2011 14:16

Re: How to counted 2 minutes from time left
 
Thank you. :)


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

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