Code: Select all
#include <amxmodx>
#include <amxmisc>
#include <csx>
#define PLUGIN "CS Misc. Stats"
#define VERSION "1.9"
#define AUTHOR "www.extreamcs.ro"
#define server "extreamcs"
public KillingStreak
public KillingStreakSound
public KnifeKillSound
public HeadShotKillSound
public BombCountVoice
public BombDefusedSound
public BombExplodingSound
const SOUNDFILE_PATH_MAXLEN = 64
const SOUND_SHORTPATH_MAXLEN = SOUNDFILE_PATH_MAXLEN - 10
const TASK_BOMB_TIMER = 8038
new const _msound[] = "_msound"
new g_streakKills[MAX_PLAYERS + 1][2]
new g_multiKills[MAX_PLAYERS + 1][2]
new g_C4Timer
new g_Defusing
new g_roundCount
new g_friend[MAX_PLAYERS + 1]
new g_left_sync
new g_pcvar_mp_c4timer, g_c4timer_value
new g_connected[MAX_PLAYERS + 1]
new g_msounds[MAX_PLAYERS + 1]
new g_knifekillsound[SOUND_SHORTPATH_MAXLEN] = "misc/cshumiliation"
new g_hssound_killer[SOUND_SHORTPATH_MAXLEN] = "misc/csheadshot"
new g_bombdefusedsound[SOUND_SHORTPATH_MAXLEN] = "misc/csbombdefused"
new g_bombexplodingsound[SOUND_SHORTPATH_MAXLEN] = "misc/csbombexploding"
new g_Sounds[12][SOUND_SHORTPATH_MAXLEN] =
{
"misc/cstriplekill",
"misc/csmultikill",
"misc/csludicrouskill",
"misc/csmegakill",
"misc/csultrakill",
"misc/csmonsterkill",
"misc/cskillingspree",
"misc/csrampage",
"misc/csholyshit",
"misc/csgodlike",
"misc/csunstoppable",
""
}
new g_KillingMsg[12][] =
{
"%s: Triple Kill",
"%s: Multi Kill",
"%s: Ludicrous Kill",
"%s: Mega Kill",
"%s: Ultra Kill",
"%s: Monster Kill",
"%s: Killing Spree",
"%s: Rampage",
"%s: Holy Shit",
"%s: God Like",
"%s: Unstoppable",
""
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("statsx.txt")
register_clcmd("say /msounds", "cmdSwitchSounds", 0, " - switches sounds on and off")
register_clcmd("say_team /msounds", "cmdSwitchSounds", 0, " - switches sounds on and off")
register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_event("StatusValue", "setTeam", "bef", "1=1")
new mapname[32]
if((get_map_objectives() & MapObjective_Bomb) || (equali(mapname, "de_", 3) || equali(mapname, "csde_", 5)))
{
register_event("BarTime", "eStopDefuse", "b", "1=0")
}
g_left_sync = CreateHudSyncObj()
g_pcvar_mp_c4timer = get_cvar_pointer("mp_c4timer")
g_c4timer_value = get_pcvar_num(g_pcvar_mp_c4timer)
}
public plugin_precache()
{
new szConfigsDir[64], szCfgFile[64]
get_configsdir(szConfigsDir, charsmax(szConfigsDir))
formatex(szCfgFile, charsmax(szCfgFile), "%s/stats.ini", szConfigsDir)
new buffer[256]
new fp = fopen(szCfgFile, "rt")
if(fp)
{
new xvarname[32], xvarid
while(!feof(fp))
{
fgets(fp, buffer, charsmax(buffer))
trim(buffer)
if(buffer[0] != ';')
{
parse(buffer, xvarname, charsmax(xvarname))
if((xvarid = get_xvar_id(xvarname)) != -1)
{
set_xvar_num(xvarid, 1)
}
}
}
fclose(fp)
}
formatex(szCfgFile, charsmax(szCfgFile), "%s/miscstats.ini", szConfigsDir)
fp = fopen(szCfgFile, "rt")
if(fp)
{
new szSoundKey[32], szSoundFile[SOUNDFILE_PATH_MAXLEN]
while(!feof(fp))
{
fgets(fp, buffer, charsmax(buffer))
trim(buffer)
if(buffer[0] != ';' && parse(buffer, szSoundKey, charsmax(szSoundKey), szSoundFile, charsmax(szSoundFile)) == 2)
{
if(equal(szSoundKey, "KnifeKillSound"))
{
copy_sound(g_knifekillsound, charsmax(g_knifekillsound), szSoundFile)
if(KnifeKillSound) precache_sound_custom(g_knifekillsound)
}
else
if(equal(szSoundKey, "HeadShotKillSoundKiller"))
{
copy_sound(g_hssound_killer, charsmax(g_hssound_killer), szSoundFile)
if(HeadShotKillSound) precache_sound_custom(g_hssound_killer)
}
else
if(equal(szSoundKey, "BombDefusedSound"))
{
copy_sound(g_bombdefusedsound, charsmax(g_bombdefusedsound), szSoundFile)
if(BombDefusedSound) precache_sound_custom(g_bombdefusedsound)
}
else
if(equal(szSoundKey, "BombExplodingSound"))
{
copy_sound(g_bombexplodingsound, charsmax(g_bombexplodingsound), szSoundFile)
if(BombExplodingSound) precache_sound_custom(g_bombexplodingsound)
}
else
{
if(equal(szSoundKey, "TripleKillSound"))
{
copy_sound(g_Sounds[0], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[0])
}
else
if(equal(szSoundKey, "MultiKillSound"))
{
copy_sound(g_Sounds[1], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[1])
}
else
if(equal(szSoundKey, "LudicrousKillSound"))
{
copy_sound(g_Sounds[2], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[2])
}
else
if(equal(szSoundKey, "MegaKillSound"))
{
copy_sound(g_Sounds[3], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[3])
}
else
if(equal(szSoundKey, "UltraKillSound"))
{
copy_sound(g_Sounds[4], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[4])
}
else
if(equal(szSoundKey, "MonsterKillSound"))
{
copy_sound(g_Sounds[5], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[5])
}
else
if(equal(szSoundKey, "KillingSpreeSound"))
{
copy_sound(g_Sounds[6], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[6])
}
else
if(equal(szSoundKey, "RampageSound"))
{
copy_sound(g_Sounds[7], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[7])
}
else
if(equal(szSoundKey, "HolyShitSound"))
{
copy_sound(g_Sounds[8], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[8])
}
else
if(equal(szSoundKey, "GodLikeSound"))
{
copy_sound(g_Sounds[9], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[9])
}
else
if(equal(szSoundKey, "UnstoppableSound"))
{
copy_sound(g_Sounds[10], charsmax(g_Sounds[]), szSoundFile)
if(KillingStreakSound) precache_sound_custom(g_Sounds[10])
}
}
}
}
fclose(fp)
}
}
precache_sound_custom(const sound[])
{
new fullpathsound[SOUNDFILE_PATH_MAXLEN]
formatex(fullpathsound, charsmax(fullpathsound), "sound/%s.wav", sound)
if(file_exists(fullpathsound))
{
precache_sound(fullpathsound[6])
}
else
{
log_amx("WARNING: Could not locate <%s> file", fullpathsound)
}
}
copy_sound(dest[], len, src[])
{
new n = copy(dest, len, src[10 * equali(src, "sound/", 10)])
if(n > 4 && equal(dest[n-4], ".wav"))
{
dest[n-4] = EOS
}
}
public plugin_cfg()
{
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast, "ST_KILL_STR", "KillingStreak")
server_cmd(g_addStast, "ST_KILL_STR_SOUND", "KillingStreakSound")
server_cmd(g_addStast, "ST_KNIFE_KILL_SOUND", "KnifeKillSound")
server_cmd(g_addStast, "ST_HS_KILL_SOUND", "HeadShotKillSound")
server_cmd(g_addStast, "ST_BOMB_CD_VOICE", "BombCountVoice")
server_cmd(g_addStast, "ST_BOMB_DEF_SUCC_SOUND", "BombDefusedSound")
server_cmd(g_addStast, "ST_BOMB_EXPLODING_SOUND", "BombExplodingSound")
}
public client_connect(id)
{
if(is_user_bot(id))
{
g_msounds[id] = 0
return
}
new info[2]
if(!get_user_info(id, _msound, info, charsmax(info)) || info[0] != '0')
{
g_msounds[id] = 1
}
else
{
g_msounds[id] = 0
}
}
public client_putinserver(id)
{
g_multiKills[id] = {0, 0}
g_streakKills[id] = {0, 0}
g_connected[id] = true
}
public client_disconnected(id)
{
g_connected[id] = false
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if(wpnindex == CSW_C4)
return
new headshot = (hitplace == HIT_HEAD) ? 1 : 0
new selfkill = (killer == victim) ? 1 : 0
if((KillingStreak || KillingStreakSound) && !TK)
{
g_streakKills[victim][1]++
g_streakKills[victim][0] = 0
if(!selfkill)
{
g_streakKills[killer][0]++
g_streakKills[killer][1] = 0
new a = g_streakKills[killer][0] - 3
if((a > -1) && !(a % 2))
{
new name[MAX_NAME_LENGTH]
get_user_name(killer, name, charsmax(name))
if((a >>= 1) > 10)
a = 11
if(KillingStreak)
{
set_hudmessage(255, 255, 255, 0.05, 0.50, 2, 0.02, 6.0, 0.01, 0.1, -1)
ShowSyncHudMsg(0, g_left_sync, g_KillingMsg[a], name)
}
if(KillingStreakSound)
{
play_sound(0, g_Sounds[a])
}
}
}
}
if(wpnindex == CSW_KNIFE && (KnifeKillSound))
{
if(KnifeKillSound)
play_sound(0, g_knifekillsound)
}
if(headshot && (HeadShotKillSound))
{
if(HeadShotKillSound)
{
if(victim != killer)
play_sound(killer, g_hssound_killer)
}
}
}
public setTeam(id)
g_friend[id] = read_data(2)
public Event_HLTV_New_Round()
{
g_c4timer_value = get_pcvar_num(g_pcvar_mp_c4timer)
++g_roundCount
g_C4Timer = 0
}
public eRestart()
{
eEndRound()
g_roundCount = 0
}
public eEndRound()
{
g_C4Timer = -2
remove_task(TASK_BOMB_TIMER)
}
public checkKills(param[])
{
new id = param[0]
new a = param[1]
if(a == g_multiKills[id][0])
{
a -= 3
if(a > -1)
{
if(a > 10)
{
a = 11
}
}
g_multiKills[id] = {0, 0}
}
}
public bombTimer()
{
if(--g_C4Timer > 0)
{
if(BombCountVoice)
{
if(g_C4Timer == 30 || g_C4Timer == 20)
{
new temp[64]
num_to_word(g_C4Timer, temp, charsmax(temp))
format(temp, charsmax(temp), "^"vox/%s seconds until explosion^"", temp)
play_sound(0, temp)
}
else
if(g_C4Timer < 11)
{
new temp[64]
num_to_word(g_C4Timer, temp, charsmax(temp))
format(temp, charsmax(temp), "^"vox/%s^"", temp)
play_sound(0, temp)
}
}
}
else
remove_task(TASK_BOMB_TIMER)
}
public eStopDefuse(id)
{
if(id == g_Defusing)
{
g_Defusing = 0
}
}
public bomb_planted(planter)
{
g_Defusing = 0
g_C4Timer = g_c4timer_value + 1
bombTimer()
set_task(1.0, "bombTimer", TASK_BOMB_TIMER, "", 0, "b")
}
public bomb_defused(defuser)
{
if(BombDefusedSound)
play_sound(0, g_bombdefusedsound)
}
public bomb_explode()
{
if(BombExplodingSound)
play_sound(0, g_bombexplodingsound)
}
play_sound(id, sound[])
{
if(id)
{
if(g_msounds[id])
{
client_cmd(id, "spk %s", sound)
}
}
else
{
new players[MAX_PLAYERS], pnum, id
get_players(players, pnum, "ch")
for(--pnum; pnum >= 0; pnum--)
{
id = players[pnum]
if(g_connected[id] && g_msounds[id])
client_cmd(id, "spk %s", sound)
}
}
}
public cmdSwitchSounds(id)
{
g_msounds[id] = !g_msounds[id]
color_chat(id, "^x04[%s]^x01 Misc Sounds:^x03 %s", server, g_msounds[id] ? "On" : "Off")
set_user_info(id, _msound, g_msounds[id] ? "1" : "0")
client_cmd(id, "setinfo %s %s", _msound, g_msounds[id] ? "1" : "0")
}
stock color_chat(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "^x01", "^1")
replace_all(msg, 190, "^x03", "^3")
replace_all(msg, 190, "^x04", "^4")
if(id)players[0] = id; else get_players(players, count, "ch")
{
for(new i = 0; i < count; i++)
{
if(is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
}