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

@ -138,6 +138,7 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
new reason = GetEventInt(event, "reason");
// Forward event to modules.
WeaponsOnRoundEnd();
RoundEndOnRoundEnd(reason);
InfectOnRoundEnd();
SEffectsOnRoundEnd();

View File

@ -33,7 +33,7 @@
* @param stack If modifying velocity, then true will stack new velocity onto the client's
* current velocity, false will reset it.
*/
ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
{
// If retrieve if true, then get client's velocity.
if (!apply)
@ -72,7 +72,7 @@ ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack
* @param client The client index.
* @param value LMV value. (1.0 = default, 2.0 = double)
*/
ToolsSetClientLMV(client, Float:fLMV)
stock ToolsSetClientLMV(client, Float:fLMV)
{
// Set lagged movement value of client.
SetEntDataFloat(client, g_iToolsLMV, fLMV / 300.0, true);
@ -85,7 +85,7 @@ ToolsSetClientLMV(client, Float:fLMV)
* @param ownership If true, enable will toggle the client's ownership of nightvision.
* If false, enable will toggle the client's on/off state of the nightvision.
*/
ToolsClientNightVision(client, bool:enable, bool:ownership = true)
stock ToolsClientNightVision(client, bool:enable, bool:ownership = true)
{
// If ownership is true, then toggle the ownership of nightvision on client.
if (ownership)
@ -104,7 +104,7 @@ ToolsClientNightVision(client, bool:enable, bool:ownership = true)
* @param client The client index.
* @param FOV The field of vision of the client.
*/
ToolsSetClientDefaultFOV(client, FOV)
stock ToolsSetClientDefaultFOV(client, FOV)
{
SetEntData(client, g_iToolsDefaultFOV, FOV, 1, true);
}
@ -118,7 +118,7 @@ ToolsSetClientDefaultFOV(client, FOV)
* @param value The value of the client's score or deaths.
* @return The score or death count of the client, -1 if setting.
*/
ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
stock ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
{
if (!apply)
{
@ -156,7 +156,7 @@ ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
* @param alpha The alpha value to set client's alpha to. (0-255)
* @param weapons Apply alpha to all client's weapons.
*/
ToolsSetClientAlpha(client, alpha)
stock ToolsSetClientAlpha(client, alpha)
{
// Turn rendermode on, on the client.
SetEntityRenderMode(client, RENDER_TRANSALPHA);
@ -174,7 +174,7 @@ ToolsSetClientAlpha(client, alpha)
* @param client The client index.
* @return The alpha value of the client. (0-255)
*/
ToolsGetEntityAlpha(entity)
stock ToolsGetEntityAlpha(entity)
{
static bool:gotconfig = false;
static String:prop[32];

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.
*