Added cvar for enabling/disabling class cookies. Fixed teleport not resetting velocity.
This commit is contained in:
parent
855ffc3c0d
commit
5591adfd25
@ -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"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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]");
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user