aaaaaah! Everything is finally getting called at the appropriate time. However, as soon as an opponent is damaged, the server crashes. The error message reads "New message started when msg '23' has not been sent yet." I am running amx 1.5 with no other heroes installed. Metamod 1.18p24. Latest release of superhero mod. Any ideas? Thanks!
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
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("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)
{
new players[32], num
get_players(players, num, "a")
for(new y=0; y<num; y++)
isTagged[id][players[y]] = false
}
//----------------------------------------------------------------------------------------------
public tracker_init()
{
new temp[128]
// First Argument is an id
read_argv(1, temp, 5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the victim has Tracker power
read_argv(2, temp, 5)
new hasPowers = str_to_num(temp)
if(hasPowers == 1)
hasTrackerPowers[id] = true
else
hasTrackerPowers[id] = false
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public tracker_damage(id)
{
new victim = id
new attacker = get_user_attacker(victim)
if(hasTrackerPowers[attacker])
{
isTagged[attacker][victim] = true
client_print(id,print_chat,"Attacker has tracker powers!")
}
}
//----------------------------------------------------------------------------------------------
public 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)
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
}
}
}
}