Страница 1 от 1
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 03 Ное 2019, 11:44
от Dachoni
Здравейте,
плъгина може да се купува и след кото се е закупил от менюто, но не дава още една маска, само взема амо паковете а не дава още една маска.
Мода е ZP 5.8.0 .
Възможно ли е да дава повече от една маска с някакво изброяване (за да знае колко остават) за рунд от 1 играч.
Възможно ли е да се направи ограничение на закупуване на брой пъти за рунд от 1 играч.
Благодаря !
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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_items_register( "Gas Mask", 30 )
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID ) {
_MarkPlayerHasMask( plr )
Icon_On( plr )
ProtoChat(plr, "You now have Gas Mask.")
}
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr) ) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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, "Infect nade is removed, you don't have mask anymore." )
}
}
}
}
}
}
public zp_fw_core_infect( 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;
}
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 03 Ное 2019, 14:34
от TryAgain
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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
new g_gas[33],g_cvar_num
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
g_cvar_num = register_cvar("zp_gasmask_limit", "3")
_ItemID = zp_items_register( "Gas Mask", 30 )
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID)
{
if(get_pcvar_num(g_cvar_num) > g_gas[plr])
{
_MarkPlayerHasMask( plr )
Icon_On( plr )
g_gas[plr]++
ProtoChat(plr, "You now have Gas Mask. [%i / %i]",g_gas[plr],get_pcvar_num(g_cvar_num))
}
else
{
ProtoChat(plr, "Limit of Gas Mask is reached.")
return ZP_ITEM_NOT_AVAILABLE
}
}
return ZP_ITEM_NOT_AVAILABLE
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr)) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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) && g_gas[plr]) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
_ClearPlayerWithMask( plr )
remove_entity( iEnt )
Icon_Off( plr )
ProtoChat( plr, "Infect nade is removed, you don't have mask anymore." )
g_gas[plr]--
}
}
}
}
}
}
public zp_fw_core_infect( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
g_gas[plr] = 0
}
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;
}
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 03 Ное 2019, 17:00
от Dachoni
TryAgain написа: ↑03 Ное 2019, 14:34
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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
new g_gas[33],g_cvar_num
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
g_cvar_num = register_cvar("zp_gasmask_limit", "3")
_ItemID = zp_items_register( "Gas Mask", 30 )
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID)
{
if(get_pcvar_num(g_cvar_num) > g_gas[plr])
{
_MarkPlayerHasMask( plr )
Icon_On( plr )
g_gas[plr]++
ProtoChat(plr, "You now have Gas Mask. [%i / %i]",g_gas[plr],get_pcvar_num(g_cvar_num))
}
else
{
ProtoChat(plr, "Limit of Gas Mask is reached.")
return ZP_ITEM_NOT_AVAILABLE
}
}
return ZP_ITEM_NOT_AVAILABLE
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr)) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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) && g_gas[plr]) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
_ClearPlayerWithMask( plr )
remove_entity( iEnt )
Icon_Off( plr )
ProtoChat( plr, "Infect nade is removed, you don't have mask anymore." )
g_gas[plr]--
}
}
}
}
}
}
public zp_fw_core_infect( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
g_gas[plr] = 0
}
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;
}
Изписава до 3/3 наличност, а ако решиш да вземеш 4 ти взема само амо паковете.
След определения брой маски, само взема амо паковете, ако решиш да купиш над лимита.
А може ли маската да остава, а не да се маха. Нали има още 2/3 примерно маски. Иконката изчезва след хвърлена граната и не се появява а има още 2/3 маски.
Благодаря!
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 03 Ное 2019, 22:36
от TryAgain
Fixed.
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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
new g_gas[33],g_cvar_num
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
g_cvar_num = register_cvar("zp_gasmask_limit", "3")
_ItemID = zp_items_register( "Gas Mask", 30)
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID)
{
if(get_pcvar_num(g_cvar_num) > g_gas[plr])
{
_MarkPlayerHasMask( plr )
Icon_On( plr )
g_gas[plr]++
ProtoChat(plr, "You now have Gas Mask. [%i / %i]",g_gas[plr],get_pcvar_num(g_cvar_num))
}
else
{
ProtoChat(plr, "Limit of Gas Mask is reached.")
return ZP_INVALID_ITEM
}
}
return ZP_INVALID_ITEM
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr)) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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) && g_gas[plr]) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
remove_entity( iEnt )
g_gas[plr]--
ProtoChat( plr, "Infect nade is removed. Now you have %d mask.",g_gas[plr])
if(!g_gas[plr])
{
_ClearPlayerWithMask(plr)
Icon_Off(plr)
}
}
}
}
}
}
}
public zp_fw_core_infect( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
g_gas[plr] = 0
}
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;
}
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 04 Ное 2019, 17:36
от Dachoni
Отново, след определения брой лимит маски, само взема амо паковете-(ако решиш да купиш над лимита).
Възможно ли е да се премахне това да взема амо пака, ако реши да пробва да вземе, още една маска над лимита. Просто да изписва че е достигнал лимита на маски за рунда.
Благодаря отново !
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 04 Ное 2019, 18:42
от JackEyedJones
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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
new g_gas[33],g_cvar_num
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
g_cvar_num = register_cvar("zp_gasmask_limit", "3")
_ItemID = zp_items_register( "Gas Mask", 30)
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID )
{
if(++g_gas[plr] >= get_pcvar_num(g_cvar_num))
{
ProtoChat(plr, "Limit of Gas Mask is reached.")
return ZP_INVALID_ITEM
}
_MarkPlayerHasMask( plr )
Icon_On( plr )
ProtoChat(plr, "You now have Gas Mask. [%i / %i]", g_gas[plr], get_pcvar_num(g_cvar_num))
}
return ZP_INVALID_ITEM
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr)) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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) && g_gas[plr]) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
remove_entity( iEnt )
g_gas[plr]--
ProtoChat( plr, "Infect nade is removed. Now you have %d mask.",g_gas[plr])
if(!g_gas[plr])
{
_ClearPlayerWithMask(plr)
Icon_Off(plr)
}
}
}
}
}
}
}
public zp_fw_core_infect( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
g_gas[plr] = 0
}
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;
}
Коригирах проверката през която минава функцията преди да даде предмета. Би трябвало сега да е окей.
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 04 Ное 2019, 19:35
от Dachoni
Сега, като задам лимит от 2 маски, след, като купя (първата) 1/2 е добре, обаче като купя(втората) 2/2 и ми изписва в чата: Limit of Gas Mask is reached. Не се променя на 2/2 а си стои 1/2 - при зададен лимит 2 маски.
Отново взема амо паковете след лимита.
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 05 Ное 2019, 09:34
от TryAgain
Пробвай така.
Код за потвърждение: Избери целия код
#include < amxmodx >
#include < hamsandwich >
#include < engine >
#include < zp50_core >
#include < zp50_items >
#include < zp50_ammopacks >
#define _MarkPlayerHasMask(%0) _bitPlayerHasMask |= (1 << (%0 & 31))
#define _ClearPlayerWithMask(%0) _bitPlayerHasMask &= ~(1 << (%0 & 31))
#define _PlayerHasMask(%0) _bitPlayerHasMask & (1 << (%0 & 31))
#define _PLUGIN "[ZP50] 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
new g_gas[33],g_cvar_num,g_cvar_ammo
public plugin_init() {
register_plugin( _PLUGIN, _VERSION, _AUTHOR )
RegisterHam( Ham_Spawn, "player", "_FW_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "_FW_PlayerKilled" )
g_cvar_num = register_cvar("zp_gasmask_limit", "3")
g_cvar_ammo = register_cvar("zp_gasmask_ammopack", "30")
_ItemID = zp_items_register( "Gas Mask", get_pcvar_num(g_cvar_ammo))
_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_fw_items_select_post( plr, itemid, ignorecost ) {
if( itemid == _ItemID)
{
if(get_pcvar_num(g_cvar_num) > g_gas[plr])
{
_MarkPlayerHasMask( plr )
Icon_On( plr )
g_gas[plr]++
ProtoChat(plr, "You now have Gas Mask. [%i / %i]",g_gas[plr],get_pcvar_num(g_cvar_num))
}
else
{
zp_ammopacks_set(plr, zp_ammopacks_get(plr)+get_pcvar_num(g_cvar_ammo))
ProtoChat(plr, "Limit of Gas Mask is reached.")
}
}
}
public zp_fw_items_select_pre( plr, itemid ) {
if( itemid == _ItemID ) {
if( zp_core_is_zombie(plr)) return ZP_ITEM_DONT_SHOW
return ZP_ITEM_AVAILABLE
}
return ZP_ITEM_AVAILABLE;
}
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) && g_gas[plr]) {
if( get_entity_distance(iEnt, plr) <= 240 ) {
remove_entity( iEnt )
g_gas[plr]--
ProtoChat( plr, "Infect nade is removed. Now you have %d mask.",g_gas[plr])
if(!g_gas[plr])
{
_ClearPlayerWithMask(plr)
Icon_Off(plr)
}
}
}
}
}
}
}
public zp_fw_core_infect( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
}
public _FW_PlayerSpawn( plr ) {
_ClearPlayerWithMask( plr )
Icon_Off( plr )
g_gas[plr] = 0
}
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;
}
Преработка [ZP] Extra Item: Gas Mask
Публикувано на: 06 Ное 2019, 20:03
от Dachoni
Благодаря, работи.