Skip to content

Commit

Permalink
Fix Persian Persuader not setting ammo correctly (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Jun 26, 2023
1 parent 0c08527 commit d62f57b
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions scripting/randomizer/loadout.sp
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,26 @@ void Loadout_ApplyClientWeapons(int iClient)
//Fill charge meter
if (!TF2Attrib_HookValueFloat(0.0, "item_meter_resupply_denied", iWeapon))
Properties_AddWeaponChargeMeter(iClient, iWeapon, 100.0);

//Fill ammo
if (HasEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType"))
{
int iAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType");
if (iAmmoType != -1)
{
int iMaxAmmo = TF2_GetMaxAmmo(iClient, iWeapon, iAmmoType);
int iAmmo = TF2_GiveAmmo(iClient, iWeapon, 0, iMaxAmmo, iAmmoType, true, kAmmoSource_Resupply);
Properties_SetWeaponPropInt(iWeapon, "m_iAmmo", iAmmo);
if (iWeapon == GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon"))
Properties_UpdateActiveWeaponAmmo(iClient);
}
}
}
}

//After all weapons has been given, fill ammo
while (TF2_GetItem(iClient, iWeapon, iPos))
{
if (!HasEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType"))
continue;

int iAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType");
if (iAmmoType == -1)
continue;

int iMaxAmmo = TF2_GetMaxAmmo(iClient, iWeapon, iAmmoType);
int iAmmo = TF2_GiveAmmo(iClient, iWeapon, 0, iMaxAmmo, iAmmoType, true, kAmmoSource_Resupply);
Properties_SetWeaponPropInt(iWeapon, "m_iAmmo", iAmmo);
if (iWeapon == GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon"))
Properties_UpdateActiveWeaponAmmo(iClient);
}

//Set active weapon if dont have one
int iActiveWeapon = GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon");
if (iActiveWeapon != INVALID_ENT_REFERENCE)
Expand Down

0 comments on commit d62f57b

Please sign in to comment.