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

Help changing Task for get_gametime()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LordOfBlade
Member
Join Date: Feb 2015
Old 05-21-2017 , 09:13   Help changing Task for get_gametime()
Reply With Quote #1

Can someone give me an example of how to use get_gametime() as that type of task

example:

PHP Code:
// on takedamage
Call_funtion(attacker
PHP Code:
Public call_funtion(id)
{
             
Remove_task(id+TASK_CALL_FUNTION)
             
Set_task(5.5"finish_call_funtion"id+TASK_CALL_FUNTION)

I want to do exactly that but with get_gametime() and I have no idea how to use it. I have too many tasks and that's why I want to change to get_gametime()

Last edited by LordOfBlade; 05-21-2017 at 09:17.
LordOfBlade is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-21-2017 , 09:40   Re: Help changing Task for get_gametime()
Reply With Quote #2

It depends on what finish call function does.
If it is preventing repeated use then get_gametime() is a better idea. But if you want something to happen at exactly that time, it's better to stick with the task. Otherwise you would have to use some kind of think and compare a lot more to achieve the same result.
__________________
Black Rose is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-21-2017 , 09:42   Re: Help changing Task for get_gametime()
Reply With Quote #3

You can't execute a function x seconds later with get-gametime. What you probably saw was how to create a cooldown without set_task.
__________________

Last edited by HamletEagle; 05-21-2017 at 09:42.
HamletEagle is offline
LordOfBlade
Member
Join Date: Feb 2015
Old 05-21-2017 , 10:05   Re: Help changing Task for get_gametime()
Reply With Quote #4

ok. Thanks for the answers.
LordOfBlade is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-21-2017 , 15:00   Re: Help changing Task for get_gametime()
Reply With Quote #5

If is there any question about it, I'll try to make it more clear with my basic knowledge about get_gametime() and get_systime(). I'll not explain what those natives are, you can read on API. But:
You can only use those natives for set a delay between things, like commands, hudmessage etc. But you can't set a task with that. Example:

You went add a delay for use a command, you can use get_gametime() or get_systime() instead of set_task(). Then instead of it:

PHP Code:
new bool:g_bUserCanUseCommand[33
PHP Code:
public cmd_command(id)
{
   if(!
g_bUserCanUseCommand[id])
       return

   
g_bUserCanUseCommand[id] = false
   set_task
(30.0"setTrue"id)

PHP Code:
public setTrue(id)
{
    
g_bUserCanUseCommand[id] = true

You can do like this:

PHP Code:
new Float:g_fGameTime 
PHP Code:
public cmd_command(id)
{
    new 
Float:fGameTime get_gametime()

    if(
fGameTime >= g_fGameTime)
    {
        
g_fGameTime = (fGameTime 15.0//  15.0 is the delay.
    
}
    else
    {
        
client_print(idprint_chat"You need to wait %.0f seconds.", (g_fGameTime fGameTime))
    }

You can do the same with get_systime(), but if you wanna check small times like 0.1, 0.2 or something else that 's less than 1.0, you'll always use get_gametime().

Another example with hud messages:

PHP Code:
new Float:g_fGameTime 
PHP Code:
public client_PreThink(id)
{
    new 
Float:fGameTime get_gametime()
    if(
fGameTime >= g_fGameTime)
    {
        
set_hudmessage(02550, -1.00.001.01.0)
        
show_hudmessage(id"bla bla")
 
        
g_fGameTime = (fGameTime 1.0)
    }

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-21-2017 at 20:33.
EFFx is offline
LordOfBlade
Member
Join Date: Feb 2015
Old 05-23-2017 , 10:56   Re: Help changing Task for get_gametime()
Reply With Quote #6

Example 2 is quite useful. He gave me an idea. Since I have a global think.
LordOfBlade 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:17.


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