Raised This Month: $32 Target: $400
 8% 

Problems with hooking events


Post New Thread Reply   
 
Thread Tools Display Modes
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-22-2005 , 19:40  
Reply With Quote #21

I have figured out that the function trace_line doesnt work like it is supposed to, and the message to create the sprite is what is causing the message error. But I have no idea how to fix either of them. With the traceline, im just trying to figure out the point on a wall that a target lies behind. And with the message, im just trying to put a sprite there that only the attacker can see on the point on the wall that the target lies behind.
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-22-2005 , 19:44  
Reply With Quote #22

hmm i dont have time right now to try to test it myself
Freecode is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-22-2005 , 20:43  
Reply With Quote #23

this will help you
http://forums.alliedmods.net/showthr...eateing+entity
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-22-2005 , 23:00  
Reply With Quote #24

Hey, Freecode, I finally have the sprite appearing. w0ot! It was a silly error that escaped my eye. Anyway, I am still having trouble with the trace_line function. I am trying to draw an imaginary line between the attacker and the victim. I want the coordinates of the first obstacle between the two players to be returned to the sprite message. For some reason, those coordinates aren't being returned. Instead, the sprite message always receives the position of the victim. Thanks in advance!

Updated code:
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")   register_cvar("tracker_scale","5")   register_cvar("tracker_bright","72")   //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 x=0; x<num; x++)     isTagged[id][players[x]] = false     for(new y=0; y<num; y++)     isTagged[players[y]][id] = 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 } //---------------------------------------------------------------------------------------------- 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")   new bright=get_cvar_num("tracker_bright")   new scale=get_cvar_num("tracker_scale")     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(players[a], source, target, location)                 message_begin(MSG_ONE, SVC_TEMPENTITY, location, 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(scale)//scale in 0.1's         write_byte(bright)//brightness         message_end()               }     }   } }
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-22-2005 , 23:36  
Reply With Quote #25

it would be really better to do something like this
Code:
public client_PreThink(id) {     if(Tracker[id])     {             for(new a=0; a<33; a++)         {             if(is_user_bot(a))             {                 new Float:origin[3]                 entity_get_vector(id,EV_VEC_origin,origin)                 new Float:sideorigin[3]                 entity_get_vector(a,EV_VEC_origin,sideorigin)                 new Float:hit[3]                 trace_line(id, origin, sideorigin, hit);                                                 if(!spriteToUser[a])                 {                     spriteToUser[a] = create_entity( "env_sprite" );                     entity_set_model( spriteToUser[a], "sprites/c4.spr" );                     entity_set_float( spriteToUser[a], EV_FL_framerate, 10.0 );                     entity_set_vector( spriteToUser[a], EV_VEC_origin, hit);                     DispatchSpawn( spriteToUser[a] );                 }                 else                     entity_set_vector(spriteToUser[a],EV_VEC_origin, hit);             }         }     }                 }
But please dont just copy the code and then ask how to do other stuff. understand it first.
You will need to delete the enteties upon attackers death.
Here are some screenshots i made (yes its a gay sprite i noe)
Attached Images
File Type: jpg 3.jpg (31.4 KB, 100 views)
File Type: jpg 2.jpg (50.3 KB, 109 views)
File Type: jpg 1.jpg (60.7 KB, 98 views)
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-23-2005 , 01:40  
Reply With Quote #26

I got your suggestion to work without any trouble. However, the sprite needs to be visible only to the attacker. Also, I ran into some issues on dust where users had to be within a certain region to view the sprite. It seems that trace_line only works with vectors, unfortunately the sprite message requires coordinates when creating a tempentity. Would it be possible to convert the vector position returned by trace_line to a set of coordinates which could be used by the sprite message? If not, is it possible to perform the same operation as the trace_line function with some other method that will return points? Thanks!
Kunlock is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-23-2005 , 02:20  
Reply With Quote #27

floatround
Freecode is offline
Kunlock
Junior Member
Join Date: Aug 2005
Old 08-23-2005 , 19:24  
Reply With Quote #28

Thanks, Freecode!
Kunlock is offline
Reply


Thread Tools
Display Modes

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 12:49.


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