Raised This Month: $ Target: $400
 0% 

get_user_attacker returns wrong id [PARTLY SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 10-04-2006 , 12:28   get_user_attacker returns wrong id [PARTLY SOLVED]
Reply With Quote #1

I have a problem with get_user_attacker returning wrong id number.
Sometimes it works and sometimes it returns a 3 digit number as id number.
And because of this I get Error 4 - index out of bounds.
Isnt get_user_attacker just returning a number between 1-32?
I am using 1.76a.

Wrong id number returned here:
Code:
new bum = get_user_attacker(id) client_print(0,print_chat, "DEBUG: Bum id = %d, Victim id = %d",bum,id)

Error 4 here:
Code:
if(isClipping[bum])


Suiciding debug pic
Working and non working id numbers

Code:
/* Plugin generated by AMXX-Studio * *  AMX Mod X script * *   Noclip for all * *   by Lt Llama * *   Thanks to: *   - NL)Ramon(NL:  For the playerclass stock *       - EKS: Mirror damage plugin * *  WHAT IS THIS? *  ==================== *   This plugin gives the client noclip for a limited amount of time set by *   the cvar amx_cliptime. *   When a player is noclipping he cant attack other enemy players, if he do the damage is *   mirrored. *   If he change team or player class during noclip he is slayed. We dont want *   him to tele back as another class or in another team. * * *  PURPOSE *  ============= *   Probably useless. I made it as a way for players on TFC skills servers to be able *   to spectate a jump with noclip. Often people ask for noclip to spec the jumps. * *  USER COMMANDS *  ============= * - say '/clipon' Gives player noclip for amx_cliptime <seconds>. When the time *   is up the player will be teleported back to the spot he started /clipon at. * * - say '/clipoff' Turns noclip off before the given timelimit and player is teleported back. * */ #include <amxmodx> #include <amxmisc> #include <engine> #include <fun> #define PLUGIN "nc4all" #define VERSION "1.0" #define AUTHOR "Lt Llama" new clipperOrigin[33][3] new clipteam[33] new clipclass[33] new bool:isClipping[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("amx_cliptime","40.0")     register_clcmd("say /clipon","skillClip",0,"- gives noclip for amx_cliptime.")     register_clcmd("say /clipoff","resetClipper",0,"- resets noclip and teleports you back")     register_event("Damage", "Event_Damage","b","2!0"); } // Clear the tasks and cvars attached to id's public client_disconnect(id) {     new authid[32] ; get_user_authid(id,authid,31)     if (task_exists(id)) remove_task(id)     isClipping[id] = false } // Give player noclip when he says /clipon for amx_cliptime <seconds> public skillClip(id){     if(is_user_alive(id)) {         if (isClipping[id]) {             client_print(id,print_chat, "Can't use while noclipping")         } else {             // Check if the use is standing still when using /clipon.             // We dont want mid air hax.             new Float:movement[3]             get_user_velocity(id,movement)             if(movement[0]==0.0 && movement[1]==0.0 && movement[2]==0.0) {                 isClipping[id] = true                 client_print(id,print_chat, "Noclip resets in %i second. /clipoff gets you back faster.",floatround(get_cvar_float("amx_cliptime")))                 get_user_origin(id,clipperOrigin[id],0)                 clipteam[id] = get_user_team(id)                 clipclass[id] = get_user_class(id)                 set_user_noclip(id,1)                 set_task(get_cvar_float("amx_cliptime"),"resetClipper",id)                 return PLUGIN_CONTINUE             } else {                 client_print(id,print_chat, "Stand still on the ground when using /clipon")                 return PLUGIN_HANDLED             }         }     }     return PLUGIN_CONTINUE } // Resets a noclipping player and teleports him back to the place he started // /clipon at. public resetClipper(id){     new classcheck,teamcheck     teamcheck = get_user_team(id)     classcheck = get_user_class(id)         if (isClipping[id] == true) {         // Check if player switched team or class. Is so = invert damage.         if(teamcheck != clipteam[id] || classcheck != clipclass[id]) {             new name[32] ; get_user_name(id,name,31)             if(is_user_alive(id)) {                 client_print(0,print_chat, "%s tried to hax! %s is now dead!",name,name)                 user_kill(id)             }             isClipping[id] = false             } else if (isClipping[id]) {             set_user_origin(id,clipperOrigin[id])             client_print(id,print_chat, "You have been teleported back to the spot you started noclip on.")             isClipping[id] = false             set_user_noclip(id,0)         }     }     return PLUGIN_CONTINUE } // If a player is attacking another player during noclip the damage is mirrored. // Inspiration by EKS Mirror Damage plugin <a href="http://forums.alliedmods.net/showthread.php?p=77112" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?p=77112</a> public Event_Damage(id) {     new damage = read_data(2);     new bum = get_user_attacker(id)     client_print(0,print_chat, "DEBUG: Bum id = %d, Victim id = %d",bum,id)     set_user_health(id,(get_user_health(id)+damage))     if(is_user_connected(id) && is_user_alive(id)) {         if(get_user_team(id) != get_user_team(bum) && id != bum) {             // client_print(0,print_chat, "DEBUG: Condition accepted")             if(isClipping[bum]) {                 new bumHp = get_user_health(bum) - damage                 new name[32] ; get_user_name(id,name,31)                 client_print(bum,print_chat, "You attacked %s when noclipping and lost %d hp",name,damage)                 if(bumHp > 0) {                     set_user_health(bum,(get_user_health(bum)-damage))                 } else {                     if (task_exists(bum)) remove_task(bum)                     resetClipper(bum)                     user_kill(bum)                 }             }         }     } } // Gets the player class // Stock made by NL)Ramon(NL stock get_user_class(id) {     new playerclass = entity_get_int(id, EV_INT_playerclass)     return playerclass }
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.

Last edited by Lt Llama; 10-05-2006 at 03:33.
Lt Llama is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-04-2006 , 12:37   Re: get_user_attacker returns wrong id
Reply With Quote #2

If you run this on other mods, like HL, that have monsters or other stuff in them, the entity index can be anywhere between the number of max players on a server and 500 (default), causing an out of bounds error.

You can essentially filter the monsters out with a simple check like:

Code:
if (!is_user_alive(id))     // It's a monster!
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-04-2006 , 12:43   Re: get_user_attacker returns wrong id
Reply With Quote #3

Use:
Code:
register_event("Damage", "Event_Damage", "b", "2!0", "3=0", "4!0")
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 10-04-2006 , 12:45   Re: get_user_attacker returns wrong id
Reply With Quote #4

Quote:
Originally Posted by Zenith77 View Post
If you run this on other mods, like HL, that have monsters or other stuff in them, the entity index can be anywhere between the number of max players on a server and 500 (default), causing an out of bounds error.

You can essentially filter the monsters out with a simple check like:

Code:
if (!is_user_alive(id))     // It's a monster!
Im running it in TFC but im using is_user_alive(id) before i check if the player is noclipping. I also tested on myself and as you can see it returns an id number of 298 as Attacker and 1 as Victim. I want it to be 1 and 1.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 10-04-2006 , 12:47   Re: get_user_attacker returns wrong id
Reply With Quote #5

check if "bum" is connected?
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 10-04-2006 , 12:49   Re: get_user_attacker returns wrong id
Reply With Quote #6

Quote:
Originally Posted by Silencer123 View Post
Use:
Code:
register_event("Damage", "Event_Damage", "b", "2!0", "3=0", "4!0")
Tested, it doesnt call the Event_Damage function at all with this.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
Ramono
Veteran Member
Join Date: Nov 2005
Location: Netherlands
Old 10-04-2006 , 12:55   Re: get_user_attacker returns wrong id
Reply With Quote #7

http://www.amxmodx.org/funcwiki.php?go=func&id=470
__________________
Um, hi.
Ramono is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-04-2006 , 14:22   Re: get_user_attacker returns wrong id
Reply With Quote #8

Try this and see what it says the classname is for the entities above 32:

Code:
new bum = get_user_attacker(id), classname[32] if(is_valid_ent(bum)) entity_get_string(bum,EV_SZ_classname,classname,31) else classname = "null" client_print(0,print_chat, "DEBUG: Bum id = %d (%s), Victim id = %d",bum,classname,id)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 10-04-2006 , 14:50   Re: get_user_attacker returns wrong id
Reply With Quote #9

Quote:
Use:

Code:
register_event("Damage", "Event_Damage", "b", "2!0", "3=0", "4!0")
You obviously don't know what each argument of this message mean. 1 - damage save, 2 - damage done, 3 - damage type, 4, 5, 6 - x, y, z coords
VEN is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-04-2006 , 14:56   Re: get_user_attacker returns wrong id
Reply With Quote #10

well i got it from somewhere and it worked for me.
where you get the information from what part of the message is what?
__________________
EAT YOUR VEGGIES
Silencer123 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 04:50.


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