Fixed weapons bug for what.. the 4th time? Finally figured out the cause, reproduced, made fix, no more bug.

Zombies no longer pick up weapons after the round.
Fixed bug where disabling restrict/weapons module allowed zombies to get weapons.
This commit is contained in:
Greyscale
2009-06-26 18:33:09 -07:00
parent 194eb9f2b8
commit 85c3400a62
4 changed files with 88 additions and 13 deletions

View File

@ -43,6 +43,11 @@ enum RestrictData
*/
new g_iCanUseHookID[MAXPLAYERS + 1] = {-1, ...};
/**
* Array to block any client from picking up weapons.
*/
new bool:g_bRestrictBlockWeapon[MAXPLAYERS + 1];
/**
* Array to store a list of different weapon groups
*/
@ -134,6 +139,9 @@ RestrictClientInit(client)
{
// Hook "Weapon_CanUse" on client.
g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
// Reset block weapons flag.
g_bRestrictBlockWeapon[client] = false;
}
/**
@ -161,6 +169,48 @@ RestrictOnClientSpawn(client)
// Re-hook "canuse" on client.
ZRTools_UnhookWeapon_CanUse(g_iCanUseHookID[client]);
g_iCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
// H4x. Unfortunately I can't disable this flag early enough for CS:S to give start USP/Glock.
// So I have to give BOOTLEG weapons. (Sorry Valve)
if (g_bRestrictBlockWeapon[client])
{
// Reset block weapons flag.
g_bRestrictBlockWeapon[client] = false;
if (ZRIsClientOnTeam(client, CS_TEAM_T))
{
GivePlayerItem(client, WEAPONS_SPAWN_T_WEAPON);
}
else if (ZRIsClientOnTeam(client, CS_TEAM_CT))
{
GivePlayerItem(client, WEAPONS_SPAWN_CT_WEAPON);
}
}
}
/**
* The round is ending.
*/
RestrictOnRoundEnd()
{
// x = Client index.
for (new x = 1; x <= MaxClients; x++)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(x))
{
continue;
}
// If client is a human, then stop.
if (InfectIsClientHuman(x))
{
continue;
}
// Enable block weapon flag.
g_bRestrictBlockWeapon[x] = true;
}
}
/**
@ -545,6 +595,18 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
return ZRTools_Continue;
}
// If the player is a zombie, then prevent pickup.
if (InfectIsClientInfected(client))
{
return ZRTools_Handled;
}
// If client is flagged for not picking up weapons, then stop.
if (g_bRestrictBlockWeapon[client])
{
return ZRTools_Handled;
}
// If weapons module is disabled, then stop.
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
if (!weapons)
@ -575,12 +637,6 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
return ZRTools_Handled;
}
// If the player is a zombie, then prevent pickup.
if (InfectIsClientInfected(client))
{
return ZRTools_Handled;
}
// Forward event to weapons module.
WeaponsOnItemPickup(client, weapon);

View File

@ -35,6 +35,15 @@
*/
#define WEAPONS_SLOTS_MAX 5
/**
* @section CS:S start weapons.
*/
#define WEAPONS_SPAWN_T_WEAPON "weapon_glock"
#define WEAPONS_SPAWN_CT_WEAPON "weapon_usp"
/**
* @endsection
*/
/**
* Weapon config data indexes.
*/
@ -325,6 +334,15 @@ WeaponsOnClientSpawnPost(client)
ZMarketOnClientSpawnPost(client);
}
/**
* The round is ending.
*/
WeaponsOnRoundEnd()
{
// Forward event to sub-modules.
RestrictOnRoundEnd();
}
/**
* Called when a client picks up an item.
*