/* Ultimate Hang (HU) – AMXX (CS 1.6) – v1.6 (AMXX 1.8.1 kompatibilis)
* Funkciok:
* - Kor eleji random uzenetek + "Ez a X. kor" (kozep HUD, random szin)
* - Headshot: global hang (4 fajta), felirat nelkul
* - Kill-lepcsok HUD (3/5/7/9/11/13/15/17), random szin bal also + hangok
* - Bomba:
* • lerakas: hang + piros villogo HUD,
* • defuse: hang + piros villogo HUD,
* • felvetel (Got_The_Bomb): NINCS hang, piros villogo HUD,
* • elejtes (Dropped_The_Bomb): NINCS hang, feher kozep HUD,
* • robbanas (Target_Bombed): HANG (HUD nelkul),
* • C4 visszaszamlalas 10→1 hangokkal
* - Granat kill hang (2), Keses kill hang (3), Suicide (3)
* - First Blood (2)
* - Elo jatekosok bal also feher HUD-on (T/CT maradek)
* - Aim-HUD (ellenseg nev; csapattars: Nev -- HP / AP / fegyver)
* - Halalkor: "Sebzett :" + listak; "Aldozatok :" + listak
* - 1vX clutch + hang; 1v1 duel + hang
* - Kor eleji CHAT stat sorok (elozo korbol): kombo / deathstreak
* - Kor vegen HUD: Legjobb pont & Legjobb sebzes; TOTAL csak a nyertes csapatnak
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <cstrike>
#define COMBO_TIMEOUT 4.0
#define HUD_CENTER_Y 0.30
#define HUD_BL_X 0.02
#define HUD_BL_Y 0.90
#define HUD_CROSS_Y 0.55
#define MAXP 33
// -------------------- Hangok --------------------
new const SND_RSTART[][] = { "quake/round1.wav","quake/round2.wav","quake/round3.wav","quake/round4.wav" };
new const SND_HS[][] = { "quake/headshot1.wav","quake/headshot2.wav","quake/headshot3.wav","quake/headshot4.wav" };
new const SND_KSTEP[][] = {
"quake/multikill.wav", "quake/ultrakill.wav","quake/monsterkill.wav","quake/unstoppable.wav",
"quake/ludicrouskill.wav","quake/combowhore.wav","quake/holyshit.wav","quake/godlike.wav"
};
// Bomba – pickup HANG NINCS; lerakas/defuse/robbanas VAN hang
new const SND_B_PLANTED[] = "quake/bomb_planted.wav";
new const SND_B_DEFUSED[] = "quake/bomb_defused.wav";
new const SND_B_EXPLODED[] = "quake/bomb_exploded.wav";
new const SND_CNT[][ ] = {
"quake/count10.wav","quake/count9.wav","quake/count8.wav","quake/count7.wav","quake/count6.wav",
"quake/count5.wav","quake/count4.wav","quake/count3.wav","quake/count2.wav","quake/count1.wav"
};
new const SND_CLUTCH[] = "quake/clutch.wav";
new const SND_DUEL1V1[] = "quake/duel1v1.wav";
new const SND_GRENADE[][] = { "quake/grenade_kill1.wav","quake/grenade_kill2.wav" };
new const SND_KNIFE[][] = { "quake/knife_kill1.wav","quake/knife_kill2.wav","quake/knife_kill3.wav" };
new const SND_SUICIDE[][] = { "quake/suicide1.wav","quake/suicide2.wav","quake/suicide3.wav" };
new const SND_FIRSTBLOOD[][] = { "quake/firstblood1.wav","quake/firstblood2.wav" };
// Kor eleji random uzenetek
new const RND_MSGS[][] = { "Kuzdj es harcolj!","Play! Play! Play! Play!","Valaszd ki a fegyvered!" };
// -------------------- Allapot --------------------
new Float:g_lastKillTime[MAXP];
new g_combo[MAXP], g_comboHS[MAXP];
new g_bestCombo[MAXP], g_lastRoundBestCombo[MAXP];
new g_deathStreak[MAXP];
new g_roundNum;
new g_kills[MAXP], g_hs[MAXP];
new Float:g_dmg[MAXP];
new g_shots[MAXP], g_hits[MAXP];
// csapat totals (index 2=T, 3=CT)
new g_tKills[4], g_tHS[4], g_tShots[4], g_tHits[4];
// per-life
new Float:g_dmgFrom[MAXP][MAXP];
new g_hitsFrom[MAXP][MAXP];
new g_lastWeap[MAXP][MAXP][24];
new bool:g_bombPlanted;
new g_bombTasks[10];
new g_tBlink[MAXP], g_tR[MAXP], g_tG[MAXP], g_tB[MAXP];
new bool:g_ann1vX, bool:g_ann1v1;
new g_prevWpn[MAXP], g_prevClip[MAXP];
new g_roundRealKills; // FIRST BLOOD számláló
// -------------------- Plugin --------------------
public plugin_init()
{
register_plugin("Ultimate Hang (HU) AMXX", "1.6", "Assistant");
register_event("HLTV","ev_round_start","a","1=0","2=0");
register_event("SendAudio","ev_ctwin","a","2=%!MRAD_ctwin");
register_event("SendAudio","ev_terwin","a","2=%!MRAD_terwin");
register_event("DeathMsg","ev_death","a");
register_event("Damage","ev_damage","b","2!0");
register_event("CurWeapon","ev_curweapon","be","1=1");
// Bomba logeventek
register_logevent("log_bomb_planted", 3, "2=Planted_The_Bomb");
register_logevent("log_bomb_defused", 3, "2=Defused_The_Bomb");
register_logevent("log_bomb_dropped", 3, "2=Dropped_The_Bomb");
register_logevent("log_bomb_got", 3, "2=Got_The_Bomb");
register_logevent("log_bomb_exploded", 3, "2=Target_Bombed");
set_task(0.15, "task_aimhud", 7777, _, _, "b");
reset_totals();
}
public plugin_precache()
{
for (new i=0;i<sizeof SND_RSTART;i++) precache_sound(SND_RSTART[i]);
for (new i=0;i<sizeof SND_HS;i++) precache_sound(SND_HS[i]);
for (new i=0;i<sizeof SND_KSTEP;i++) precache_sound(SND_KSTEP[i]);
for (new i=0;i<sizeof SND_CNT;i++) precache_sound(SND_CNT[i]);
precache_sound(SND_B_PLANTED);
precache_sound(SND_B_DEFUSED);
precache_sound(SND_B_EXPLODED);
precache_sound(SND_CLUTCH);
precache_sound(SND_DUEL1V1);
for (new i=0;i<sizeof SND_GRENADE;i++) precache_sound(SND_GRENADE[i]);
for (new i=0;i<sizeof SND_KNIFE;i++) precache_sound(SND_KNIFE[i]);
for (new i=0;i<sizeof SND_SUICIDE;i++) precache_sound(SND_SUICIDE[i]);
for (new i=0;i<sizeof SND_FIRSTBLOOD;i++) precache_sound(SND_FIRSTBLOOD[i]);
}
// -------------------- Round start --------------------
public ev_round_start()
{
g_roundNum++;
g_bombPlanted = false;
g_roundRealKills = 0;
cancel_c4_tasks();
reset_totals_round();
g_ann1v1 = false;
g_ann1vX = false;
for (new i=1;i<MAXP;i++)
{
g_combo[i]=0; g_comboHS[i]=0; g_lastKillTime[i]=0.0;
reset_perlife(i);
g_prevWpn[i]=0; g_prevClip[i]=-1;
}
spk_all(SND_RSTART[random_num(0, sizeof SND_RSTART - 1)]);
new r,g,b; rand_rgb(r,g,b);
center_all(r,g,b, 2.0, "%s", RND_MSGS[random_num(0, sizeof RND_MSGS - 1)]);
center_all(r,g,b, 2.0, "Ez a %d. kor", g_roundNum);
for (new i=1; i<MAXP; i++)
{
if (!is_user_connected(i)) continue;
if (g_lastRoundBestCombo[i] >= 2)
client_print(i, print_chat, "* Te megoltel %d ellenseget egymas utan.", g_lastRoundBestCombo[i]);
else if (g_deathStreak[i] >= 1)
client_print(i, print_chat, "* Ovatosabban egymas utan %d haltal meg.", g_deathStreak[i]);
g_bestCombo[i] = 0;
}
}
// -------------------- CurWeapon -> loves szamlalo --------------------
public ev_curweapon(id)
{
if (!is_user_alive(id)) return;
new wpn = read_data(2);
new clip = read_data(3);
if (g_prevWpn[id] != wpn)
{
g_prevWpn[id] = wpn;
g_prevClip[id] = clip;
return;
}
if (g_prevClip[id] == -1)
{
g_prevClip[id] = clip;
return;
}
if (clip < g_prevClip[id])
{
g_shots[id]++;
new team = get_user_team(id);
if (team==1) g_tShots[2]++;
else if (team==2) g_tShots[3]++;
}
g_prevClip[id] = clip;
}
// -------------------- Damage/hits/dmg + fegyver nyomkovetes --------------------
public ev_damage(victim)
{
if (!is_user_connected(victim)) return;
new wpn, body;
new attacker = get_user_attacker(victim, wpn, body);
if (attacker<=0 || attacker==victim || !is_user_connected(attacker)) return;
new dmg = read_data(2);
g_dmg[attacker] += float(dmg);
g_hits[attacker]++;
new teamA = get_user_team(attacker); // 1=T, 2=CT
if (teamA==1) g_tHits[2]++; else if (teamA==2) g_tHits[3]++;
g_dmgFrom[attacker][victim] += float(dmg);
g_hitsFrom[attacker][victim]++;
new wname[24] = "unknown";
if (wpn>0) get_weaponname(wpn, wname, charsmax(wname)); // "weapon_m4a1"
trim_weapon_prefix(wname);
copy(g_lastWeap[attacker][victim], 23, wname);
}
// -------------------- Death --------------------
public ev_death()
{
new killer = read_data(1);
new victim = read_data(2);
new hs = read_data(3);
new weap[24]; read_data(4, weap, charsmax(weap));
// Suicide
if (killer == victim && is_user_connected(victim))
{
spk_all(SND_SUICIDE[random_num(0, sizeof SND_SUICIDE - 1)]);
g_deathStreak[victim]++;
reset_perlife(victim);
return;
}
// HE grenade (random 2)
if (equali(weap, "hegrenade"))
spk_all(SND_GRENADE[random_num(0, sizeof SND_GRENADE - 1)]);
// Knife kill (random 3)
if (equali(weap, "knife"))
spk_all(SND_KNIFE[random_num(0, sizeof SND_KNIFE - 1)]);
// Headshot hang
if (hs == 1)
spk_all(SND_HS[random_num(0, sizeof SND_HS - 1)]);
// FIRST BLOOD: elso valodi kill (nem suicide)
if (is_user_connected(killer) && killer!=victim)
{
if (g_roundRealKills == 0)
spk_all(SND_FIRSTBLOOD[random_num(0, sizeof SND_FIRSTBLOOD - 1)]);
g_roundRealKills++;
// per-kor
g_kills[killer]++;
if (hs==1) g_hs[killer]++;
// team totals (1=T,2=CT -> 2=T,3=CT)
new tA = get_user_team(killer);
if (tA==1){ g_tKills[2]++; if (hs==1) g_tHS[2]++; }
else if (tA==2){ g_tKills[3]++; if (hs==1) g_tHS[3]++; }
// combo
new Float:now = get_gametime();
if (now - g_lastKillTime[killer] <= COMBO_TIMEOUT) g_combo[killer]++;
else { g_combo[killer]=1; g_comboHS[killer]=0; }
g_lastKillTime[killer]=now;
if (hs==1) g_comboHS[killer]++;
handle_combo_threshold(killer, g_combo[killer]);
show_alive_hint();
g_deathStreak[killer]=0;
if (g_combo[killer] > g_bestCombo[killer]) g_bestCombo[killer]=g_combo[killer];
}
if (is_user_connected(victim))
{
// Halalkori listak
new rr,gg,bb; rand_bright(rr,gg,bb);
center_to(victim, rr,gg,bb, 1.6, "Sebzett :");
new idx[32], cnt=0;
for (new a=1; a<MAXP; a++)
{
if (!is_user_connected(a) || a==victim) continue;
if (g_dmgFrom[a][victim] > 0.0) idx[cnt++]=a;
}
sort_by_dmg(idx, cnt, true, victim);
new lines = (cnt>5)?5:cnt;
for (new i=0; i<lines; i++)
{
new a = idx[i];
new nm[32]; get_user_name(a, nm, charsmax(nm));
new dmg = floatround(g_dmgFrom[a][victim], floatround_floor);
new hits = g_hitsFrom[a][victim];
new w[24]; copy(w, charsmax(w), g_lastWeap[a][victim]);
center_to(victim, rr,gg,bb, 1.3, "%s - %d talalat / %d dmg / %s", nm, hits, dmg, (w[0]?w:"unknown"));
}
center_to(victim, rr,gg,bb, 1.6, "Aldozatok :");
new jdx[32], jcnt=0;
for (new t=1; t<MAXP; t++)
{
if (!is_user_connected(t) || t==victim) continue;
if (g_dmgFrom[victim][t] > 0.0) jdx[jcnt++]=t;
}
sort_by_dmg(jdx, jcnt, true, -victim);
new lines2 = (jcnt>5)?5:jcnt;
for (new j=0; j<lines2; j++)
{
new t = jdx[j];
new nm2[32]; get_user_name(t, nm2, charsmax(nm2));
new dmg2 = floatround(g_dmgFrom[victim][t], floatround_floor);
new hits2 = g_hitsFrom[victim][t];
new w2[24]; copy(w2, charsmax(w2), g_lastWeap[victim][t]);
center_to(victim, rr,gg,bb, 1.3, "%s - %d talalat / %d dmg / %s", nm2, hits2, dmg2, (w2[0]?w2:"unknown"));
}
reset_perlife(victim);
}
check_clutch_state();
}
// -------------------- Bomb esemenyek --------------------
stock get_log_actor(name[], len, &userid)
{
new loguser[96];
read_logargv(0, loguser, charsmax(loguser));
parse_loguser(loguser, name, len, userid);
}
// LERAKÁS – VAN hang + piros villogo HUD + 10→1 visszaszamlalo hangok
public log_bomb_planted()
{
g_bombPlanted = true;
new name[64], userid;
get_log_actor(name, charsmax(name), userid);
spk_all(SND_B_PLANTED);
flash_center("%s jatekos elesitette a bombat", name);
new c4 = get_cvar_num("mp_c4timer"); if (c4<=0) c4=35;
for (new i=0;i<10;i++)
{
new delay = c4 - (10 - i);
if (delay < 0) delay = 0;
set_task(float(delay), "task_countdown", 500+i);
g_bombTasks[i] = 500+i;
}
}
public task_countdown(tid)
{
if (!g_bombPlanted) return;
new idx = tid - 500; if (idx<0 || idx>9) return;
spk_all(SND_CNT[idx]);
}
// DEFUSE – VAN hang + piros villogo HUD
public log_bomb_defused()
{
new name[64], userid;
get_log_actor(name, charsmax(name), userid);
spk_all(SND_B_DEFUSED);
flash_center("%s jatekos hatastalanitotta a bombat", name);
g_bombPlanted=false;
cancel_c4_tasks();
}
// ELEJTÉS – NINCS hang, feher kozep HUD
public log_bomb_dropped()
{
new name[64], userid;
get_log_actor(name, charsmax(name), userid);
set_hudmessage(255,255,255, -1.0, HUD_CENTER_Y, 0, 0.0, 1.6, 0.0, 0.0, -1);
show_hudmessage(0, "%s jatekos elejtette a bombat", name);
}
// FELVÉTEL – NINCS hang, piros villogo HUD
public log_bomb_got()
{
new name[64], userid;
get_log_actor(name, charsmax(name), userid);
flash_center("%s jatekos felvette a bombat", name);
}
// ROBBANÁS – CSAK hang (HUD nelkul)
public log_bomb_exploded()
{
spk_all(SND_B_EXPLODED);
g_bombPlanted = false;
cancel_c4_tasks();
}
stock cancel_c4_tasks()
{
for (new i=0;i<10;i++)
{
if (g_bombTasks[i] > 0) remove_task(g_bombTasks[i]);
g_bombTasks[i]=0;
}
}
// -------------------- Round end (ctwin/terwin) – AMXX 1.8.1 kompat (nincs goto) --------------------
public ev_ctwin(){ round_end_summary(3); }
public ev_terwin(){ round_end_summary(2); }
round_end_summary(winner) // 2=T, 3=CT
{
for (new i=1;i<MAXP;i++)
if (is_user_connected(i)) g_lastRoundBestCombo[i]=g_bestCombo[i];
new bestScorePl=0, bestScore=-99999;
new bestDmgPl=0, shots=0, hits=0, hs=0; new Float:bestDmg=-1.0;
for (new i=1;i<MAXP;i++)
{
if (!is_user_connected(i)) continue;
new score = get_user_frags(i);
if (score > bestScore){ bestScore=score; bestScorePl=i; }
if (g_dmg[i] > bestDmg)
{
bestDmg = g_dmg[i];
shots = g_shots[i];
hits = g_hits[i];
hs = g_hs[i];
bestDmgPl = i;
}
}
if (bestScorePl>0)
{
new n1[32]; get_user_name(bestScorePl, n1, charsmax(n1));
new r,g,b; rand_rgb(r,g,b);
center_all(r,g,b, 0.0, "Legjobb pont : %s", n1);
rand_rgb(r,g,b);
center_all(r,g,b, 0.0, "Pont : %d", bestScore);
}
if (bestDmgPl>0)
{
new n2[32]; get_user_name(bestDmgPl, n2, charsmax(n2));
new r2,g2,b2; rand_rgb(r2,g2,b2);
center_all(r2,g2,b2, 0.0, "Legjobb sebzes : %s", n2);
new Float:pct = (shots>0) ? (float(hits)/float(shots)*100.0) : 0.0;
rand_rgb(r2,g2,b2);
center_all(r2,g2,b2, 0.0, "Sebzes : %d Talalatok : %d / %d (%.0f%%%%)", floatround(bestDmg), hits, shots, pct);
rand_rgb(r2,g2,b2);
center_all(r2,g2,b2, 0.0, "Headshotok : %d", hs);
}
if (winner==2 || winner==3)
{
new kills, ths, tshots, thits; new Float:tpct;
new teamName[4];
if (winner==3) { // CT
kills=g_tKills[3]; ths=g_tHS[3]; tshots=g_tShots[3]; thits=g_tHits[3];
tpct = (tshots>0) ? (float(thits)/float(tshots)*100.0) : 0.0;
copy(teamName, charsmax(teamName), "CT");
} else { // T
kills=g_tKills[2]; ths=g_tHS[2]; tshots=g_tShots[2]; thits=g_tHits[2];
tpct = (tshots>0) ? (float(thits)/float(tshots)*100.0) : 0.0;
copy(teamName, charsmax(teamName), "T");
}
new r3,g3,b3; rand_rgb(r3,g3,b3);
center_all(r3,g3,b3, 0.0, "TOTAL");
rand_rgb(r3,g3,b3);
center_all(r3,g3,b3, 0.0, "%s osszesen: %d oles (%d headshot)", teamName, kills, ths);
rand_rgb(r3,g3,b3);
center_all(r3,g3,b3, 0.0, "Talalatok : %d / %d (%.0f%%%%)", thits, tshots, tpct);
}
for (new i2=1;i2<MAXP;i2++)
{
reset_roundstats_client(i2);
reset_perlife(i2);
g_prevWpn[i2]=0; g_prevClip[i2]=-1;
}
reset_totals_round();
}
// -------------------- Kill-lepcsok HUD + hang --------------------
handle_combo_threshold(id, kills)
{
new idx = -1;
if (kills>=17) idx=7;
else if (kills>=15) idx=6;
else if (kills>=13) idx=5;
else if (kills>=11) idx=4;
else if (kills>=9) idx=3;
else if (kills>=7) idx=2;
else if (kills>=5) idx=1;
else if (kills>=3) idx=0;
if (idx==-1) return;
spk_all(SND_KSTEP[idx]);
if (kills>=5)
{
new r,g,b; rand_bright(r,g,b);
bottomleft_all(r,g,b, 2.0, "%s",
(idx==0)?"multi kill":
(idx==1)?"ultra kill":
(idx==2)?"monster kill":
(idx==3)?"unstoppable":
(idx==4)?"ludicrous kill":
(idx==5)?"combo whore":
(idx==6)?"holy shit":"godlike");
}
set_task(COMBO_TIMEOUT+0.2, "task_combo_end", id);
}
public task_combo_end(id)
{
if (!is_user_connected(id)) return;
if (get_gametime() - g_lastKillTime[id] <= COMBO_TIMEOUT) return;
if (g_combo[id] >= 2)
{
new r,g,b; rand_bright(r,g,b);
bottomleft_all(r,g,b, 2.2, "%d kill kombo, %d headshot", g_combo[id], g_comboHS[id]);
}
g_combo[id]=0; g_comboHS[id]=0;
}
// -------------------- Elo jatekosok kiirasa --------------------
show_alive_hint()
{
new t=0, ct=0;
for (new i=1;i<MAXP;i++)
{
if (!is_user_connected(i) || !is_user_alive(i)) continue;
new tm = get_user_team(i);
if (tm==1) t++;
else if (tm==2) ct++;
}
set_hudmessage(255,255,255, HUD_BL_X, HUD_BL_Y, 0, 0.0, 2.0, 0.0, 0.0, -1);
show_hudmessage(0, "%d Terrorista maradt hatra^n%d CT maradt hatra", t, ct);
}
// -------------------- AIM-HUD --------------------
public task_aimhud()
{
for (new id=1; id<MAXP; id++)
{
if (!is_user_connected(id) || !is_user_alive(id)) continue;
new target, body;
get_user_aiming(id, target, body, 9999);
if (target<=0 || target>=MAXP) continue;
if (!is_user_connected(target) || !is_user_alive(target)) continue;
g_tBlink[id] = 1 - g_tBlink[id];
if (g_tBlink[id]) rand_bright(g_tR[id], g_tG[id], g_tB[id]);
new nm[32]; get_user_name(target, nm, charsmax(nm));
new myT = get_user_team(id);
new tgT = get_user_team(target);
if (myT == tgT && myT >= 1)
{
new hp = get_user_health(target);
new ap = get_user_armor(target);
new clip, ammo, wpnid = get_user_weapon(target, clip, ammo);
new wname[24] = "unknown";
if (wpnid>0) get_weaponname(wpnid, wname, charsmax(wname));
trim_weapon_prefix(wname);
set_hudmessage(g_tR[id], g_tG[id], g_tB[id], -1.0, HUD_CROSS_Y, 0, 0.0, 0.18, 0.0, 0.0, -2);
show_hudmessage(id, "%s -- %d HP / %d AP / %s", nm, hp, ap, wname);
}
else if ((tgT==1 || tgT==2) && myT != tgT)
{
set_hudmessage(g_tR[id], g_tG[id], g_tB[id], -1.0, HUD_CROSS_Y, 0, 0.0, 0.18, 0.0, 0.0, -2);
show_hudmessage(id, "%s", nm);
}
}
}
// -------------------- Segedfuggvenyek --------------------
stock spk_all(const sound[]){ client_cmd(0, "spk ^"%s^"", sound); }
stock center_all(r,g,b, Float:hold, const fmt[], any:...)
{
static msg[192];
vformat(msg, charsmax(msg), fmt, 5);
set_hudmessage(r,g,b, -1.0, HUD_CENTER_Y, 0, 0.0, hold>0.0?hold:2.0, 0.0, 0.0, -1);
show_hudmessage(0, "%s", msg);
}
stock center_to(id, r,g,b, Float:hold, const fmt[], any:...)
{
if (!is_user_connected(id)) return;
static msg[192];
vformat(msg, charsmax(msg), fmt, 7);
set_hudmessage(r,g,b, -1.0, HUD_CENTER_Y, 0, 0.0, hold>0.0?hold:1.8, 0.0, 0.0, -1);
show_hudmessage(id, "%s", msg);
}
stock bottomleft_all(r,g,b, Float:hold, const fmt[], any:...)
{
static msg[192];
vformat(msg, charsmax(msg), fmt, 5);
set_hudmessage(r,g,b, HUD_BL_X, HUD_BL_Y, 0, 0.0, hold>0.0?hold:2.0, 0.0, 0.0, -1);
show_hudmessage(0, "%s", msg);
}
stock flash_center(const fmt[], any:...)
{
static msg[128]; vformat(msg, charsmax(msg), fmt, 1);
set_hudmessage(255,0,0, -1.0, HUD_CENTER_Y, 0, 0.0, 0.9, 0.0, 0.0, -1);
show_hudmessage(0, "%s", msg);
set_task(0.22, "flash_again");
}
public flash_again()
{
set_hudmessage(255,0,0, -1.0, HUD_CENTER_Y, 0, 0.0, 0.12, 0.0, 0.0, -1);
show_hudmessage(0, "( ! )");
}
stock rand_rgb(&r,&g,&b){ r=random_num(128,255); g=random_num(128,255); b=random_num(128,255); }
stock rand_bright(&r,&g,&b){ r=random_num(160,255); g=random_num(160,255); b=random_num(160,255); }
stock trim_weapon_prefix(w[])
{
if (w[0] == 0) return;
if (contain(w, "weapon_") == 0)
copy(w, 23, w[7]); // "weapon_xxx" -> "xxx"
}
stock reset_roundstats_client(i)
{
g_kills[i]=0; g_hs[i]=0; g_dmg[i]=0.0; g_shots[i]=0; g_hits[i]=0;
}
stock reset_perlife(i)
{
for (new j=1;j<MAXP;j++)
{
g_dmgFrom[j][i]=0.0; g_hitsFrom[j][i]=0; g_lastWeap[j][i][0]=0;
g_dmgFrom[i][j]=0.0; g_hitsFrom[i][j]=0; g_lastWeap[i][j][0]=0;
}
}
stock reset_totals_round()
{
g_tKills[2]=g_tKills[3]=0;
g_tHS[2]=g_tHS[3]=0;
g_tShots[2]=g_tShots[3]=0;
g_tHits[2]=g_tHits[3]=0;
}
stock reset_totals(){ reset_totals_round(); }
stock sort_by_dmg(arr[], cnt, bool:desc, pivot)
{
for (new i=0;i<cnt-1;i++)
{
new best=i;
for (new j=i+1;j<cnt;j++)
{
new a = arr[j], b = arr[best];
new Float:da = (pivot>0) ? g_dmgFrom[a][pivot] : g_dmgFrom[-pivot][a];
new Float:db = (pivot>0) ? g_dmgFrom[b][pivot] : g_dmgFrom[-pivot][b];
if (desc ? (da>db) : (da<db)) best=j;
}
if (best!=i){ new t=arr[i]; arr[i]=arr[best]; arr[best]=t; }
}
}
// -------------------- Clutch / Duel --------------------
check_clutch_state()
{
new tAlive=0, ctAlive=0, loneT=0, loneCT=0;
for (new i=1;i<MAXP;i++)
{
if (!is_user_connected(i) || !is_user_alive(i)) continue;
new tm = get_user_team(i);
if (tm==1){ tAlive++; loneT=i; }
else if (tm==2){ ctAlive++; loneCT=i; }
}
// 1v1
if (tAlive==1 && ctAlive==1)
{
if (!g_ann1v1)
{
new tn[32], cn[32];
get_user_name(loneT, tn, charsmax(tn));
get_user_name(loneCT, cn, charsmax(cn));
new thp=get_user_health(loneT), chp=get_user_health(loneCT);
new r,g,b; rand_bright(r,g,b);
center_all(r,g,b, 2.6, "%s (%d hp) VS %s (%d hp)", cn, chp, tn, thp);
spk_all(SND_DUEL1V1);
g_ann1v1 = true;
g_ann1vX = true;
}
return;
}
// 1vX
if (!g_ann1vX)
{
if (ctAlive==1 && tAlive>=2)
{
new nm[32]; get_user_name(loneCT, nm, charsmax(nm));
new hp = get_user_health(loneCT);
new r,g,b; rand_bright(r,g,b);
center_all(r,g,b, 2.6, "%s (%d hp) vs %d Terrorista. A csapatod elveszett...", nm, hp, tAlive);
spk_all(SND_CLUTCH);
g_ann1vX=true; return;
}
if (tAlive==1 && ctAlive>=2)
{
new nm2[32]; get_user_name(loneT, nm2, charsmax(nm2));
new hp2 = get_user_health(loneT);
new r2,g2,b2; rand_bright(r2,g2,b2);
center_all(r2,g2,b2, 2.6, "%s (%d hp) vs %d CT. A csapatod elveszett...", nm2, hp2, ctAlive);
spk_all(SND_CLUTCH);
g_ann1vX=true; return;
}
}
}