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

Problems with hooking events


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-21-2005 , 16:28   Problems with hooking events
Reply With Quote #1

Im having issues with my functions that hook DeathMSG, ResetHUD, and Damage. The functions never seem to get called even though I hooked the way I have seen many other plugins hook. I am not sure what is going wrong. My tracker_loop never gets called either. The client messages are in there for debugging purposes.


Code:
#include <amxmod> #include <superheromod> #define PLUGINNAME "Tracker" #define VERSION "0.1" #define AUTHOR "Kunlock" #define HERONAME "Tracker" #define SHORTDESC "Tracks victims" #define LONGDESC "Shooting enemies tags them so you can track them down" new bool:hasTrackerPowers[SH_MAXSLOTS+1] new bool:isTagged[SH_MAXSLOTS+1][SH_MAXSLOTS+1] new spriteTarget //---------------------------------------------------------------------------------------------- public plugin_init() {   //Plugin Info   register_plugin(PLUGINNAME, VERSION, AUTHOR)     //Create the hero   client_print(0,print_chat,"Attempting to create %s Hero", HERONAME)   register_cvar("tracker_level", "5" )   //Hero Name- Short Description- Long Description- false=Automatic Powers true=KeyDown powers- Hero level   shCreateHero(HERONAME, SHORTDESC, LONGDESC, false, "tracker_level" )     //Hook events and init main functions   register_srvcmd("tracker_init", "tracker_init")   shRegHeroInit(HERONAME, "tracker_init")     register_event("DeathMSG","tracker_death","a")   register_event("ResetHUD","newRound","b")   register_event("Damage", "tracker_damage", "b", "2!0")   set_task(1.0,"tracker_loop",0,"",0,"b") } //---------------------------------------------------------------------------------------------- public plugin_precache() {     spriteTarget = precache_model("sprites/thorns2.spr") } //---------------------------------------------------------------------------------------------- public newRound() {   client_print(0,print_chat,"NewRound")   new players[32], num   get_players(players, num, "a")   for(new x=0; x<num; x++)     for(new y=0; y<num; y++)       isTagged[players[x]][players[y]] = false } //---------------------------------------------------------------------------------------------- public tracker_init() {   client_print(0,print_chat,"Tracker_Init")   new temp[128]   // First Argument is an id   read_argv(1, temp, 5)   new id = strtonum(temp)   // 2nd Argument is 0 or 1 depending on whether the victim has Tracker power   read_argv(2, temp, 5)   new hasPowers = strtonum(temp)   if(hasPowers)      hasTrackerPowers[id] = true   else      hasTrackerPowers[id] = false   return PLUGIN_CONTINUE } //---------------------------------------------------------------------------------------------- public tracker_damage(id) {   new victim = id   new attacker = get_user_attacker(victim)   client_print(0,print_chat,"Tracker_Damage   Victim:%d    Attacker:%d",victim,attacker)   if(!shModActive() || !hasTrackerPowers[attacker])     return PLUGIN_CONTINUE   if(is_user_alive(victim) && victim != attacker)   {     isTagged[attacker][victim] = true     client_print(0,print_chat,"Attacker has tracker powers!")   }   return PLUGIN_CONTINUE } //---------------------------------------------------------------------------------------------- public tracker_death() {   new id=read_data(2)   client_print(0,print_chat,"Death")   new players[32], num   get_players(players, num, "a")   for(new x=0; x<num; x++)     isTagged[id][players[x]] = false } //---------------------------------------------------------------------------------------------- public tracker_loop() {   client_print(0,print_chat,"Tracker_Loop")   new players[32], num   get_players(players, num, "a")     for(new a=1; a<num; a++)     for(new v=1; v<num; v++)       if(isTagged[players[a]][players[v]])       {         new Float:location[3], Float:source[3], Float:target[3]         get_user_origin(players[a], source, 0)         get_user_origin(players[v], target, 0)         trace_line(0, source, target, location)                         message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])         write_byte(17)//additive sprite, plays 1 cycle         write_coord(location[0])//x         write_coord(location[1])//y         write_coord(location[2])//z         write_short(spriteTarget)//sprite index         write_byte(10)//scale in 0.1's         write_byte(200)//brightness       } } //----------------------------------------------------------------------------------------------
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-21-2005 , 16:48  
Reply With Quote #2

in ur damage event u must do something like this

Code:
if(hasTrackerPowers[attacker]) {      isTagged[attacker][victim] = true }

then when checking if user is tagged.

Code:
get_players(players, num, "a")   for(new a=1; a<num; a++)      for(new v=1; v<num; v++)           if(hasTrackerPowers[players[a]])                if(isTagged[players[a]][players[v]])
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-21-2005 , 17:22  
Reply With Quote #3

Yes, that makes my code look a little better, but it doesnt fix the problem that I am having with being unable to get my function hooks to work.
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-21-2005 , 18:16  
Reply With Quote #4

update your source code.
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-21-2005 , 18:38  
Reply With Quote #5

Updated Source:

Code:
#include <amxmod> #include <superheromod> #define PLUGINNAME "Tracker" #define VERSION "0.1" #define AUTHOR "Kunlock" #define HERONAME "Tracker" #define SHORTDESC "Tracks victims" #define LONGDESC "Shooting enemies tags them so you can track them down" new bool:hasTrackerPowers[SH_MAXSLOTS+1] new bool:isTagged[SH_MAXSLOTS+1][SH_MAXSLOTS+1] new spriteTarget //---------------------------------------------------------------------------------------------- public plugin_init() {   //Plugin Info   register_plugin(PLUGINNAME, VERSION, AUTHOR)     //Create the hero   client_print(0,print_chat,"Attempting to create %s Hero", HERONAME)   register_cvar("tracker_level", "5" )   //Hero Name- Short Description- Long Description- false=Automatic Powers true=KeyDown powers- Hero level   shCreateHero(HERONAME, SHORTDESC, LONGDESC, false, "tracker_level" )     //Hook events and init main functions   register_srvcmd("tracker_init", "tracker_init")   shRegHeroInit(HERONAME, "tracker_init")     register_event("DeathMSG","tracker_death","a")   register_event("ResetHUD","newRound","b")   register_event("Damage", "tracker_damage", "b", "2!0")   set_task(1.0,"tracker_loop",0,"",0,"b") } //---------------------------------------------------------------------------------------------- public plugin_precache() {     spriteTarget = precache_model("sprites/thorns2.spr") } //---------------------------------------------------------------------------------------------- public newRound() {   client_print(0,print_chat,"NewRound")   new players[32], num   get_players(players, num, "a")   for(new x=0; x<num; x++)     for(new y=0; y<num; y++)       isTagged[players[x]][players[y]] = false } //---------------------------------------------------------------------------------------------- public tracker_init() {   client_print(0,print_chat,"Tracker_Init")   new temp[128]   // First Argument is an id   read_argv(1, temp, 5)   new id = strtonum(temp)   // 2nd Argument is 0 or 1 depending on whether the victim has Tracker power   read_argv(2, temp, 5)   new hasPowers = strtonum(temp)   if(hasPowers)      hasTrackerPowers[id] = true   else      hasTrackerPowers[id] = false   return PLUGIN_CONTINUE } //---------------------------------------------------------------------------------------------- public tracker_damage(id) {   new victim = id   new attacker = get_user_attacker(victim)   client_print(0,print_chat,"Tracker_Damage   Victim:%d    Attacker:%d",victim,attacker)   if(hasTrackerPowers[attacker])   {     isTagged[attacker][victim] = true     client_print(0,print_chat,"Attacker has tracker powers!")   } } //---------------------------------------------------------------------------------------------- public tracker_death() {   new id=read_data(2)   client_print(0,print_chat,"Death")   new players[32], num   get_players(players, num, "a")   for(new x=0; x<num; x++)     isTagged[id][players[x]] = false } //---------------------------------------------------------------------------------------------- public tracker_loop() {   client_print(0,print_chat,"Tracker_Loop")   new players[32], num   get_players(players, num, "a")     for(new a=1; a<num; a++)     for(new v=1; v<num; v++)       if(hasTrackerPowers[players[a]])         if(isTagged[players[a]][players[v]])         {           new Float:location[3], Float:source[3], Float:target[3]           get_user_origin(players[a], source, 0)           get_user_origin(players[v], target, 0)           trace_line(0, source, target, location)                   message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])           write_byte(17)//additive sprite, plays 1 cycle           write_coord(location[0])//x           write_coord(location[1])//y           write_coord(location[2])//z           write_short(spriteTarget)//sprite index           write_byte(10)//scale in 0.1's           write_byte(200)//brightness         } } //----------------------------------------------------------------------------------------------
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-21-2005 , 20:44  
Reply With Quote #6

Code:
public tracker_death() {   new id=read_data(2)   client_print(0,print_chat,"Death")   if(hasTrackerPowers[id])     for(new a=0; a<33; a++)       isTagged[id][a] = false           } //---------------------------------------------------------------------------------------------- public tracker_loop() {   client_print(0,print_chat,"Tracker_Loop")   new players[32], num   get_players(players, num, "a")     for(new a=0; a<num; a++)     for(new v=0; v<num; v++)       if(hasTrackerPowers[players[a]])         if(isTagged[players[a]][players[v]])         {           new Float:location[3], Float:source[3], Float:target[3]           get_user_origin(players[a], source, 0)           get_user_origin(players[v], target, 0)           trace_line(0, source, target, location)                   client_print(0,print_chat,"Source:%d,%d,%d Target:%d,%d,%d Location:%d,%d,%d",source[0],source[1],source[2],target[0],target[1],target[2],location[0],location[1],location[2])                   message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])           write_byte(17)//additive sprite, plays 1 cycle           write_coord(location[0])//x           write_coord(location[1])//y           write_coord(location[2])//z           write_short(spriteTarget)//sprite index           write_byte(10)//scale in 0.1's           write_byte(200)//brightness         } }
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-21-2005 , 23:07  
Reply With Quote #7

Still nothing... >_<

Code:
#include <amxmod> #include <superheromod> #define PLUGINNAME "Tracker" #define VERSION "0.1" #define AUTHOR "Kunlock" #define HERONAME "Tracker" #define SHORTDESC "Tracks victims" #define LONGDESC "Shooting enemies tags them so you can track them down" new bool:hasTrackerPowers[SH_MAXSLOTS+1] new bool:isTagged[SH_MAXSLOTS+1][SH_MAXSLOTS+1] new spriteTarget //---------------------------------------------------------------------------------------------- public plugin_init() {   //Plugin Info   register_plugin(PLUGINNAME, VERSION, AUTHOR)     //Create the hero   client_print(0,print_chat,"Attempting to create %s Hero", HERONAME)   register_cvar("tracker_level", "5" )   //Hero Name- Short Description- Long Description- false=Automatic Powers true=KeyDown powers- Hero level   shCreateHero(HERONAME, SHORTDESC, LONGDESC, false, "tracker_level" )     //Hook events and init main functions   register_srvcmd("tracker_init", "tracker_init")   shRegHeroInit(HERONAME, "tracker_init")     register_event("DeathMSG","tracker_death","a")   register_event("ResetHUD","newRound","b")   register_event("Damage", "tracker_damage", "b", "2!0")   set_task(1.0,"tracker_loop",0,"",0,"b") } //---------------------------------------------------------------------------------------------- public plugin_precache() {     spriteTarget = precache_model("sprites/thorns2.spr") } //---------------------------------------------------------------------------------------------- public newRound() {   client_print(0,print_chat,"NewRound")   new players[32], num   get_players(players, num, "a")   for(new x=0; x<num; x++)     for(new y=0; y<num; y++)       isTagged[players[x]][players[y]] = false } //---------------------------------------------------------------------------------------------- public tracker_init() {   client_print(0,print_chat,"Tracker_Init")   new temp[128]   // First Argument is an id   read_argv(1, temp, 5)   new id = strtonum(temp)   // 2nd Argument is 0 or 1 depending on whether the victim has Tracker power   read_argv(2, temp, 5)   new hasPowers = strtonum(temp)   if(hasPowers)      hasTrackerPowers[id] = true   else      hasTrackerPowers[id] = false   return PLUGIN_CONTINUE } //---------------------------------------------------------------------------------------------- public tracker_damage(id) {   new victim = id   new attacker = get_user_attacker(victim)   client_print(0,print_chat,"Tracker_Damage   Victim:%d    Attacker:%d",victim,attacker)   if(hasTrackerPowers[attacker])   {     isTagged[attacker][victim] = true     client_print(0,print_chat,"Attacker has tracker powers!")   } } //---------------------------------------------------------------------------------------------- public tracker_death() {   new id=read_data(2)   client_print(0,print_chat,"Death")   if(hasTrackerPowers[id])     for(new a=0; a<33; a++)       isTagged[id][a] = false           } //---------------------------------------------------------------------------------------------- public tracker_loop()  {   client_print(0,print_chat,"Tracker_Loop")   new players[32], num   get_players(players, num, "a")       for(new a=0; a<num; a++)     for(new v=0; v<num; v++)       if(hasTrackerPowers[players[a]])         if(isTagged[players[a]][players[v]])         {           new Float:location[3], Float:source[3], Float:target[3]           get_user_origin(players[a], source, 0)           get_user_origin(players[v], target, 0)           trace_line(0, source, target, location)                     message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])           write_byte(17)//additive sprite, plays 1 cycle           write_coord(location[0])//x           write_coord(location[1])//y           write_coord(location[2])//z           write_short(spriteTarget)//sprite index           write_byte(10)//scale in 0.1's           write_byte(200)//brightness         } }
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-22-2005 , 00:48  
Reply With Quote #8

Code:
public newRound(id) {   client_print(0,print_chat,"NewRound")   new players[32], num   get_players(players, num, "a")   for(new y=0; y<num; y++)     isTagged[id][players[y]] = false }
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-22-2005 , 01:33  
Reply With Quote #9

Still no go, Freecode. I seriously don't understand where I've gone wrong.

Code:
#include <amxmod> #include <superheromod> #define PLUGINNAME "Tracker" #define VERSION "0.1" #define AUTHOR "Kunlock" #define HERONAME "Tracker" #define SHORTDESC "Tracks victims" #define LONGDESC "Shooting enemies tags them so you can track them down" new bool:hasTrackerPowers[SH_MAXSLOTS+1] new bool:isTagged[SH_MAXSLOTS+1][SH_MAXSLOTS+1] new spriteTarget //---------------------------------------------------------------------------------------------- public plugin_init() {   //Plugin Info   register_plugin(PLUGINNAME, VERSION, AUTHOR)   //Create the hero   client_print(0,print_chat,"Attempting to create %s Hero", HERONAME)   register_cvar("tracker_level", "5" )   //Hero Name- Short Description- Long Description- false=Automatic Powers true=KeyDown powers- Hero level   shCreateHero(HERONAME, SHORTDESC, LONGDESC, false, "tracker_level" )       //Hook events and init main functions   register_srvcmd("tracker_init", "tracker_init")   shRegHeroInit(HERONAME, "tracker_init")       register_event("DeathMSG","tracker_death","a")   register_event("ResetHUD","newRound","b")   register_event("Damage", "tracker_damage", "b", "2!0")   set_task(1.0,"tracker_loop",0,"",0,"b") } //---------------------------------------------------------------------------------------------- public plugin_precache() {     spriteTarget = precache_model("sprites/thorns2.spr") } //---------------------------------------------------------------------------------------------- public newRound(id) {   client_print(0,print_chat,"NewRound")   new players[32], num   get_players(players, num, "a")   for(new y=0; y<num; y++)     isTagged[id][players[y]] = false } //---------------------------------------------------------------------------------------------- public tracker_init()  {   client_print(0,print_chat,"Tracker_Init")   new temp[128]    // First Argument is an id   read_argv(1, temp, 5)    new id = strtonum(temp)    // 2nd Argument is 0 or 1 depending on whether the victim has Tracker power   read_argv(2, temp, 5)    new hasPowers = strtonum(temp)    if(hasPowers)       hasTrackerPowers[id] = true    else       hasTrackerPowers[id] = false   return PLUGIN_CONTINUE } //---------------------------------------------------------------------------------------------- public tracker_damage(id) {   new victim = id   new attacker = get_user_attacker(victim)    client_print(0,print_chat,"Tracker_Damage   Victim:%d    Attacker:%d",victim,attacker)   if(hasTrackerPowers[attacker])   {     isTagged[attacker][victim] = true     client_print(0,print_chat,"Attacker has tracker powers!")   }  } //---------------------------------------------------------------------------------------------- public tracker_death()  {    new id=read_data(2)    client_print(0,print_chat,"Death")    if(hasTrackerPowers[id])      for(new a=0; a<33; a++)        isTagged[id][a] = false              }  //---------------------------------------------------------------------------------------------- public tracker_loop()    {    client_print(0,print_chat,"Tracker_Loop")    new players[32], num    get_players(players, num, "a")        for(new a=0; a<num; a++)      for(new v=0; v<num; v++)        if(hasTrackerPowers[players[a]])          if(isTagged[players[a]][players[v]])          {            new Float:location[3], Float:source[3], Float:target[3]            get_user_origin(players[a], source, 0)            get_user_origin(players[v], target, 0)            trace_line(0, source, target, location)                     message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])            write_byte(17)//additive sprite, plays 1 cycle           write_coord(location[0])//x           write_coord(location[1])//y           write_coord(location[2])//z           write_short(spriteTarget)//sprite index           write_byte(10)//scale in 0.1's           write_byte(200)//brightness         }  }
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-22-2005 , 02:42  
Reply With Quote #10

lets see. get rid of death event. its not nedded. NewRound already does its purpose.

try this
Code:
public tracker_loop() {   client_print(0,print_chat,"Tracker_Loop")   new players[32], num   get_players(players, num, "a")     for(new a=0; a<num; a++)   {     for(new v=0; v<num; v++)     {       if(isTagged[players[a]][players[v]])       {         new Float:location[3], Float:source[3], Float:target[3]         get_user_origin(players[a], source, 0)         get_user_origin(players[v], target, 0)         trace_line(0, source, target, location)                 client_print(0,print_chat,"Source:%d,%d,%d Target:%d,%d,%d Location:%d,%d,%d",source[0],source[1],source[2],target[0],target[1],target[2],location[0],location[1],location[2])                 message_begin(MSG_ONE, SVC_TEMPENTITY, {0,0,0}, players[a])         write_byte(17)//additive sprite, plays 1 cycle         write_coord(location[0])//x         write_coord(location[1])//y         write_coord(location[2])//z         write_short(spriteTarget)//sprite index         write_byte(10)//scale in 0.1's         write_byte(200)//brightness       }     }   } }
Freecode 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 11:39.


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