AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   amx_slay problem (https://forums.alliedmods.net/showthread.php?t=209876)

yanke3 03-03-2013 04:26

amx_slay problem
 
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

Kard1nal 03-03-2013 04:48

Re: amx_slay problem
 
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.

ConnorMcLeod 03-03-2013 05:05

Re: amx_slay problem
 
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



yanke3 03-03-2013 07:11

Re: amx_slay problem
 
Thanks . Problem solved.

ConnorMcLeod 03-03-2013 07:19

Re: amx_slay problem
 
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.


All times are GMT -4. The time now is 21:37.

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