diff --git a/changelog.txt b/changelog.txt index d8c6554..52c5e13 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +2008.10.11 - 2.5.1.6 - Richard + * Fixed bugs in IsClientPlayer + * Made a zombie admin menu (zr_admin). + 2008.10.10 - 2.5.1.6 - Richard * Fixed night vision state not remembered. If zomibes turn off zvision, nvgs will be off next time too. diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 922275a..4a4b343 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -15,7 +15,7 @@ #undef REQUIRE_PLUGIN #include -#define VERSION "2.5.1.6" +#define VERSION "2.5.1.7" #include "zr/zombiereloaded" #include "zr/global" @@ -28,6 +28,7 @@ #include "zr/overlays" #include "zr/zombie" #include "zr/menu" +#include "zr/zradmin" #include "zr/sayhooks" #include "zr/weaponrestrict" #include "zr/damagecontrol" diff --git a/src/zr/commands.inc b/src/zr/commands.inc index b7f67bf..6de64e3 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -14,8 +14,11 @@ 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"); + RegAdminCmd("zr_set_class_knockback", Command_SetClassKnockback, ADMFLAG_GENERIC, "Sets the knockback to the specified class. Usage: zr_set_class_knockback "); + RegAdminCmd("zr_get_class_knockback", Command_GetClassKnockback, ADMFLAG_GENERIC, "Gets the knockback to the specified class. Usage: zr_get_class_knockback "); + + RegAdminCmd("zr_admin", Command_AdminMenu, ADMFLAG_GENERIC, "Displays the admin menu for Zombie: Reloaded."); + RegAdminCmd("zr_knockback_m", Command_KnockbackMMenu, ADMFLAG_GENERIC, "Displays the knockback multiplier menu."); } public Action:Command_Infect(client, argc) @@ -212,5 +215,33 @@ public Action:Command_GetClassKnockback(client, argc) PrintToConsole(client, "Current knockback for %s: %f", classname, knockback); } + return Plugin_Handled; +} + +public Action:Command_AdminMenu(client, argc) +{ + if (IsClientPlayer(client)) + { + ZRAdminMenu(client); + } + else + { + PrintToServer("This menu cannot be used in the console. Client: %d", client); + if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client); + } + return Plugin_Handled; +} + +public Action:Command_KnockbackMMenu(client, argc) +{ + if (IsClientPlayer(client)) + { + ZRKnockbackMMenu(client); + } + else + { + PrintToServer("This menu cannot be used in the console. Client: %d", client); + if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client); + } return Plugin_Handled; } \ No newline at end of file diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 167b2c8..8c03bec 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -193,7 +193,7 @@ bool:IntToBool(intval) bool:IsClientPlayer(client) { - if (client > 1 && client <= maxclients) + if (client > 0 && client <= maxclients) { return true; } diff --git a/src/zr/zradmin.inc b/src/zr/zradmin.inc new file mode 100644 index 0000000..6fcfd4c --- /dev/null +++ b/src/zr/zradmin.inc @@ -0,0 +1,415 @@ +/** + * ==================== + * Zombie:Reloaded + * File: admin.inc + * Author: Richard H + * ==================== + */ + +#include "include/adminmenu.inc" +new SelectedClassIndex[MAXPLAYERS]; + +ZRAdminMenu(client) +{ + new Handle:zr_admin_menu = CreateMenu(ZRAdminMenuHandle); + + SetMenuTitle(zr_admin_menu, "ZR admin menu"); + + decl String:zknockbackm[] = "Change knockback multiplier"; + decl String:zknockback[] = "Change class knockback"; + decl String:znvgs[] = "Change night vision settings"; + decl String:zinfect[] = "Infect a player"; + decl String:zspawn[] = "Spawn a player"; + decl String:zrestrict[] = "Restrict a weapon"; + decl String:zunrestrict[] = "Unrestrict a weapon"; + + + AddMenuItem(zr_admin_menu, "zknockbackm", zknockbackm); + AddMenuItem(zr_admin_menu, "zknockback", zknockback); + AddMenuItem(zr_admin_menu, "znvgs", znvgs); + AddMenuItem(zr_admin_menu, "zinfect", zinfect); + AddMenuItem(zr_admin_menu, "zspawn", zspawn, ITEMDRAW_DISABLED); + AddMenuItem(zr_admin_menu, "zrestrict", zrestrict, ITEMDRAW_DISABLED); + AddMenuItem(zr_admin_menu, "zunrestrict", zunrestrict, ITEMDRAW_DISABLED); + + DisplayMenu(zr_admin_menu, client, MENU_TIME_FOREVER); +} + +public ZRAdminMenuHandle(Handle:zr_admin_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + switch(slot) + { + case 0: + { + ZRKnockbackMMenu(client); + } + case 1: + { + ZRClassSelectMenu(client); + } + case 2: + { + ZRNVGSMenu(client); + } + case 3: + { + ZRInfectMenu(client); + } + case 4: + { + // ZRSpawnMenu(client); + } + case 5: + { + // restrict + } + case 6: + { + // unrestrict + } + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_admin_menu); + } +} + +ZRKnockbackMMenu(client) +{ + new Handle:zr_knockbackm_menu = CreateMenu(ZRKnockbackMHandle); + new Float:current_knockback = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]); + + SetMenuTitle(zr_knockbackm_menu, "Change knockback multiplier\nCurrent value: %f\n\n", current_knockback); + + decl String:zincreasehalf[] = "Increase by 0.5"; + decl String:zincreasedeca[] = "Increase by 0.1"; + decl String:zdecreasedeci[] = "Decrease by 0.1"; + decl String:zdecreasehalf[] = "Decrease by 0.5"; + + AddMenuItem(zr_knockbackm_menu, "zincreasehalf", zincreasehalf); + AddMenuItem(zr_knockbackm_menu, "zincreasedeca", zincreasedeca); + AddMenuItem(zr_knockbackm_menu, "zdecreasedeci", zdecreasedeci); + AddMenuItem(zr_knockbackm_menu, "zdecreasehalf", zdecreasehalf); + + SetMenuExitBackButton(zr_knockbackm_menu, true); + + DisplayMenu(zr_knockbackm_menu, client, MENU_TIME_FOREVER); +} + +public ZRKnockbackMHandle(Handle:zr_knockbackm_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + switch(slot) + { + case 0: + { + AddToKnockbackMultiplier(0.5); + ZRKnockbackMMenu(client); + } + case 1: + { + AddToKnockbackMultiplier(0.1); + ZRKnockbackMMenu(client); + } + case 2: + { + AddToKnockbackMultiplier(-0.1); + ZRKnockbackMMenu(client); + } + case 3: + { + AddToKnockbackMultiplier(-0.5); + ZRKnockbackMMenu(client); + } + } + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRAdminMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_knockbackm_menu); + } +} + +ZRClassSelectMenu(client) +{ + new Handle:zr_class_select_menu = CreateMenu(ZRClassSelectHandle); + new classindex; + + SetMenuTitle(zr_class_select_menu, "Select class to change:\n"); + + for (classindex = 0; classindex < classCount; classindex++) + { + AddMenuItem(zr_class_select_menu, arrayClasses[classindex][data_name], arrayClasses[classindex][data_name]); + } + + SetMenuExitBackButton(zr_class_select_menu, true); + DisplayMenu(zr_class_select_menu, client, MENU_TIME_FOREVER); +} + +public ZRClassSelectHandle(Handle:zr_class_select_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + SelectedClassIndex[client] = slot; + ZRClassKnockbackMenu(client, slot); + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRAdminMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_class_select_menu); + } +} + +ZRClassKnockbackMenu(client, classindex) +{ + new Handle:zr_knockback_menu = CreateMenu(ZRClassKnockbackHandle); + new Float:current_knockback = arrayClasses[classindex][data_knockback]; + new String:classname[64]; + GetClassName(classindex, classname, sizeof(classname)); + + SetMenuTitle(zr_knockback_menu, "Change %s knockback\nCurrent value: %f\n\n", classname, current_knockback); + + decl String:zincreasehalf[] = "Increase by 0.5"; + decl String:zincreasedeca[] = "Increase by 0.1"; + decl String:zdecreasedeci[] = "Decrease by 0.1"; + decl String:zdecreasehalf[] = "Decrease by 0.5"; + + AddMenuItem(zr_knockback_menu, "zincreasehalf", zincreasehalf); + AddMenuItem(zr_knockback_menu, "zincreasedeca", zincreasedeca); + AddMenuItem(zr_knockback_menu, "zdecreasedeci", zdecreasedeci); + AddMenuItem(zr_knockback_menu, "zdecreasehalf", zdecreasehalf); + + SetMenuExitBackButton(zr_knockback_menu, true); + + DisplayMenu(zr_knockback_menu, client, MENU_TIME_FOREVER); +} + +public ZRClassKnockbackHandle(Handle:zr_knockback_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + switch(slot) + { + case 0: + { + AddToClassKnockback(SelectedClassIndex[client], 0.5); + ZRClassKnockbackMenu(client, SelectedClassIndex[client]); + } + case 1: + { + AddToClassKnockback(SelectedClassIndex[client], 0.1); + ZRClassKnockbackMenu(client, SelectedClassIndex[client]); + } + case 2: + { + AddToClassKnockback(SelectedClassIndex[client], -0.1); + ZRClassKnockbackMenu(client, SelectedClassIndex[client]); + } + case 3: + { + AddToClassKnockback(SelectedClassIndex[client], -0.5); + ZRClassKnockbackMenu(client, SelectedClassIndex[client]); + } + } + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRClassSelectMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_knockback_menu); + } +} + +ZRNVGSMenu(client) +{ + new Handle:zr_nvgs_menu = CreateMenu(ZRNVGSHandle); + new current_nvgs = GetConVarInt(gCvars[CVAR_ZOMBIE_NVGS]); + + SetMenuTitle(zr_nvgs_menu, "Change night vision settings\nCurrent value: %i\n", current_nvgs); + + decl String:znooverride[] = "-1: No override/Default"; + decl String:zoff[] = "0: Never give nvgs"; + decl String:zon[] = "1: Always give nvgs"; + + AddMenuItem(zr_nvgs_menu, "znooverride", znooverride); + AddMenuItem(zr_nvgs_menu, "zoff", zoff); + AddMenuItem(zr_nvgs_menu, "zon", zon); + + SetMenuExitBackButton(zr_nvgs_menu, true); + + DisplayMenu(zr_nvgs_menu, client, MENU_TIME_FOREVER); +} + +public ZRNVGSHandle(Handle:zr_nvgs_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + switch(slot) + { + case 0: + { + SetConVarInt(gCvars[CVAR_ZOMBIE_NVGS], -1); + ZRNVGSMenu(client); + } + case 1: + { + SetConVarInt(gCvars[CVAR_ZOMBIE_NVGS], 0); + ZRNVGSMenu(client); + } + case 2: + { + SetConVarInt(gCvars[CVAR_ZOMBIE_NVGS], 1); + ZRNVGSMenu(client); + } + } + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRAdminMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_nvgs_menu); + } +} + +ZRInfectMenu(client) +{ + new Handle:zr_infect_menu = CreateMenu(ZRInfectHandle); + + SetMenuTitle(zr_infect_menu, "Infect a player:"); + AddTargetsToMenu(zr_infect_menu, client, true, true); + SetMenuExitBackButton(zr_infect_menu, true); + DisplayMenu(zr_infect_menu, client, MENU_TIME_FOREVER); +} + +public ZRInfectHandle(Handle:zr_infect_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(zr_infect_menu, slot, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + ReplyToCommand(client, "[ZR] Player no longer available"); + } + else if (!CanUserTarget(client, target)) + { + ReplyToCommand(client, "[ZR] Unable to target player"); + } + else if (!IsPlayerAlive(target)) + { + ReplyToCommand(client, "[ZR] Player is dead"); + } + else + { + decl String:name[64]; + GetClientName(target, name, sizeof(name)); + Zombify(target, 0); + ShowActivity2(client, "[ZR] ", "Infected %s", name); + ZRInfectMenu(client); + } + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRAdminMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_infect_menu); + } +} + +/*ZRSpawnMenu(client) +{ + new Handle:zr_spawn_menu = CreateMenu(ZRSpawnHandle); + + SetMenuTitle(zr_spawn_menu, "Spawn a player:"); + + // Todo: List only dead players. + + AddTargetsToMenu(zr_spawn_menu, client, true, true); + SetMenuExitBackButton(zr_spawn_menu, true); + DisplayMenu(zr_spawn_menu, client, MENU_TIME_FOREVER); +}*/ + +/*public ZRSpawnHandle(Handle:zr_spawn_menu, MenuAction:action, client, slot) +{ + if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(zr_spawn_menu, slot, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + ReplyToCommand(client, "[ZR] Player no longer available"); + } + else if (!CanUserTarget(client, target)) + { + ReplyToCommand(client, "[ZR] Unable to target player"); + } + else + { + decl String:name[32]; + GetClientName(target, name, sizeof(name)); + // Todo: Do spawn. + ShowActivity2(client, "[ZR] Spawned %s", name); + } + } + if (action == MenuAction_Cancel) + { + if (slot == MenuCancel_ExitBack) + { + ZRAdminMenu(client); + } + } + if (action == MenuAction_End) + { + CloseHandle(zr_spawn_menu); + } +}*/ + +AddToKnockbackMultiplier(Float:value) +{ + new Float:current_val = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]); + SetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK], current_val + value); +} + +AddToClassKnockback(classindex, Float:value) +{ + arrayClasses[classindex][data_knockback] = arrayClasses[classindex][data_knockback] + value; +} diff --git a/todo.txt b/todo.txt index 3401240..3e93927 100644 --- a/todo.txt +++ b/todo.txt @@ -2,10 +2,6 @@ Section content is listed in order of importance. Some of these can be ideas too ---- CRITICAL/IMPORTANT ---- -* When you turn off zvision it's remembered to next time you get zombified, but - not the nightvision. Make it remember the last nvgs state as zombie too. - Got some complains and it's a bit annoying too. Should be an easy fix. - * FIXED -- fix spawn protection players gets invisible, but not protected against zombies. the array pProtect isn't used at all, just set to off and on.