Added cvar for enabling/disabling class cookies. Fixed teleport not resetting velocity.

This commit is contained in:
richard 2009-08-15 19:48:51 +02:00
parent 855ffc3c0d
commit 5591adfd25
6 changed files with 63 additions and 20 deletions

View File

@ -156,10 +156,14 @@ zr_classes_spawn "0"
// Default: "0" // Default: "0"
zr_classes_random "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" // Default: "20"
zr_classes_change_timelimit "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] // Admin class assigned to admins on connect. ["random" = Random admin class | "" = Class config default]
// Default: "random" // Default: "random"
zr_classes_default_admin "random" zr_classes_default_admin "random"

View File

@ -882,6 +882,25 @@ Class console variables:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Assign random classes to all players each round. 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: Options:
0 or 1 0 or 1

View File

@ -56,6 +56,7 @@ enum CvarsList
Handle:CVAR_CLASSES_SPAWN, Handle:CVAR_CLASSES_SPAWN,
Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_RANDOM,
Handle:CVAR_CLASSES_CHANGE_TIMELIMIT, Handle:CVAR_CLASSES_CHANGE_TIMELIMIT,
Handle:CVAR_CLASSES_SAVE,
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE, Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
Handle:CVAR_CLASSES_DEFAULT_M_ZOMB, Handle:CVAR_CLASSES_DEFAULT_M_ZOMB,
Handle:CVAR_CLASSES_DEFAULT_HUMAN, Handle:CVAR_CLASSES_DEFAULT_HUMAN,
@ -249,7 +250,8 @@ CvarsCreate()
// General // General
g_hCvarsList[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Re-display class selection menu every spawn."); 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_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_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_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]"); 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]");

View File

@ -389,8 +389,11 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot)
ClassSelected[client][teamid] = classindex; ClassSelected[client][teamid] = classindex;
} }
// Save selected class index in cookie. // Save selected class index in cookie if enabled.
CookiesSetInt(client, g_hClassCookieClassSelected[teamid], classindex + 1); if (GetConVarBool(g_hCvarsList[CVAR_CLASSES_SAVE]))
{
CookiesSetInt(client, g_hClassCookieClassSelected[teamid], classindex + 1);
}
} }
} }
case MenuAction_Cancel: case MenuAction_Cancel:

View File

@ -931,6 +931,7 @@ ClassClientSetDefaultIndexes(client = -1)
{ {
new bool:clientvalid = ZRIsClientValid(client); new bool:clientvalid = ZRIsClientValid(client);
new filter[ClassFilter]; new filter[ClassFilter];
new bool:saveclasses = GetConVarBool(g_hCvarsList[CVAR_CLASSES_SAVE]);
new zombieindex; new zombieindex;
new humanindex; new humanindex;
@ -943,10 +944,21 @@ ClassClientSetDefaultIndexes(client = -1)
// Check if a client is specified. // Check if a client is specified.
if (clientvalid) if (clientvalid)
{ {
// Get cookie indexes. // Get cookie indexes if enabled.
zombieindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]); if (saveclasses)
humanindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]); {
adminindex = CookiesGetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]); 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 // 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 // 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. // Copy human class data to player cache.
ClassReloadPlayerCache(client, humanindex); ClassReloadPlayerCache(client, humanindex);
// Save indexes in cookies if not already saved. // Save indexes in cookies if enabled, and not already saved.
if (!haszombie) if (saveclasses)
{ {
CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES], zombieindex + 1); if (!haszombie)
} {
if (!hashuman) CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES], zombieindex + 1);
{ }
CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS], humanindex + 1); if (!hashuman)
} {
if (!hasadmin) CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS], humanindex + 1);
{ }
CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS], adminindex + 1); if (!hasadmin)
{
CookiesSetInt(client, g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS], adminindex + 1);
}
} }
} }
else else

View File

@ -233,7 +233,7 @@ bool:ZTeleClient(client, bool:force = false)
ZTeleTeleportClient(client) ZTeleTeleportClient(client)
{ {
// Teleport 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});
} }
/** /**