From bedb4d4bda2f17d128274f059957ca46bb4cb21b Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 20 Nov 2009 18:20:45 +0100 Subject: [PATCH] Made cvar for displaying class menu on first spawn. Renamed class menu cvars. --- .../cfg/sourcemod/zombiereloaded/zombiereloaded.cfg | 6 +++++- src/zr/cvars.inc | 6 ++++-- src/zr/playerclasses/classevents.inc | 11 ++++++++--- src/zr/playerclasses/playerclasses.inc | 5 +++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 96486b5..b41affd 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -154,7 +154,11 @@ zr_permissions_use_groups "0" // Re-display class selection menu every spawn. // Default: "0" -zr_classes_spawn "0" +zr_classes_menu_spawn "0" + +// Display class selection menu when a player spawn for the first time. +// Default: "0" +zr_classes_menu_join "0" // Player is assigned a random class every spawn. [Override: zr_classes_default_*] // Default: "0" diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 96bb49f..cd5c7da 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -53,7 +53,8 @@ enum CvarsList Handle:CVAR_CONFIG_PATH_WEAPONS, Handle:CVAR_CONFIG_PATH_HITGROUPS, Handle:CVAR_PERMISSIONS_USE_GROUPS, - Handle:CVAR_CLASSES_SPAWN, + Handle:CVAR_CLASSES_MENU_SPAWN, + Handle:CVAR_CLASSES_MENU_JOIN, Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_CHANGE_TIMELIMIT, Handle:CVAR_CLASSES_SAVE, @@ -255,7 +256,8 @@ CvarsCreate() // =========================== // General - g_hCvarsList[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Re-display class selection menu every spawn."); + g_hCvarsList[CVAR_CLASSES_MENU_SPAWN] = CreateConVar("zr_classes_menu_spawn", "0", "Re-display class selection menu every spawn."); + g_hCvarsList[CVAR_CLASSES_MENU_JOIN] = CreateConVar("zr_classes_menu_join", "0", "Display class selection menu when a player spawn for the first time."); g_hCvarsList[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "Player is assigned a random class every spawn. [Override: zr_classes_default_*]"); g_hCvarsList[CVAR_CLASSES_CHANGE_TIMELIMIT] = CreateConVar("zr_classes_change_timelimit", "20", "Time limit to change human class with instant change after spawning. Time is in seconds. Use 0 or negative to disable."); g_hCvarsList[CVAR_CLASSES_SAVE] = CreateConVar("zr_classes_save", "1", "Save players' class selections in server cookies and restore when connecting. [Override: zr_classes_default_*]"); diff --git a/src/zr/playerclasses/classevents.inc b/src/zr/playerclasses/classevents.inc index 8ae8af1..d741b65 100644 --- a/src/zr/playerclasses/classevents.inc +++ b/src/zr/playerclasses/classevents.inc @@ -75,6 +75,9 @@ ClassClientInit(client) // Forward event to sub-modules. ClassOverlayClientInit(client); } + + // Reset spawn flag. + ClassPlayerSpawned[client] = false; } /** @@ -176,10 +179,12 @@ ClassOnClientSpawn(client) TranslationPrintToChat(client, "Classes random assignment", classname); } - // Display class menu if enabled. - new bool:classmenu = GetConVarBool(g_hCvarsList[CVAR_CLASSES_SPAWN]); - if (classmenu) + // Display class menu if either menu cvar is set. + new bool:menuspawn = GetConVarBool(g_hCvarsList[CVAR_CLASSES_MENU_SPAWN]); + new bool:menujoin = GetConVarBool(g_hCvarsList[CVAR_CLASSES_MENU_JOIN]); + if (menuspawn || (menujoin && !ClassPlayerSpawned[client])) { + ClassPlayerSpawned[client] = true; ClassMenuMain(client); } } diff --git a/src/zr/playerclasses/playerclasses.inc b/src/zr/playerclasses/playerclasses.inc index 7193003..6f2eb7a 100644 --- a/src/zr/playerclasses/playerclasses.inc +++ b/src/zr/playerclasses/playerclasses.inc @@ -458,6 +458,11 @@ new bool:ClassAllowInstantChange[MAXPLAYERS + 1]; */ new String:ClassOriginalPlayerModel[MAXPLAYERS + 1][PLATFORM_MAX_PATH]; +/** + * Specifies whether a player has spawned. + */ +new bool:ClassPlayerSpawned[MAXPLAYERS + 1]; + #include "zr/playerclasses/filtertools" #include "zr/playerclasses/attributes" #include "zr/playerclasses/apply"