Raised This Month: $ Target: $400
 0% 

get_user_attacker returns wrong id [PARTLY SOLVED]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


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 04:50.


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