From 5591adfd257d700d42625906979ad93fa1dc0c86 Mon Sep 17 00:00:00 2001 From: richard Date: Sat, 15 Aug 2009 19:48:51 +0200 Subject: [PATCH] Added cvar for enabling/disabling class cookies. Fixed teleport not resetting velocity. --- .../zombiereloaded/zombiereloaded.cfg | 6 ++- docs/zr_manual.txt | 19 ++++++++ src/zr/cvars.inc | 4 +- src/zr/playerclasses/classmenus.inc | 7 ++- src/zr/playerclasses/playerclasses.inc | 45 ++++++++++++------- src/zr/ztele.inc | 2 +- 6 files changed, 63 insertions(+), 20 deletions(-) diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 00261b9..7151e00 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -156,10 +156,14 @@ zr_classes_spawn "0" // Default: "0" zr_classes_random "0" -// Time limit to change class with instant change after spawning. Time is in seconds. Use 0 or negative to disable. +// Time limit to change human class with instant change after spawning. Time is in seconds. Use 0 or negative to disable. // Default: "20" zr_classes_change_timelimit "20" +// Save players' class selections in server cookies and restore when connecting. [Override: zr_classes_default_*] +// Default: "1" +zr_classes_save "1" + // Admin class assigned to admins on connect. ["random" = Random admin class | "" = Class config default] // Default: "random" zr_classes_default_admin "random" diff --git a/docs/zr_manual.txt b/docs/zr_manual.txt index f4757e4..34355e5 100644 --- a/docs/zr_manual.txt +++ b/docs/zr_manual.txt @@ -882,6 +882,25 @@ Class console variables: --------------------------------------------------------------------------- Assign random classes to all players each round. + This setting overrides zr_classes_save. + + Options: + 0 or 1 + + zr_classes_change_timelimit 20 + --------------------------------------------------------------------------- + The time limit to change human classes with instant change after + spawning. So humans don't have to set class before spawning. Time is in + seconds. + + zr_classes_save 1 + --------------------------------------------------------------------------- + Save players' class selections in server cookies. Class selections are + restored next time players connect. + + This setting overrides zr_classes_default_*, but on first-time + connecting players the default classes are assigned. + Options: 0 or 1 diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 02b9ec6..8108115 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -56,6 +56,7 @@ enum CvarsList Handle:CVAR_CLASSES_SPAWN, Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_CHANGE_TIMELIMIT, + Handle:CVAR_CLASSES_SAVE, Handle:CVAR_CLASSES_DEFAULT_ZOMBIE, Handle:CVAR_CLASSES_DEFAULT_M_ZOMB, Handle:CVAR_CLASSES_DEFAULT_HUMAN, @@ -249,7 +250,8 @@ CvarsCreate() // General g_hCvarsList[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Re-display class selection menu every spawn."); 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 class with instant change after spawning. Time is in seconds. Use 0 or negative to disable."); + 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_*]"); g_hCvarsList[CVAR_CLASSES_DEFAULT_ZOMBIE] = CreateConVar("zr_classes_default_zombie", "random", "Zombie class assigned to players on connect. [\"random\" = Random zombie class | \"\" = Class config default]"); g_hCvarsList[CVAR_CLASSES_DEFAULT_M_ZOMB] = CreateConVar("zr_classes_default_mother_zombie", "motherzombies","Zombie class assigned to mother zombies. [\"motherzombies\" = Random mother zombie class | \"random\" = Random regular zombie class | \"disabled\" = Don't change class on mother zombies]"); g_hCvarsList[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "random", "Human class assigned to players on connect. [\"random\" = Random human class | \"\" = Class config default]"); diff --git a/src/zr/playerclasses/classmenus.inc b/src/zr/playerclasses/classmenus.inc index a32c894..981032e 100644 --- a/src/zr/playerclasses/classmenus.inc +++ b/src/zr/playerclasses/classmenus.inc @@ -389,8 +389,11 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot) ClassSelected[client][teamid] = classindex; } - // Save selected class index in cookie. - CookiesSetInt(client, g_hClassCookieClassSelected[teamid], classindex + 1); + // Save selected class index in cookie if enabled. + if (GetConVarBool(g_hCvarsList[CVAR_CLASSES_SAVE])) + { + CookiesSetInt(client, g_hClassCookieClassSelected[teamid], classindex + 1); + } } } case MenuAction_Cancel: diff --git a/src/zr/playerclasses/playerclasses.inc b/src/zr/playerclasses/playerclasses.inc index abdb3c2..ba13f15 100644 --- a/src/zr/playerclasses/playerclasses.inc +++ b/src/zr/playerclasses/playerclasses.inc @@ -931,6 +931,7 @@ ClassClientSetDefaultIndexes(client = -1) { new bool:clientvalid = ZRIsClientValid(client); new filter[ClassFilter]; + new bool:saveclasses = GetConVarBool(g_hCvarsList[CVAR_CLASSES_SAVE]); new zombieindex; new humanindex; @@ -943,10 +944,21 @@ ClassClientSetDefaultIndexes(client = -1) // Check if a client is specified. if (clientvalid) { - // Get cookie indexes. - zombieindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]); - humanindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]); - adminindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]); + // Get cookie indexes if enabled. + if (saveclasses) + { + zombieindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]); + humanindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]); + adminindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]); + } + else + { + // Do not use indexes in cookies. Set invalid values so it will + // fall back to default class. + zombieindex = 0; + humanindex = 0; + adminindex = 0; + } // Note: When class indexes are set on cookies, they're incremented by // one so zero means no class set and will result in a invalid @@ -1041,18 +1053,21 @@ ClassClientSetDefaultIndexes(client = -1) // Copy human class data to player cache. ClassReloadPlayerCache(client, humanindex); - // Save indexes in cookies if not already saved. - if (!haszombie) + // Save indexes in cookies if enabled, and not already saved. + if (saveclasses) { - CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES], zombieindex + 1); - } - if (!hashuman) - { - CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS], humanindex + 1); - } - if (!hasadmin) - { - CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS], adminindex + 1); + if (!haszombie) + { + CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES], zombieindex + 1); + } + if (!hashuman) + { + CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS], humanindex + 1); + } + if (!hasadmin) + { + CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS], adminindex + 1); + } } } else diff --git a/src/zr/ztele.inc b/src/zr/ztele.inc index 33aec78..ca5d90e 100644 --- a/src/zr/ztele.inc +++ b/src/zr/ztele.inc @@ -233,7 +233,7 @@ bool:ZTeleClient(client, bool:force = false) ZTeleTeleportClient(client) { // Teleport client. - TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, NULL_VECTOR); + TeleportEntity(client, g_vecZTeleSpawn[client], NULL_VECTOR, Float:{0.0, 0.0, 0.0}); } /**