Raised This Month: $ Target: $400
 0% 

amx_slay problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yanke3
Junior Member
Join Date: Apr 2010
Old 03-03-2013 , 04:26   amx_slay problem
Reply With Quote #1

I have this plugin


PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "plugin_slay"
#define VERSION "1.0"
#define AUTHOR "YANKEE"


public plugin_init() {
   
register_plugin(PLUGINVERSIONAUTHOR)
   
register_concmd("amx_slay","cmdSlay",ADMIN_KICK"<nume> - il omori")
}

public 
cmdSlay(id,level,cid){
   if(!
cmd_access(id,level,cid,2)){
        
   return 
PLUGIN_HANDLED;
}   
   new 
arg[32],admin[32],name2[32];
  
  
   
read_argv arg 31 )
   
   new 
target cmd_target id arg )
   if(!
is_user_alive(id)){
   
console_print(id"[Bucov AMXX] %s nu este viu."target)

   return 
PLUGIN_HANDLED
}   
   
get_user_name(id,admin,31);
   
get_user_name(targetname231);
   
   
   
   
client_cmd(target,"kill")
   
log_amx("Slay: ^"%s^" amx_slay ^"%s^" "adminname2)

   
   
client_print(0print_chat"Admin %s: foloseste comanda amx_slay %s"adminname2)

   return 
PLUGIN_HANDLED

if an admin has immunity he still get slay
yanke3 is offline
Kard1nal
Senior Member
Join Date: Dec 2012
Location: Russia
Old 03-03-2013 , 04:48   Re: amx_slay problem
Reply With Quote #2

Add this before killing cmd:
Code:
if(get_user_flags(target) & ADMIN_IMMUNITY) return PLUGIN_HANDLED
Btw, it's not a good way to kill player via client_cmd. The better way is user_kill or user_silentkill.

Last edited by Kard1nal; 03-03-2013 at 04:48.
Kard1nal is offline
Send a message via Skype™ to Kard1nal
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-03-2013 , 05:05   Re: amx_slay problem
Reply With Quote #3

Code about immunity seems ok with cmd_target.
Anyway, i've cleaned up a bit, try it now.
Make sure you have disabled default amx_slay command.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "plugin_slay"
#define VERSION "1.0"
#define AUTHOR "YANKEE"

public plugin_init() {
   
register_plugin(PLUGINVERSIONAUTHOR)
   
register_concmd("amx_slay""cmdSlay"ADMIN_KICK"<nume> - il omori")
}

public 
cmdSlay(idlevelcid)
{
    if( 
cmd_access(idlevelcid2) )
    {
        new 
arg[32];
        
read_argv arg charsmax(arg) )

        
// #define CMDTARGET_OBEY_IMMUNITY (1<<0)
        // #define CMDTARGET_ALLOW_SELF    (1<<1)
        // #define CMDTARGET_ONLY_ALIVE    (1<<2)
        // #define CMDTARGET_NO_BOTS        (1<<3)
        // 9 is CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS so previous code seemed to be ok
        
new target cmd_target id arg CMDTARGET_OBEY_IMMUNITY CMDTARGET_ALLOW_SELF CMDTARGET_ONLY_ALIVE )

        if( 
target )
        {
            new 
admin[32], name2[32]
            
get_user_name(idadmincharsmax(admin));
            
get_user_name(targetname2charsmax(name2));

            
user_kill(target1)
            
log_amx("Slay: ^"%s^" amx_slay ^"%s^""adminname2)

            
show_activity(idadmin"foloseste comanda amx_slay %s"name2)
        }
    }

    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
yanke3
Junior Member
Join Date: Apr 2010
Old 03-03-2013 , 07:11   Re: amx_slay problem
Reply With Quote #4

Thanks . Problem solved.

Last edited by yanke3; 03-03-2013 at 07:12.
yanke3 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-03-2013 , 07:19   Re: amx_slay problem
Reply With Quote #5

PHP Code:
   new target cmd_target id arg )
   if(!
is_user_alive(id)){
   
console_print(id"[Bucov AMXX] %s nu este viu."target)

   return 
PLUGIN_HANDLED

Problem was there :

1. you don't check if target is different from 0 -> client_cmd(id, "kill") was sent to all players.

2. not related but still a problem, you was check if 'id' is alive instead of target.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 21:37.


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