From 54931dfc8299e5a134ab0d1e17245ba99bc8a112 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 9 Apr 2009 06:49:15 +0200 Subject: [PATCH] Uploaded weapongroups.txt config file --- .../sourcemod/configs/zr/weapongroups.txt | 86 +++++++++++ src/zombiereloaded.sp | 20 ++- src/zr/commands.inc | 140 ++++++++++++------ src/zr/sayhooks.inc | 2 +- 4 files changed, 193 insertions(+), 55 deletions(-) create mode 100644 cstrike/addons/sourcemod/configs/zr/weapongroups.txt diff --git a/cstrike/addons/sourcemod/configs/zr/weapongroups.txt b/cstrike/addons/sourcemod/configs/zr/weapongroups.txt new file mode 100644 index 0000000..8eec683 --- /dev/null +++ b/cstrike/addons/sourcemod/configs/zr/weapongroups.txt @@ -0,0 +1,86 @@ +// Weapon Lists +// +// +// Counter-Strike: Source | +// -----------------------| +// glock | +// usp | +// p228 | +// deagle | +// elite | +// fiveseven | +// m3 | +// xm1014 | +// mac10 | +// tmp | +// mp5navy | +// ump45 | +// p90 | +// galil | +// famas | +// ak47 | +// m4a1 | +// sg552 | +// aug | +// scout | +// sg550 | +// g3sg1 | +// awp | +// -----------------------| + + +// Format +// +// +// "weapon group name" +// { +// "weaponname (listed above)" {} <-- To satisfy the standard format of a keyvalues file, +// without these brackets the weapon will be ommitted +// } + + +"weapongroups" +{ + "pistols" + { + "glock" {} + "usp" {} + "p228" {} + "deagle" {} + "elite" {} + "fiveseven" {} + } + + "shotguns" + { + "m3" {} + "xm1014" {} + } + + "smgs" + { + "mac10" {} + "tmp" {} + "mp5navy" {} + "ump45" {} + "p90" {} + } + + "rifles" + { + "galil" {} + "famas" {} + "ak47" {} + "m4a1" {} + "sg552" {} + "aug" {} + } + + "snipers" + { + "scout" {} + "sg550" {} + "g2sg1" {} + "awp" {} + } +} \ No newline at end of file diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 48cc557..1009db5 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -34,7 +34,7 @@ #include "zr/menu" #include "zr/sayhooks" #include "zr/zadmin" -#include "zr/weaponrestrict" +#include "zr/weapons/restrict" #include "zr/damagecontrol" #include "zr/commands" #include "zr/event" @@ -74,7 +74,7 @@ public OnPluginStart() HookCommands(); FindOffsets(); SetupGameData(); - InitWeaponRestrict(); + WeaponRestrictInit(); InitDmgControl(); // ====================================================================== @@ -116,6 +116,9 @@ public OnMapStart() LoadModelData(); LoadDownloadData(); + // Weapon restrict + WeaponRestrictMapStart(); + new i; new classindex = GetDefaultClassIndex(); for (i = 1; i <= MAXPLAYERS; i++) @@ -136,7 +139,6 @@ public OnConfigsExecuted() FindMapSky(); LoadClassData(); - ClassLoad(); LoadAmbienceData(); decl String:mapconfig[PLATFORM_MAX_PATH]; @@ -165,7 +167,9 @@ public OnClientPutInServer(client) new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP_DEFAULT]); dispHP[client] = zhp; - ClientHookUse(client); + // Weapon restrict + WeaponRestrictClientInit(client); + ClientHookAttack(client); FindClientDXLevel(client); @@ -181,7 +185,9 @@ public OnClientPutInServer(client) public OnClientDisconnect(client) { - ClientUnHookUse(client); + // Weapon restrict + WeaponRestrictClientDisconnect(client); + ClientUnHookAttack(client); PlayerLeft(client); @@ -202,8 +208,6 @@ public OnClientDisconnect(client) MapChangeCleanup() { - ClearArray(restrictedWeapons); - tRound = INVALID_HANDLE; tInfect = INVALID_HANDLE; AmbienceStopAll(); @@ -245,4 +249,4 @@ ZREnd() } } } -} +} \ No newline at end of file diff --git a/src/zr/commands.inc b/src/zr/commands.inc index bed26fd..8feec2e 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -10,18 +10,19 @@ CreateCommands() { RegAdminCmd("zr_infect", Command_Infect, ADMFLAG_GENERIC, "Infects the specified player"); RegAdminCmd("zr_spawn", Command_Respawn, ADMFLAG_GENERIC, "Respawns the specified player following auto-respawning rules"); - + RegAdminCmd("zr_teleport", Command_Teleport, ADMFLAG_GENERIC, "Teleports one or more players to spawn. Usage: zr_teleport "); RegAdminCmd("zr_tele_saveloc", Command_TeleSaveLocation, ADMFLAG_GENERIC, "Saves your or a players location to a buffer. Usage: zr_tele_saveloc [#userid|name]"); RegAdminCmd("zr_tele_loc", Command_TeleportToLocation, ADMFLAG_GENERIC, "Teleports you or a player to the saved location. Usage: zr_tele_loc [#userid|name]"); RegAdminCmd("zr_tele_abort", Command_TeleportAbort, ADMFLAG_GENERIC, "Aborts a teleportation or cooldown on a client. Usage: zr_tele_abort "); - + + // Weapon restrict commands RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon"); - RegAdminCmd("zr_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict 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 "); 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."); RegAdminCmd("zr_teleadmin", Command_TeleMenu, ADMFLAG_GENERIC, "Displays the teleport admin menu for Zombie: Reloaded."); @@ -45,18 +46,19 @@ public Action:Command_Infect(client, argc) GetCmdArg(1, arg1, sizeof(arg1)); decl String:target_name_list[MAX_TARGET_LENGTH]; - decl String:target_name[64]; - decl String:client_name[64]; new targets[MAXPLAYERS]; new bool:tn_is_ml; - new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name_list, sizeof(target_name), tn_is_ml); + new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name_list, sizeof(target_name_list), tn_is_ml); if (tcount <= 0) { ReplyToTargetError(client, tcount); return Plugin_Handled; } + decl String:target_name[64]; + decl String:client_name[64]; + if (client > 0) { GetClientName(client, client_name, sizeof(client_name)); @@ -82,8 +84,6 @@ public Action:Command_Infect(client, argc) public Action:Command_Respawn(client, argc) { new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); - decl String:client_name[64]; - decl String:target_name[64]; if (argc < 1 || !enabled) { return Plugin_Handled; @@ -96,13 +96,16 @@ public Action:Command_Respawn(client, argc) new targets[MAXPLAYERS]; new bool:tn_is_ml; - new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_DEAD, target_name_list, sizeof(target_name), tn_is_ml); + new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_DEAD, target_name_list, sizeof(target_name_list), tn_is_ml); if (tcount <= 0) { ReplyToTargetError(client, tcount); return Plugin_Handled; } + decl String:client_name[64]; + decl String:target_name[64]; + if (client > 0) { GetClientName(client, client_name, sizeof(client_name)); @@ -123,6 +126,7 @@ public Action:Command_Respawn(client, argc) GetClientName(targets[x], target_name, sizeof(target_name)); ZR_LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name); } + RespawnPlayer(targets[x]); } } @@ -130,75 +134,119 @@ public Action:Command_Respawn(client, argc) return Plugin_Handled; } +/** + * @param client The client index. + * @param argc Argument count. +*/ public Action:Command_Restrict(client, argc) { + // If plugin is disabled then stop new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); - decl String:client_name[64]; if (argc < 1 || !enabled) { return Plugin_Handled; } + // arg1 = weapon being restricted decl String:arg1[32]; GetCmdArg(1, arg1, sizeof(arg1)); - new WepRestrictQuery:output = RestrictWeapon(arg1); + // Strip "weapon_" from entity name + ReplaceString(arg1, sizeof(arg1), "weapon_", ""); - if (output == Existing) + new WpnRestrictQuery:output = WeaponRestrictRestrict(arg1); + + switch(output) { - ZR_ReplyToCommand(client, "Weapon already restricted", arg1); - } - else - { - if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) + case Successful_Weapon: { - if (client > 0) - { - GetClientName(client, client_name, sizeof(client_name)); - } - else - { - client_name = "Console\0"; - } - ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" restricted weapon \"%s\".", true, client_name, arg1); + ZR_ReplyToCommand(client, "Restrict weapon", arg1); } + case Successful_Group: + { + decl String:weaponlist[128]; + WeaponRestrictGetWeaponList(arg1, weaponlist, sizeof(weaponlist), ", "); + + ZR_ReplyToCommand(client, "Restrict custom weapon group", arg1, weaponlist); + } + case Invalid: + { + ZR_ReplyToCommand(client, "Weapon invalid", arg1); + + return Plugin_Handled; + } + } + + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) + { + decl String:client_name[64]; + + if (client > 0) + { + GetClientName(client, client_name, sizeof(client_name)); + } + else + { + client_name = "Console\0"; + } + ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" restricted weapon (group): \"%s\".", true, client_name, arg1); } return Plugin_Handled; } -public Action:Command_UnRestrict(client, argc) +public Action:Command_Unrestrict(client, argc) { + // If plugin is disabled then stop new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); - decl String:client_name[64]; if (argc < 1 || !enabled) { return Plugin_Handled; } + // arg1 = weapon being restricted decl String:arg1[32]; GetCmdArg(1, arg1, sizeof(arg1)); - new WepRestrictQuery:output = UnRestrictWeapon(arg1); + // Strip "weapon_" from entity name + ReplaceString(arg1, sizeof(arg1), "weapon_", ""); - if (output == Invalid) + new WpnRestrictQuery:output = WeaponRestrictUnrestrict(arg1); + + switch(output) { - ZR_ReplyToCommand(client, "Weapon invalid", arg1); - } - else - { - if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) + case Successful_Weapon: { - if (client > 0) - { - GetClientName(client, client_name, sizeof(client_name)); - } - else - { - client_name = "Console\0"; - } - ZR_LogMessageFormatted(client, "admin commands", "weapon restictions", "\"%s\" removed weapon restriction on \"%s\".", true, client_name, arg1); + ZR_ReplyToCommand(client, "Unrestrict weapon", arg1); } + case Successful_Group: + { + decl String:weaponlist[128]; + WeaponRestrictGetWeaponList(arg1, weaponlist, sizeof(weaponlist), ", "); + + ZR_ReplyToCommand(client, "Unrestrict custom weapon group", arg1, weaponlist); + } + case Invalid: + { + ZR_ReplyToCommand(client, "Weapon invalid", arg1); + + return Plugin_Handled; + } + } + + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) + { + decl String:client_name[64]; + + if (client > 0) + { + GetClientName(client, client_name, sizeof(client_name)); + } + else + { + client_name = "Console\0"; + } + ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" unrestricted weapon (group): \"%s\".", true, client_name, arg1); } return Plugin_Handled; diff --git a/src/zr/sayhooks.inc b/src/zr/sayhooks.inc index ab6b239..c83e620 100644 --- a/src/zr/sayhooks.inc +++ b/src/zr/sayhooks.inc @@ -167,7 +167,7 @@ public bool:Market_OnWeaponSelected(client, String:weaponid[]) ReplaceString(weapon, sizeof(weapon), "weapon_", ""); - if (IsWeaponRestricted(weapon)) + if (WeaponRestrictIsRestricted(weapon)) { ZR_PrintToChat(client, "Weapon is restricted", weapon);