Raised This Month: $ Target: $400
 0% 

Solved set_task help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-28-2020 , 00:22   set_task help
Reply With Quote #1

hello. I have this code

PHP Code:
public plugin_init(){
register_event("HLTV""roundstart""a""1=0""2=0"
}

public 
roundstart(id){
    
stopplugin=false
    set_task
25.0"roundcounters"___"b");
    
ColorChat(0GREEN"^3[JoiNET]^1 Anti-rush plugin is ^3enabled^1!")
    
ColorChat(0GREEN"^3[JoiNET]^1 Counter-Terrorists can't rush for^3 25 seconds^1.")

}

public 
roundcounters(id){

stopplugin=true
ColorChat
(0GREEN"^3[JoiNET]^1 test.")


everything is working, but there is a problem with set_task.

after a few rounds, there are more task at different times. i want this task to disable plugin after first 25 seconds, but with more tasks working, sometimes plugin is disabled after a random num of seconds.

Last edited by lexzor; 12-29-2020 at 17:26.
lexzor is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-28-2020 , 02:21   Re: set_task help
Reply With Quote #2

You're creating an infinitely repeating task (flag "b") every time the HLTV event occurs. So, you are creating several simultaneous tasks that never stop. So, after 5 HLTV events, you have 5 tasks that will all keep run until the map changes.

You should probably describe what you are actually trying to do so that we can give you the proper advice. Your "stopplugin" variable doesn't do anything. To run a task only once, don't use any flags.
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-28-2020 , 20:34   Re: set_task help
Reply With Quote #3

^

And using the HLTV event is not the proper way of catching roundstart, read this for more info: https://forums.alliedmods.net/showthread.php?t=42159
__________________

Last edited by Napoleon_be; 12-28-2020 at 20:34.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-29-2020 , 13:04   Re: set_task help
Reply With Quote #4

that is how i hook roundstart now
PHP Code:
register_logevent("logevent_round_start"2"1=Round_Start"
I said very clearly what I want to do in the first post. I want that task to run 25 seconds after the start of the round and not have multiple tasks on top of each other. Usually I get the tasks from the last round to the current round and i used task like this:

PHP Code:
set_task25.0"roundcounters"____); 
and
PHP Code:
set_task25.0"roundcounters"); 
but still don't works

and i have another ask.
can i use set_task like this
PHP Code:
new Float:time 15

set_task
time"public_func"
?

Last edited by lexzor; 12-29-2020 at 13:06.
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-29-2020 , 13:20   Re: set_task help
Reply With Quote #5

This is not complicated
PHP Code:

#include <amxmodx>

const RoundTaskID 57882;

public 
plugin_init() 
{
    
register_logevent("logevent_round_start"2"1=Round_Start"
}

public 
logevent_round_start()
{
    
remove_taskRoundTaskID );
    
set_task25.0 "roundcounters" RoundTaskID );
}

public 
roundcounters()
{
    
client_printprint_chat "round counters called" );

__________________

Last edited by Bugsy; 12-29-2020 at 13:44.
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-29-2020 , 13:24   Re: set_task help
Reply With Quote #6

Thank you guys, but my server is running a csgo mode and i have warmup round, so that's why in first round my tasks are more than normal

how can i do something like.. if an task is starting, to stop previously task ?
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-29-2020 , 13:44   Re: set_task help
Reply With Quote #7

See above
__________________
Bugsy is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-29-2020 , 13:49   Re: set_task help
Reply With Quote #8

omg i didn t read all lines, thank you

Last edited by lexzor; 12-29-2020 at 13:49.
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-29-2020 , 14:00   Re: set_task help
Reply With Quote #9

is this ok ?
PHP Code:
if(task_exists1024 ))
        
remove_task1024 );
        
set_task25.0 "antirushoff" 1024 ); 
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-29-2020 , 14:44   Re: set_task help
Reply With Quote #10

You do not need to first call task_exists() before calling remove_task(), just do what I posted. task_exists() should only be used if you want to know if the task exists for other reasons/conditions.
__________________
Bugsy 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 14:08.


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