Hi
Serious Bug:
Code:
g_iFlashTeamCount[id]++
If the flasher flashbanged someone, this count add flashteamcount to another people, not to him (my buddy confirmed it, he discovered it, he didn't use flashbangs, and he was often flashbanged by others, then he couldn't use a flashbang)
I think that it should be:
Code:
g_iFlashTeamCount[iFlasher]++
Additionally i added that everybody in your team (also dead, however it can be changed) see who flashbanged whom, and i changed that "you fully flashbanged xxx" only if you fully blinded him
Anyway, it's great plugin, thx
Final code:
Code:
/* AMX Mod X Plugin
*
* (c) Copyright 2008, ConnorMcLeod
* This file is provided as is (no warranties).
*
*/
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#define MAX_PLAYERS 32
#define OFFSET_TEAM 114
#define W_FLASH_MODEL_STRLEN 22
#define FLASH_XPLODE_SOUND_STRLEN 23
new g_iMaxClients
new g_iHasJustBeenFlashed[MAX_PLAYERS+1]
new g_iFlashTeamCount[MAX_PLAYERS+1]
new g_pcvarTeamFlash, g_pcvarMax, g_pcvarSlap, g_pcvarPunish
public plugin_init()
{
register_plugin("Team Flash Punish", "1.0.0", "ConnorMcLeod")
g_pcvarTeamFlash = register_cvar("tfp_count", "1") // 0: don't count, 1:count only fully blinded, 2:count all flash
g_pcvarMax = register_cvar("tfp_max_count", "6") // disallow flashbang after X count
g_pcvarPunish = register_cvar("tfp_slap", "1") // 0: don't slap, 1:slap only fully blinded, 2:slap all flash
g_pcvarSlap = register_cvar("tfp_slap_amount", "10") // slap powaaaa
register_event("ScreenFade", "Event_ScreenFade", "be", "4=255", "5=255", "6=255", "7=200", "7=255")
register_forward(FM_SetModel, "Forward_SetModel")
register_forward(FM_EmitSound, "Forward_EmitSound")
}
public plugin_cfg()
{
g_iMaxClients = global_get(glb_maxClients)
}
public Forward_SetModel(iEntity, const szModel[])
{
if(strlen(szModel) != W_FLASH_MODEL_STRLEN)
{
return FMRES_IGNORED
}
if(szModel[7] != 'w' || szModel[9] != 'f' || szModel[14] != 'b')
{
return FMRES_IGNORED
}
if(!pev_valid(iEntity))
{
return FMRES_IGNORED
}
static Float:fVelocity[3]
pev(iEntity, pev_velocity, fVelocity)
if(!fVelocity[0] && !fVelocity[1] && !fVelocity[2])
{
return FMRES_IGNORED
}
static iOwner, iMax
iOwner = pev(iEntity, pev_owner)
iMax = get_pcvar_num(g_pcvarMax)
if(iMax && g_iFlashTeamCount[iOwner] >= iMax)
{
engfunc(EngFunc_RemoveEntity, iEntity)
client_print(iOwner, print_center, "Your flashbanged your teammate too much time, now you cannot use flashbang")
return FMRES_SUPERCEDE
}
set_pev(iEntity, pev_iuser4, iOwner)
return FMRES_HANDLED
}
public Forward_EmitSound(iEntity, iChannel, const szSample[])
{
if(strlen(szSample) != FLASH_XPLODE_SOUND_STRLEN)
{
return FMRES_IGNORED
}
if(szSample[0] != 'w' || szSample[8] != 'f' || szSample[9] != 'l')
{
return FMRES_IGNORED
}
if(!pev_valid(iEntity))
{
return FMRES_IGNORED
}
static iFlasher
iFlasher = pev(iEntity, pev_iuser4)
if(pev_valid(iFlasher) != 2)
return FMRES_IGNORED
static iCount, iPunish
iCount = get_pcvar_num(g_pcvarTeamFlash)
iPunish = get_pcvar_num(g_pcvarPunish)
if(!iCount && !iPunish)
{
return FMRES_HANDLED
}
static iTeam, id, iFlashed
iTeam = get_pdata_int(iFlasher, OFFSET_TEAM)
new iFlasherName[32]
get_user_name(iFlasher,iFlasherName,31)
for(id=1; id<=g_iMaxClients; id++)
{
iFlashed = g_iHasJustBeenFlashed[id]
if(!iFlashed)
continue
g_iHasJustBeenFlashed[id] = 0
if(pev_valid(id) != 2)
continue
if(id != iFlasher && get_pdata_int(id, OFFSET_TEAM) == iTeam)
{
if( iCount && (iCount==2 || iFlashed==255) )
{
new iFlashedName[32]
get_user_name(id,iFlashedName,31)
new players[32],num
if(cs_get_user_team(id) == CS_TEAM_CT)
{
get_players(players,num,"ae","CT")
} else
if(cs_get_user_team(id) == CS_TEAM_T)
{
get_players(players,num,"ae","TERRORIST")
}
client_print(0,print_chat,"%s fully flashbanged his teammate %s",iFlasherName,iFlashedName)
g_iFlashTeamCount[iFlasher]++
client_print(iFlasher, print_center, "You fully flashbanged your teammate, watch what are you doing!")
}
if( iPunish && (iPunish==2 || iFlashed==255) )
{
user_slap(iFlasher, get_pcvar_num(g_pcvarSlap), 0)
}
}
}
return FMRES_HANDLED
}
public Event_ScreenFade(id)
{
g_iHasJustBeenFlashed[id] = read_data(7)
}
public client_putinserver(id)
{
g_iFlashTeamCount[id] = 0
g_iHasJustBeenFlashed[id] = 0
}