Merged heads.
This commit is contained in:
commit
637c04aa21
@ -230,17 +230,53 @@
|
|||||||
|
|
||||||
"Classes menu zombie"
|
"Classes menu zombie"
|
||||||
{
|
{
|
||||||
"en" "Select Zombie Class"
|
"en" "Select Zombie Class:"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu zombie current"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Select Zombie Class\n {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu zombie next"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s}"
|
||||||
|
"en" "Select Zombie Class\n Active: {1}\n Next spawn: {2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Classes menu human"
|
"Classes menu human"
|
||||||
{
|
{
|
||||||
"en" "Select Human Class"
|
"en" "Select Human Class:"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu human current"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Select Human Class\n {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu human next"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s}"
|
||||||
|
"en" "Select Human Class\n Active: {1}\n Next spawn: {2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Classes menu admin"
|
"Classes menu admin"
|
||||||
{
|
{
|
||||||
"en" "Select Admin Class"
|
"en" "Select Admin Mode Class:"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu admin current"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Select Admin Mode Class\n {1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Classes menu admin next"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s}"
|
||||||
|
"en" "Select Admin Mode Class\n Active: {1}\n Next spawn: {2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Classes menu admin mode toggle"
|
"Classes menu admin mode toggle"
|
||||||
|
@ -60,6 +60,9 @@ ClassOnClientDisconnect(client)
|
|||||||
{
|
{
|
||||||
// Disable class attributes with timers.
|
// Disable class attributes with timers.
|
||||||
ClassHealthRegenStop(client);
|
ClassHealthRegenStop(client);
|
||||||
|
|
||||||
|
// Reset previously selected class indexes.
|
||||||
|
ClassResetNextIndexes(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,13 +76,14 @@ ClassOnClientSpawn(client)
|
|||||||
decl String:steamid[16];
|
decl String:steamid[16];
|
||||||
decl String:classname[64];
|
decl String:classname[64];
|
||||||
|
|
||||||
// Check if the player is alive.
|
// Check if the player is dead. Spawning into the game is also a event in
|
||||||
|
// the connection process.
|
||||||
if (!IsPlayerAlive(client))
|
if (!IsPlayerAlive(client))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are valid classes. Block this event if classes aren't
|
// Check if there are no valid classes. Block this event if classes aren't
|
||||||
// done loading.
|
// done loading.
|
||||||
if (!ClassValidated)
|
if (!ClassValidated)
|
||||||
{
|
{
|
||||||
@ -89,62 +93,59 @@ ClassOnClientSpawn(client)
|
|||||||
// Reset attributes by triggering death event.
|
// Reset attributes by triggering death event.
|
||||||
ClassOnClientDeath(client);
|
ClassOnClientDeath(client);
|
||||||
|
|
||||||
|
// Restore class indexes to be selected on spawn, if available.
|
||||||
|
ClassRestoreNextIndexes(client);
|
||||||
|
|
||||||
// Cache original player model.
|
// Cache original player model.
|
||||||
GetClientModel(client, originalmodel, sizeof(originalmodel));
|
GetClientModel(client, originalmodel, sizeof(originalmodel));
|
||||||
strcopy(ClassOriginalPlayerModel[client], PLATFORM_MAX_PATH, originalmodel);
|
strcopy(ClassOriginalPlayerModel[client], PLATFORM_MAX_PATH, originalmodel);
|
||||||
|
|
||||||
// Exclude special class flags like mother zombies and admin classes.
|
|
||||||
new denyflags = ZR_CLASS_SPECIALFLAGS;
|
|
||||||
|
|
||||||
// Allow admin classes if admin.
|
|
||||||
denyflags -= ZRIsClientAdmin(client) ? ZR_CLASS_FLAG_ADMIN_ONLY : 0;
|
|
||||||
|
|
||||||
// Get random class setting.
|
|
||||||
new bool:randomclass = GetConVarBool(g_hCvarsList[CVAR_CLASSES_RANDOM]);
|
|
||||||
|
|
||||||
// Assign random classes if enabled. Always do it for bots.
|
|
||||||
GetClientAuthString(client, steamid, sizeof(steamid));
|
|
||||||
if (randomclass || StrEqual(steamid, "BOT"))
|
|
||||||
{
|
|
||||||
// Get random classes for each type.
|
|
||||||
new randomzombie = ClassGetRandomClass(ZR_CLASS_TEAM_ZOMBIES, _, _, denyflags);
|
|
||||||
new randomhuman = ClassGetRandomClass(ZR_CLASS_TEAM_HUMANS, _, _, denyflags);
|
|
||||||
|
|
||||||
// Save selected zombie class index.
|
|
||||||
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = randomzombie;
|
|
||||||
ClassGetName(randomzombie, classname, sizeof(classname), ZR_CLASS_TEAM_ZOMBIES);
|
|
||||||
TranslationPrintToChat(client, "Classes random assignment", classname);
|
|
||||||
|
|
||||||
// Save selected human class index.
|
|
||||||
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = randomhuman;
|
|
||||||
ClassGetName(randomhuman, classname, sizeof(classname), ZR_CLASS_TEAM_HUMANS);
|
|
||||||
TranslationPrintToChat(client, "Classes random assignment", classname);
|
|
||||||
|
|
||||||
// Update player cache with the human class data, and apply it.
|
|
||||||
ClassReloadPlayerCache(client, randomhuman);
|
|
||||||
ClassApplyAttributes(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the player should spawn in admin mode.
|
// Check if the player should spawn in admin mode.
|
||||||
if (ClassPlayerAdminMode[client])
|
if (ClassPlayerInAdminMode[client])
|
||||||
{
|
{
|
||||||
// Mark player as in admin mode.
|
// Mark player as in admin mode.
|
||||||
ClassPlayerInAdminMode[client] = true;
|
ClassPlayerInAdminMode[client] = true;
|
||||||
|
|
||||||
// Update player cache with the admin class and apply attributes.
|
// TODO: This is the place to initialize admin mode stuff like no-block
|
||||||
new adminindex = ClassPlayerNextAdminClass[client];
|
// and other stuff.
|
||||||
ClassReloadPlayerCache(client, adminindex);
|
|
||||||
ClassApplyAttributes(client);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mark player as not in admin mode.
|
// Mark player as not in admin mode.
|
||||||
ClassPlayerInAdminMode[client] = false;
|
ClassPlayerInAdminMode[client] = false;
|
||||||
|
|
||||||
// Apply class attributes for the currently active class.
|
// Get random class setting and steam id.
|
||||||
|
new bool:randomclass = GetConVarBool(g_hCvarsList[CVAR_CLASSES_RANDOM]);
|
||||||
|
GetClientAuthString(client, steamid, sizeof(steamid));
|
||||||
|
|
||||||
|
// Assign random classes if enabled. Always do it for bots.
|
||||||
|
if (randomclass || StrEqual(steamid, "BOT"))
|
||||||
|
{
|
||||||
|
// Exclude special class flags like mother zombies and admin classes.
|
||||||
|
new denyflags = ZR_CLASS_SPECIALFLAGS;
|
||||||
|
|
||||||
|
// Allow admin classes if admin.
|
||||||
|
denyflags -= ZRIsClientAdmin(client) ? ZR_CLASS_FLAG_ADMIN_ONLY : 0;
|
||||||
|
|
||||||
|
// Get random classes for each type.
|
||||||
|
new randomzombie = ClassGetRandomClass(ZR_CLASS_TEAM_ZOMBIES, _, _, denyflags);
|
||||||
|
new randomhuman = ClassGetRandomClass(ZR_CLASS_TEAM_HUMANS, _, _, denyflags);
|
||||||
|
|
||||||
|
// Set selected zombie class index.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = randomzombie;
|
||||||
|
ClassGetName(randomzombie, classname, sizeof(classname), ZR_CLASS_TEAM_ZOMBIES);
|
||||||
|
TranslationPrintToChat(client, "Classes random assignment", classname);
|
||||||
|
|
||||||
|
// Set selected human class index.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = randomhuman;
|
||||||
|
ClassGetName(randomhuman, classname, sizeof(classname), ZR_CLASS_TEAM_HUMANS);
|
||||||
|
TranslationPrintToChat(client, "Classes random assignment", classname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply class attributes for the active class.
|
||||||
ClassReloadPlayerCache(client, ClassGetActiveIndex(client));
|
ClassReloadPlayerCache(client, ClassGetActiveIndex(client));
|
||||||
ClassApplyAttributes(client);
|
ClassApplyAttributes(client);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,6 +204,9 @@ ClassOnClientInfected(client, bool:motherzombie = false)
|
|||||||
// Validate index. Do not change class if it's invalid.
|
// Validate index. Do not change class if it's invalid.
|
||||||
if (ClassValidateIndex(motherindex))
|
if (ClassValidateIndex(motherindex))
|
||||||
{
|
{
|
||||||
|
// Save active class index to be restored next spawn.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES] = classindex;
|
||||||
|
|
||||||
// Change class.
|
// Change class.
|
||||||
classindex = motherindex;
|
classindex = motherindex;
|
||||||
}
|
}
|
||||||
@ -215,10 +219,13 @@ ClassOnClientInfected(client, bool:motherzombie = false)
|
|||||||
// Validate index. Do not change class if it's invalid.
|
// Validate index. Do not change class if it's invalid.
|
||||||
if (ClassValidateIndex(motherindex))
|
if (ClassValidateIndex(motherindex))
|
||||||
{
|
{
|
||||||
// This is a mother zombie class. Reset mother zombie setting so
|
// This is a mother zombie class. Reset mother zombie setting
|
||||||
// class skills aren't improved.
|
// so class skills aren't improved.
|
||||||
motherzombie = false;
|
motherzombie = false;
|
||||||
|
|
||||||
|
// Save active class index to be restored next spawn.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES] = classindex;
|
||||||
|
|
||||||
// Change class.
|
// Change class.
|
||||||
classindex = motherindex;
|
classindex = motherindex;
|
||||||
}
|
}
|
||||||
@ -231,13 +238,22 @@ ClassOnClientInfected(client, bool:motherzombie = false)
|
|||||||
// Validate index.
|
// Validate index.
|
||||||
if (ClassValidateIndex(motherindex))
|
if (ClassValidateIndex(motherindex))
|
||||||
{
|
{
|
||||||
|
// Save active class index to be restored next spawn.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES] = classindex;
|
||||||
|
|
||||||
// Change class.
|
// Change class.
|
||||||
classindex = motherindex;
|
classindex = motherindex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the players cache with zombie attributes.
|
// Update the player's selected class index.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = classindex;
|
||||||
|
|
||||||
|
// Restore next indexes, if available. But don't restore the zombie index.
|
||||||
|
ClassRestoreNextIndexes(client, ZR_CLASS_TEAM_ZOMBIES);
|
||||||
|
|
||||||
|
// Update the player's cache with zombie attributes.
|
||||||
ClassReloadPlayerCache(client, classindex);
|
ClassReloadPlayerCache(client, classindex);
|
||||||
|
|
||||||
// Apply the new attributes.
|
// Apply the new attributes.
|
||||||
|
@ -45,9 +45,13 @@ ClassMenuMain(client)
|
|||||||
SetGlobalTransTarget(client);
|
SetGlobalTransTarget(client);
|
||||||
SetMenuTitle(menu, "%t\n", "Classes menu title");
|
SetMenuTitle(menu, "%t\n", "Classes menu title");
|
||||||
|
|
||||||
decl String:zombieclass[128];
|
decl String:zombieclass[64];
|
||||||
decl String:humanclass[128];
|
decl String:humanclass[64];
|
||||||
decl String:adminclass[128];
|
decl String:adminclass[64];
|
||||||
|
|
||||||
|
decl String:nextzombiename[64];
|
||||||
|
decl String:nexthumanname[64];
|
||||||
|
decl String:nextadminname[64];
|
||||||
|
|
||||||
decl String:zombieselect[128];
|
decl String:zombieselect[128];
|
||||||
decl String:humanselect[128];
|
decl String:humanselect[128];
|
||||||
@ -62,7 +66,13 @@ ClassMenuMain(client)
|
|||||||
new humancount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
|
new humancount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
|
||||||
new admincount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
|
new admincount = ClassCountTeam(ZR_CLASS_TEAM_ZOMBIES);
|
||||||
|
|
||||||
|
// Get previously selected class indexes, if set.
|
||||||
|
new nextzombie = ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES];
|
||||||
|
new nexthuman = ClassSelectedNext[client][ZR_CLASS_TEAM_HUMANS];
|
||||||
|
new nextadmin = ClassSelectedNext[client][ZR_CLASS_TEAM_ADMINS];
|
||||||
|
|
||||||
// Set draw style on class options depending on number of enabled classes.
|
// Set draw style on class options depending on number of enabled classes.
|
||||||
|
// Disable class selection if there's only one class.
|
||||||
new zombie_itemdraw = (zombiecount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
new zombie_itemdraw = (zombiecount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||||
new human_itemdraw = (humancount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
new human_itemdraw = (humancount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||||
new admin_itemdraw = (admincount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
new admin_itemdraw = (admincount > 1) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
||||||
@ -76,25 +86,78 @@ ClassMenuMain(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List zombie class options.
|
// List zombie class options.
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
|
// Get current class name.
|
||||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES], zombieclass, sizeof(zombieclass), ZR_CLASS_CACHE_MODIFIED);
|
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES], zombieclass, sizeof(zombieclass), ZR_CLASS_CACHE_MODIFIED);
|
||||||
Format(zombieselect, sizeof(zombieselect), "%t\n %s", "Classes menu zombie", zombieclass);
|
|
||||||
|
// Check if previous index is set.
|
||||||
|
if (ClassValidateIndex(nextzombie))
|
||||||
|
{
|
||||||
|
// Get name of previous class index and format item text.
|
||||||
|
ClassGetName(nextzombie, nextzombiename, sizeof(nextzombiename), ZR_CLASS_CACHE_MODIFIED);
|
||||||
|
Format(zombieselect, sizeof(zombieselect), "%t", "Classes menu zombie next", zombieclass, nextzombiename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use current class name and format item text.
|
||||||
|
Format(zombieselect, sizeof(zombieselect), "%t", "Classes menu zombie current", zombieclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add item to list.
|
||||||
AddMenuItem(menu, "", zombieselect, zombie_itemdraw);
|
AddMenuItem(menu, "", zombieselect, zombie_itemdraw);
|
||||||
|
|
||||||
|
|
||||||
// List human class options.
|
// List human class options.
|
||||||
|
// -------------------------
|
||||||
|
|
||||||
|
// Get current class name.
|
||||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_HUMANS], humanclass, sizeof(humanclass), ZR_CLASS_CACHE_MODIFIED);
|
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_HUMANS], humanclass, sizeof(humanclass), ZR_CLASS_CACHE_MODIFIED);
|
||||||
Format(humanselect, sizeof(humanselect), "%t\n %s", "Classes menu human", humanclass);
|
|
||||||
|
// Check if previous index is set.
|
||||||
|
if (ClassValidateIndex(nexthuman))
|
||||||
|
{
|
||||||
|
// Get name of previous class index and format item text.
|
||||||
|
ClassGetName(nexthuman, nexthumanname, sizeof(nexthumanname), ZR_CLASS_CACHE_MODIFIED);
|
||||||
|
Format(humanselect, sizeof(humanselect), "%t", "Classes menu human next", humanclass, nexthumanname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use current class name and format item text.
|
||||||
|
Format(humanselect, sizeof(humanselect), "%t", "Classes menu human current", humanclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add item to list.
|
||||||
AddMenuItem(menu, "", humanselect, human_itemdraw);
|
AddMenuItem(menu, "", humanselect, human_itemdraw);
|
||||||
|
|
||||||
|
|
||||||
|
// List admin class options, if they exist.
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
// Only display admin class options for admins, and if admin classes exist.
|
// Only display admin class options for admins, and if admin classes exist.
|
||||||
if (ZRIsClientAdmin(client) && ClassCountTeam(ZR_CLASS_TEAM_ADMINS))
|
if (ZRIsClientAdmin(client) && ClassCountTeam(ZR_CLASS_TEAM_ADMINS))
|
||||||
{
|
{
|
||||||
// List admin class options.
|
// Get current class name.
|
||||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ADMINS], adminclass, sizeof(adminclass), ZR_CLASS_CACHE_MODIFIED);
|
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ADMINS], adminclass, sizeof(adminclass), ZR_CLASS_CACHE_MODIFIED);
|
||||||
Format(adminselect, sizeof(adminselect), "%t\n %s", "Classes menu admin", adminclass);
|
|
||||||
|
// Check if previous index is set.
|
||||||
|
if (ClassValidateIndex(nextadmin))
|
||||||
|
{
|
||||||
|
// Get name of previous class index and format item text.
|
||||||
|
ClassGetName(nextadmin, nextadminname, sizeof(nextadminname), ZR_CLASS_CACHE_MODIFIED);
|
||||||
|
Format(adminselect, sizeof(adminselect), "%t", "Classes menu admin next", adminclass, nextadminname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use current class name and format item text.
|
||||||
|
Format(adminselect, sizeof(adminselect), "%t", "Classes menu admin current", adminclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add item to list.
|
||||||
AddMenuItem(menu, "", adminselect, admin_itemdraw);
|
AddMenuItem(menu, "", adminselect, admin_itemdraw);
|
||||||
|
|
||||||
// Set admin mode status string.
|
// Set admin mode status string.
|
||||||
if (ClassPlayerAdminMode[client])
|
if (ClassPlayerInAdminMode[client])
|
||||||
{
|
{
|
||||||
Format(adminmode, sizeof(adminmode), "%t", "On");
|
Format(adminmode, sizeof(adminmode), "%t", "On");
|
||||||
}
|
}
|
||||||
@ -247,6 +310,7 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot)
|
|||||||
new classindex;
|
new classindex;
|
||||||
new teamid;
|
new teamid;
|
||||||
new bool:autoclose = GetConVarBool(g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE]);
|
new bool:autoclose = GetConVarBool(g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE]);
|
||||||
|
new bool:iszombie = InfectIsClientInfected(client);
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@ -261,15 +325,27 @@ public ClassMenuSelectHandle(Handle:menu, MenuAction:action, client, slot)
|
|||||||
// Solve teamid from the class index.
|
// Solve teamid from the class index.
|
||||||
teamid = ClassGetTeamID(classindex, ZR_CLASS_CACHE_MODIFIED);
|
teamid = ClassGetTeamID(classindex, ZR_CLASS_CACHE_MODIFIED);
|
||||||
|
|
||||||
// Check if the class is a admin class.
|
// Check if the player is alive.
|
||||||
if (teamid == ZR_CLASS_TEAM_ADMINS)
|
if (IsPlayerAlive(client))
|
||||||
{
|
{
|
||||||
// Set the admin class to be used on next admin spawn.
|
// Set next spawn index if the player is changing the class on
|
||||||
ClassPlayerNextAdminClass[client] = classindex;
|
// his active team.
|
||||||
|
if ((iszombie && teamid == ZR_CLASS_TEAM_ZOMBIES) ||
|
||||||
|
(!iszombie && teamid == ZR_CLASS_TEAM_HUMANS) ||
|
||||||
|
(ClassPlayerInAdminMode[client] && teamid == ZR_CLASS_TEAM_ADMINS))
|
||||||
|
{
|
||||||
|
// Set class to be used on next spawn.
|
||||||
|
ClassSelectedNext[client][teamid] = classindex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set the players active class to the specified class.
|
// Directly change the selected class index.
|
||||||
|
ClassSelected[client][teamid] = classindex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Player isn't alive. The class can be directly changed.
|
||||||
ClassSelected[client][teamid] = classindex;
|
ClassSelected[client][teamid] = classindex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,6 @@ stock bool:ClassValidateIndex(classindex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the class team ID with a team ID.
|
* Compares the class team ID with a team ID.
|
||||||
*
|
*
|
||||||
|
@ -337,10 +337,15 @@ new ClassCount;
|
|||||||
new bool:ClassValidated;
|
new bool:ClassValidated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores what class that the player have selected, for each team.
|
* Stores what class the player has selected, for each team.
|
||||||
*/
|
*/
|
||||||
new ClassSelected[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT];
|
new ClassSelected[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores what class to be restored on next spawn, if available.
|
||||||
|
*/
|
||||||
|
new ClassSelectedNext[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for the currently selected team (admin menus).
|
* Cache for the currently selected team (admin menus).
|
||||||
*/
|
*/
|
||||||
@ -356,15 +361,10 @@ new ClassMultipliers:ClassAdminAttributeSelected[MAXPLAYERS + 1];
|
|||||||
*/
|
*/
|
||||||
new bool:ClassPlayerInAdminMode[MAXPLAYERS + 1];
|
new bool:ClassPlayerInAdminMode[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies whether a player is set to be in admin mode next spawn.
|
|
||||||
*/
|
|
||||||
new bool:ClassPlayerAdminMode[MAXPLAYERS + 1];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the admin class to use on next admin mode spawn.
|
* Specifies the admin class to use on next admin mode spawn.
|
||||||
*/
|
*/
|
||||||
new ClassPlayerNextAdminClass[MAXPLAYERS + 1];
|
//new ClassPlayerNextAdminClass[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for storing original model path before applying custom models. Used
|
* Cache for storing original model path before applying custom models. Used
|
||||||
@ -527,6 +527,9 @@ ClassLoad(bool:keepMultipliers = false)
|
|||||||
// Cache class data.
|
// Cache class data.
|
||||||
ClassReloadDataCache();
|
ClassReloadDataCache();
|
||||||
|
|
||||||
|
// Reset selected class indexes for next spawn.
|
||||||
|
ClassResetNextIndexes();
|
||||||
|
|
||||||
// Reset attribute multipliers, if not keeping.
|
// Reset attribute multipliers, if not keeping.
|
||||||
if (!keepMultipliers)
|
if (!keepMultipliers)
|
||||||
{
|
{
|
||||||
@ -542,7 +545,6 @@ ClassLoad(bool:keepMultipliers = false)
|
|||||||
// Set config data.
|
// Set config data.
|
||||||
ConfigSetConfigLoaded(File_Classes, true);
|
ConfigSetConfigLoaded(File_Classes, true);
|
||||||
ConfigSetConfigReloadFunc(File_Classes, GetFunctionByName(GetMyHandle(), "ClassOnConfigReload"));
|
ConfigSetConfigReloadFunc(File_Classes, GetFunctionByName(GetMyHandle(), "ClassOnConfigReload"));
|
||||||
// ConfigSetConfigHandle(File_Classes, INVALID_HANDLE);
|
|
||||||
ConfigSetConfigPath(File_Classes, pathclasses);
|
ConfigSetConfigPath(File_Classes, pathclasses);
|
||||||
|
|
||||||
// Remove key/value cache.
|
// Remove key/value cache.
|
||||||
@ -747,7 +749,7 @@ bool:ClassReloadPlayer(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Refresh cache and re-apply attributes.
|
// Refresh cache and re-apply attributes.
|
||||||
ClassOnClientDeath(client); // Dummy event to clean up stuff.
|
ClassOnClientDeath(client); // Dummy event to clean up and turn off stuff.
|
||||||
ClassReloadPlayerCache(client, activeclass);
|
ClassReloadPlayerCache(client, activeclass);
|
||||||
ClassApplyAttributes(client);
|
ClassApplyAttributes(client);
|
||||||
|
|
||||||
@ -774,6 +776,91 @@ ClassResetMultiplierCache()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the selected class indexes for next span on one or all clients.
|
||||||
|
*
|
||||||
|
* @param client Optional. Specify client to reset. Default is all.
|
||||||
|
*/
|
||||||
|
ClassResetNextIndexes(client = -1)
|
||||||
|
{
|
||||||
|
new teamid;
|
||||||
|
|
||||||
|
if (client > 0)
|
||||||
|
{
|
||||||
|
for (teamid = 0; teamid < ZR_CLASS_TEAMCOUNT; teamid++)
|
||||||
|
{
|
||||||
|
ClassSelectedNext[client][teamid] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (client = 1; client <= MAXPLAYERS; client++)
|
||||||
|
{
|
||||||
|
for (teamid = 0; teamid < ZR_CLASS_TEAMCOUNT; teamid++)
|
||||||
|
{
|
||||||
|
ClassSelectedNext[client][teamid] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores next class indexes on a player, if available.
|
||||||
|
* Note: Does not apply attributes. The classes are only marked as selected.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param excludeTeam Do not restore the specified team.
|
||||||
|
*/
|
||||||
|
ClassRestoreNextIndexes(client, excludeTeam = -1)
|
||||||
|
{
|
||||||
|
// Get next class indexes.
|
||||||
|
new zombie = ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES];
|
||||||
|
new human = ClassSelectedNext[client][ZR_CLASS_TEAM_HUMANS];
|
||||||
|
new admin = ClassSelectedNext[client][ZR_CLASS_TEAM_ADMINS];
|
||||||
|
|
||||||
|
// Check if the zombie team should be excluded.
|
||||||
|
if (excludeTeam != ZR_CLASS_TEAM_ZOMBIES)
|
||||||
|
{
|
||||||
|
// Validate zombie class index.
|
||||||
|
if (ClassValidateIndex(zombie))
|
||||||
|
{
|
||||||
|
// Mark next zombie class as selected.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = zombie;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset index.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_ZOMBIES] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the human team should be excluded.
|
||||||
|
if (excludeTeam != ZR_CLASS_TEAM_HUMANS)
|
||||||
|
{
|
||||||
|
// Validate human class index.
|
||||||
|
if (ClassValidateIndex(human))
|
||||||
|
{
|
||||||
|
// Mark next zombie class as selected.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = human;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset index.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_HUMANS] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the human team should be excluded.
|
||||||
|
if (excludeTeam != ZR_CLASS_TEAM_ADMINS)
|
||||||
|
{
|
||||||
|
// Validate admin class index.
|
||||||
|
if (ClassValidateIndex(admin))
|
||||||
|
{
|
||||||
|
// Mark next zombie class as selected.
|
||||||
|
ClassSelected[client][ZR_CLASS_TEAM_ADMINS] = admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset index.
|
||||||
|
ClassSelectedNext[client][ZR_CLASS_TEAM_ADMINS] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets default class indexes for each team on all players, or a single player
|
* Sets default class indexes for each team on all players, or a single player
|
||||||
* if specified.
|
* if specified.
|
||||||
@ -827,7 +914,6 @@ ClassClientSetDefaultIndexes(client = -1)
|
|||||||
ClassSelected[clientindex][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
ClassSelected[clientindex][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
||||||
ClassSelected[clientindex][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
ClassSelected[clientindex][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
||||||
ClassSelected[clientindex][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
ClassSelected[clientindex][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
||||||
ClassPlayerNextAdminClass[clientindex] = adminindex;
|
|
||||||
|
|
||||||
// Copy human class data to player cache.
|
// Copy human class data to player cache.
|
||||||
ClassReloadPlayerCache(client, humanindex);
|
ClassReloadPlayerCache(client, humanindex);
|
||||||
@ -838,7 +924,6 @@ ClassClientSetDefaultIndexes(client = -1)
|
|||||||
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
||||||
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
||||||
ClassSelected[client][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
ClassSelected[client][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
||||||
ClassPlayerNextAdminClass[client] = adminindex;
|
|
||||||
|
|
||||||
// Copy human class data to player cache.
|
// Copy human class data to player cache.
|
||||||
ClassReloadPlayerCache(client, humanindex);
|
ClassReloadPlayerCache(client, humanindex);
|
||||||
|
Loading…
Reference in New Issue
Block a user