/*================================================================================
* Team Flashed
* Plugin By ZWP8741(WPZ)
================================================================================*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <csx>
#include <hamsandwich>
new bool:g_flashdisable_round[33]
new const COLOR[] = {0, 0, 0}
enum FLASH{
Float:GameTime = 0,
Duration,
HoldTime,
FadeType,
Alpha
}
new PLAYER[33][FLASH]
new pTeamFlashed
new gMsgScreenFade
new gMaxPlayers
new const FLASHSOUND[2][]={
"weapons/flashbang-1.wav",
"weapons/flashbang-2.wav"
}
public plugin_init(){
register_plugin("Team Flashed", "1.0", "WPZ")
register_event("CurWeapon", "event_weapon", "b")
register_forward(FM_EmitSound, "fw_FM_EmitSound")
register_event("ScreenFade", "event_ScreenFade", "be", "4=255", "5=255", "6=255", "7>199")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
pTeamFlashed = register_cvar("team_flashed", "1")
gMsgScreenFade = get_user_msgid("ScreenFade")
gMaxPlayers = get_maxplayers()
}
public event_weapon(id){
if(get_user_weapon(id) == CSW_FLASHBANG && g_flashdisable_round[id] > 0){
ham_strip_weapon(id, "weapon_flashbang")
client_print(id, print_center, "*!FLASH Gránát letiltva!*")
}
}
stock ham_strip_weapon(id,weapon[]){
if(!equal(weapon,"weapon_",7)) return 0;
new wId = get_weaponid(weapon);
if(!wId) return 0;
new wEnt;
while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
if(!wEnt) return 0;
if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
ExecuteHamB(Ham_Item_Kill,wEnt);
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
return 1;
}
public event_round_start(){
new i
for(i=0;i<= gMaxPlayers;i++)
if(g_flashdisable_round[i] > 0)
g_flashdisable_round[i] --
}
public fw_FM_EmitSound(entity, channel, const sample[], Float:volume, Float:attenuation, fFlags, pitch)
{
if(!get_pcvar_num(pTeamFlashed))
return FMRES_IGNORED
if(!equali(sample, FLASHSOUND[0]) && !equali(sample, FLASHSOUND[1]))
return FMRES_IGNORED
static flashed, Float:time, name[32], flasher, team
flashed = 0
flasher = pev(entity, pev_iuser3)
team = pev(entity, pev_iuser4)
time = get_gametime()
get_user_name(flasher, name, 31)
if (is_user_connected(flasher))
{
for(new id=1; id<=gMaxPlayers; id++)
{
if (is_user_connected(id)
&& PLAYER[id][GameTime]==time
&& team==get_user_team(id)
&& flasher!=id)
{
client_print(id, print_chat, "[AMXX] Te már vakítottad %s!", name)
FlashedEvent(id, PLAYER[id][Duration], PLAYER[id][HoldTime], PLAYER[id][FadeType], COLOR[0], COLOR[1], COLOR[2], PLAYER[id][Alpha])
flashed = 1
}
}
if (flashed)
{
client_print(flasher, print_chat, "[AMXX] Te bevakítottad a csapattársad, ezért nem vehetsz %d körben Vakító Gránátot!", 5)
g_flashdisable_round[flasher] = 5
}
}
return FMRES_IGNORED
}
public event_ScreenFade(id)
{
PLAYER[id][GameTime] = _:get_gametime()
PLAYER[id][Duration] = read_data(1)
PLAYER[id][HoldTime] = read_data(2)
PLAYER[id][FadeType] = read_data(3)
PLAYER[id][Alpha] = read_data(7)
}
public grenade_throw(id, entity, WpnID)
{
if (WpnID == CSW_FLASHBANG)
{
set_pev(entity, pev_iuser3, id)
set_pev(entity, pev_iuser4, get_user_team(id))
}
}
stock FlashedEvent(id, iDuration, iHoldTime, iFadeType, iRed, iGreen, iBlue, iAlpha)
{
message_begin(MSG_ONE, gMsgScreenFade, {0,0,0}, id)
write_short(iDuration) // Duration
write_short(iHoldTime) // Hold time
write_short(iFadeType) // Fade type
write_byte (iRed) // Red
write_byte (iGreen) // Green
write_byte (iBlue) // Blue
write_byte (iAlpha) // Alpha
message_end()
}