Fixed weapon not rendering correctly in rare cases and added a cvar to allow zombies to pick up weapons at the end of the round.

This commit is contained in:
Greyscale
2010-01-03 23:25:35 -08:00
parent 74ac9540cf
commit edf301da42
4 changed files with 65 additions and 0 deletions

View File

@ -214,6 +214,12 @@ RestrictOnClientSpawn(client)
*/
RestrictOnRoundEnd()
{
new bool:restrictzombieequip = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT_ENDEQUIP]);
if (!restrictzombieequip)
{
return;
}
// x = Client index.
for (new x = 1; x <= MaxClients; x++)
{

View File

@ -343,6 +343,9 @@ WeaponsOnClientSpawn(client)
*/
WeaponsOnClientSpawnPost(client)
{
// Refresh all weapons on clients to cleanup any rendering errors.
WeaponsRefreshAllClientWeapons(client);
// Forward event to sub-modules.
ZMarketOnClientSpawnPost(client);
}
@ -805,6 +808,31 @@ stock WeaponsRemoveClientGrenades(client, bool:weaponsdrop)
}
}
/**
* Refresh a weapon by taking it and giving it back.
*
* @param client The client index.
* @param slot The weapon slot to refresh. (see enum WeaponsSlot)
*/
stock WeaponsRefreshClientWeapon(client, WeaponsSlot:slot)
{
new weaponindex = GetPlayerWeaponSlot(client, _:slot);
// If weapon is invalid, then stop.
if (weaponindex == -1)
{
return;
}
// Get the classname of the weapon to re-give.
decl String:entityname[WEAPONS_MAX_LENGTH];
GetEdictClassname(weaponindex, entityname, sizeof(entityname));
// Refresh weapon.
RemovePlayerItem(client, weaponindex);
GivePlayerItem(client, entityname);
}
/**
* Remove all weapons, except knife, on a client, with options.
*
@ -853,3 +881,28 @@ stock WeaponsRemoveAllClientWeapons(client, bool:weaponsdrop)
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
GivePlayerItem(client, "weapon_knife");
}
/**
* Refresh a weapon by taking it and giving it back.
*
* @param client The client index.
*/
stock WeaponsRefreshAllClientWeapons(client)
{
// Get a list of all client's weapon indexes.
new weapons[WeaponsSlot];
WeaponsGetClientWeapons(client, weapons);
// Loop through array slots and force drop.
// x = weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
{
// If weapon is invalid, then stop.
if (weapons[x] == -1)
{
continue;
}
WeaponsRefreshClientWeapon(client, WeaponsSlot:x);
}
}