bomba blind nade
#1
Hola como limito la compra de este extra item a 1 vez por ronda??

Código PHP:
/*
    [ZP] Extra Item: Blind Bomb
    
        Credits :- Catastrophe

    
*/

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < zombieplague >
#include < zp50_class_nemesis>



// 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_neme

// 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_iTrailm_iRing

// Item ID
new g_blind

// Player variables
new g_NadeCount MAXPLAYERS+]

// Message ID's
new g_msgScreenFadeg_msgAmmoPickup

// CVAR pointers
new cvar_nade_radiuscvar_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.0""Catastrophe" )
    
    
    
// New extra item
    
g_blind zp_register_extra_item("Blind Bomb"65ZP_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 PlayerItem )
{
    
// This is our grenade
    
if ( Item == g_blind )
    {
        
// Player already have it
        
if ( g_NadeCount Player ] >= )
        {
            
// Increase nade count
            
g_NadeCount Player ]++
            
            
// Increase bp ammo
            
set_pdata_int PlayerOFFSET_FLAMMOget_pdata_int PlayerOFFSET_FLAMMOLINUX_DIFF )+1LINUX_DIFF )
            
            
// Ammo pickup
            
message_begin MSG_ONEg_msgAmmoPickup_Player )
            
write_byte 11 // Ammo ID
            
write_byte // Ammo amount
            
message_end ( )
            
            
// Emit sound
            
emit_sound PlayerCHAN_WEAPONpurchase_sound2VOL_NORMATTN_NORM0PITCH_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 PlayerInfector )
{

 
#if defined give_neme

        
if ( zp_class_nemesis_get(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 PlayerSurvivor )
{
    
// We dont' have nade anymore
    
if ( g_NadeCount Player ] )
    {
        
g_NadeCount Player ] = 0
    
}
}

// New round started
public Event_NewRound ( )
{
    
// Reset nade count
    
arrayset g_NadeCountfalse33 )
        
    
// And they aren't affected by conc.grenade
    
remove_task TASK_AFFECT )    
}

// Someone died
public Event_DeathMsg ( )
{
    
// Get victim
    
new victim read_data )
    
    
// 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 ] <= )
        return 
PLUGIN_CONTINUE
    
    
// Replace flashbang model with our ones
    
set_pev Playerpev_viewmodel2grenade_model )
    
set_pev Playerpev_weaponmodel2grenade_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 Entitypev_dmgtime ) == 0.0 )
        return 
FMRES_IGNORED
        
    
// We are throwing Blind Bomb    
    
if ( g_NadeCount pev Entitypev_owner ) ] >= && equal Model [], "w_fl") )
    {
        
//Draw trail
        
message_begin MSG_BROADCASTSVC_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 // Blue amount
        
write_byte 255 // Alpha
        
message_end ( )
        
        
// Set grenade entity
        
set_pev Entitypev_flTimeStepSoundNADE_TYPE_BLIND )
        
        
// Decrease nade count
        
g_NadeCount pev Entitypev_owner ) ]--
        
        
// Set world model
        
engfunc EngFunc_SetModelEntitygrenade_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 
Entitypev_dmgtimedmg_time )
    
    
// maybe it is time to go off
    
if ( dmg_time get_gametime ( ) )
        return 
HAM_IGNORED
        
    
// Our grenade    
    
if ( pev Entitypev_flTimeStepSound ) == NADE_TYPE_BLIND )
    {
        
// Force to explode
        
blind_explode Entity )
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED
}

// Command start
public fw_CmdStart PlayerUC_HandleSeed )
{
    
// 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_HandleUC_Buttons )
    
    
// We are firing
    
if ( buttons IN_ATTACK )
    {
        
// We are holding an active weapon
        
if ( get_pdata_cbase PlayerOFFSET_ACTIVELINUX_DIFF ) )
        {
            
// New recoil
            
set_pev Playerpev_punchangleFloat:{3.03.04.0} )
        }
    }
    return 
FMRES_HANDLED
}
            

// Grenade explode
public blind_explode Entity )
{
    
// Invalid entity ?
    
if ( !pev_valid Entity  ) )
        return
    
    
// Get entities origin
    
static Float:origin ]
    
pev Entitypev_originorigin )
    
    
// Draw ring
    
UTIL_DrawRing (origin )
    
    
// Explosion sound
    
emit_sound EntityCHAN_WEAPONexplosion_soundVOL_NORMATTN_NORM0PITCH_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_FindEntityInSpherevictimoriginradius ) ) != )
    {
        
// 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_RemoveEntityEntity )
}

// We are going to affect you
public affect_victim taskid )
{
    
// Dead
    
if ( !is_user_alive ID_AFFECT ) )
        return
        
    
// Make a screen fade

   
ScreenFade(ID_AFFECTget_pcvar_floatcvar_duration ), 000255)      
    
    
// Remove task after all
    
remove_task ID_AFFECT )
}

// Draw explosion ring ( from zombie_plague40.sma )
stock UTIL_DrawRing ( const Float:origin ] )
{
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordorigin[0]) // x
    
engfunc(EngFunc_WriteCoordorigin[1]) // y
    
engfunc(EngFunc_WriteCoordorigin[2]) // z
    
engfunc(EngFunc_WriteCoordorigin[0]) // x axis
    
engfunc(EngFunc_WriteCoordorigin[1]) // y axis
    
engfunc(EngFunc_WriteCoordorigin[2]+555.0// z axis
    
write_shortm_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(plrFloat:fDurationredgreenbluealpha)
{
    new 
plr plr get_maxplayers();
    if( !
)
    {
        return 
0;
    } 

    
message_begin(plr MSG_ONE MSG_ALLget_user_msgid"ScreenFade"), {000}, plr);
    
write_short(floatround(4096.0 fDurationfloatround_round));
    
write_short(floatround(4096.0 fDurationfloatround_round));
    
write_short(4096);
    
write_byte(red);
    
write_byte(green);
    
write_byte(blue);
    
write_byte(alpha);
    
message_end();
    
    return 
1;

Responder
#2
Creas una variable cualquiera
Código PHP:
new g_comprado[33

Reemplaza tu zp_extra_item_selected por este.
Código PHP:
public zp_extra_item_selected PlayerItem )

    
// Si ya compro no podra volver a comprar hasta la otra ronda
    
if (g_comprado[Player]) return;
 
    
// This is our grenade
    
if ( Item == g_blind )
    {
        
// Player already have it
        
if ( g_NadeCount Player ] >= )
        {
            
// Increase nade count
            
g_NadeCount Player ]++
            
            
// Increase bp ammo
            
set_pdata_int PlayerOFFSET_FLAMMOget_pdata_int PlayerOFFSET_FLAMMOLINUX_DIFF )+1LINUX_DIFF )
            
            
// Ammo pickup
            
message_begin MSG_ONEg_msgAmmoPickup_Player )
            
write_byte 11 // Ammo ID
            
write_byte // Ammo amount
            
message_end ( )
            
            
// Emit sound
            
emit_sound PlayerCHAN_WEAPONpurchase_sound2VOL_NORMATTN_NORM0PITCH_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 )    
        }
    }
    
g_comprado[Player] = true
    
return PLUGIN_CONTINUE

y en event_newround() agregas
Código PHP:
for (new id 1id <= 32id++) g_comprado[id] = false 

Código PHP:
// Someone decided to buy our an extra item
public Event_NewRound ( )
{
    
// Puede volver a comprar la granada si es nueva ronda
    
for (new id 1id <= 32id++) g_comprado[id] = false
    
    
// Reset nade count
    
arrayset g_NadeCountfalse33 )
    
    
// And they aren't affected by conc.grenade
    
remove_task TASK_AFFECT )    

___________________________________
SI NECESITAS UN PLUGIN TE LO HAGO $$$
COMUNICATE A MI DISCORD: emanuelitop15
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)