#include <amxmodx>
#include <reapi>
#include <fakemeta>
#include <HamSandwich>
#include <nvault_array>
#pragma semicolon 1
enum _:PCVAR
{
KF,
KD,
DMG,
COUNT,
FADE,
OHS,
SAVE,
AMMO
}
enum _:ePlayersData
{
AuthId[MAX_AUTHID_LENGTH],
AmmoSet,
KillFeedStatus,
KillDeadStatus,
DamagerStatus,
DamagerStyle,
DamagerInDamage,
CountStatus,
FadeStatus,
FadeColor,
FadeAlpha,
OnlyHsStatus
}
enum _:ePlayersCount
{
Float: Kills,
Float: Deaths,
Float: HeadShots,
Counts
}
new g_pCvar[PCVAR], g_PlayersData[MAX_PLAYERS + 1][ePlayersData], g_PlayersCount[MAX_PLAYERS + 1][ePlayersCount], taskid = 30112021;
enum FRGB {R, G, B}
new const FadeColors[][FRGB] =
{
{0,0,0},
{255,0,0},
{0,255,0},
{0,127,255},
{255,255,255},
{255,127,0},
{127,0,255},
{255,100,150}
};
new const FadeAlphas[] = {10, 20, 30, 40, 50, 60, 70, 80, 90};
new const VAULT_FILE[] = "gm_csdmm_data";
new countSyncHudCreate, kdSyncHudCreate, damageSyncHudCreate, g_hVault = INVALID_HANDLE;
new const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_0;
new const g_szWpns[24][] =
{
"weapon_p228",
"weapon_scout",
"weapon_xm1014",
"weapon_mac10",
"weapon_aug",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_awp",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_m4a1",
"weapon_tmp",
"weapon_g3sg1",
"weapon_deagle",
"weapon_sg552",
"weapon_ak47",
"weapon_p90"
};
public plugin_init()
{
register_plugin("[GM] CSDM Menu", "1.2.0", "[GM] NWC");
register_dictionary("gm_csdm_menu.txt");
register_clcmd("say /menu","CSDMM_Menu");
register_clcmd("say_team /menu","CSDMM_Menu");
register_menucmd(register_menuid("CSDMM_Menu"), MENU_KEYS, "CSDMM_Menu_Handler");
register_menucmd(register_menuid("Damager_Menu"), MENU_KEYS, "Damager_Menu_Handler");
register_menucmd(register_menuid("Fade_Menu"), MENU_KEYS, "Fade_Menu_Handler");
bind_pcvar_num(create_cvar("csdmm_killfeed", "1", FCVAR_NONE, "Adds the killfeed configuration feature", true, 0.0, true, 1.0), g_pCvar[KF]);
bind_pcvar_num(create_cvar("csdmm_killdead", "1", FCVAR_NONE, "Adds the killdead output function", true, 0.0, true, 1.0), g_pCvar[KD]);
bind_pcvar_num(create_cvar("csdmm_damager", "1", FCVAR_NONE, "Adds a setting damager", true, 0.0, true, 1.0), g_pCvar[DMG]);
bind_pcvar_num(create_cvar("csdmm_count", "1", FCVAR_NONE, "Adds the output of the number of kills", true, 0.0, true, 1.0), g_pCvar[COUNT]);
bind_pcvar_num(create_cvar("csdmm_fade", "1", FCVAR_NONE, "Adds a setting screen fade", true ,0.0, true, 1.0), g_pCvar[FADE]);
bind_pcvar_num(create_cvar("csdmm_onlyhs", "1", FCVAR_NONE, "Adds a kill setup feature to the head", true, 0.0, true, 1.0), g_pCvar[OHS]);
bind_pcvar_num(create_cvar("csdmm_ammo", "1", FCVAR_NONE, "Add the ability to select the number of cartridges in the clip", true, 0.0, true, 1.0), g_pCvar[AMMO]);
bind_pcvar_num(create_cvar("csdmm_save", "7", FCVAR_NONE, "Saving player settings in days", true, 1.0), g_pCvar[SAVE]);
register_message(get_user_msgid("DeathMsg"), "@Message_DeathMsg");
RegisterHookChain(RG_CSGameRules_PlayerKilled, "@RG_CSGameRules_PlayerKilled_Post", true);
RegisterHookChain(RG_CBasePlayer_TakeDamage, "@RG_CBasePlayer_TakeDamage_Post", true);
RegisterHookChain(RG_CBasePlayer_TraceAttack , "@RG_CBasePlayer_TraceAttack_Pre", false);
for(new i; i < sizeof(g_szWpns); i++)
{
RegisterHam(Ham_Item_Deploy, g_szWpns[i], "@CAmmo_Item_Deploy_Post", true);
RegisterHam(Ham_Weapon_Reload, g_szWpns[i], "@CAmmo_Weapon_Reload_Pre", false);
}
countSyncHudCreate = CreateHudSyncObj();
kdSyncHudCreate = CreateHudSyncObj();
damageSyncHudCreate = CreateHudSyncObj();
AutoExecConfig(true, "csdm_menu", "gm_plugins");
}
public plugin_cfg()
{
if((g_hVault = nvault_open(VAULT_FILE)) == INVALID_HANDLE)
{
set_fail_state("[GM CSDMM] ERROR: Opening nVault failed!");
}
else
{
nvault_prune(g_hVault, 0, get_systime() - (86400 * g_pCvar[SAVE]));
}
}
public client_putinserver(iPlayer)
{
g_PlayersData[iPlayer][AuthId][0] = 0;
if(is_user_bot(iPlayer) || is_user_hltv(iPlayer))
{
return;
}
get_user_authid(iPlayer, g_PlayersData[iPlayer][AuthId], MAX_AUTHID_LENGTH - 1);
if(nvault_get_array(g_hVault, g_PlayersData[iPlayer][AuthId], g_PlayersData[iPlayer], ePlayersData) > 0)
{
if(g_PlayersData[iPlayer][KillDeadStatus])
{
set_task_ex(1.0, "@Player_KillDeadHud", iPlayer + taskid, "", 0, SetTask_Repeat);
}
if(g_PlayersData[iPlayer][CountStatus])
{
set_task_ex(1.0, "@Player_KillCountHud", iPlayer + taskid, "", 0, SetTask_Repeat);
}
}
set_task_ex(8.0, "@Player_InfoMenu", iPlayer + taskid);
}
public client_disconnected(iPlayer)
{
arrayset(g_PlayersCount[iPlayer], 0, sizeof(g_PlayersCount[]));
arrayset(g_PlayersData[iPlayer], 0, sizeof(g_PlayersData[]));
}
public CSDMM_Menu(const iPlayer)
{
new szMenu[512], iLen, key;
iLen = formatex(szMenu[iLen], charsmax(szMenu), "%L^n^n", iPlayer, "CSDMM_MENU_NAME");
if(g_pCvar[KF])
{
key |= MENU_KEY_1;
switch(g_PlayersData[iPlayer][KillFeedStatus])
{
case 0: {iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_KILL_FEED", iPlayer, "CSDMM_OFF");}
case 1: {iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_KILL_FEED", iPlayer, "CSDMM_ON");}
case 2: {iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_KILL_FEED", iPlayer, "CSDMM_OFF_ALL");}
}
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[1] %L %L^n", iPlayer, "CSDMM_KILL_FEED", iPlayer, "CSDMM_OFF_PCVAR");
}
if(g_pCvar[KD])
{
key |= MENU_KEY_2;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r2\y] \w%L %L^n", iPlayer, "CSDMM_KILL_DEAD", iPlayer, (g_PlayersData[iPlayer][KillDeadStatus]) ? "CSDMM_ON" : "CSDMM_OFF");
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[2] %L %L^n", iPlayer, "CSDMM_KILL_DEAD", iPlayer, "CSDMM_OFF_PCVAR");
}
if(g_pCvar[COUNT])
{
key |= MENU_KEY_3;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r3\y] \w%L %L^n", iPlayer, "CSDMM_COUNT", iPlayer, (g_PlayersData[iPlayer][CountStatus]) ? "CSDMM_ON" : "CSDMM_OFF");
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[3] %L %L^n", iPlayer, "CSDMM_COUNT", iPlayer, "CSDMM_OFF_PCVAR");
}
if(g_pCvar[OHS])
{
key |= MENU_KEY_4;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r4\y] \w%L %L^n", iPlayer, "CSDMM_HS", iPlayer, (g_PlayersData[iPlayer][OnlyHsStatus]) ? "CSDMM_ON" : "CSDMM_OFF");
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[4] %L %L^n", iPlayer, "CSDMM_HS", iPlayer, "CSDMM_OFF_PCVAR");
}
if(g_pCvar[AMMO])
{
key |= MENU_KEY_5;
if(g_PlayersData[iPlayer][AmmoSet])
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r5\y] \w%L \y%i^n", iPlayer, "CSDMM_AMMO", g_PlayersData[iPlayer][AmmoSet]);
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r5\y] \w%L %L^n", iPlayer, "CSDMM_AMMO", iPlayer, "CSDMM_OFF");
}
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[5] %L %L^n", iPlayer, "CSDMM_AMMO", iPlayer, "CSDMM_OFF_PCVAR");
}
if(g_pCvar[FADE])
{
key |= MENU_KEY_6;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r6\y] \w[\y%L\w]^n", iPlayer, "CSDMM_FADE");
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[6] [%L]^n", iPlayer, "CSDMM_FADE");
}
if(g_pCvar[DMG])
{
key |= MENU_KEY_7;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r7\y] \w[\y%L\w]^n^n", iPlayer, "CSDMM_DMG");
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[7] [%L]^n^n", iPlayer, "CSDMM_DMG");
}
key |= MENU_KEY_0;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r0\y] %L^n^n\r[\yCSDMM\r]", iPlayer, "CSDMM_EXIT");
show_menu(iPlayer, key, szMenu, -1, "CSDMM_Menu");
return PLUGIN_CONTINUE;
}
public CSDMM_Menu_Handler(const iPlayer, const iKey)
{
if(iKey == 9)
{
SaveUserInfo(iPlayer);
return PLUGIN_HANDLED;
}
switch(iKey)
{
case 0: {(g_PlayersData[iPlayer][KillFeedStatus] != 2) ? (g_PlayersData[iPlayer][KillFeedStatus]++) : (g_PlayersData[iPlayer][KillFeedStatus] = 0);}
case 1: {(g_PlayersData[iPlayer][KillDeadStatus]) ? (g_PlayersData[iPlayer][KillDeadStatus] = 0) : (g_PlayersData[iPlayer][KillDeadStatus]= 1, set_task_ex(1.0, "@Player_KillDeadHud", iPlayer + taskid, "", 0, SetTask_Repeat));}
case 2: {(g_PlayersData[iPlayer][CountStatus]) ? (g_PlayersData[iPlayer][CountStatus] = 0) : (g_PlayersData[iPlayer][CountStatus] = 1, set_task_ex(1.0, "@Player_KillCountHud", iPlayer + taskid, "", 0, SetTask_Repeat));}
case 3: {(g_PlayersData[iPlayer][OnlyHsStatus]) ? (g_PlayersData[iPlayer][OnlyHsStatus] = 0) : (g_PlayersData[iPlayer][OnlyHsStatus] = 1);}
case 4: {(g_PlayersData[iPlayer][AmmoSet] != 3) ? (g_PlayersData[iPlayer][AmmoSet]++) : (g_PlayersData[iPlayer][AmmoSet] = 0);}
case 5: {return Fade_Menu(iPlayer);}
case 6: {return Damager_Menu(iPlayer);}
}
return CSDMM_Menu(iPlayer);
}
public Damager_Menu(const iPlayer)
{
new szMenu[512], iLen, key;
iLen = formatex(szMenu[iLen], charsmax(szMenu), "%L^n^n", iPlayer, "CSDMM_DMENU_NAME");
if(!g_PlayersData[iPlayer][DamagerStatus])
{
key |= MENU_KEY_1;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_STATUS", iPlayer, "CSDMM_OFF");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[1] %L %L^n", iPlayer, "CSDMM_DAMAGER_STYLE", iPlayer, (g_PlayersData[iPlayer][DamagerStyle]) ? "CSDMM_STYLE_NUMBERS" : "CSDMM_STYLE_STAR");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[2] %L %L^n^n", iPlayer, "CSDMM_DAMAGER_INDAMAGE", iPlayer, (g_PlayersData[iPlayer][DamagerInDamage]) ? "CSDMM_ON" : "CSDMM_OFF");
}
else
{
key |= MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_STATUS", iPlayer, "CSDMM_ON");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r2\y] \w%L \y%L^n", iPlayer, "CSDMM_DAMAGER_STYLE", iPlayer, (g_PlayersData[iPlayer][DamagerStyle]) ? "CSDMM_STYLE_NUMBERS" : "CSDMM_STYLE_STAR");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r3\y] \w%L \y%L^n^n", iPlayer, "CSDMM_DAMAGER_INDAMAGE", iPlayer, (g_PlayersData[iPlayer][DamagerInDamage]) ? "CSDMM_ON" : "CSDMM_OFF");
}
key |= MENU_KEY_0;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r0\y] %L^n^n\r[\yCSDMM\r]", iPlayer, "CSDMM_BACK");
show_menu(iPlayer, key, szMenu, -1, "Damager_Menu");
return PLUGIN_CONTINUE;
}
public Damager_Menu_Handler(const iPlayer, const iKey)
{
if(iKey == 9)
{
SaveUserInfo(iPlayer);
CSDMM_Menu(iPlayer);
return PLUGIN_HANDLED;
}
switch(iKey)
{
case 0: {(g_PlayersData[iPlayer][DamagerStatus]) ? (g_PlayersData[iPlayer][DamagerStatus] = 0) : (g_PlayersData[iPlayer][DamagerStatus] = 1);}
case 1: {(g_PlayersData[iPlayer][DamagerStyle]) ? (g_PlayersData[iPlayer][DamagerStyle] = 0) : (g_PlayersData[iPlayer][DamagerStyle] = 1);}
case 2: {(g_PlayersData[iPlayer][DamagerInDamage]) ? (g_PlayersData[iPlayer][DamagerInDamage] = 0) : (g_PlayersData[iPlayer][DamagerInDamage] = 1);}
}
return Damager_Menu(iPlayer);
}
public Fade_Menu(const iPlayer)
{
new szMenu[512], iLen, key;
iLen = formatex(szMenu[iLen], charsmax(szMenu), "%L^n^n", iPlayer, "CSDMM_FMENU_NAME");
static const FadeColorLang[sizeof(FadeColors)][] = {"CSDMM_FADE_RANDOM", "CSDMM_FADE_RED", "CSDMM_FADE_GREEN", "CSDMM_FADE_BLUE", "CSDMM_FADE_WHITE", "CSDMM_FADE_ORANGE", "CSDMM_FADE_PURPLE", "CSDMM_FADE_PINK"};
if(!g_PlayersData[iPlayer][FadeStatus])
{
key |= MENU_KEY_1;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_STATUS", iPlayer, "CSDMM_OFF");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[2] %L %L^n", iPlayer, "CSDMM_FADE_COLOR", iPlayer, FadeColorLang[g_PlayersData[iPlayer][FadeColor]]);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[3] %L %i^n^n", iPlayer, "CSDMM_FADE_ALPHA", FadeAlphas[g_PlayersData[iPlayer][FadeAlpha]]);
}
else
{
key |= MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r1\y] \w%L %L^n", iPlayer, "CSDMM_STATUS", iPlayer, "CSDMM_ON");
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r2\y] \w%L \y%L^n", iPlayer, "CSDMM_FADE_COLOR", iPlayer, FadeColorLang[g_PlayersData[iPlayer][FadeColor]]);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r3\y] \w%L \y%i^n^n", iPlayer, "CSDMM_FADE_ALPHA", FadeAlphas[g_PlayersData[iPlayer][FadeAlpha]]);
}
key |= MENU_KEY_0;
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y[\r0\y] %L^n^n\r[\yCSDMM\r]", iPlayer, "CSDMM_BACK");
show_menu(iPlayer, key, szMenu, -1, "Fade_Menu");
return PLUGIN_CONTINUE;
}
public Fade_Menu_Handler(const iPlayer, const iKey)
{
if(iKey == 9)
{
SaveUserInfo(iPlayer);
CSDMM_Menu(iPlayer);
return PLUGIN_HANDLED;
}
new iCol = g_PlayersData[iPlayer][FadeColor];
new iAlpha = g_PlayersData[iPlayer][FadeAlpha];
switch(iKey)
{
case 0: {(g_PlayersData[iPlayer][FadeStatus]) ? (g_PlayersData[iPlayer][FadeStatus] = 0) : (g_PlayersData[iPlayer][FadeStatus] = 1);}
case 1:
{
(iCol != charsmax(FadeColors)) ? (g_PlayersData[iPlayer][FadeColor]++) : (g_PlayersData[iPlayer][FadeColor] = 0);
UTIL_ScreenFade(iPlayer, (g_PlayersData[iPlayer][FadeColor]) ? (FadeColors[g_PlayersData[iPlayer][FadeColor]]) : (FadeColors[random_num(1, charsmax(FadeColors))]), FadeAlphas[g_PlayersData[iPlayer][FadeAlpha]]);
}
case 2:
{
(iAlpha != charsmax(FadeAlphas)) ? (g_PlayersData[iPlayer][FadeAlpha]++) : (g_PlayersData[iPlayer][FadeAlpha] = 0);
UTIL_ScreenFade(iPlayer, (iCol) ? (FadeColors[iCol]) : (FadeColors[random_num(1, charsmax(FadeColors))]), FadeAlphas[g_PlayersData[iPlayer][FadeAlpha]]);
}
}
return Fade_Menu(iPlayer);
}
@Player_KillDeadHud(tid)
{
new iPlayer = tid - taskid;
if(!g_pCvar[KD] || !g_PlayersData[iPlayer][KillDeadStatus] || !is_user_connected(iPlayer))
{
remove_task(tid);
}
new Float: fKD, Float: fHS;
(g_PlayersCount[iPlayer][Kills]/g_PlayersCount[iPlayer][Deaths] < 0) ? (fKD = 0.0) : (fKD = g_PlayersCount[iPlayer][Kills]/g_PlayersCount[iPlayer][Deaths]);
(g_PlayersCount[iPlayer][HeadShots]) ? (fHS = g_PlayersCount[iPlayer][HeadShots]/g_PlayersCount[iPlayer][Kills]) : (fHS = 0.0);
set_hudmessage(255, 255, 255, 0.01, 0.32, 0, 0.0, 2.0, 0.1, 0.2, -1);
ShowSyncHudMsg(iPlayer ,kdSyncHudCreate, "(%L %.2f | %L %.2f)", -1, "CSDMM_KILL_DEAD", fKD, -1, "CSDMM_HS_HUD", fHS);
}
@Player_KillCountHud(tid)
{
new iPlayer = tid - taskid;
if(!g_pCvar[COUNT] || !g_PlayersData[iPlayer][CountStatus] || !is_user_connected(iPlayer))
{
remove_task(tid);
}
set_hudmessage(255, 255, 255, 0.01, 0.3, 0, 0.0, 2.0, 0.1, 0.2, -1);
ShowSyncHudMsg(iPlayer, countSyncHudCreate, "%L %i", -1, "CSDMM_COUNT_HUD", g_PlayersCount[iPlayer][Counts]);
}
@Message_DeathMsg(msgid, dest, receiver)
{
enum {arg_killer = 1, arg_victim, arg_headshot, arg_weapon_name};
new iKiller = get_msg_arg_int(arg_killer);
new iVictim = get_msg_arg_int(arg_victim);
new iHeadshot = get_msg_arg_int(arg_headshot);
new weapon_name[64];
get_msg_arg_string(arg_weapon_name, weapon_name, charsmax(weapon_name));
if(g_PlayersData[iKiller][CountStatus])
{
g_PlayersCount[iKiller][Counts]++;
}
if(g_PlayersData[iVictim][CountStatus])
{
g_PlayersCount[iVictim][Counts] = 0;
}
if(iKiller != iVictim)
{
g_PlayersCount[iKiller][Kills]++;
g_PlayersCount[iVictim][Deaths]++;
if(iHeadshot)
{
g_PlayersCount[iKiller][HeadShots]++;
}
}
if(!g_pCvar[KF])
{
return PLUGIN_CONTINUE;
}
if(g_PlayersData[iKiller][KillFeedStatus] == 1)
{
send_deathmsg(msgid, MSG_ONE, iKiller, iKiller, iVictim, iHeadshot, weapon_name);
}
if(iVictim != iKiller && g_PlayersData[iVictim][KillFeedStatus] == 1)
{
send_deathmsg(msgid, MSG_ONE, iVictim, iKiller, iVictim, iHeadshot, weapon_name);
}
for(new iPlayer = 1; iPlayer <= MaxClients; iPlayer++)
{
if(is_user_connected(iPlayer) && !is_user_hltv(iPlayer) && !is_user_bot(iPlayer))
{
if(g_PlayersData[iPlayer][KillFeedStatus] == 0)
{
send_deathmsg(msgid, MSG_ONE, iPlayer, iKiller, iVictim, iHeadshot, weapon_name);
}
}
}
return PLUGIN_HANDLED;
}
@RG_CBasePlayer_TraceAttack_Pre(const iVictim, const iAttacker, Float: flDamage, Float: vecDir[3], iTrace, iBitsDamage)
{
if(!g_pCvar[OHS] || !is_user_connected(iAttacker) || !(iBitsDamage & DMG_BULLET) || g_PlayersData[iAttacker][OnlyHsStatus] == 0)
{
return HC_CONTINUE;
}
if(get_tr2(iTrace, TR_iHitgroup) != HIT_HEAD && get_user_weapon(iAttacker) != CSW_KNIFE)
{
SetHookChainReturn(ATYPE_INTEGER, false);
return HC_SUPERCEDE;
}
return HC_CONTINUE;
}
@RG_CBasePlayer_TakeDamage_Post(const iVictim, const iInflictor, const iAttacker, Float:flDamage, iBitsDamage)
{
if(!g_pCvar[DMG] || !is_user_connected(iAttacker) || flDamage <= 0.0 || !rg_is_player_can_takedamage(iVictim, iAttacker) || iVictim == iAttacker)
{
return HC_CONTINUE;
}
if(g_PlayersData[iAttacker][OnlyHsStatus] && g_pCvar[OHS] && !(get_member(iVictim, m_LastHitGroup) == HITGROUP_HEAD) && get_user_weapon(iAttacker) != CSW_KNIFE)
{
return HC_CONTINUE;
}
if(iBitsDamage & DMG_BLAST)
{
return HC_CONTINUE;
}
if(g_PlayersData[iAttacker][DamagerStatus])
{
set_hudmessage(0, 100, 200, random_float(0.45, 0.55), random_float(0.45, 0.55), 0, 0.1, 2.5, 0.02, 0.02);
ShowSyncHudMsg(iAttacker, damageSyncHudCreate, (g_PlayersData[iAttacker][DamagerStyle]) ? "%.0f" : "*", flDamage);
}
if(is_user_connected(iVictim) && g_PlayersData[iVictim][DamagerStatus] && g_PlayersData[iVictim][DamagerInDamage])
{
set_hudmessage(255, 36, 0, random_float(0.45, 0.55), random_float(0.45, 0.55), 0, 0.1, 2.5, 0.02, 0.02);
ShowSyncHudMsg(iVictim, damageSyncHudCreate, (g_PlayersData[iVictim][DamagerStyle]) ? "%.0f" : "*", flDamage);
}
return HC_CONTINUE;
}
@RG_CSGameRules_PlayerKilled_Post(const iVictim, const iKiller, const iInflictor)
{
if(iVictim == iKiller || iKiller != iInflictor || !is_user_alive(iKiller) || !g_pCvar[FADE] || !g_PlayersData[iKiller][FadeStatus])
{
return HC_CONTINUE;
}
if(g_pCvar[AMMO] && g_PlayersData[iKiller][AmmoSet])
{
rg_instant_reload_weapons(iKiller);
}
new iCol = g_PlayersData[iKiller][FadeColor];
UTIL_ScreenFade(iKiller, (iCol) ? FadeColors[iCol] : (FadeColors[random_num(1,charsmax(FadeColors))]), FadeAlphas[g_PlayersData[iKiller][FadeAlpha]]);
return HC_CONTINUE;
}
@Player_InfoMenu(iPlayer)
{
remove_task(iPlayer);
iPlayer -= taskid;
set_dhudmessage(0, 255, 0, 0.35, 0.8, 0, 6.0, 12.0);
show_dhudmessage(iPlayer, "%L", iPlayer, "CSDMM_INFO_DHUD");
client_print_color(iPlayer, print_team_blue, "%L %L", -1, "CSDMM_PREFIX", -1, "CSDMM_INFO_CHAT");
}
@CAmmo_Weapon_Reload_Pre(const iEntity)
{
if(!g_pCvar[AMMO])
{
return HAM_IGNORED;
}
new iPlayer = get_member(iEntity, m_pPlayer);
if(!is_user_connected(iPlayer) || !is_user_alive(iPlayer) || !g_PlayersData[iPlayer][AmmoSet])
{
return HAM_IGNORED;
}
if(get_member(iEntity, m_Weapon_iClip) < g_PlayersData[iPlayer][AmmoSet])
{
return HAM_IGNORED;
}
SendWeaponAnimation(iPlayer);
return HAM_SUPERCEDE;
}
@CAmmo_Item_Deploy_Post(const iEntity)
{
new iPlayer = get_member(iEntity, m_pPlayer);
if(!is_user_connected(iPlayer) || !is_user_alive(iPlayer))
{
return HAM_IGNORED;
}
new item = get_member(iPlayer, m_pActiveItem);
new WeaponIdType: WeaponID = get_member(item, m_iId);
if((!g_PlayersData[iPlayer][AmmoSet] || !g_pCvar[AMMO]) && !is_def_max_clip(iEntity, WeaponID))
{
rg_set_iteminfo(iEntity, ItemInfo_iMaxClip, rg_get_weapon_info(WeaponID, WI_GUN_CLIP_SIZE));
rg_set_iteminfo(iEntity, ItemInfo_iMaxAmmo1, rg_get_weapon_info(WeaponID, WI_MAX_ROUNDS));
rg_instant_reload_weapons(iPlayer);
return HAM_IGNORED;
}
if(is_def_max_clip(iEntity, WeaponID) && !g_PlayersData[iPlayer][AmmoSet])
{
return HAM_IGNORED;
}
if(rg_get_iteminfo(iEntity, ItemInfo_iMaxClip) != g_PlayersData[iPlayer][AmmoSet])
{
rg_set_iteminfo(iEntity, ItemInfo_iMaxClip, g_PlayersData[iPlayer][AmmoSet]);
rg_set_iteminfo(iEntity, ItemInfo_iMaxAmmo1, g_PlayersData[iPlayer][AmmoSet]);
rg_set_user_bpammo(iPlayer, WeaponID, g_PlayersData[iPlayer][AmmoSet]);
rg_set_user_ammo(iPlayer, WeaponID, g_PlayersData[iPlayer][AmmoSet]);
}
return HAM_SUPERCEDE;
}
public plugin_end()
{
if(g_hVault != INVALID_HANDLE)
{
nvault_close(g_hVault);
}
}
stock SendWeaponAnimation(const iPlayer)
{
set_entvar(iPlayer, var_weaponanim, 0);
message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iPlayer);
write_byte(0);
write_byte(0);
message_end();
}
stock is_def_max_clip(const iEntity, const WeaponIdType: WeaponID)
{
if(rg_get_iteminfo(iEntity, ItemInfo_iMaxClip) == rg_get_weapon_info(WeaponID, WI_GUN_CLIP_SIZE)) return true;
return false;
}
stock send_deathmsg(msgid, dest, receiver, killer, victim, headshot, weapon_name[])
{
message_begin(dest, msgid, _, receiver);
write_byte(killer);
write_byte(victim);
write_byte(headshot);
write_string(weapon_name);
message_end();
}
stock SaveUserInfo(const iPlayer)
{
if(!is_user_bot(iPlayer) && !is_user_hltv(iPlayer))
{
nvault_set_array(g_hVault, g_PlayersData[iPlayer][AuthId], g_PlayersData[iPlayer], ePlayersData);
}
}
stock UTIL_ScreenFade(const iPlayer, const iColor[FRGB], const Alpha)
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), .player = iPlayer);
write_short(1<<12);
write_short(1<<12);
write_short(0x0000);
write_byte(iColor[R]);
write_byte(iColor[G]);
write_byte(iColor[B]);
write_byte(Alpha);
message_end();
}
stock set_task_ex(Float:time, const function[], id = 0, const any:parameter[] = "", len = 0, SetTaskFlags:flags = SetTask_Once, repeat = 0)
{
new strFlags[2];
get_flags(_:flags, strFlags, charsmax(strFlags));
set_task(time, function, id, parameter, len, strFlags, repeat);
}