From d466ab8b2443c09b54cfa580033e75d5f1e40d19 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Mon, 18 May 2009 23:14:18 -0700 Subject: [PATCH] Fixed weaponalpha from changing weapon's rendermode before spawn which caused display problems. --- src/zr/event.inc | 8 ++++++++ src/zr/weapons/restrict.inc | 12 +++++------ src/zr/weapons/weaponalpha.inc | 37 ++++++++++++++++++++++++++++++++++ src/zr/weapons/weapons.inc | 20 ++++++++++++++++++ 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/zr/event.inc b/src/zr/event.inc index bd91a15..f9d1e16 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -71,6 +71,7 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc // Forward event to sub-modules. OverlaysOnRoundStart(); + WeaponsOnRoundStart(); RoundEndOnRoundStart(); InfectOnRoundStart(); SEffectsOnRoundStart(); @@ -111,6 +112,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(); @@ -202,6 +204,12 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad */ public Action:EventPlayerSpawnPost(Handle:timer, any:index) { + // If client isn't in-game, then stop. + if (!IsClientInGame(index)) + { + return; + } + // Forward event to modules. SpawnProtectOnClientSpawnPost(index); } diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index 1172232..de01c65 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -374,12 +374,6 @@ WpnRestrictQuery:RestrictUnrestrict(const String:weapon[], String:display[] = "" // Check if weapon is a custom group name. if (RestrictIsWeaponGroup(weapon)) { - // Return restrict failed if group isn't restricted. - if (RestrictIsGroupUnrestricted(weapon)) - { - return Failed_Group; - } - // Jump to weapon group key. KvRewind(kvWeaponGroups); KvJumpToKey(kvWeaponGroups, weapon); @@ -387,6 +381,12 @@ WpnRestrictQuery:RestrictUnrestrict(const String:weapon[], String:display[] = "" // Get display name of the weapon group. KvGetSectionName(kvWeaponGroups, display, WEAPONS_MAX_LENGTH); + // Return restrict failed if group isn't restricted. + if (RestrictIsGroupUnrestricted(weapon)) + { + return Failed_Group; + } + // Traverse into the group's weapons. if (KvGotoFirstSubKey(kvWeaponGroups)) { diff --git a/src/zr/weapons/weaponalpha.inc b/src/zr/weapons/weaponalpha.inc index ab3e1b0..5eee26e 100644 --- a/src/zr/weapons/weaponalpha.inc +++ b/src/zr/weapons/weaponalpha.inc @@ -20,6 +20,11 @@ */ new g_iWeaponDropHookID[MAXPLAYERS + 1] = {-1, ...}; +/** + * Global variable that stops render mode modifying + */ +new bool:g_bWeaponAlpha; + /** * Client is joining the server. * @@ -46,6 +51,26 @@ WeaponAlphaOnClientDisconnect(client) } } +/** + * The round is starting. + */ +WeaponAlphaOnRoundStart() +{ + // Allow weapon render mode to be modified. + g_bWeaponAlpha = true; +} + +/** + * The round is ending. + * + * @param reason Reason the round has ended. + */ +WeaponAlphaOnRoundEnd() +{ + // Disallow weapon render mode to be modified. + g_bWeaponAlpha = false; +} + /** * Client has just picked up a weapon. * @@ -54,6 +79,12 @@ WeaponAlphaOnClientDisconnect(client) */ WeaponAlphaOnItemPickup(client, weapon) { + // If weapon alpha updating is disabled, then stop. + if (!g_bWeaponAlpha) + { + return; + } + // Get client's current alpha. new alpha = ToolsGetEntityAlpha(client); @@ -70,6 +101,12 @@ WeaponAlphaOnItemPickup(client, weapon) */ public ZRTools_Action:WeaponAlphaDrop(client, weapon) { + // If weapon alpha updating is disabled, then stop. + if (!g_bWeaponAlpha) + { + return; + } + // If weapon isn't a valid entity, then stop. if (weapon < MaxClients) { diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index 58fe732..f6ccf04 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -174,6 +174,26 @@ WeaponsOnClientDisconnect(client) WeaponAlphaOnClientDisconnect(client); } +/** + * The round is starting. + */ +WeaponsOnRoundStart() +{ + // Forward event to sub-modules + WeaponAlphaOnRoundStart(); +} + +/** + * The round is ending. + * + * @param reason Reason the round has ended. + */ +WeaponsOnRoundEnd() +{ + // Forward event to sub-modules + WeaponAlphaOnRoundEnd(); +} + /** * Creates an array of all listed weapons in weapons.txt. * @param arrayWeapons The handle of the array, don't forget to call CloseHandle