diff --git a/addons/sourcemod/scripting/include/shavit/hud.inc b/addons/sourcemod/scripting/include/shavit/hud.inc index b14889fc..90099e5c 100644 --- a/addons/sourcemod/scripting/include/shavit/hud.inc +++ b/addons/sourcemod/scripting/include/shavit/hud.inc @@ -55,7 +55,7 @@ #define HUD2_PERFS (1 << 11) #define HUD2_TOPLEFT_RANK (1 << 12) #define HUD2_VELOCITYDIFFERENCE (1 << 13) -#define HUD2_USPSILENCER (1 << 14) // spawns usps with a silencer on (only used in CSS) +#define HUD2_USPSILENCER (1 << 14) // spawns usps with a silencer on #define HUD2_GLOCKBURST (1 << 15) // spawns glocks with burst #define HUD_DEFAULT (HUD_MASTER|HUD_CENTER|HUD_ZONEHUD|HUD_OBSERVE|HUD_TOPLEFT|HUD_SYNC|HUD_TIMELEFT|HUD_2DVEL|HUD_SPECTATORS) diff --git a/addons/sourcemod/scripting/include/shavit/weapon-stocks.inc b/addons/sourcemod/scripting/include/shavit/weapon-stocks.inc index 1179995f..938caf85 100644 --- a/addons/sourcemod/scripting/include/shavit/weapon-stocks.inc +++ b/addons/sourcemod/scripting/include/shavit/weapon-stocks.inc @@ -4,6 +4,40 @@ #endif #define _shavit_weapon_stocks_included +stock int GiveSkinnedWeapon(int client, const char[] classname) +{ + int target_team = 0; + int current_team = 0; + + if (StrContains(classname, "usp") != -1) + { + target_team = 3; + } + else if (StrContains(classname, "glock") != -1) + { + target_team = 2; + } + + if (target_team != 0) + { + current_team = GetEntProp(client, Prop_Send, "m_iTeamNum"); + + if (current_team != target_team) + { + SetEntProp(client, Prop_Send, "m_iTeamNum", target_team); + } + } + + int weapon = GivePlayerItem(client, classname); + + if (current_team != target_team) + { + SetEntProp(client, Prop_Send, "m_iTeamNum", current_team); + } + + return weapon; +} + stock void RemoveAllWeapons(int client) { int weapon = -1, max = GetEntPropArraySize(client, Prop_Send, "m_hMyWeapons"); diff --git a/addons/sourcemod/scripting/shavit-hud.sp b/addons/sourcemod/scripting/shavit-hud.sp index b52793e4..5f236acb 100644 --- a/addons/sourcemod/scripting/shavit-hud.sp +++ b/addons/sourcemod/scripting/shavit-hud.sp @@ -28,6 +28,8 @@ #include #include +#include + #undef REQUIRE_PLUGIN #include #include @@ -764,10 +766,7 @@ Action ShowHUDMenu(int client, int item) FormatEx(sInfo, 16, "@%d", HUD2_GLOCKBURST); FormatEx(sHudItem, 64, "%T", "HudGlockBurst", client); menu.AddItem(sInfo, sHudItem); - } - if (gEV_Type == Engine_CSS) - { FormatEx(sInfo, 16, "@%d", HUD2_USPSILENCER); FormatEx(sHudItem, 64, "%T", "HudUSPSilencer", client); menu.AddItem(sInfo, sHudItem); @@ -874,10 +873,24 @@ public int MenuHandler_HUD(Menu menu, MenuAction action, int param1, int param2) return 0; } +bool is_usp(int entity, const char[] classname) +{ + if (gEV_Type == Engine_CSGO) + { + return (61 == GetEntProp(entity, Prop_Send, "m_iItemDefinitionIndex")); + } + else + { + return StrEqual(classname, "weapon_usp"); + } +} + public void OnEntityCreated(int entity, const char[] classname) { - if ((gEV_Type == Engine_CSS && StrEqual(classname, "weapon_usp")) - || (StrEqual(classname, "weapon_glock"))) + if (StrEqual(classname, "weapon_glock") + || StrEqual(classname, "weapon_hkp2000") + || StrContains(classname, "weapon_usp") != -1 + ) { SDKHook(entity, SDKHook_Touch, Hook_GunTouch); } @@ -897,11 +910,17 @@ public Action Hook_GunTouch(int entity, int client) SetEntProp(entity, Prop_Send, "m_bBurstMode", 1); } } - else if (gEV_Type == Engine_CSS && StrEqual(classname, "weapon_usp") && !(gI_HUD2Settings[client] & HUD2_USPSILENCER)) + else if (is_usp(entity, classname)) { - SetEntProp(entity, Prop_Send, "m_bSilencerOn", 1); - SetEntProp(entity, Prop_Send, "m_weaponMode", 1); - SetEntPropFloat(entity, Prop_Send, "m_flDoneSwitchingSilencer", GetGameTime() - 0.1); + if (!(gI_HUD2Settings[client] & HUD2_USPSILENCER) != (gEV_Type == Engine_CSS)) + { + return Plugin_Continue; + } + + int state = (gEV_Type == Engine_CSS) ? 1 : 0; + SetEntProp(entity, Prop_Send, "m_bSilencerOn", state); + SetEntProp(entity, Prop_Send, "m_weaponMode", state); + SetEntPropFloat(entity, Prop_Send, "m_flDoneSwitchingSilencer", GetGameTime()); } } @@ -934,7 +953,7 @@ void GivePlayerDefaultGun(int client) AcceptEntityInput(iWeapon, "Kill"); } - iWeapon = GivePlayerItem(client, sWeapon); + iWeapon = (gEV_Type == Engine_CSGO) ? GiveSkinnedWeapon(client, sWeapon) : GivePlayerItem(client, sWeapon); FakeClientCommand(client, "use %s", sWeapon); } diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index d70f2b89..92b99b23 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -1676,7 +1676,7 @@ public Action Command_Weapon(int client, int args) AcceptEntityInput(iWeapon, "Kill"); } - iWeapon = GivePlayerItem(client, sWeapon); + iWeapon = (gEV_Type == Engine_CSGO) ? GiveSkinnedWeapon(client, sWeapon) : GivePlayerItem(client, sWeapon); FakeClientCommand(client, "use %s", sWeapon); if(iSlot != CS_SLOT_KNIFE) @@ -2209,7 +2209,7 @@ public void Weapon_Fire(Event event, const char[] name, bool dB) char sWeapon[16]; event.GetString("weapon", sWeapon, 16); - if(StrContains(sWeapon, "usp") != -1 || StrContains(sWeapon, "hpk") != -1 || StrContains(sWeapon, "glock") != -1) + if(StrContains(sWeapon, "usp") != -1 || StrContains(sWeapon, "hkp") != -1 || StrContains(sWeapon, "glock") != -1) { int client = GetClientOfUserId(event.GetInt("userid")); SetMaxWeaponAmmo(client, GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon"), gCV_WeaponCommands.IntValue >= 3); diff --git a/addons/sourcemod/scripting/shavit-replay-playback.sp b/addons/sourcemod/scripting/shavit-replay-playback.sp index ecb1260d..0518d9d3 100644 --- a/addons/sourcemod/scripting/shavit-replay-playback.sp +++ b/addons/sourcemod/scripting/shavit-replay-playback.sp @@ -2253,14 +2253,14 @@ void UpdateReplayClient(int client) bool same_thing = false; - // special case for csgo stuff because the usp classname becomes weapon_hpk2000 + // special case for csgo stuff because the usp classname becomes weapon_hkp2000 if (gEV_Type == Engine_CSGO) { - if (StrEqual(sWeapon, "weapon_usp_silencer")) + if (StrEqual(sWeapon, "weapon_usp_silencer") || StrEqual(sWeapon, "weapon_usp")) { same_thing = (61 == GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex")); } - else if (StrEqual(sWeapon, "weapon_hpk2000")) + else if (StrEqual(sWeapon, "weapon_hkp2000")) { same_thing = (32 == GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex")); }