Made new admin_only class attribute.

This commit is contained in:
richard 2009-06-19 02:31:05 +02:00
parent 10fd954ede
commit 424a852d3a
5 changed files with 167 additions and 76 deletions

View File

@ -54,6 +54,7 @@
"enabled" "1" "enabled" "1"
"team" "0" "team" "0"
"team_default" "1" "team_default" "1"
"admin_only" "0"
"name" "Classic" "name" "Classic"
"description" "Need brains!!! Arrrrggghh!" "description" "Need brains!!! Arrrrggghh!"
@ -96,6 +97,7 @@
"enabled" "1" "enabled" "1"
"team" "0" "team" "0"
"team_default" "0" "team_default" "0"
"admin_only" "0"
"name" "Fast" "name" "Fast"
"description" "-HP | +Speed | +Jump | +Knockback" "description" "-HP | +Speed | +Jump | +Knockback"
@ -138,6 +140,7 @@
"enabled" "1" "enabled" "1"
"team" "0" "team" "0"
"team_default" "0" "team_default" "0"
"admin_only" "0"
"name" "Mutated" "name" "Mutated"
"description" "+HP | -Speed | +Jump | +Knockback" "description" "+HP | -Speed | +Jump | +Knockback"
@ -180,6 +183,7 @@
"enabled" "1" "enabled" "1"
"team" "0" "team" "0"
"team_default" "0" "team_default" "0"
"admin_only" "0"
"name" "Heavy" "name" "Heavy"
"description" "+HP | -Speed | -Jump | -Knockback" "description" "+HP | -Speed | -Jump | -Knockback"
@ -228,6 +232,7 @@
"enabled" "1" "enabled" "1"
"team" "1" "team" "1"
"team_default" "1" "team_default" "1"
"admin_only" "0"
"name" "Normal Human" "name" "Normal Human"
"description" "Default Counter-Strike settings" "description" "Default Counter-Strike settings"
@ -270,6 +275,7 @@
"enabled" "1" "enabled" "1"
"team" "1" "team" "1"
"team_default" "0" "team_default" "0"
"admin_only" "0"
"name" "Speedy" "name" "Speedy"
"description" "Fast human" "description" "Fast human"
@ -312,6 +318,7 @@
"enabled" "1" "enabled" "1"
"team" "1" "team" "1"
"team_default" "0" "team_default" "0"
"admin_only" "0"
"name" "Light" "name" "Light"
"description" "Regular human with improved jump skills" "description" "Regular human with improved jump skills"

View File

@ -132,6 +132,39 @@ stock bool:ClassGetTeamDefault(index, cachetype = ZR_CLASS_CACHE_MODIFIED)
return false; return false;
} }
/**
* Checks if the specified class is for admins only or not.
*
* @param index Index of the class in a class cache or a client index,
* depending on the cache type specified.
* @param cachetype Optional. Specifies what class cache to read from. Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
* ZR_CLASS_CACHE_MODIFIED (default) - Changed/newest class
* data.
* ZR_CLASS_CACHE_PLAYER - Player cache. If this one is used,
* index will be used as a client index.
* @return True if it's for admins only, false otherwise.
*/
stock bool:ClassGetAdminOnly(index, cachetype = ZR_CLASS_CACHE_MODIFIED)
{
switch (cachetype)
{
case ZR_CLASS_CACHE_ORIGINAL:
{
return ClassData[index][class_admin_only];
}
case ZR_CLASS_CACHE_MODIFIED:
{
return ClassDataCache[index][class_admin_only];
}
case ZR_CLASS_CACHE_PLAYER:
{
return ClassPlayerCache[index][class_admin_only];
}
}
return false;
}
/** /**
* Gets the class name to be displayed in the class menu. * Gets the class name to be displayed in the class menu.
* *
@ -963,6 +996,10 @@ stock ClassAttributeNameToFlag(const String:attributename[])
{ {
return ZR_CLASS_FLAG_TEAM_DEFAULT; return ZR_CLASS_FLAG_TEAM_DEFAULT;
} }
else if (StrEqual(attributename, "admin_only", false))
{
return ZR_CLASS_FLAG_ADMIN_ONLY;
}
else if (StrEqual(attributename, "name", false)) else if (StrEqual(attributename, "name", false))
{ {
return ZR_CLASS_FLAG_NAME; return ZR_CLASS_FLAG_NAME;
@ -1121,7 +1158,8 @@ stock ClassDataTypes:ClassGetAttributeType(attributeflag)
// Boolean. // Boolean.
case ZR_CLASS_FLAG_ENABLED, case ZR_CLASS_FLAG_ENABLED,
ZR_CLASS_FLAG_NVGS, ZR_CLASS_FLAG_NVGS,
ZR_CLASS_FLAG_NO_FALL_DAMAGE: ZR_CLASS_FLAG_NO_FALL_DAMAGE,
ZR_CLASS_FLAG_ADMIN_ONLY:
{ {
return ClassDataType_Boolean; return ClassDataType_Boolean;
} }

View File

@ -177,6 +177,7 @@ ClassMenuSelect(client, teamid)
new Handle:menu = CreateMenu(ClassMenuSelectHandle); new Handle:menu = CreateMenu(ClassMenuSelectHandle);
new arraycount; new arraycount;
new classindex; new classindex;
new bool:clientisadmin = ZRIsClientAdmin(client);
decl String:title[64]; decl String:title[64];
decl String:classname[64]; decl String:classname[64];
@ -207,7 +208,8 @@ ClassMenuSelect(client, teamid)
new Handle:classarray = CreateArray(); new Handle:classarray = CreateArray();
// Copy all class indexes into the array, with the specified team filter. // Copy all class indexes into the array, with the specified team filter.
if (ClassAddToArray(classarray, teamid)) // Also list admin-only classes if client is a admin.
if (ClassAddToArray(classarray, teamid, _, clientisadmin))
{ {
// Get number of classes. // Get number of classes.
arraycount = GetArraySize(classarray); arraycount = GetArraySize(classarray);

View File

@ -47,8 +47,8 @@ stock bool:ClassValidateTeamRequirements(cachetype = ZR_CLASS_CACHE_ORIGINAL)
} }
// Test if a zombie and human class was found. // Test if a zombie and human class was found.
zombieindex = ClassGetFirstClass(ZR_CLASS_TEAM_ZOMBIES, _, cachetype); zombieindex = ClassGetFirstClass(ZR_CLASS_TEAM_ZOMBIES, _, _, cachetype);
humanindex = ClassGetFirstClass(ZR_CLASS_TEAM_HUMANS, _, cachetype); humanindex = ClassGetFirstClass(ZR_CLASS_TEAM_HUMANS, _, _, cachetype);
// Validate indexes. // Validate indexes.
if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex)) if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex))
@ -79,8 +79,8 @@ stock bool:ClassValidateTeamDefaults(cachetype = ZR_CLASS_CACHE_ORIGINAL)
} }
// Test if a default zombie and human class was found. // Test if a default zombie and human class was found.
zombieindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ZOMBIES, _, cachetype); zombieindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ZOMBIES, _, _, cachetype);
humanindex = ClassGetDefaultClass(ZR_CLASS_TEAM_HUMANS, _, cachetype); humanindex = ClassGetDefaultClass(ZR_CLASS_TEAM_HUMANS, _, _, cachetype);
// Validate indexes. // Validate indexes.
if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex)) if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex))
@ -449,10 +449,12 @@ stock Float:ClassGetAttributeMultiplier(client, ClassMultipliers:attribute)
* specified array. * specified array.
* *
* @param array The destination array to add class indexes. * @param array The destination array to add class indexes.
* @param teamfilter Optional. The team ID to filter. A negative value for * @param teamfilter Optional. The team ID to filter. A negative value
* no filter (default). * for no filter (default).
* @param ignoreEnabled Optional. Ignore the class's enabled attribute. Default * @param ignoreEnabled Optional. Ignore whether the class is enabled or
* is false. * not. Default is false.
* @param ignoreAdminOnly Optional. Ignore whether the class is for admins
* only or not. Default is false.
* @param cachetype Optional. Specifies what class cache to read from. * @param cachetype Optional. Specifies what class cache to read from.
* Options: * Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
@ -461,7 +463,7 @@ stock Float:ClassGetAttributeMultiplier(client, ClassMultipliers:attribute)
* @return True on success. False on error or if no classes were added or * @return True on success. False on error or if no classes were added or
* found. * found.
*/ */
stock bool:ClassAddToArray(Handle:array, teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED) stock bool:ClassAddToArray(Handle:array, teamfilter = -1, bool:ignoreEnabled = false, bool:ignoreAdminOnly = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
{ {
// Validate the array. // Validate the array.
if (array == INVALID_HANDLE) if (array == INVALID_HANDLE)
@ -489,6 +491,13 @@ stock bool:ClassAddToArray(Handle:array, teamfilter = -1, bool:ignoreEnabled = f
continue; continue;
} }
if (!ignoreAdminOnly && ClassGetAdminOnly(classindex, cachetype))
{
// The class is for admins only. This attribute isn't ignored so
// skip to the next class.
continue;
}
// Check team filtering. // Check team filtering.
if (has_filter) if (has_filter)
{ {
@ -524,7 +533,10 @@ stock bool:ClassAddToArray(Handle:array, teamfilter = -1, bool:ignoreEnabled = f
* *
* @param teamfilter Optional. The team ID to filter. Negative value for * @param teamfilter Optional. The team ID to filter. Negative value for
* no filter (default). * no filter (default).
* @param ignoreEnabled Ignore the enabled attribute. * @param ignoreEnabled Optional. Ignore whether the class is enabled or
* not. Default is false.
* @param ignoreAdminOnly Optional. Ignore whether the class is for admins
* only or not. Default is false.
* @param cachetype Optional. Specifies what class cache to read from. * @param cachetype Optional. Specifies what class cache to read from.
* Options: * Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
@ -532,7 +544,7 @@ stock bool:ClassAddToArray(Handle:array, teamfilter = -1, bool:ignoreEnabled = f
* class data. * class data.
* @return Number of total classes or classes in the specified team. * @return Number of total classes or classes in the specified team.
*/ */
stock ClassCountTeam(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED) stock ClassCountTeam(teamfilter = -1, bool:ignoreEnabled = false, bool:ignoreAdminOnly = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
{ {
// Check if there are no classes. // Check if there are no classes.
if (ClassCount == 0) if (ClassCount == 0)
@ -554,6 +566,13 @@ stock ClassCountTeam(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR
continue; continue;
} }
if (!ignoreAdminOnly && ClassGetAdminOnly(classindex, cachetype))
{
// The class is for admins only. This attribute isn't ignored so
// skip to the next class.
continue;
}
// Check team filtering. // Check team filtering.
if (has_filter) if (has_filter)
{ {
@ -578,10 +597,12 @@ stock ClassCountTeam(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR
/** /**
* Gets a random class index from a specified team or from all classes. * Gets a random class index from a specified team or from all classes.
* *
* @param teamfilter Optional. The team ID to filter. A negative value for * @param teamfilter Optional. The team ID to filter. A negative value
* no filter (default). * for no filter (default).
* @param ignoreEnabled Optional. Ignore the class's enabled attribute. Default * @param ignoreEnabled Optional. Ignore whether the class is enabled or
* is false. * not. Default is false.
* @param ignoreAdminOnly Optional. Ignore whether the class is for admins
* only or not. Default is false.
* @param cachetype Optional. Specifies what class cache to read from. * @param cachetype Optional. Specifies what class cache to read from.
* Options: * Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
@ -589,7 +610,7 @@ stock ClassCountTeam(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR
* class data. * class data.
* @return The class index if successful, or -1 on error. * @return The class index if successful, or -1 on error.
*/ */
stock ClassGetRandomClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED) stock ClassGetRandomClass(teamfilter = -1, bool:ignoreEnabled = false, bool:ignoreAdminOnly = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
{ {
new Handle:classarray; new Handle:classarray;
new arraycount; new arraycount;
@ -598,7 +619,7 @@ stock ClassGetRandomClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
classarray = CreateArray(); classarray = CreateArray();
// Try to get a class list. // Try to get a class list.
if (ClassAddToArray(classarray, teamfilter, ignoreEnabled, cachetype)) if (ClassAddToArray(classarray, teamfilter, ignoreEnabled, ignoreAdminOnly, cachetype))
{ {
// Get a random index from the new class array. // Get a random index from the new class array.
arraycount = GetArraySize(classarray); arraycount = GetArraySize(classarray);
@ -618,10 +639,12 @@ stock ClassGetRandomClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
* Gets the first class index, or the first class index with the specified team * Gets the first class index, or the first class index with the specified team
* ID. * ID.
* *
* @param teamfilter Optional. The team ID to filter. A negative value for * @param teamfilter Optional. The team ID to filter. A negative value
* no filter (default). * for no filter (default).
* @param ignoreEnabled Optional. Ignore the class's enabled attribute. Default * @param ignoreEnabled Optional. Ignore whether the class is enabled or
* is false. * not. Default is false.
* @param ignoreAdminOnly Optional. Ignore whether the class is for admins
* only or not. Default is false.
* @param cachetype Optional. Specifies what class cache to read from. * @param cachetype Optional. Specifies what class cache to read from.
* Options: * Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
@ -630,7 +653,7 @@ stock ClassGetRandomClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
* @return The first class index, or the first class index with the specified * @return The first class index, or the first class index with the specified
* team ID. -1 on error. * team ID. -1 on error.
*/ */
stock ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED) stock ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, bool:ignoreAdminOnly = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
{ {
// Check if there are no classes. // Check if there are no classes.
if (ClassCount == 0) if (ClassCount == 0)
@ -645,6 +668,15 @@ stock ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
{ {
if (!ignoreEnabled && !ClassIsEnabled(classindex, cachetype)) if (!ignoreEnabled && !ClassIsEnabled(classindex, cachetype))
{ {
// The class is disabled and the enabled attribute is NOT ignored.
// Skip to the next class.
continue;
}
if (!ignoreAdminOnly && ClassGetAdminOnly(classindex, cachetype))
{
// The class is for admins only. This attribute isn't ignored so
// skip to the next class.
continue; continue;
} }
@ -670,8 +702,10 @@ stock ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
* Gets the first class marked as default for the specified team. * Gets the first class marked as default for the specified team.
* *
* @param teamid The team ID. * @param teamid The team ID.
* @param ignoreEnabled Optional. Ignore the class's enabled attribute. Default * @param ignoreEnabled Optional. Ignore whether the class is enabled or
* is false. * not. Default is false.
* @param ignoreAdminOnly Optional. Ignore whether the class is for admins
* only or not. Default is false.
* @param cachetype Optional. Specifies what class cache to read from. * @param cachetype Optional. Specifies what class cache to read from.
* Options: * Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data. * ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
@ -679,7 +713,7 @@ stock ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype
* class data. * class data.
* @return The first default class index. -1 on error. * @return The first default class index. -1 on error.
*/ */
stock ClassGetDefaultClass(teamid, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED) stock ClassGetDefaultClass(teamid, bool:ignoreEnabled = false, bool:ignoreAdminOnly = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
{ {
new Handle:classarray; new Handle:classarray;
new arraycount; new arraycount;
@ -688,7 +722,7 @@ stock ClassGetDefaultClass(teamid, bool:ignoreEnabled = false, cachetype = ZR_CL
classarray = CreateArray(); classarray = CreateArray();
// Get all classes from the specified team. // Get all classes from the specified team.
if (!ClassAddToArray(classarray, teamid, ignoreEnabled, cachetype)) if (!ClassAddToArray(classarray, teamid, ignoreEnabled, ignoreAdminOnly, cachetype))
{ {
// Failed to get classes. // Failed to get classes.
return -1; return -1;
@ -759,7 +793,7 @@ stock ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
if (strcmp(classname, "random", false) == 0) if (strcmp(classname, "random", false) == 0)
{ {
// Get a list of all classes with the specified team ID. // Get a list of all classes with the specified team ID.
classindex = ClassGetRandomClass(teamid, _, cachetype); classindex = ClassGetRandomClass(teamid, _, _, cachetype);
// Validate the result, in case there were errors. // Validate the result, in case there were errors.
if (ClassValidateIndex(classindex)) if (ClassValidateIndex(classindex))
@ -791,7 +825,7 @@ stock ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
// The class index is invalid or the team IDs didn't match. // The class index is invalid or the team IDs didn't match.
// Because it's user input, we'll fall back to the first class // Because it's user input, we'll fall back to the first class
// in the specified team, and log a warning. // in the specified team, and log a warning.
classindex = ClassGetFirstClass(teamid, _, cachetype); classindex = ClassGetFirstClass(teamid, _, _, cachetype);
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Playerclasses, "Default Spawn Class", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", classname, teamid); LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Playerclasses, "Default Spawn Class", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", classname, teamid);
@ -813,6 +847,6 @@ stock ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
else else
{ {
// Blank class name, get the default class and return the index. // Blank class name, get the default class and return the index.
return ClassGetDefaultClass(teamid, _, cachetype); return ClassGetDefaultClass(teamid, _, _, cachetype);
} }
} }

View File

@ -91,6 +91,7 @@
#define ZR_CLASS_DEFAULT_ENABLED true #define ZR_CLASS_DEFAULT_ENABLED true
#define ZR_CLASS_DEFAULT_TEAM ZR_CLASS_TEAM_ZOMBIES #define ZR_CLASS_DEFAULT_TEAM ZR_CLASS_TEAM_ZOMBIES
#define ZR_CLASS_DEFAULT_TEAM_DEFAULT true #define ZR_CLASS_DEFAULT_TEAM_DEFAULT true
#define ZR_CLASS_DEFAULT_ADMIN_ONLY false
#define ZR_CLASS_DEFAULT_NAME "classic" #define ZR_CLASS_DEFAULT_NAME "classic"
#define ZR_CLASS_DEFAULT_DESCRIPTION "Need brains!!! Arrrrggghh!" #define ZR_CLASS_DEFAULT_DESCRIPTION "Need brains!!! Arrrrggghh!"
#define ZR_CLASS_DEFAULT_MODEL_PATH "models/player/zh/zh_zombie003.mdl" #define ZR_CLASS_DEFAULT_MODEL_PATH "models/player/zh/zh_zombie003.mdl"
@ -165,29 +166,30 @@
#define ZR_CLASS_FLAG_ENABLED (1<<0) #define ZR_CLASS_FLAG_ENABLED (1<<0)
#define ZR_CLASS_FLAG_TEAM (1<<1) #define ZR_CLASS_FLAG_TEAM (1<<1)
#define ZR_CLASS_FLAG_TEAM_DEFAULT (1<<2) #define ZR_CLASS_FLAG_TEAM_DEFAULT (1<<2)
#define ZR_CLASS_FLAG_NAME (1<<3) #define ZR_CLASS_FLAG_ADMIN_ONLY (1<<3)
#define ZR_CLASS_FLAG_DESCRIPTION (1<<4) #define ZR_CLASS_FLAG_NAME (1<<4)
#define ZR_CLASS_FLAG_MODEL_PATH (1<<5) #define ZR_CLASS_FLAG_DESCRIPTION (1<<5)
#define ZR_CLASS_FLAG_ALPHA_INITIAL (1<<6) #define ZR_CLASS_FLAG_MODEL_PATH (1<<6)
#define ZR_CLASS_FLAG_ALPHA_DAMAGED (1<<7) #define ZR_CLASS_FLAG_ALPHA_INITIAL (1<<7)
#define ZR_CLASS_FLAG_ALPHA_DAMAGE (1<<8) #define ZR_CLASS_FLAG_ALPHA_DAMAGED (1<<8)
#define ZR_CLASS_FLAG_OVERLAY_PATH (1<<9) #define ZR_CLASS_FLAG_ALPHA_DAMAGE (1<<9)
#define ZR_CLASS_FLAG_NVGS (1<<10) #define ZR_CLASS_FLAG_OVERLAY_PATH (1<<10)
#define ZR_CLASS_FLAG_FOV (1<<11) #define ZR_CLASS_FLAG_NVGS (1<<11)
#define ZR_CLASS_FLAG_HAS_NAPALM (1<<12) #define ZR_CLASS_FLAG_FOV (1<<12)
#define ZR_CLASS_FLAG_NAPALM_TIME (1<<13) #define ZR_CLASS_FLAG_HAS_NAPALM (1<<13)
#define ZR_CLASS_FLAG_IMMUNITY_MODE (1<<14) #define ZR_CLASS_FLAG_NAPALM_TIME (1<<14)
#define ZR_CLASS_FLAG_IMMUNITY_AMOUNT (1<<15) #define ZR_CLASS_FLAG_IMMUNITY_MODE (1<<15)
#define ZR_CLASS_FLAG_NO_FALL_DAMAGE (1<<16) #define ZR_CLASS_FLAG_IMMUNITY_AMOUNT (1<<16)
#define ZR_CLASS_FLAG_HEALTH (1<<17) #define ZR_CLASS_FLAG_NO_FALL_DAMAGE (1<<17)
#define ZR_CLASS_FLAG_HEALTH_REGEN_INTERVAL (1<<18) #define ZR_CLASS_FLAG_HEALTH (1<<18)
#define ZR_CLASS_FLAG_HEALTH_REGEN_AMOUNT (1<<19) #define ZR_CLASS_FLAG_HEALTH_REGEN_INTERVAL (1<<19)
#define ZR_CLASS_FLAG_HEALTH_INFECT_GAIN (1<<20) #define ZR_CLASS_FLAG_HEALTH_REGEN_AMOUNT (1<<20)
#define ZR_CLASS_FLAG_KILL_BONUS (1<<21) #define ZR_CLASS_FLAG_HEALTH_INFECT_GAIN (1<<21)
#define ZR_CLASS_FLAG_SPEED (1<<22) #define ZR_CLASS_FLAG_KILL_BONUS (1<<22)
#define ZR_CLASS_FLAG_KNOCKBACK (1<<23) #define ZR_CLASS_FLAG_SPEED (1<<23)
#define ZR_CLASS_FLAG_JUMP_HEIGHT (1<<24) #define ZR_CLASS_FLAG_KNOCKBACK (1<<24)
#define ZR_CLASS_FLAG_JUMP_DISTANCE (1<<25) #define ZR_CLASS_FLAG_JUMP_HEIGHT (1<<25)
#define ZR_CLASS_FLAG_JUMP_DISTANCE (1<<26)
/** /**
* @endsection * @endsection
*/ */
@ -201,6 +203,7 @@ enum ClassAttributes
bool:class_enabled, bool:class_enabled,
class_team, class_team,
bool:class_team_default, bool:class_team_default,
bool:class_admin_only,
String:class_name[64], String:class_name[64],
String:class_description[256], String:class_description[256],
@ -426,6 +429,7 @@ ClassLoad(bool:keepMultipliers = false)
ClassData[ClassCount][class_enabled] = bool:KvGetNum(kvClassData, "enabled", ZR_CLASS_DEFAULT_ENABLED); ClassData[ClassCount][class_enabled] = bool:KvGetNum(kvClassData, "enabled", ZR_CLASS_DEFAULT_ENABLED);
ClassData[ClassCount][class_team] = KvGetNum(kvClassData, "team", ZR_CLASS_DEFAULT_TEAM); ClassData[ClassCount][class_team] = KvGetNum(kvClassData, "team", ZR_CLASS_DEFAULT_TEAM);
ClassData[ClassCount][class_team_default] = bool:KvGetNum(kvClassData, "team_default", ZR_CLASS_DEFAULT_TEAM_DEFAULT); ClassData[ClassCount][class_team_default] = bool:KvGetNum(kvClassData, "team_default", ZR_CLASS_DEFAULT_TEAM_DEFAULT);
ClassData[ClassCount][class_admin_only] = bool:KvGetNum(kvClassData, "admin_only", ZR_CLASS_DEFAULT_ADMIN_ONLY);
KvGetString(kvClassData, "name", name, sizeof(name), ZR_CLASS_DEFAULT_NAME); KvGetString(kvClassData, "name", name, sizeof(name), ZR_CLASS_DEFAULT_NAME);
strcopy(ClassData[ClassCount][class_name], 64, name); strcopy(ClassData[ClassCount][class_name], 64, name);
@ -553,6 +557,7 @@ bool:ClassReloadDataCache()
ClassDataCache[classindex][class_enabled] = ClassData[classindex][class_enabled]; ClassDataCache[classindex][class_enabled] = ClassData[classindex][class_enabled];
ClassDataCache[classindex][class_team] = ClassData[classindex][class_team]; ClassDataCache[classindex][class_team] = ClassData[classindex][class_team];
ClassDataCache[classindex][class_team_default] = ClassData[classindex][class_team_default]; ClassDataCache[classindex][class_team_default] = ClassData[classindex][class_team_default];
ClassDataCache[classindex][class_admin_only] = ClassData[classindex][class_admin_only];
strcopy(ClassDataCache[classindex][class_name], 64, ClassData[classindex][class_name]); strcopy(ClassDataCache[classindex][class_name], 64, ClassData[classindex][class_name]);
strcopy(ClassDataCache[classindex][class_description], 256, ClassData[classindex][class_description]); strcopy(ClassDataCache[classindex][class_description], 256, ClassData[classindex][class_description]);
@ -616,6 +621,7 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
ClassPlayerCache[client][class_enabled] = ClassData[classindex][class_enabled]; ClassPlayerCache[client][class_enabled] = ClassData[classindex][class_enabled];
ClassPlayerCache[client][class_team] = ClassData[classindex][class_team]; ClassPlayerCache[client][class_team] = ClassData[classindex][class_team];
ClassPlayerCache[client][class_team_default] = ClassData[classindex][class_team_default]; ClassPlayerCache[client][class_team_default] = ClassData[classindex][class_team_default];
ClassPlayerCache[client][class_admin_only] = ClassData[classindex][class_admin_only];
strcopy(ClassPlayerCache[client][class_name], 64, ClassData[classindex][class_name]); strcopy(ClassPlayerCache[client][class_name], 64, ClassData[classindex][class_name]);
strcopy(ClassPlayerCache[client][class_description], 256, ClassData[classindex][class_description]); strcopy(ClassPlayerCache[client][class_description], 256, ClassData[classindex][class_description]);
@ -654,6 +660,7 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
ClassPlayerCache[client][class_enabled] = ClassDataCache[classindex][class_enabled]; ClassPlayerCache[client][class_enabled] = ClassDataCache[classindex][class_enabled];
ClassPlayerCache[client][class_team] = ClassDataCache[classindex][class_team]; ClassPlayerCache[client][class_team] = ClassDataCache[classindex][class_team];
ClassPlayerCache[client][class_team_default] = ClassDataCache[classindex][class_team_default]; ClassPlayerCache[client][class_team_default] = ClassDataCache[classindex][class_team_default];
ClassPlayerCache[client][class_admin_only] = ClassDataCache[classindex][class_admin_only];
strcopy(ClassPlayerCache[client][class_name], 64, ClassDataCache[classindex][class_name]); strcopy(ClassPlayerCache[client][class_name], 64, ClassDataCache[classindex][class_name]);
strcopy(ClassPlayerCache[client][class_description], 256, ClassDataCache[classindex][class_description]); strcopy(ClassPlayerCache[client][class_description], 256, ClassDataCache[classindex][class_description]);
@ -852,6 +859,9 @@ ClassDumpData(index, cachetype, String:buffer[], maxlen)
Format(attribute, sizeof(attribute), "team_default: \"%d\"\n", ClassGetTeamDefault(index, cachetype)); Format(attribute, sizeof(attribute), "team_default: \"%d\"\n", ClassGetTeamDefault(index, cachetype));
cellcount += StrCat(buffer, maxlen, attribute); cellcount += StrCat(buffer, maxlen, attribute);
Format(attribute, sizeof(attribute), "admin_only: \"%d\"\n", ClassGetAdminOnly(index, cachetype));
cellcount += StrCat(buffer, maxlen, attribute);
ClassGetName(index, format_buffer, sizeof(format_buffer), cachetype); ClassGetName(index, format_buffer, sizeof(format_buffer), cachetype);
Format(attribute, sizeof(attribute), "name: \"%s\"\n", format_buffer); Format(attribute, sizeof(attribute), "name: \"%s\"\n", format_buffer);
cellcount += StrCat(buffer, maxlen, attribute); cellcount += StrCat(buffer, maxlen, attribute);