Код за потвърждение: Избери целия код
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombie_plague_advance>
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP43] Extra item: Gas Mask"
#define _VERSION "3.0"
#define _AUTHOR "H.RED.ZONE"
#define EV_INT_nadetype EV_INT_flTimeStepSound
#define NADETYPE_INFECTION 1111
new _ItemID
new _bitPlayerHasMask
new _gMaxPlayers, _gIcon, _gMsgSayText
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
_ItemID = zp_register_extra_item( "Anti-Virus Mask \y(\rSingle-Use\y)", 200, ZP_TEAM_HUMAN )
_gMaxPlayers = get_maxplayers( )
_gIcon = get_user_msgid( "StatusIcon" )
_gMsgSayText = get_user_msgid( "SayText" )
}
public plugin_precache() {
RegisterHam( Ham_Think, "grenade", "_FW_ThinkGrenade", 1 )
}
public zp_extra_item_selected( plr, itemid ) {
if( itemid == _ItemID ) {
_MarkPlayerHasMask( plr )
Icon_On( plr )
ProtoChat(plr, "You now have Anti-Virus Mask. It will neutralize the effect of 1 infection grenade!")
}
}
public _FW_ThinkGrenade( iEnt ) {
if( is_valid_ent(iEnt) ) {
if( entity_get_int(iEnt, EV_INT_nadetype) == NADETYPE_INFECTION ) {
for( new plr = 1; plr <= _gMaxPlayers; plr++ ) {
if( is_user_alive(plr)
&& _PlayerHasMask(plr) ) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
_ClearPlayerWithMask( plr )
remove_entity( iEnt )
Icon_Off( plr )
ProtoChat( plr, "Infection prevented! Your Anti-Virus mask can no longer be used." )
}
}
}
}
}
}
public zp_user_infected_post( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerKilled( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public client_disconnect( plr ) {
Icon_Off( plr )
}
public Icon_On( plr ) {
message_begin( MSG_ONE_UNRELIABLE, _gIcon, { 0, 0, 0 }, plr );
write_byte( 1 )
write_string( "dmg_gas" )
write_byte( 0 )
write_byte( 255 )
write_byte( 0 )
message_end( )
}
public Icon_Off( plr ) {
message_begin( MSG_ONE_UNRELIABLE, _gIcon, { 0, 0, 0 }, plr )
write_byte( 0 )
write_string( "dmg_gas" )
write_byte( 0 )
write_byte( 255 )
write_byte( 0 )
message_end( )
}
ProtoChat( plr, const sFormat[], any:... ) {
static i; i = plr ? plr : get_player( )
if ( !i ) {
return PLUGIN_HANDLED;
}
new sMessage[ 256 ]
new len = formatex( sMessage, 255, "^x01[^x04ZP^x01] ")
vformat( sMessage[len], 255-len, sFormat, 3 )
sMessage[ 192 ] = '^0'
Make_SayText( plr, i, sMessage )
return PLUGIN_CONTINUE
}
get_player( ) {
for ( new plr; plr <= _gMaxPlayers; plr++ ) {
if ( is_user_connected(plr) ) {
return plr
}
}
return PLUGIN_HANDLED
}
Make_SayText( Receiver, Sender, sMessage[] ) {
if ( !Sender ) {
return PLUGIN_HANDLED;
}
message_begin( Receiver ? MSG_ONE_UNRELIABLE : MSG_ALL, _gMsgSayText, {0,0,0}, Receiver )
write_byte( Sender )
write_string( sMessage )
message_end( )
return PLUGIN_CONTINUE;
}
Благодаря.