From da56988372af177f4836b1e703c00d6af73a6282 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 8 Oct 2008 01:43:26 +0200 Subject: [PATCH] Made console commands for getting and setting class knockback: zr_set/get_class_knockback. --- changelog.txt | 3 ++ src/zombiereloaded.sp | 2 +- src/zr/classes.inc | 19 +++++++++ src/zr/commands.inc | 98 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 63677ee..8536c4d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2008.10.08 - 2.5.1.3 + * Made the console commands zr_set_class_knockback and zr_get_class_knockback. + 2008.10.07 - 2.5.1.2 * Added support for overriding class nvgs with the CVAR. -1: Disable override, 0/1: Off/On diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 0875db6..9bb0af4 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -15,7 +15,7 @@ #undef REQUIRE_PLUGIN #include -#define VERSION "2.5.1.2" +#define VERSION "2.5.1.3" #include "zr/zombiereloaded" #include "zr/global" diff --git a/src/zr/classes.inc b/src/zr/classes.inc index 6791fdc..7bc217c 100644 --- a/src/zr/classes.inc +++ b/src/zr/classes.inc @@ -120,6 +120,25 @@ GetClassName(classindex, String:name[], maxlen) strcopy(name, maxlen, arrayClasses[classindex][data_name]); } +GetClassIndex(String:name[]) +{ + new i; + decl String:current_name[64]; + + // Search through all classes for the specified name. + for (i = 0; i < classCount; i++) + { + GetClassName(i, current_name, sizeof(current_name)); + if (strcmp(name, current_name, false) == 0) + { + return i; + } + } + + // Class not found. + return -1; +} + GetClassModel(classindex, String:model[], maxlen) { strcopy(model, maxlen, arrayClasses[classindex][data_model]); diff --git a/src/zr/commands.inc b/src/zr/commands.inc index 93dfc54..b7f67bf 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -13,6 +13,9 @@ CreateCommands() RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon"); RegAdminCmd("zr_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon"); + + RegAdminCmd("zr_set_class_knockback", Command_SetClassKnockback, ADMFLAG_GENERIC, "Sets the knockback to the specified class. Usage: zr_set_class_knockback classname value"); + RegAdminCmd("zr_get_class_knockback", Command_GetClassKnockback, ADMFLAG_GENERIC, "Gets the knockback to the specified class. Usage: zr_get_class_knockback classname"); } public Action:Command_Infect(client, argc) @@ -114,5 +117,100 @@ public Action:Command_UnRestrict(client, argc) ZR_ReplyToCommand(client, "Weapon invalid", arg1); } + return Plugin_Handled; +} + +public Action:Command_SetClassKnockback(client, argc) +{ + if (argc < 2) + { + if (client == 0) + { + PrintToServer("Sets the specified class knockback. Usage: zr_set_class_knockback classname value"); + return Plugin_Handled; + } + else + { + PrintToConsole(client, "Sets the specified class knockback. Usage: zr_set_class_knockback classname value"); + return Plugin_Handled; + } + } + + decl String:classname[64]; + decl String:knockback_arg[8]; + new classindex; + new Float:knockback; + + GetCmdArg(1, classname, sizeof(classname)); + GetCmdArg(2, knockback_arg, sizeof(knockback_arg)); + classindex = GetClassIndex(classname); + knockback = StringToFloat(knockback_arg); + + if (classindex < 0) + { + if (client == 0) + { + PrintToServer("Could not find the class %s.", classname); + return Plugin_Handled; + } + else + { + PrintToConsole(client, "Could not find the class %s.", classname); + return Plugin_Handled; + } + } + + arrayClasses[classindex][data_knockback] = knockback; + return Plugin_Handled; +} + +public Action:Command_GetClassKnockback(client, argc) +{ + if (argc < 1) + { + if (client == 0) + { + PrintToServer("Gets the specified class knockback. Usage: zr_get_class_knockback classname"); + return Plugin_Handled; + } + else + { + PrintToConsole(client, "Gets the specified class knockback. Usage: zr_get_class_knockback classname"); + return Plugin_Handled; + } + } + + decl String:classname[64]; + new classindex; + new Float:knockback; + + GetCmdArg(1, classname, sizeof(classname)); + classindex = GetClassIndex(classname); + + if (classindex < 0) + { + if (client == 0) + { + PrintToServer("Could not find the class %s.", classname); + return Plugin_Handled; + } + else + { + PrintToConsole(client, "Could not find the class %s.", classname); + return Plugin_Handled; + } + } + + knockback = arrayClasses[classindex][data_knockback]; + + if (client == 0) + { + PrintToServer("Current knockback for %s: %f", classname, knockback); + } + else + { + PrintToConsole(client, "Current knockback for %s: %f", classname, knockback); + } + return Plugin_Handled; } \ No newline at end of file