Raised This Month: $ Target: $400
 0% 

[HELP] Set_Task question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-10-2016 , 08:01   [HELP] Set_Task question
Reply With Quote #1

So let's say we have this, is there any good way to execute a code in the burning_flame function every two seconds?

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "White"

#define TASK_BURN 304943
#define ID_BURN (taskid - TASK_BURN)


public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
client_cmd("command""function")
    
    
// Add your code here...
}

public function(
id)
{
    
set_task(0.2"burning_flame"victim+TASK_BURN__"b")
}

public 
burning_flame(taskid)
{
    

__________________
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-10-2016 , 08:19   Re: [HELP] Set_Task question
Reply With Quote #2

Use 2.0 instead of 0.2 as the first argument in set_task()? Your example is not good enough if that's not what you want, give us more info.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-10-2016 , 08:33   Re: [HELP] Set_Task question
Reply With Quote #3

Well, i want to do something like this
Without the need to set one more task

PHP Code:
public function(id)
{
    
set_task(0.2"burning_flame"victim+TASK_BURN__"b")
}

public 
burning_flame(taskid)
{
    
every 2 seconds
    
{
        
execute and this code
    
}
    
    
execute this code

__________________

Last edited by Depresie; 02-10-2016 at 08:35.
Depresie is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 02-10-2016 , 08:37   Re: [HELP] Set_Task question
Reply With Quote #4

well you can create a var that holds next burn sound time like:

Code:
new Float:g_flNextBurnSound[33];

....

public burning_flame(taskid)
{
.....

if (g_flNextBurnSound[ID_BURN] <= get_gametime())
{
       ///emit sound here
       g_flNextBurnSound[ID_BURN] = get_gametime() + 2.0;
}
...
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-10-2016 , 08:41   Re: [HELP] Set_Task question
Reply With Quote #5

You can use a thinking entity, read this.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-10-2016 , 08:49   Re: [HELP] Set_Task question
Reply With Quote #6

any other ideea without the need of an array or thinking entities?
maybe with switch and cases? i know how to do it using a random num, but i want exactly at 2.0 seconds
__________________

Last edited by Depresie; 02-10-2016 at 08:50.
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-10-2016 , 08:59   Re: [HELP] Set_Task question
Reply With Quote #7

Just use two tasks? Or just use what has been already suggested by others.
klippy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-10-2016 , 09:00   Re: [HELP] Set_Task question
Reply With Quote #8

Quote:
Originally Posted by Depresie View Post
any other ideea without the need of an array or thinking entities?
maybe with switch and cases? i know how to do it using a random num, but i want exactly at 2.0 seconds
What in the world does a random number have anything to do with it?

If you want something to execute every two seconds, set the time for your tast to 2.0 seconds. If you want it to be called immediately, in addition to the task, call the function directly before setting the task.
__________________
fysiks is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-10-2016 , 09:38   Re: [HELP] Set_Task question
Reply With Quote #9

2/0.2 =10 so:

PHP Code:

new count[33]

public 
burning_flame(taskid)
{
    if(
count[taskid]==10)
    {
       
// yourcode for 2 sec
       
count[taskid]=//reseting counter
    
}
   
//yourcode for 0.2 sec
    
count[taskid]++     //adding +1 every 0.2 seconds

And don't forget do add count[id]=0 when player executes the command and starts the task.
siriusmd99 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-10-2016 , 15:57   Re: [HELP] Set_Task question
Reply With Quote #10

done, thanks, i tought there is a better method, but, i went with the array and counter
__________________
Depresie 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 09:34.


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