como faço para limitar essa bomba por playes.
gostaria se alguem consegue me ajudar estou querendo limitar o uso de Zombie Madness por player e não estou conseguindo eu uso ZP 5.0.8
Última edição por cancels em 15/7/2017, 7:56 pm, editado 1 vez(es)
Código:
/*
[ZP] Extra Item: Blind Bomb
Credits :- Catastrophe
*/
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < zombieplague >
// Defines
#define MAXPLAYERS 32
#define FCVAR_FLAGS ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
#define OFFSET_PLAYER 41
#define OFFSET_ACTIVE 373
#define LINUX_DIFF 5
#define NADE_TYPE_BLIND 8634
#define FFADE_IN 0x0000
#define REPEAT 0.2 // Time when next screen fade message is being sent
#define TASK_AFFECT 666
#define ID_AFFECT ( taskid - TASK_AFFECT )
#define OFFSET_FLAMMO 387
// Grenade cost
#define GRENADE_COST 30
#define give_nemesis // Выдавать ли гранату Nemesis
// Grenade models
new const grenade_model_p [ ] = "models/p_flashbang.mdl"
new const grenade_model [ ] = "models/zombie_plague/v_grenade_infect.mdl"
new const grenade_model_w [ ] = "models/w_flashbang.mdl"
// Sounds
new const explosion_sound [ ] = "zombie_plague/Strider_Buster_stick1.wav"
new const purchase_sound [ ] = "items/gunpickup2.wav"
new const purchase_sound2 [ ] = "items/9mmclip1.wav"
// Cached sprite indexes
new m_iTrail, m_iRing
// Item ID
new g_blind
// Player variables
new g_NadeCount [ MAXPLAYERS+1 ]
// Message ID's
new g_msgScreenFade, g_msgAmmoPickup
// CVAR pointers
new cvar_nade_radius, cvar_duration
// Precache
public plugin_precache ( )
{
// Precache grenade models
precache_model ( grenade_model_p )
precache_model ( grenade_model )
precache_model ( grenade_model_w )
// Precache sounds
precache_sound ( explosion_sound )
precache_sound ( purchase_sound )
precache_sound ( purchase_sound2 )
// Precache sprites
m_iRing = precache_model ( "sprites/shockwave.spr" )
m_iTrail = precache_model ( "sprites/laserbeam.spr" )
}
// Plugin initialization
public plugin_init ( )
{
// New plugin
register_plugin ( "[ZP] Extra Item: Blind Bomb", "1.1", "Catastrophe" )
// New extra item
g_blind = zp_register_extra_item("Blind Bomb", 65, ZP_TEAM_ZOMBIE)
// Events
register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event ( "DeathMsg", "Event_DeathMsg", "a" )
register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
// Forwards
register_forward ( FM_SetModel, "fw_SetModel" )
RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
register_forward ( FM_CmdStart, "fw_CmdStart" )
// CVARs
cvar_nade_radius = register_cvar ( "zp_blind_nade_radius", "500" )
cvar_duration = register_cvar ( "zp_blind_nade_duration", "5" )
// Messages
g_msgScreenFade = get_user_msgid ( "ScreenFade" )
g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
}
// Someone decided to buy our an extra item
public zp_extra_item_selected ( Player, Item )
{
// This is our grenade
if ( Item == g_blind )
{
// Player already have it
if ( g_NadeCount [ Player ] >= 1 )
{
// Increase nade count
g_NadeCount [ Player ]++
// Increase bp ammo
set_pdata_int ( Player, OFFSET_FLAMMO, get_pdata_int ( Player, OFFSET_FLAMMO, LINUX_DIFF )+1, LINUX_DIFF )
// Ammo pickup
message_begin ( MSG_ONE, g_msgAmmoPickup, _, Player )
write_byte ( 11 ) // Ammo ID
write_byte ( 1 ) // Ammo amount
message_end ( )
// Emit sound
emit_sound ( Player, CHAN_WEAPON, purchase_sound2, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
}
else // 0 grenades
{
// Increase nade count
g_NadeCount [ Player ] = 1
// Give him flashbang
give_item ( Player, "weapon_flashbang" )
// Play purchase sound
client_cmd ( Player, "spk %s", purchase_sound )
}
}
return PLUGIN_CONTINUE
}
// Someone was infected
public zp_user_infected_post ( Player, Infector )
{
#if defined give_nemesis
if ( zp_get_user_nemesis(Player) && zp_is_nemesis_round())
{
g_NadeCount [ Player ] = 1
give_item ( Player, "weapon_flashbang" )
}
#endif
// We were affected by Blind Bomb
if ( task_exists ( Player+TASK_AFFECT ) )
remove_task ( Player+TASK_AFFECT )
}
// Someone were turned back to human
public zp_user_humanized_post ( Player, Survivor )
{
// We dont' have nade anymore
if ( g_NadeCount [ Player ] )
{
g_NadeCount [ Player ] = 0
}
}
// New round started
public Event_NewRound ( )
{
// Reset nade count
arrayset ( g_NadeCount, false, 33 )
// And they aren't affected by conc.grenade
remove_task ( TASK_AFFECT )
}
// Someone died
public Event_DeathMsg ( )
{
// Get victim
new victim = read_data ( 2 )
// Some people had error without this check
if ( !is_user_connected ( victim ) )
return
// Remove hallucinations
remove_task ( victim+TASK_AFFECT )
// Reset nade count
g_NadeCount [ victim ] = 0
}
// Current weapon player is holding
public Event_CurrentWeapon ( Player )
{
// Dead or not zombie or don't have conc. grenade
if ( !is_user_alive ( Player ) || !zp_get_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
return PLUGIN_CONTINUE
// Replace flashbang model with our ones
set_pev ( Player, pev_viewmodel2, grenade_model )
set_pev ( Player, pev_weaponmodel2, grenade_model_p )
return PLUGIN_CONTINUE
}
// Set model
public fw_SetModel ( Entity, const Model [ ] )
{
// Prevent invalid ent messages
if ( !pev_valid ( Entity ) )
return FMRES_IGNORED
// Grenade not thrown yet
if ( pev ( Entity, pev_dmgtime ) == 0.0 )
return FMRES_IGNORED
// We are throwing Blind Bomb
if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
{
//Draw trail
message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
write_short ( Entity ) // Entity to follow
write_short ( m_iTrail ) // Sprite index
write_byte ( 10 ) // Life
write_byte ( 10 ) // Line width
write_byte ( 255 ) // Red amount
write_byte ( 255 ) // Blue amount
write_byte ( 0 ) // Blue amount
write_byte ( 255 ) // Alpha
message_end ( )
// Set grenade entity
set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_BLIND )
// Decrease nade count
g_NadeCount [ pev ( Entity, pev_owner ) ]--
// Set world model
engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
// Grenade is getting to explode
public fw_ThinkGrenade ( Entity )
{
// Prevent invalid ent messages
if ( !pev_valid ( Entity ) )
return HAM_IGNORED
// Get damage time
static Float:dmg_time
pev ( Entity, pev_dmgtime, dmg_time )
// maybe it is time to go off
if ( dmg_time > get_gametime ( ) )
return HAM_IGNORED
// Our grenade
if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_BLIND )
{
// Force to explode
blind_explode ( Entity )
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
// Command start
public fw_CmdStart ( Player, UC_Handle, Seed )
{
// Dead, zombie or not affected
if ( !is_user_alive ( Player ) || zp_get_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
return FMRES_IGNORED
// Get buttons
new buttons = get_uc ( UC_Handle, UC_Buttons )
// We are firing
if ( buttons & IN_ATTACK )
{
// We are holding an active weapon
if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
{
// New recoil
set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
}
}
return FMRES_HANDLED
}
// Grenade explode
public blind_explode ( Entity )
{
// Invalid entity ?
if ( !pev_valid ( Entity ) )
return
// Get entities origin
static Float:origin [ 3 ]
pev ( Entity, pev_origin, origin )
// Draw ring
UTIL_DrawRing (origin )
// Explosion sound
emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
// Collisions
static victim
victim = -1
// Find radius
static Float:radius
radius = get_pcvar_float ( cvar_nade_radius )
// Find all players in a radius
while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
{
// Dead or zombie
if ( !is_user_alive ( victim ) || zp_get_user_zombie ( victim ) )
continue
// Victim isn't affected yet
if ( !task_exists ( victim+TASK_AFFECT ) )
{
// Get duration
new duration = get_pcvar_num ( cvar_duration )
// Calculate affect times
new affect_count = floatround ( duration / REPEAT )
// Continiously affect them
set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
}
}
// Remove entity from ground
engfunc ( EngFunc_RemoveEntity, Entity )
}
// We are going to affect you
public affect_victim ( taskid )
{
// Dead
if ( !is_user_alive ( ID_AFFECT ) )
return;
// Make a screen fade
ScreenFade(ID_AFFECT, get_pcvar_float( cvar_duration ), 0, 0, 0, 255)
// Remove task after all
remove_task( ID_AFFECT )
}
// Draw explosion ring ( from zombie_plague40.sma )
stock UTIL_DrawRing ( const Float:origin [ 3 ] )
{
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, origin[0]) // x
engfunc(EngFunc_WriteCoord, origin[1]) // y
engfunc(EngFunc_WriteCoord, origin[2]) // z
engfunc(EngFunc_WriteCoord, origin[0]) // x axis
engfunc(EngFunc_WriteCoord, origin[1]) // y axis
engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
write_short( m_iRing ) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(4) // life
write_byte(60) // width
write_byte(0) // noise
write_byte(200) // red
write_byte(200) // green
write_byte(200) // blue
write_byte(200) // brightness
write_byte(0) // speed
message_end()
}
// ScreenFade
stock ScreenFade(plr, Float:fDuration, red, green, blue, alpha)
{
new i = plr ? plr : get_maxplayers();
if( !i )
{
return 0;
}
message_begin(plr ? MSG_ONE : MSG_ALL, g_msgScreenFade, {0, 0, 0}, plr);
write_short(floatround(4096.0 * fDuration, floatround_round));
write_short(floatround(4096.0 * fDuration, floatround_round));
write_short(4096);
write_byte(red);
write_byte(green);
write_byte(blue);
write_byte(alpha);
message_end();
return 1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
gostaria se alguem consegue me ajudar estou querendo limitar o uso de Zombie Madness por player e não estou conseguindo eu uso ZP 5.0.8
Código:
/*================================================================================
---------------------------------
-*- [ZP] Item: Zombie Madness -*-
---------------------------------
This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
================================================================================*/
#define ITEM_NAME "Zombie Madness"
#define ITEM_COST 15
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <amx_settings_api>
#include <cs_ham_bots_api>
#include <zp50_items>
#define LIBRARY_GRENADE_FROST "zp50_grenade_frost"
#include <zp50_grenade_frost>
#define LIBRARY_GRENADE_FIRE "zp50_grenade_fire"
#include <zp50_grenade_fire>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_DRAGON "zp50_class_dragon"
#include <zp50_class_dragon>
#define LIBRARY_ASSASSIN "zp50_class_assassin"
#include <zp50_class_assassin>
#define LIBRARY_NIGHTCRAWLER "zp50_class_nightcrawler"
#include <zp50_class_nightcrawler>
// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
// Default sounds
new const sound_zombie_madness[][] = { "zombie_plague/zombie_madness1.wav" }
#define SOUND_MAX_LENGTH 64
new Array:g_sound_zombie_madness
#define TASK_MADNESS 100
#define TASK_AURA 200
#define ID_MADNESS (taskid - TASK_MADNESS)
#define ID_AURA (taskid - TASK_AURA)
#define flag_get(%1,%2) (%1 & (1 << (%2 & 31)))
#define flag_get_boolean(%1,%2) (flag_get(%1,%2) ? true : false)
#define flag_set(%1,%2) %1 |= (1 << (%2 & 31))
#define flag_unset(%1,%2) %1 &= ~(1 << (%2 & 31))
new g_ItemID
new g_MadnessBlockDamage
new cvar_zombie_madness_time
new cvar_madness_aura_color_R, cvar_madness_aura_color_G, cvar_madness_aura_color_B
public plugin_init()
{
register_plugin("[ZP] Item: Zombie Madness", ZP_VERSION_STRING, "ZP Dev Team")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHamBots(Ham_Spawn, "fw_PlayerSpawn_Post", 1)
RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
RegisterHamBots(Ham_TraceAttack, "fw_TraceAttack")
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage")
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
RegisterHamBots(Ham_Killed, "fw_PlayerKilled_Post", 1)
cvar_zombie_madness_time = register_cvar("zp_zombie_madness_time", "5.0")
cvar_madness_aura_color_R = register_cvar("zp_madness_aura_color_R", "150")
cvar_madness_aura_color_G = register_cvar("zp_madness_aura_color_G", "0")
cvar_madness_aura_color_B = register_cvar("zp_madness_aura_color_B", "0")
g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
}
public plugin_precache()
{
// Initialize arrays
g_sound_zombie_madness = ArrayCreate(SOUND_MAX_LENGTH, 1)
// Load from external file
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ZOMBIE MADNESS", g_sound_zombie_madness)
// If we couldn't load custom sounds from file, use and save default ones
new index
if (ArraySize(g_sound_zombie_madness) == 0)
{
for (index = 0; index < sizeof sound_zombie_madness; index++)
ArrayPushString(g_sound_zombie_madness, sound_zombie_madness[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ZOMBIE MADNESS", g_sound_zombie_madness)
}
// Precache sounds
new sound[SOUND_MAX_LENGTH]
for (index = 0; index < ArraySize(g_sound_zombie_madness); index++)
{
ArrayGetString(g_sound_zombie_madness, index, sound, charsmax(sound))
precache_sound(sound)
}
}
public plugin_natives()
{
register_library("zp50_item_zombie_madness")
register_native("zp_item_zombie_madness_get", "native_item_zombie_madness_get")
set_module_filter("module_filter")
set_native_filter("native_filter")
}
public module_filter(const module[])
{
if (equal(module, LIBRARY_NEMESIS) || equal(module, LIBRARY_DRAGON) || equal(module, LIBRARY_NIGHTCRAWLER) || equal(module, LIBRARY_ASSASSIN) || equal(module, LIBRARY_GRENADE_FROST) || equal(module, LIBRARY_GRENADE_FIRE))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public native_item_zombie_madness_get(plugin_id, num_params)
{
new id = get_param(1)
if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
return flag_get_boolean(g_MadnessBlockDamage, id);
}
public zp_fw_items_select_pre(id, itemid, ignorecost)
{
// This is not our item
if (itemid != g_ItemID)
return ZP_ITEM_AVAILABLE;
// Zombie madness only available to zombies
if (!zp_core_is_zombie(id))
return ZP_ITEM_DONT_SHOW;
// Zombie madness not available to Nemesis/Assassin/Dragon/Nightcrawler
if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && zp_class_nemesis_get(id) || LibraryExists(LIBRARY_ASSASSIN, LibType_Library) && zp_class_assassin_get(id) || LibraryExists(LIBRARY_DRAGON, LibType_Library) && zp_class_dragon_get(id) || LibraryExists(LIBRARY_NIGHTCRAWLER, LibType_Library) && zp_class_nightcrawler_get(id))
return ZP_ITEM_DONT_SHOW;
// Player already has madness
if (flag_get(g_MadnessBlockDamage, id))
return ZP_ITEM_NOT_AVAILABLE;
return ZP_ITEM_AVAILABLE;
}
public zp_fw_items_select_post(id, itemid, ignorecost)
{
// This is not our item
if (itemid != g_ItemID)
return;
// Do not take damage
flag_set(g_MadnessBlockDamage, id)
// Madness aura
set_task(0.1, "madness_aura", id+TASK_AURA, _, _, "b")
// Madness sound
new sound[SOUND_MAX_LENGTH]
ArrayGetString(g_sound_zombie_madness, random_num(0, ArraySize(g_sound_zombie_madness) - 1), sound, charsmax(sound))
emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
// Set task to remove it
set_task(get_pcvar_float(cvar_zombie_madness_time), "remove_zombie_madness", id+TASK_MADNESS)
}
// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id) || !cs_get_user_team(id))
return;
// Remove zombie madness from a previous round
remove_task(id+TASK_MADNESS)
remove_task(id+TASK_AURA)
flag_unset(g_MadnessBlockDamage, id)
}
// Ham Trace Attack Forward
public fw_TraceAttack(victim, attacker)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_alive(attacker))
return HAM_IGNORED;
// Prevent attacks when victim has zombie madness
if (flag_get(g_MadnessBlockDamage, victim))
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
// Ham Take Damage Forward (needed to block explosion damage too)
public fw_TakeDamage(victim, inflictor, attacker)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_alive(attacker))
return HAM_IGNORED;
// Prevent attacks when victim has zombie madness
if (flag_get(g_MadnessBlockDamage, victim))
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public zp_fw_grenade_frost_pre(id)
{
// Prevent frost when victim has zombie madness
if (flag_get(g_MadnessBlockDamage, id))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_grenade_fire_pre(id)
{
// Prevent burning when victim has zombie madness
if (flag_get(g_MadnessBlockDamage, id))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_core_cure(id, attacker)
{
// Remove zombie madness task
remove_task(id+TASK_MADNESS)
remove_task(id+TASK_AURA)
flag_unset(g_MadnessBlockDamage, id)
}
// Ham Player Killed Post Forward
public fw_PlayerKilled_Post(victim, attacker, shouldgib)
{
// Remove zombie madness task
remove_task(victim+TASK_MADNESS)
remove_task(victim+TASK_AURA)
flag_unset(g_MadnessBlockDamage, victim)
}
// Remove Spawn Protection Task
public remove_zombie_madness(taskid)
{
// Remove aura
remove_task(ID_MADNESS+TASK_AURA)
// Remove zombie madness
flag_unset(g_MadnessBlockDamage, ID_MADNESS)
}
public client_disconnect(id)
{
// Remove tasks on disconnect
remove_task(id+TASK_MADNESS)
remove_task(id+TASK_AURA)
flag_unset(g_MadnessBlockDamage, id)
}
// Madness aura task
public madness_aura(taskid)
{
// Get player's origin
static origin[3]
get_user_origin(ID_AURA, origin)
// Colored Aura
message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(TE_DLIGHT) // TE id
write_coord(origin[0]) // x
write_coord(origin[1]) // y
write_coord(origin[2]) // z
write_byte(20) // radius
write_byte(get_pcvar_num(cvar_madness_aura_color_R)) // r
write_byte(get_pcvar_num(cvar_madness_aura_color_G)) // g
write_byte(get_pcvar_num(cvar_madness_aura_color_B)) // b
write_byte(2) // life
write_byte(0) // decay rate
message_end()
}
Última edição por cancels em 15/7/2017, 7:56 pm, editado 1 vez(es)