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:
parent
74ac9540cf
commit
edf301da42
@ -239,6 +239,10 @@ zr_weapons "1"
|
|||||||
// Default: "1"
|
// Default: "1"
|
||||||
zr_weapons_restrict "1"
|
zr_weapons_restrict "1"
|
||||||
|
|
||||||
|
// Restricts zombies from picking up weapons after the round has ended but before the next round has begun.
|
||||||
|
// Default: "1"
|
||||||
|
zr_weapons_restrict_endequip "1"
|
||||||
|
|
||||||
// ZMarket
|
// ZMarket
|
||||||
|
|
||||||
// Allow player to buy from a list of weapons in the weapons config.
|
// Allow player to buy from a list of weapons in the weapons config.
|
||||||
|
@ -72,6 +72,7 @@ enum CvarsList
|
|||||||
Handle:CVAR_CLASSES_ADMIN_SELECT,
|
Handle:CVAR_CLASSES_ADMIN_SELECT,
|
||||||
Handle:CVAR_WEAPONS,
|
Handle:CVAR_WEAPONS,
|
||||||
Handle:CVAR_WEAPONS_RESTRICT,
|
Handle:CVAR_WEAPONS_RESTRICT,
|
||||||
|
Handle:CVAR_WEAPONS_RESTRICT_ENDEQUIP,
|
||||||
Handle:CVAR_WEAPONS_ZMARKET,
|
Handle:CVAR_WEAPONS_ZMARKET,
|
||||||
Handle:CVAR_WEAPONS_ZMARKET_BUYZONE,
|
Handle:CVAR_WEAPONS_ZMARKET_BUYZONE,
|
||||||
Handle:CVAR_WEAPONS_ZMARKET_REBUY,
|
Handle:CVAR_WEAPONS_ZMARKET_REBUY,
|
||||||
@ -288,6 +289,7 @@ CvarsCreate()
|
|||||||
|
|
||||||
// Restrict
|
// Restrict
|
||||||
g_hCvarsList[CVAR_WEAPONS_RESTRICT] = CreateConVar("zr_weapons_restrict", "1", "Enable weapon restriction module, disabling this will disable weapon restriction commands.");
|
g_hCvarsList[CVAR_WEAPONS_RESTRICT] = CreateConVar("zr_weapons_restrict", "1", "Enable weapon restriction module, disabling this will disable weapon restriction commands.");
|
||||||
|
g_hCvarsList[CVAR_WEAPONS_RESTRICT_ENDEQUIP] = CreateConVar("zr_weapons_restrict_endequip", "1", "Restricts zombies from picking up weapons after the round has ended but before the next round has begun.");
|
||||||
|
|
||||||
// ZMarket
|
// ZMarket
|
||||||
g_hCvarsList[CVAR_WEAPONS_ZMARKET] = CreateConVar("zr_weapons_zmarket", "1", "Allow player to buy from a list of weapons in the weapons config.");
|
g_hCvarsList[CVAR_WEAPONS_ZMARKET] = CreateConVar("zr_weapons_zmarket", "1", "Allow player to buy from a list of weapons in the weapons config.");
|
||||||
|
@ -214,6 +214,12 @@ RestrictOnClientSpawn(client)
|
|||||||
*/
|
*/
|
||||||
RestrictOnRoundEnd()
|
RestrictOnRoundEnd()
|
||||||
{
|
{
|
||||||
|
new bool:restrictzombieequip = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT_ENDEQUIP]);
|
||||||
|
if (!restrictzombieequip)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// x = Client index.
|
// x = Client index.
|
||||||
for (new x = 1; x <= MaxClients; x++)
|
for (new x = 1; x <= MaxClients; x++)
|
||||||
{
|
{
|
||||||
|
@ -343,6 +343,9 @@ WeaponsOnClientSpawn(client)
|
|||||||
*/
|
*/
|
||||||
WeaponsOnClientSpawnPost(client)
|
WeaponsOnClientSpawnPost(client)
|
||||||
{
|
{
|
||||||
|
// Refresh all weapons on clients to cleanup any rendering errors.
|
||||||
|
WeaponsRefreshAllClientWeapons(client);
|
||||||
|
|
||||||
// Forward event to sub-modules.
|
// Forward event to sub-modules.
|
||||||
ZMarketOnClientSpawnPost(client);
|
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.
|
* 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)
|
// Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning)
|
||||||
GivePlayerItem(client, "weapon_knife");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user