Skip to content

Commit

Permalink
Fixed crash with item_ start weapons
Browse files Browse the repository at this point in the history
Also changed the default CT loadout in csgo to use the usp instead of the P2000
  • Loading branch information
azalty committed Jul 10, 2023
1 parent 4acd02d commit 809f333
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions addons/sourcemod/scripting/hosties/startweapons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void StartWeapons_OnPluginStart()
}
else if (g_Game == Game_CSGO)
{
gH_Cvar_CT_Weapons = AutoExecConfig_CreateConVar("sm_hosties_ct_start", "weapon_knife,weapon_m4a1,weapon_hkp2000", "Comma delimitted list of items to give to CTs at spawn", 0);
Format(gShadow_CT_Weapons, sizeof(gShadow_CT_Weapons), "weapon_knife,weapon_m4a1,weapon_hkp2000");
gH_Cvar_CT_Weapons = AutoExecConfig_CreateConVar("sm_hosties_ct_start", "weapon_knife,weapon_m4a1,weapon_usp_silencer", "Comma delimitted list of items to give to CTs at spawn", 0);
Format(gShadow_CT_Weapons, sizeof(gShadow_CT_Weapons), "weapon_knife,weapon_m4a1,weapon_usp_silencer");
}
UpdateStartWeapons();

Expand Down Expand Up @@ -91,8 +91,12 @@ void StartWeapons_Spawn(Event event, const char[] name, bool dontBroadcast)
{
for (int Tidx = 0; Tidx < g_iSizeOfTList; Tidx++)
{
if (!Client_HasWeapon(client, gs_T_WeaponList[Tidx]))
EMP_GiveWeapon(client, gs_T_WeaponList[Tidx]);
/* Ignore check if starts with "item_", as you can also give items like kevlars+helmet "item_assaultsuit", which are not weapons.
* Not checking will crash the game. */
if (StrContains(gs_T_WeaponList[Tidx], "item_") == 0)
GivePlayerItem(client, sWeapon)
else if (!Client_HasWeapon(client, gs_T_WeaponList[Tidx]))
EMP_GiveWeapon(client, sWeapon); // Gives the weapon with the skin if a player has one (CS:GO)
}
}
case CS_TEAM_CT:
Expand All @@ -103,15 +107,19 @@ void StartWeapons_Spawn(Event event, const char[] name, bool dontBroadcast)

if(g_Game == Game_CSGO && strcmp(gs_CT_WeaponList[CTidx], "weapon_usp", false) == 0)
{
Format(sWeapon, sizeof(sWeapon), "weapon_hkp2000");
Format(sWeapon, sizeof(sWeapon), "weapon_usp_silencer");
}
else
{
Format(sWeapon, sizeof(sWeapon), gs_CT_WeaponList[CTidx]);
}

if (!Client_HasWeapon(client, sWeapon))
EMP_GiveWeapon(client, sWeapon);
/* Ignore check if starts with "item_", as you can also give items like kevlars+helmet "item_assaultsuit", which are not weapons.
* Not checking will crash the game. */
if (StrContains(sWeapon, "item_") == 0)
GivePlayerItem(client, sWeapon)
else if (!Client_HasWeapon(client, sWeapon))
EMP_GiveWeapon(client, sWeapon); // Gives the weapon with the skin if a player has one (CS:GO)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/sm_hosties_e.sp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#pragma semicolon 1

#define PLUGIN_VERSION "5.0.2"
#define PLUGIN_VERSION "5.0.3"
#define PLUGIN_NAME "Hosties+"
#define MAX_DISPLAYNAME_SIZE 64
#define MAX_DATAENTRY_SIZE 5
Expand Down

0 comments on commit 809f333

Please sign in to comment.