Raised This Month: $ Target: $400
 0% 

[SOLVED] Prevent shooting players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 08-13-2011 , 11:23   [SOLVED] Prevent shooting players
Reply With Quote #1

What I want to do is enable friendlyfire only for some players in a team.
When one player shoots another, if they both have 'enabled' variable on 1, the victim will normally take the damage. But if one of them doesn't, nothing will happen:

PHP Code:
new enabled[33]
public 
plugin_init() {
    
register_message(get_user_msgid("TextMsg") , "block_message");
    
RegisterHam(Ham_TakeDamage"player""tk")
    
register_concmd("amx_ff""enable"ADMIN_RCON"")
}

public 
tk(victiminflictorkillerdamagebits) {
    if (
killer == victim)
    {    
        return 
HAM_IGNORED;
    }
    if (
enabled[killer] == && enabled[victim] == 1) {
        return 
HAM_IGNORED;
        
    }
    else {
        return 
HAM_SUPERCEDE
        
    
}
    return 
HAM_SUPERCEDE
}

public 
enable(idlevelcid) {
    if(!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
    
    
new arg[32]
    
read_argv(1arg31)
    new 
player cmd_target(idargCMDTARGET_NO_BOTS CMDTARGET_ALLOW_SELF)
    if(
enabled[player] == 0) {
        
enabled[player] = 1
        client_print
(idprint_console"Ukljuceno.")
        return 
PLUGIN_HANDLED
    
}
    if(
enabled[player] == 1) {
        
enabled[player] = 0
        client_print
(idprint_console"Iskljuceno.")
    }
    return 
PLUGIN_HANDLED
}
public 
block_message() {
    if(
get_msg_argtype(2) == ARG_STRING) {
        new 
value[64];
        
get_msg_arg_string(value 63);
        if(
equali(value "#Game_teammate_attack")) {
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE;

The code works but if the victim has no armor there will be blood and he gets pushed back and slowed if you hit him in the head. How can I prevent that (except giving 9999 armor )?

Last edited by Desikac; 08-15-2011 at 09:45.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
 



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 03:26.


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