AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block Damage (https://forums.alliedmods.net/showthread.php?t=178427)

H.RED.ZONE 02-15-2012 17:36

Block Damage
 
Would this work to block damage for all players except admins?
PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if(!(
get_user_flags(attacker) & ADMIN_USER))
    {
    
//Victim is not lasermine.
    
new sz_classname[32]
    
entity_get_stringvictim EV_SZ_classname sz_classname 31 )
    if( !
equali(sz_classname,"lasermine") )
        return 
HAM_IGNORED;
    
    
//Attacker is zombie
    
if( zp_get_user_zombieattacker ) ) 
        return 
HAM_IGNORED;
    }
    
//Block Damage
    
return HAM_SUPERCEDE;



lucas_7_94 02-15-2012 17:40

Re: Block Damage
 
look how are you hooking the takedamage.

H.RED.ZONE 02-15-2012 17:45

Re: Block Damage
 
Quote:

Originally Posted by lucas_7_94 (Post 1651228)
look how are you hooking the takedamage.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombieplague>

#define PLUGIN    "[ZP] Addon : Laser Destroy Preventer"
#define AUTHOR    "Hezerf"
#define VERSION    "1.1"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage,"func_breakable","fw_TakeDamage"ADMIN_USER);
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if(!(
get_user_flags(attacker) & ADMIN_USER))
    {
    
//Victim is not lasermine.
    
new sz_classname[32]
    
entity_get_stringvictim EV_SZ_classname sz_classname 31 )
    if( !
equali(sz_classname,"lasermine") )
        return 
HAM_IGNORED;
    
    
//Attacker is zombie
    
if( zp_get_user_zombieattacker ) ) 
        return 
HAM_IGNORED;
}
    
//Block Damage
    
return HAM_SUPERCEDE;



DeWilX 02-15-2012 18:04

Re: Block Damage
 
If you remove
Code:

if(!(get_user_flags(attacker) & ADMIN_USER))
than it will work for all people.

H.RED.ZONE 02-15-2012 18:13

Re: Block Damage
 
I know that but i want to block it only for admin_user not admins (players with flag Z)
So that admin is alowed to destroy but player is not.

DeWilX 02-15-2012 18:17

Re: Block Damage
 
Sorry I didn't understood you. There
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombieplague>

#define PLUGIN    "[ZP] Addon : Laser Destroy Preventer"
#define AUTHOR    "Hezerf"
#define VERSION    "1.1"

#define ADMIN_USER ADMIN_LEVEL_B

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage,"func_breakable","fw_TakeDamage"ADMIN_USER);
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if(!(
get_user_flags(attacker) & ADMIN_USER))
    {
    
//Victim is not lasermine.
    
new sz_classname[32]
    
entity_get_stringvictim EV_SZ_classname sz_classname 31 )
    if( !
equali(sz_classname,"lasermine") )
        return 
HAM_IGNORED;
    
    
//Attacker is zombie
    
if( zp_get_user_zombieattacker ) ) 
        return 
HAM_IGNORED;
}
    
//Block Damage
    
return HAM_SUPERCEDE;


Change this to set which flag you want use
Code:

ADMIN_LEVEL_B

H.RED.ZONE 02-15-2012 19:06

Re: Block Damage
 
Nope that is not blocking it but you know what i want to do.

lucas_7_94 02-16-2012 06:01

Re: Block Damage
 
Do you tested the code ? ( i mean , the code by hezerf )

H.RED.ZONE 02-16-2012 10:33

Re: Block Damage
 
Quote:

Originally Posted by lucas_7_94 (Post 1651452)
Do you tested the code ? ( i mean , the code by hezerf )

Yes i tested it and it doesent work it blocks damage for all players i want it to be blocked and that only admin can deal damage.

Exolent[jNr] 02-16-2012 10:42

Re: Block Damage
 
Quote:

Originally Posted by H.RED.ZONE (Post 1651580)
only admin can deal damage.

To anything specific like players, lasermines, etc.?
Or they can be the only players to deal damage to anything?


All times are GMT -4. The time now is 06:30.

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