#include <amxmodx>
#include <engine>
#include <cs_weapons_api>
#include <ttt>
//CREDITOS: Totopizza
#define WEAPON_CSWID CSW_DEAGLE
#define WEAPON_NAME "weapon_deagle"
new g_szModels[3][TTT_FILELENGHT];
new g_TpGun;
new cvar_weapon_damage, cvar_weapon_ammo, cvar_weapon_clip, cvar_weapon_price, cvar_weapon_reload, cvar_weapon_recoil, cvar_weapon_blind, g_MaxPlayers;
new g_iAttacker_Coord[33] = {-1, -1, ...}, g_iVictim_Coord[33] = {-1, -1, ...};
new Float:g_fPlayerOrigin[33][3];
new const tp_wav[] = { "events/tutor_msg.wav" }
new g_msgScreenFade;
public plugin_precache()
{
if(!amx_load_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_V", g_szModels[0], charsmax(g_szModels[])))
{
g_szModels[0] = "models/ttt/v_tpgun.mdl";
amx_save_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_V", g_szModels[0]);
}
precache_model(g_szModels[0]);
if(!amx_load_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_P", g_szModels[1], charsmax(g_szModels[])))
{
g_szModels[1] = "models/ttt/p_tpgun.mdl";
amx_save_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_P", g_szModels[1]);
}
precache_model(g_szModels[1]);
if(!amx_load_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_W", g_szModels[2], charsmax(g_szModels[])))
{
g_szModels[2] = "models/ttt/w_tpgun.mdl";
amx_save_setting_string(TTT_SETTINGSFILE, "TELEPORT GUN", "MODEL_W", g_szModels[2]);
}
precache_model(g_szModels[2]);
precache_sound(tp_wav);
}
public plugin_init()
{
register_plugin("[TTT] Item: Teleport Gun", TTT_VERSION, "GabsHp");
cvar_weapon_clip = my_register_cvar("ttt_tpgun_clip", "1", "Teleport Gun clip(s). (Default: 2)");
cvar_weapon_ammo = my_register_cvar("ttt_tpgun_ammo", "0", "Teleport Gun ammo (Default: 0)");
cvar_weapon_damage = my_register_cvar("ttt_tpgun_damage", "0.0", "Teleport Gun damage multiplier. (Default: 0.0)");
cvar_weapon_reload = my_register_cvar("ttt_tpgun_reload", "0.0", "Teleport Gun reload speed. (Default: 0.0)");
cvar_weapon_recoil = my_register_cvar("ttt_tpgun_recoil", "0.0", "Teleport Gun recoil. (Default: 0.0)");
cvar_weapon_price = my_register_cvar("ttt_tpgun_price", "2", "Teleport Gun price. (Default: 3)");
cvar_weapon_blind = my_register_cvar("ttt_tpgun_blind", "1", "Le provoca ceguera por cierto tiempo a la victima");
g_MaxPlayers = get_maxplayers();
g_msgScreenFade = get_user_msgid("ScreenFade");
}
public ttt_plugin_cfg()
{
g_FakeGolden = ttt_buymenu_add( "Teleport Gun", get_pcvar_num(cvar_weapon_price), PC_TRAITOR);
}
public ttt_item_selected(id, item, name[], price)
{
if(g_TpGun== item)
{
if(user_has_weapon(id, WEAPON_CSWID))
engclient_cmd(id, "drop", WEAPON_NAME);
static data[STOREABLE_STRUCTURE];
if(!data[STRUCT_CSWA_CSW])
{
data[STRUCT_CSWA_ITEMID] = g_FakeGolden;
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_DAMAGE] = _:get_pcvar_float(cvar_weapon_damage);
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(id, data);
client_print_color(id, print_team_default, "%s Compraste: !g'Teleport Gun'", TTT_TAG);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public cswa_damage(weapon_id, victim, attacker, Float:damage)
{
if(get_weapon_edict(weapon_id, REPL_CSWA_ITEMID) == g_TpGun)
{
if(ttt_get_playerstate(attacker) != PC_TRAITOR ){
new szAttackerName[32]; get_user_name(attacker, szAttackerName, 31);
ExecuteHamB(Ham_Killed, attacker, attacker, 2);
client_print_color(attacker, print_team_default, "%s !nExplotaste por tratar de usar un arma exclusiva de traidores");
client_print_color(0, print_team_default, "%s !g%s Exploto al tratar de usar una Teleport Gun", TTT_TAG, szAttackerName);
return HAM_IGNORED
}else{
new Float:vAttacker[3], Float:vVictim[3];
entity_get_vector(attacker, EV_VEC_origin, vAttacker);
entity_get_vector(victim, EV_VEC_origin, vVictim);
entity_set_origin(victim, vAttacker);
entity_set_origin(attacker, vVictim);
new szVictimName[32]; get_user_name(victim, szVictimName, 31);
client_print_color(attacker, print_team_default, "%s ^x01Has sido intercambiado de lugar con ^x04%s ", TTT_TAG, szVictimName);
client_print_color(victim, print_team_default, "%s ^x01Has sido intercambiado de lugar mediante una ^x04Teleport Gun", TTT_TAG);
emit_sound (attacker, CHAN_AUTO, tp_wav, VOL_NORMAL, ATTN_NORM, 0, PITCH_NORM)
emit_sound (victim, CHAN_AUTO, tp_wav, VOL_NORMAL, ATTN_NORM, 0, PITCH_NORM)
if(get_pcvar_num(cvar_weapon_blind) == 1) {
set_user_screenfade(victim);
}
}
}
}
stock set_user_screenfade(id, rrr=255, ggg=255, bbb=255, alpha=5, duration=4)
{
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_msgScreenFade, .player = id);
write_short( duration * 4096 );
write_short( duration * 4096 );
write_short( 0x0000 );
write_byte( rrr );
write_byte( ggg );
write_byte( bbb );
write_byte( alpha );
message
}