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

sending data through set_task not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-11-2009 , 20:56   sending data through set_task not working
Reply With Quote #1

This plugin that I have written works well if I don't use tasks and just execute my command immediately (engclient_cmd), but doesn't work right with a set task delay. It looks like the data isn't being passed correctly.

Code:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
public plugin_init()
{
 
register_plugin("Bot Say Sorry for TK""1.0""Fysiks")
 
RegisterHam(Ham_Killed"player""ham_player_killed",1)
}
public 
ham_player_killedvictimkillergib// killer, victim, wpnindex, hitplace, TK)
{
 
// if(!is_user_bot(killer) || victim == killer || get_user_team(killer) != get_user_team(victim))
  // return
 
 // if(task_exists(killer)) remove_task(killer)  // If bot kills two teammates less than 3 seconds apart
 
 
new idstring[3]
 
num_to_str(killeridstring,2)
 
set_task(3.0"say_sorry",killer,idstring,0)
 
server_print("Task Set %d,%s"killer,idstring)
 return
}
public 
say_sorry(idstr[])
{
 new 
idnum str_to_num(idstr)
 if(
idnumengclient_cmd(idnum,"say","Sorry!")
 
server_print("Should have been done (%d,%s)"idnumidstr)

Some Results:
Code:
 
Task Set 8,8
Task Set 5,5
Should have been done (0,mFilter)
Should have been done (0,
And yes, there was nothing after that last comma .
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-11-2009 , 21:38   Re: sending data through set_task not working
Reply With Quote #2

You are telling set_task the size of idstring is 0 and it should be 3.

set_task( 3.0 , "say_sorry" ,killer , idstring , 3 )

And

public say_sorry(idstr[3])
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2009 , 02:15   Re: sending data through set_task not working
Reply With Quote #3

That worked, Thanks, +karma.

I started thinking more about it and realized that I should pass the number through as direct as possible for effeciency(i.e. not using an intermediary string and conversion functions). So I put "killer" into a single cell array and passed the array:

Code:
 new param[1]
 param[0] = killer
 set_task(3.0,"say_sorry",killer,param,1)
and
Code:
say_sorry(param[])
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-12-2009 , 02:42   Re: sending data through set_task not working
Reply With Quote #4

If you want to pass the id, just do :

set_task( 3.0, "say_sorry", killer );

public say_sorry ( id )
{

}
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2009 , 14:52   Re: sending data through set_task not working
Reply With Quote #5

Will that assign a task id as well as pass the actual id so that my remove task will work?
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-12-2009 , 14:55   Re: sending data through set_task not working
Reply With Quote #6

player's id is just a number, you can pass what you want as task id.
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2009 , 15:19   Re: sending data through set_task not working
Reply With Quote #7

Quote:
Originally Posted by arkshine View Post
If you want to pass the id, just do :

set_task( 3.0, "say_sorry", killer );

public say_sorry ( id )
{

}
Quote:
set_task ( Float:time, const function[], id = 0, parameter[]="", len = 0, flags[]="", repeat = 0 )
"killer" is in the argument for the task id but it passes it as a parameter is what you said. I need it to assign the task id "killer" and pass the value "killer" so that I can remove the task if there is a second kill before the first set_task(id=same killer) has executed.

I need to prevent: kill, sorry, kill, sorry, kill sorry. I need: kill, kill, kill, sorry.
fysiks 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:28.


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