Merged heads.

This commit is contained in:
Greyscale 2009-04-19 19:54:57 +02:00
commit d154ed163d
3 changed files with 14 additions and 13 deletions

View File

@ -25,6 +25,7 @@ enum ZRSettings
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
Handle:CVAR_CLASSES_DEFAULT_HUMAN,
Handle:CVAR_CLASSES_DEFAULT_ADMIN,
Handle:CVAR_CLASSES_FILE,
Handle:CVAR_ZOMBIE_HEALTH,
Handle:CVAR_ZOMBIE_SPEED,
Handle:CVAR_ZOMBIE_JUMP_DISTANCE,
@ -115,6 +116,7 @@ CreateCvars()
gCvars[CVAR_CLASSES_DEFAULT_ZOMBIE] = CreateConVar("zr_classes_default_zombie", "random", "Default zombie class selected for all players when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
gCvars[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "random", "Default human class selected for all players when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
gCvars[CVAR_CLASSES_DEFAULT_ADMIN] = CreateConVar("zr_classes_default_admin", "random", "Default admin-only class selected for admins when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
gCvars[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", "Class data file to read from, in Valves key/values format. The path is relative to the \"sourcemod\" folder.");
gCvars[CVAR_ZOMBIE_HEALTH] = CreateConVar("zr_zombie_health", "5000", "The default health of a zombie");
gCvars[CVAR_ZOMBIE_SPEED] = CreateConVar("zr_zombie_speed", "350", "How fast zombies travel (300: Default speed, 600: Double speed)");
gCvars[CVAR_ZOMBIE_JUMP_DISTANCE] = CreateConVar("zr_zombie_jump_distance", "0.1", "How far the zombie jumps, (0: Regular jump distance)");

View File

@ -246,14 +246,10 @@ new bool:ClassPlayerAdminMode[MAXPLAYERS + 1];
#include "zr/playerclasses/classcommands"
/**
* Loads class attributes from playerclasses.txt into the ClassData array. If
* any error occour the plugin load will fail.
*
* @param classfile Optional. Specifies what file to read from. Valves key/
* values format. The path is relative to the sourcemod
* folder.
* Loads class attributes from the class file into ClassData array. If any
* error occour the plugin load will fail, and errors will be logged.
*/
ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
ClassLoad()
{
// Make sure kvClassData is ready to use.
if (kvClassData != INVALID_HANDLE)
@ -262,13 +258,16 @@ ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
}
kvClassData = CreateKeyValues("classes");
decl String:classfile[256];
GetConVarString(gCvars[CVAR_CLASSES_FILE], classfile, sizeof(classfile));
// Try to load the class configuration file.
decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), classfile);
if (!FileToKeyValues(kvClassData, path))
{
SetFailState("Class data (\"%s\") missing from server.", path);
SetFailState("Could not load class data file (\"%s\"). Check path in zr_classes_file in the configuration file.", path);
}
// Try to find the first class.
@ -294,7 +293,7 @@ ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
// Maximum classes reached. Write a warning and exit the loop.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{
ZR_LogMessageFormatted(-1, "classes", "loading classes", "Warning: Maximum classes reached (%d). The rest is skipped.", _, ZR_CLASS_MAX + 1);
ZR_LogMessageFormatted(-1, "Classes", "Load", "Warning: Maximum classes reached (%d). Skipping other classes.", _, ZR_CLASS_MAX + 1);
}
break;
@ -358,7 +357,7 @@ ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
ClassData[ClassCount][class_enabled] = false;
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{
ZR_LogMessageFormatted(-1, "classes", "load", "Invalid class at index %d. Class error flags: %d.", LOG_FORMAT_TYPE_ERROR, ClassCount, ClassErrorFlags);
ZR_LogMessageFormatted(-1, "Classes", "Load", "Warning: Invalid class at index %d, disabled class. Class error flags: %d.", LOG_FORMAT_TYPE_ERROR, ClassCount, ClassErrorFlags);
}
}

View File

@ -143,19 +143,19 @@ stock ZR_LogMessageFormatted(client, const String:module[], const String:block[]
case LOG_FORMAT_TYPE_SIMPLE:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "Log -- %s", message);
Format(text, sizeof(text), "%s", message);
LogMessage(text);
}
case LOG_FORMAT_TYPE_FULL:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "Log (%s : %s) -- %s", module, block, buffer);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogMessage(text);
}
case LOG_FORMAT_TYPE_ERROR:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "Log (%s : %s) -- %s", module, block, buffer);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogError(text);
}
}