MxEMexico

Versión completa: Target Gun (Con limite de compras por ronda)
Actualmente estas viendo una versión simplificada de nuestro contenido. Ver la versión completa con el formato correcto.
Wenas, es la misma target gun pero con un limite de compras (1 target por ronda)  :foreveralone:

Código PHP:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <cs_weapons_api>
#include <fun>
#include <amx_settings_api>
#include <ttt>

#define WEAPON_CSWID CSW_DEAGLE
#define WEAPON_NAME "weapon_deagle"

new g_TargetGung_Glowing[33], g_pMsgScreeFadeg_pMsgScreeShakeg_MaxPlayersg_Attacker[33], g_iCount[33];
new 
g_szModels[3][TTT_FILELENGHT];
new 
g_szSounds[TTT_FILELENGHT];
new 
cvar_weapon_speedcvar_weapon_ammocvar_weapon_clipcvar_weapon_pricecvar_weapon_reloadcvar_weapon_recoil,
 cvar_target_damagecvar_target_radiuscvar_time_explodecvar_message_mode;

public 
plugin_precache()
{
    if(!amx_load_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_V"g_szModels[0], charsmax(g_szModels[])))
    {
        g_szModels[0] = "models/ttt/v_targetgun.mdl";
        amx_save_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_V"g_szModels[0]);
    }
    precache_model(g_szModels[0]);
    
    
if(!amx_load_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_P"g_szModels[1], charsmax(g_szModels[])))
    {
        g_szModels[1] = "models/ttt/p_targetgun.mdl";
        amx_save_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_P"g_szModels[1]);
    }
    precache_model(g_szModels[1]);
    
    
if(!amx_load_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_W"g_szModels[2], charsmax(g_szModels[])))
    {
        g_szModels[2] = "models/ttt/w_targetgun.mdl";
        amx_save_setting_string(TTT_SETTINGSFILE"TARGET GUN""MODEL_W"g_szModels[2]);
    }
    precache_model(g_szModels[2]);
    
    
if(!amx_load_setting_string(TTT_SETTINGSFILE"TARGET GUN""SOUND_BEEP"g_szSoundscharsmax(g_szSounds)))
    {
        g_szSounds "ttt/targetgun_beep.wav";
        amx_save_setting_string(TTT_SETTINGSFILE"TARGET GUN""SOUND_BEEP"g_szSounds);
    }
    precache_sound(g_szSounds);
}

public 
plugin_init()
{
    register_plugin("[TTT] Item: Target Gun"TTT_VERSION"SthoNy'");
    
    cvar_target_damage    
my_register_cvar("ttt_target_damage",    "300.0",    "Target gun explosion damage. (Default: 300.0)");
    cvar_target_radius    my_register_cvar("ttt_target_radius",    "420.0",    "Target gun radius. (Default: 420.0)");
    cvar_weapon_clip    my_register_cvar("ttt_target_clip",        "1",    "Target gun clip ammo. (Default: 1)");
    cvar_weapon_ammo    my_register_cvar("ttt_target_ammo",        "0",    "Target gun backpack ammo. (Default: 1)");
    cvar_weapon_speed    my_register_cvar("ttt_target_speed",        "10.0",    "Target gun attack speed delay. (Default: 10.0)");
    cvar_weapon_reload    my_register_cvar("ttt_target_reload",    "0.0",    "Target gun reload speed. (Default: 0.0)");
    cvar_weapon_recoil    my_register_cvar("ttt_target_recoil",    "0.0",    "Target gun recoil. (Default: 0.0)");
    cvar_weapon_price    my_register_cvar("ttt_price_target",        "3",    "Target gun price. (Default: 3)");
    cvar_message_mode    my_register_cvar("ttt_message_mode""1""Message type 0 || 1. (Default: 1)");
    
    cvar_time_explode    
my_register_cvar("ttt_time_explode""3.0""Target gun time explode (Default: 3.0)");
    
    g_MaxPlayers 
get_maxplayers();
    g_pMsgScreeFade                                get_user_msgid("ScreenFade");
    g_pMsgScreeShake                                get_user_msgid("ScreenShake");
}

public 
client_disconnect(idremove_task(id);

public 
ttt_plugin_cfg()
{
    g_TargetGun ttt_buymenu_add"Target Gun"get_pcvar_num(cvar_weapon_price), PC_TRAITOR);
    ttt_add_exceptiong_TargetGun );
}

public 
ttt_gamemode(gamemode)
{
    
    
if(gamemode == GAME_ENDED || gamemode == GAME_RESTARTING || gamemode == GAME_PREPARING)
    {    
        
for( new 1<= g_MaxPlayersi++ )
        {
            if(g_Glowing[i])
            {
                g_Glowing[i] = false;
    
   g_iCount[i] = false;
                set_user_rendering(i);
                
                
if(task_exists(i))
                remove_task(i);
            }
        }
    }
}
public 
ttt_item_selected(iditemname[], price)
{
    if(
g_TargetGun == item )
    {
        if(!
g_iCount[id])
        {
    
            
if(user_has_weapon(idWEAPON_CSWID))
            
engclient_cmd(id"drop"WEAPON_NAME);
        
            
static data[STOREABLE_STRUCTURE];
            if(!
data[STRUCT_CSWA_CSW])
            {
                
data[STRUCT_CSWA_ITEMID] = g_TargetGun;
                
data[STRUCT_CSWA_CSW] = WEAPON_CSWID;
                
data[STRUCT_CSWA_CLIP] = get_pcvar_num(cvar_weapon_clip);
                
data[STRUCT_CSWA_MAXCLIP] = get_pcvar_num(cvar_weapon_clip);
                
data[STRUCT_CSWA_AMMO] = get_pcvar_num(cvar_weapon_ammo);
                
data[STRUCT_CSWA_STACKABLE] = true;
                
data[STRUCT_CSWA_SILENCED] = -1;
                
data[STRUCT_CSWA_SPEEDDELAY] = _:get_pcvar_float(cvar_weapon_speed);
                
data[STRUCT_CSWA_DAMAGE] = _:0;
                
data[STRUCT_CSWA_RELOADTIME] = _:get_pcvar_float(cvar_weapon_reload);
                
data[STRUCT_CSWA_RECOIL] = _:get_pcvar_float(cvar_weapon_recoil);
                
data[STRUCT_CSWA_MODEL_V] = g_szModels[0];
                
data[STRUCT_CSWA_MODEL_P] = g_szModels[1];
                
data[STRUCT_CSWA_MODEL_W] = g_szModels[2];
            }
            
cswa_give_specific(iddata);
        
            client_print_color
(idprint_team_default"%s Compraste una !gTarget Gun!"TTT_TAG);
            
g_iCount[id] = true;
            
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
client_print_color(idprint_team_default"%s Ya alcanzaste tu limite de !gTarget's Gun!"TTT_TAG);
        }
    }
    return 
PLUGIN_CONTINUE;
   
}

public 
cswa_damage(weapon_idvictimattackerFloat:damage)
{
    new NameA[32];
    get_user_name(attackerNameAcharsmax(NameA));
     
    
if(get_weapon_edict(weapon_idREPL_CSWA_ITEMID) == g_TargetGun)
    {
        if(get_pcvar_num(cvar_message_mode) >=1)
        {
            client_print_colorvictimprint_team_default"%s Han introducido un !tProyectil Explosivo !nen ti, !gEXPLOTARAS!"TTT_TAG);
        }
        else
        {
            client_print_colorvictimprint_team_default"%s !t%s !nintrodujo un !tProyectil Explosivo !nen ti, !gEXPLOTARAS"TTT_TAGNameA);
        }
        
        g_Glowing
[victim] = true;
        g_Attacker[victim] = attacker;
        
        set_user_rendering
(victimkRenderFxGlowShell25500kRenderNormal30);
        
        emit_sound
(victimCHAN_AUTOg_szSounds1.0ATTN_NORM0PITCH_NORM);
        set_taskget_pcvar_float(cvar_time_explode), "targetgun_Explode"victim);
        
        Set_user_screenfade
(victim255002100);
        shake_user_screen(victim);
    }
}
public 
targetgun_Explode(id)
{
    if( !is_user_alive(id) || ttt_get_gamemode() == GAME_ENDED || ttt_get_gamemode() == GAME_PREPARING || !is_user_connected(g_Attacker[id]) )
        return PLUGIN_HANDLED;
    
    strip_user_weapons
(id);
    Explode(id);
    CreateExplosion(id);
    remove_task(id);
    
    
return PLUGIN_HANDLED;
}

CreateExplosion(id)
{
    static Float:origin[3];
    entity_get_vector(idEV_VEC_originorigin);

    new victim = -1Float:damage;
    new Float:radius get_pcvar_float(cvar_target_radius);
    new Float:dmg get_pcvar_float(cvar_target_damage);

    while((victim find_ent_in_sphere(victimoriginradius)) != 0)
    {
        if(is_valid_ent(victim) && entity_get_float(victimEV_FL_takedamage) != DAMAGE_NO)
        {
            damage = (dmg/radius)*(radius entity_range(idvictim));
        
            
if(damage 0.0 )
            {
                if(is_user_connected(victim))
                ttt_set_playerdata(victimPD_KILLEDBYITEMg_TargetGun);
                ExecuteHam(Ham_TakeDamagevictimg_Attacker[id], g_Attacker[id], damageDMG_BLAST);
                entity_set_vector(victimEV_VEC_velocityFloat:{0.00.00.0});
                if(is_user_alive(victim))
                ttt_set_playerdata(victimPD_KILLEDBYITEMg_TargetGun);
            }
        }
    }
    
    ttt_set_playerdata
(idPD_KILLEDBYITEMg_TargetGun);
    ExecuteHam(Ham_TakeDamageidg_Attacker[id], g_Attacker[id], dmgDMG_BLAST);
}

Explode(id)
{
    static origin[3];
    get_user_origin(idorigin0);

    message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    write_byte(TE_TAREXPLOSION);
    write_coord(origin[0]);
    write_coord(origin[1]);
    write_coord(origin[2]);
    message_end();
}
public 
Set_user_screenfade(indexrrrgggbbbduracionalpha)
{
    message_beginindex MSG_ONE_UNRELIABLE MSG_BROADCASTg_pMsgScreeFade_index );
    write_shortduracion 4096 );
    write_shortduracion 4096 );
    write_short0x0000 );
    write_byterrr ); 
    write_byte
ggg );
    write_bytebbb ); 
    write_byte
alpha );
    message_end( );    
}
stock shake_user_screen(index)
{
    message_begin(MSG_ONEg_pMsgScreeShake, {0,0,0}, index); // Shake Screen
    write_short(1<<14);
    write_short(1<<14);
    write_short(1<<14);
    message_end();
}
  

por sí deciden implementarla de nuevo con un poco más de orden.

EDIT; Le removí lo de no hacerle daño a traidores a petición del público  :no:
@mxemexico @R0B1N @Banana Nerv

Esta versión esta muy buena.
lo de no bajar hp a traidores no se me hace correcto ya que si explota un cabron y si hay 3 al rededor y solo mueren 1 o 2 te darias cuenta que quien quedo vivo es traidor men
lo de arriba x2
Actualizado, ya le quité eso e.e
Ahora si se viene lo chido, gracias man xd.. @mxemexico
No hay de que Smile
No me manejo mucho con este mod, el evento ttt_gamemode se registra principio de cada ronda?
la native ttt_gamemode se utiliza para verificar sí la partida está iniciada, terminada, siendo reiniciada etc, etc...