Coded menus for most base plugins
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401542
This commit is contained in:
parent
2008ca0e0b
commit
ae5e3217bd
9
configs/menu_configs.cfg
Normal file
9
configs/menu_configs.cfg
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* List config files here (relative to moddir) to have them added to the exec config menu list
|
||||
* Left side is the filename, right side is the text to be added to the menu
|
||||
*/
|
||||
Configs
|
||||
{
|
||||
"cfg/server.cfg" "Standard Server Setup"
|
||||
"cfg/sourcemod/sourcemod.cfg" "SourceMod Settings"
|
||||
}
|
7
configs/menu_maplist.ini
Normal file
7
configs/menu_maplist.ini
Normal file
@ -0,0 +1,7 @@
|
||||
// menu_maplist.ini
|
||||
//
|
||||
// List maps here to be added to the map and votemap sections of the admin menu
|
||||
//
|
||||
de_dust
|
||||
de_dust2
|
||||
de_aztec
|
@ -34,6 +34,8 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
@ -44,6 +46,13 @@ public Plugin:myinfo =
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
new g_BanTarget[MAXPLAYERS+1];
|
||||
new g_BanTime[MAXPLAYERS+1];
|
||||
|
||||
#include "basebans/ban.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -52,6 +61,40 @@ public OnPluginStart()
|
||||
RegAdminCmd("sm_unban", Command_Unban, ADMFLAG_UNBAN, "sm_unban <steamid>");
|
||||
RegAdminCmd("sm_addban", Command_AddBan, ADMFLAG_RCON, "sm_addban <time> <steamid> [reason]");
|
||||
RegAdminCmd("sm_banip", Command_BanIp, ADMFLAG_BAN, "sm_banip <time> <ip|#userid|name> [reason]");
|
||||
|
||||
/* Account for late loading */
|
||||
new Handle:topmenu;
|
||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
}
|
||||
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
{
|
||||
/* Block us from being called twice */
|
||||
if (topmenu == hTopMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the Handle */
|
||||
hTopMenu = topmenu;
|
||||
|
||||
/* Find the "Player Commands" category */
|
||||
new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
|
||||
|
||||
if (player_commands != INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Ban Player",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Ban,
|
||||
player_commands,
|
||||
"sm_ban",
|
||||
ADMFLAG_BAN);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_BanIp(client, args)
|
||||
@ -219,66 +262,3 @@ public Action:Command_Unban(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Ban(client, args)
|
||||
{
|
||||
if (args < 2)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg, true);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:s_time[12];
|
||||
GetCmdArg(2, s_time, sizeof(s_time));
|
||||
|
||||
new time = StringToInt(s_time);
|
||||
|
||||
decl String:reason[128];
|
||||
if (args >= 3)
|
||||
{
|
||||
GetCmdArg(3, reason, sizeof(reason));
|
||||
} else {
|
||||
reason[0] = '\0';
|
||||
}
|
||||
|
||||
decl String:authid[64];
|
||||
GetClientAuthString(target, authid, sizeof(authid));
|
||||
GetClientName(target, arg, sizeof(arg));
|
||||
|
||||
if (!time)
|
||||
{
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
ShowActivity(client, "%t", "Permabanned player", arg);
|
||||
} else {
|
||||
ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
|
||||
}
|
||||
} else {
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
ShowActivity(client, "%t", "Banned player", arg, time);
|
||||
} else {
|
||||
ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
|
||||
}
|
||||
}
|
||||
|
||||
LogAction(client, target, "\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, target, time, reason);
|
||||
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
strcopy(reason, sizeof(reason), "Banned");
|
||||
}
|
||||
|
||||
BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
229
plugins/basebans/ban.sp
Normal file
229
plugins/basebans/ban.sp
Normal file
@ -0,0 +1,229 @@
|
||||
PrepareBan(client, target, time, String:reason[], size)
|
||||
{
|
||||
decl String:authid[64], String:name[32];
|
||||
GetClientAuthString(target, authid, sizeof(authid));
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!time)
|
||||
{
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
ShowActivity(client, "%t", "Permabanned player", name);
|
||||
} else {
|
||||
ShowActivity(client, "%t", "Permabanned player reason", name, reason);
|
||||
}
|
||||
} else {
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
ShowActivity(client, "%t", "Banned player", name, time);
|
||||
} else {
|
||||
ShowActivity(client, "%t", "Banned player reason", name, time, reason);
|
||||
}
|
||||
}
|
||||
|
||||
LogAction(client, target, "\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, target, time, reason);
|
||||
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
strcopy(reason, size, "Banned");
|
||||
}
|
||||
|
||||
BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client);
|
||||
}
|
||||
|
||||
DisplayBanTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_BanPlayerList);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Ban Player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
DisplayBanTimeMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_BanTimeList);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Ban Player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddMenuItem(menu, "0", "Permanent");
|
||||
AddMenuItem(menu, "10", "10 Minutes");
|
||||
AddMenuItem(menu, "30", "30 Minutes");
|
||||
AddMenuItem(menu, "60", "1 Hour");
|
||||
AddMenuItem(menu, "240", "4 Hours");
|
||||
AddMenuItem(menu, "1440", "1 Day");
|
||||
AddMenuItem(menu, "10080", "1 Week");
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
DisplayBanReasonMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_BanReasonList);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Ban Reason", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddMenuItem(menu, "Abusive", "Abusive");
|
||||
AddMenuItem(menu, "Racism", "Racism");
|
||||
AddMenuItem(menu, "General cheating/exploits", "General cheating/exploits");
|
||||
AddMenuItem(menu, "Wallhack", "Wallhack");
|
||||
AddMenuItem(menu, "Aimbot", "Aimbot");
|
||||
AddMenuItem(menu, "Speedhacking", "Speedhacking");
|
||||
AddMenuItem(menu, "Mic spamming", "Mic spamming");
|
||||
AddMenuItem(menu, "Admin disrepect", "Admin disrepect");
|
||||
AddMenuItem(menu, "Camping", "Camping");
|
||||
AddMenuItem(menu, "Team killing", "Team killing");
|
||||
AddMenuItem(menu, "Unacceptable Spray", "Unacceptable Spray");
|
||||
AddMenuItem(menu, "Breaking Server Rules", "Breaking Server Rules");
|
||||
AddMenuItem(menu, "Other", "Other");
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Ban(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Ban Player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayBanTargetMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_BanReasonList(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[64];
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
|
||||
PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info, sizeof(info));
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_BanPlayerList(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_BanTarget[param1] = target;
|
||||
DisplayBanTimeMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_BanTimeList(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
g_BanTime[param1] = StringToInt(info);
|
||||
|
||||
DisplayBanReasonMenu(param1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Action:Command_Ban(client, args)
|
||||
{
|
||||
if (args < 2)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg, true);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:s_time[12];
|
||||
GetCmdArg(2, s_time, sizeof(s_time));
|
||||
|
||||
new time = StringToInt(s_time);
|
||||
|
||||
decl String:reason[128];
|
||||
if (args >= 3)
|
||||
{
|
||||
GetCmdArg(3, reason, sizeof(reason));
|
||||
} else {
|
||||
reason[0] = '\0';
|
||||
}
|
||||
|
||||
PrepareBan(client, target, time, reason, sizeof(reason));
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -33,6 +33,8 @@
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
|
||||
#pragma semicolon 1
|
||||
|
||||
@ -52,6 +54,12 @@ new Handle:g_Cvar_Deadtalk = INVALID_HANDLE; // Holds the handle for sm_deadtalk
|
||||
new Handle:g_Cvar_Alltalk = INVALID_HANDLE; // Holds the handle for sv_alltalk
|
||||
new bool:g_Hooked = false; // Tracks if we've hooked events for deadtalk
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
new g_GagTarget[MAXPLAYERS+1];
|
||||
|
||||
#include "basecomm/gag.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -72,6 +80,39 @@ public OnPluginStart()
|
||||
RegAdminCmd("sm_unsilence", Command_Unsilence, ADMFLAG_CHAT, "sm_unsilence <player> - Restores a player's ability to use voice and chat.");
|
||||
|
||||
HookConVarChange(g_Cvar_Deadtalk, ConVarChange_Deadtalk);
|
||||
|
||||
/* Account for late loading */
|
||||
new Handle:topmenu;
|
||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
}
|
||||
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
{
|
||||
/* Block us from being called twice */
|
||||
if (topmenu == hTopMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the Handle */
|
||||
hTopMenu = topmenu;
|
||||
|
||||
/* Build the "Player Commands" category */
|
||||
new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
|
||||
|
||||
if (player_commands != INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Gag/Mute",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Gag,
|
||||
player_commands,
|
||||
"sm_gag",
|
||||
ADMFLAG_CHAT);
|
||||
}
|
||||
}
|
||||
|
||||
public ConVarChange_Deadtalk(Handle:convar, const String:oldValue[], const String:newValue[])
|
||||
@ -112,267 +153,6 @@ public Action:Command_Say(client, args)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:Command_Mute(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Muted");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_Muted[target] = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Muted", name);
|
||||
ReplyToCommand(client, "%t", "Player Muted", name);
|
||||
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Gag(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (g_Gagged[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Gagged");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_Gagged[target] = true;
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Gagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Gagged", name);
|
||||
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Silence(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (g_Gagged[target] && g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Silenced");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!g_Gagged[target])
|
||||
{
|
||||
g_Gagged[target] = true;
|
||||
|
||||
ShowActivity(client, "%t", "Player Gagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Gagged", name);
|
||||
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
if (!g_Muted[target])
|
||||
{
|
||||
g_Muted[target] = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
|
||||
ShowActivity(client, "%t", "Player Muted", name);
|
||||
ReplyToCommand(client, "%t", "Player Muted", name);
|
||||
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Unmute(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Muted");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_Muted[target] = false;
|
||||
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_LISTENALL);
|
||||
}
|
||||
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_TEAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_NORMAL);
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Unmuted", name);
|
||||
ReplyToCommand(client, "%t", "Player Unmuted", name);
|
||||
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Ungag(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!g_Gagged[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Gagged");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_Gagged[target] = false;
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Ungagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Ungagged", name);
|
||||
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Unsilence(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!g_Gagged[target] && !g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Silenced");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (g_Gagged[target])
|
||||
{
|
||||
g_Gagged[target] = false;
|
||||
|
||||
ShowActivity(client, "%t", "Player Ungagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Ungagged", name);
|
||||
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
if (g_Muted[target])
|
||||
{
|
||||
g_Muted[target] = false;
|
||||
|
||||
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_LISTENALL);
|
||||
}
|
||||
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_TEAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_NORMAL);
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Player Unmuted", name);
|
||||
ReplyToCommand(client, "%t", "Player Unmuted", name);
|
||||
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
|
443
plugins/basecomm/gag.sp
Normal file
443
plugins/basecomm/gag.sp
Normal file
@ -0,0 +1,443 @@
|
||||
enum CommType
|
||||
{
|
||||
CommType_Mute,
|
||||
CommType_UnMute,
|
||||
CommType_Gag,
|
||||
CommType_UnGag,
|
||||
CommType_Silence,
|
||||
CommType_UnSilence
|
||||
|
||||
};
|
||||
|
||||
DisplayGagTypesMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_GagTypes);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Choose Type", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
new target = g_GagTarget[client];
|
||||
|
||||
if (!g_Muted[target])
|
||||
{
|
||||
AddMenuItem(menu, "0", "Mute Player");
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMenuItem(menu, "1", "UnMute Player");
|
||||
}
|
||||
|
||||
if (!g_Gagged[target])
|
||||
{
|
||||
AddMenuItem(menu, "2", "Gag Player");
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMenuItem(menu, "3", "UnGag Player");
|
||||
}
|
||||
|
||||
if (!g_Muted[target] || !g_Gagged[target])
|
||||
{
|
||||
AddMenuItem(menu, "4", "Silence Player");
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMenuItem(menu, "5", "UnSilence Player");
|
||||
}
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
DisplayGagPlayerMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_GagPlayer);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Gag/Mute Player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Gag(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Gag/Mute Player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayGagPlayerMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_GagTarget[param1] = GetClientOfUserId(userid);
|
||||
DisplayGagTypesMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new CommType:type;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
type = CommType:StringToInt(info);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CommType_Mute: PerformMute(param1, g_GagTarget[param1]);
|
||||
case CommType_UnMute: PerformUnMute(param1, g_GagTarget[param1]);
|
||||
case CommType_Gag: PerformGag(param1, g_GagTarget[param1]);
|
||||
case CommType_UnGag: PerformUnGag(param1, g_GagTarget[param1]);
|
||||
case CommType_Silence: PerformSilence(param1, g_GagTarget[param1]);
|
||||
case CommType_UnSilence: PerformUnSilence(param1, g_GagTarget[param1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PerformMute(client, target)
|
||||
{
|
||||
if (g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Muted");
|
||||
return;
|
||||
}
|
||||
|
||||
g_Muted[target] = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Muted", name);
|
||||
ReplyToCommand(client, "%t", "Player Muted", name);
|
||||
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
|
||||
}
|
||||
|
||||
PerformUnMute(client, target)
|
||||
{
|
||||
if (!g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Muted");
|
||||
return;
|
||||
}
|
||||
|
||||
g_Muted[target] = false;
|
||||
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_LISTENALL);
|
||||
}
|
||||
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_TEAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_NORMAL);
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Unmuted", name);
|
||||
ReplyToCommand(client, "%t", "Player Unmuted", name);
|
||||
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
|
||||
}
|
||||
|
||||
PerformGag(client, target)
|
||||
{
|
||||
if (g_Gagged[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Gagged");
|
||||
return;
|
||||
}
|
||||
|
||||
g_Gagged[target] = true;
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Gagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Gagged", name);
|
||||
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
PerformUnGag(client, target)
|
||||
{
|
||||
if (!g_Gagged[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Gagged");
|
||||
return;
|
||||
}
|
||||
|
||||
g_Gagged[target] = false;
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
ShowActivity(client, "%t", "Player Ungagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Ungagged", name);
|
||||
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
PerformSilence(client, target)
|
||||
{
|
||||
if (g_Gagged[target] && g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Already Silenced");
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!g_Gagged[target])
|
||||
{
|
||||
g_Gagged[target] = true;
|
||||
|
||||
ShowActivity(client, "%t", "Player Gagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Gagged", name);
|
||||
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
if (!g_Muted[target])
|
||||
{
|
||||
g_Muted[target] = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
|
||||
ShowActivity(client, "%t", "Player Muted", name);
|
||||
ReplyToCommand(client, "%t", "Player Muted", name);
|
||||
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
PerformUnSilence(client, target)
|
||||
{
|
||||
if (!g_Gagged[target] && !g_Muted[target])
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Player Not Silenced");
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:name[64];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (g_Gagged[target])
|
||||
{
|
||||
g_Gagged[target] = false;
|
||||
|
||||
ShowActivity(client, "%t", "Player Ungagged", name);
|
||||
ReplyToCommand(client, "%t", "Player Ungagged", name);
|
||||
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
|
||||
}
|
||||
|
||||
if (g_Muted[target])
|
||||
{
|
||||
g_Muted[target] = false;
|
||||
|
||||
if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_LISTENALL);
|
||||
}
|
||||
else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_TEAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_NORMAL);
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Player Unmuted", name);
|
||||
ReplyToCommand(client, "%t", "Player Unmuted", name);
|
||||
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Mute(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformMute(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Gag(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformGag(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Silence(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformSilence(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Unmute(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformUnMute(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Ungag(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformUnGag(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Unsilence(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformUnSilence(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -48,9 +48,17 @@ public Plugin:myinfo =
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_MapList;
|
||||
new g_mapFileTime;
|
||||
|
||||
new Handle:g_ConfigList;
|
||||
|
||||
#include "basecommands/kick.sp"
|
||||
#include "basecommands/reloadadmins.sp"
|
||||
#include "basecommands/cancelvote.sp"
|
||||
#include "basecommands/who.sp"
|
||||
#include "basecommands/map.sp"
|
||||
#include "basecommands/execcfg.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
@ -72,6 +80,26 @@ public OnPluginStart()
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
|
||||
g_MapList = CreateMenu(MenuHandler_ChangeMap);
|
||||
SetMenuTitle(g_MapList, "Please select a map");
|
||||
SetMenuExitBackButton(g_MapList, true);
|
||||
}
|
||||
|
||||
public OnMapStart()
|
||||
{
|
||||
LoadMaps(g_MapList);
|
||||
|
||||
ParseConfigs();
|
||||
}
|
||||
|
||||
public OnMapEnd()
|
||||
{
|
||||
if (g_ConfigList != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_ConfigList);
|
||||
g_ConfigList = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
@ -97,6 +125,14 @@ public OnAdminMenuReady(Handle:topmenu)
|
||||
player_commands,
|
||||
"sm_kick",
|
||||
ADMFLAG_KICK);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Get Info",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Who,
|
||||
player_commands,
|
||||
"sm_who",
|
||||
ADMFLAG_GENERIC);
|
||||
}
|
||||
|
||||
new TopMenuObject:server_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_SERVERCOMMANDS);
|
||||
@ -110,6 +146,22 @@ public OnAdminMenuReady(Handle:topmenu)
|
||||
server_commands,
|
||||
"sm_reloadadmins",
|
||||
ADMFLAG_BAN);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Change Map",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Map,
|
||||
server_commands,
|
||||
"sm_map",
|
||||
ADMFLAG_CHANGEMAP);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Exec CFG",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_ExecCFG,
|
||||
server_commands,
|
||||
"sm_execcfg",
|
||||
ADMFLAG_CONFIG);
|
||||
}
|
||||
|
||||
new TopMenuObject:voting_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_VOTINGCOMMANDS);
|
||||
@ -193,106 +245,6 @@ FlagsToString(String:buffer[], maxlength, flags)
|
||||
ImplodeStrings(joins, total, ", ", buffer, maxlength);
|
||||
}
|
||||
|
||||
public Action:Command_Who(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
/* Display header */
|
||||
decl String:t_access[16], String:t_name[16];
|
||||
Format(t_access, sizeof(t_access), "%t", "Access", client);
|
||||
Format(t_name, sizeof(t_name), "%t", "Name", client);
|
||||
|
||||
PrintToConsole(client, "%-24.23s %s", t_name, t_access);
|
||||
|
||||
/* List all players */
|
||||
new maxClients = GetMaxClients();
|
||||
decl String:flagstring[255];
|
||||
|
||||
for (new i=1; i<=maxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
new flags = GetUserFlagBits(i);
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
decl String:name[65];
|
||||
GetClientName(i, name, sizeof(name));
|
||||
PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
|
||||
}
|
||||
|
||||
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "See console for output");
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new clients[2];
|
||||
new numClients = SearchForClients(arg, clients, 2);
|
||||
|
||||
if (numClients == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "No matching client");
|
||||
return Plugin_Handled;
|
||||
} else if (numClients > 1) {
|
||||
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new flags = GetUserFlagBits(clients[0]);
|
||||
decl String:flagstring[255];
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "[SM] %t: %s", "Access", flagstring);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_ExecCfg(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_execcfg <filename>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new String:path[64] = "cfg/";
|
||||
GetCmdArg(1, path[4], sizeof(path)-4);
|
||||
|
||||
if (!FileExists(path))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Config not found", path[4]);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Executed config", path[4]);
|
||||
|
||||
LogAction(client, -1, "\"%L\" executed config (file \"%s\")", client, path[4]);
|
||||
|
||||
ServerCommand("exec \"%s\"", path[4]);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Cvar(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
@ -388,44 +340,3 @@ public Action:Command_Rcon(client, args)
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Map(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:map[64];
|
||||
GetCmdArg(1, map, sizeof(map));
|
||||
|
||||
if (!IsMapValid(map))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Changing map", map);
|
||||
|
||||
LogAction(client, -1, "\"%L\" changed map to \"%s\"", client, map);
|
||||
|
||||
new Handle:dp;
|
||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
|
||||
{
|
||||
decl String:map[65];
|
||||
|
||||
ResetPack(dp);
|
||||
ReadPackString(dp, map, sizeof(map));
|
||||
|
||||
ServerCommand("changelevel \"%s\"", map);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
|
116
plugins/basecommands/execcfg.sp
Normal file
116
plugins/basecommands/execcfg.sp
Normal file
@ -0,0 +1,116 @@
|
||||
PerformExec(client, String:path[])
|
||||
{
|
||||
if (!FileExists(path))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Config not found", path[4]);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Executed config", path[4]);
|
||||
|
||||
LogAction(client, -1, "\"%L\" executed config (file \"%s\")", client, path[4]);
|
||||
|
||||
ServerCommand("exec \"%s\"", path[4]);
|
||||
}
|
||||
|
||||
public AdminMenu_ExecCFG(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Exec CFG", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayMenu(g_ConfigList, param, MENU_TIME_FOREVER);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_ExecCFG(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:path[256];
|
||||
|
||||
GetMenuItem(menu, param2, path, sizeof(path));
|
||||
|
||||
PerformExec(param1, path);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_ExecCfg(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_execcfg <filename>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new String:path[64] = "cfg/";
|
||||
GetCmdArg(1, path[4], sizeof(path)-4);
|
||||
|
||||
PerformExec(client, path);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ParseConfigs()
|
||||
{
|
||||
new Handle:list = SMC_CreateParser();
|
||||
SMC_SetReaders(list, NewSection, KeyValue, EndSection);
|
||||
SMC_SetParseEnd(list, ParseEnd);
|
||||
|
||||
new Handle:menu = CreateMenu(MenuHandler_ExecCFG);
|
||||
SetMenuTitle(menu, "Choose Config");
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
decl String:configPath[256];
|
||||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/menu_configs.cfg");
|
||||
|
||||
if (!FileExists(configPath))
|
||||
{
|
||||
LogError("Unable to locate exec config file, no maps loaded.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_ConfigList = menu;
|
||||
|
||||
SMC_ParseFile(list, configPath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
|
||||
{
|
||||
AddMenuItem(g_ConfigList, key, value);
|
||||
}
|
||||
|
||||
public SMCResult:EndSection(Handle:smc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ParseEnd(Handle:smc, bool:halted, bool:failed)
|
||||
{
|
||||
if (halted || failed)
|
||||
LogError("Reading of configs file failed");
|
||||
|
||||
CloseHandle(smc);
|
||||
}
|
147
plugins/basecommands/map.sp
Normal file
147
plugins/basecommands/map.sp
Normal file
@ -0,0 +1,147 @@
|
||||
|
||||
public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:map[64];
|
||||
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
ShowActivity(param1, "%t", "Changing map", map);
|
||||
|
||||
LogAction(param1, -1, "\"%L\" changed map to \"%s\"", param1, map);
|
||||
|
||||
new Handle:dp;
|
||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AdminMenu_Map(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Choose Map", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayMenu(g_MapList, param, MENU_TIME_FOREVER);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Map(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:map[64];
|
||||
GetCmdArg(1, map, sizeof(map));
|
||||
|
||||
if (!IsMapValid(map))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Changing map", map);
|
||||
|
||||
LogAction(client, -1, "\"%L\" changed map to \"%s\"", client, map);
|
||||
|
||||
new Handle:dp;
|
||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||
WritePackString(dp, map);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
|
||||
{
|
||||
decl String:map[65];
|
||||
|
||||
ResetPack(dp);
|
||||
ReadPackString(dp, map, sizeof(map));
|
||||
|
||||
ServerCommand("changelevel \"%s\"", map);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
LoadMaps(Handle:menu)
|
||||
{
|
||||
decl String:mapPath[256];
|
||||
BuildPath(Path_SM, mapPath, sizeof(mapPath), "configs/menu_maplist.ini");
|
||||
|
||||
if (!FileExists(mapPath))
|
||||
{
|
||||
LogError("Unable to locate menu_maplist, no maps loaded.");
|
||||
|
||||
if (g_MapList != INVALID_HANDLE)
|
||||
{
|
||||
RemoveAllMenuItems(menu);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If the file hasn't changed, there's no reason to reload
|
||||
// all of the maps.
|
||||
new fileTime = GetFileTime(mapPath, FileTime_LastChange);
|
||||
if (g_mapFileTime == fileTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_mapFileTime = fileTime;
|
||||
|
||||
// Reset the array
|
||||
if (g_MapList != INVALID_HANDLE)
|
||||
{
|
||||
RemoveAllMenuItems(menu);
|
||||
}
|
||||
|
||||
LogMessage("[SM] Loading menu map list file [%s]", mapPath);
|
||||
|
||||
new Handle:file = OpenFile(mapPath, "rt");
|
||||
if (file == INVALID_HANDLE)
|
||||
{
|
||||
LogError("[SM] Could not open file: %s", mapPath);
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:buffer[64], len;
|
||||
while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
|
||||
{
|
||||
TrimString(buffer);
|
||||
|
||||
if ((len = StrContains(buffer, ".bsp", false)) != -1)
|
||||
{
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AddMenuItem(menu, buffer, buffer);
|
||||
}
|
||||
|
||||
CloseHandle(file);
|
||||
return;
|
||||
}
|
157
plugins/basecommands/who.sp
Normal file
157
plugins/basecommands/who.sp
Normal file
@ -0,0 +1,157 @@
|
||||
|
||||
PerformWho(client, target, ReplySource:reply)
|
||||
{
|
||||
new flags = GetUserFlagBits(target);
|
||||
decl String:flagstring[255];
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
|
||||
if (reply == SM_REPLY_TO_CHAT)
|
||||
PrintToChat(client, "[SM] %t: %s", "Access", flagstring);
|
||||
else
|
||||
PrintToConsole(client, "[SM] %t: %s", "Access", flagstring);
|
||||
}
|
||||
|
||||
DisplayWhoMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Who);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Check player access", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Who(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Check player access", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayWhoMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformWho(param1, target, SM_REPLY_TO_CHAT);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
|
||||
/* - Close the menu? redisplay? jump back up to the category?
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplayWhoMenu(param1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
public Action:Command_Who(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
/* Display header */
|
||||
decl String:t_access[16], String:t_name[16];
|
||||
Format(t_access, sizeof(t_access), "%t", "Access", client);
|
||||
Format(t_name, sizeof(t_name), "%t", "Name", client);
|
||||
|
||||
PrintToConsole(client, "%-24.23s %s", t_name, t_access);
|
||||
|
||||
/* List all players */
|
||||
new maxClients = GetMaxClients();
|
||||
decl String:flagstring[255];
|
||||
|
||||
for (new i=1; i<=maxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
new flags = GetUserFlagBits(i);
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
decl String:name[65];
|
||||
GetClientName(i, name, sizeof(name));
|
||||
PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
|
||||
}
|
||||
|
||||
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "See console for output");
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new clients[2];
|
||||
new numClients = SearchForClients(arg, clients, 2);
|
||||
|
||||
if (numClients == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "No matching client");
|
||||
return Plugin_Handled;
|
||||
} else if (numClients > 1) {
|
||||
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformWho(client, clients[0], GetCmdReplySource());
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
@ -45,6 +47,14 @@ public Plugin:myinfo =
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
new g_SlapDamage[MAXPLAYERS+1];
|
||||
|
||||
#include "basefuncommands/slay.sp"
|
||||
#include "basefuncommands/burn.sp"
|
||||
#include "basefuncommands/slap.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -53,6 +63,55 @@ public OnPluginStart()
|
||||
RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
|
||||
RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
|
||||
RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
|
||||
|
||||
/* Account for late loading */
|
||||
new Handle:topmenu;
|
||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
}
|
||||
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
{
|
||||
/* Block us from being called twice */
|
||||
if (topmenu == hTopMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the Handle */
|
||||
hTopMenu = topmenu;
|
||||
|
||||
/* Find the "Player Commands" category */
|
||||
new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
|
||||
|
||||
if (player_commands != INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Slay Player",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Slay,
|
||||
player_commands,
|
||||
"sm_slay",
|
||||
ADMFLAG_SLAY);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Burn Player",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Burn,
|
||||
player_commands,
|
||||
"sm_burn",
|
||||
ADMFLAG_SLAY);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Slap Player",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_Slap,
|
||||
player_commands,
|
||||
"sm_slap",
|
||||
ADMFLAG_SLAY);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Play(client, args)
|
||||
@ -102,122 +161,3 @@ public Action:Command_Play(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Burn(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
GetClientName(target, arg, sizeof(arg));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new Float:seconds = 20.0;
|
||||
if (args > 1)
|
||||
{
|
||||
decl String:time[20];
|
||||
GetCmdArg(2, time, sizeof(time));
|
||||
if (StringToFloatEx(time, seconds) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Ignited player", arg);
|
||||
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
|
||||
IgniteEntity(target, seconds);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Slap(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
GetClientName(target, arg, sizeof(arg));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new damage = 0;
|
||||
if (args > 1)
|
||||
{
|
||||
decl String:arg2[20];
|
||||
GetCmdArg(2, arg2, sizeof(arg2));
|
||||
if (StringToIntEx(arg2, damage) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Slapped player", arg);
|
||||
LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
|
||||
SlapPlayer(target, damage, true);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Slay(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
GetClientName(target, arg, sizeof(arg));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Slayed player", arg);
|
||||
LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
|
||||
ForcePlayerSuicide(target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
124
plugins/basefuncommands/burn.sp
Normal file
124
plugins/basefuncommands/burn.sp
Normal file
@ -0,0 +1,124 @@
|
||||
PerformBurn(client, target, Float:seconds)
|
||||
{
|
||||
new String:name[32];
|
||||
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", name);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Ignited player", name);
|
||||
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
|
||||
IgniteEntity(target, seconds);
|
||||
}
|
||||
|
||||
DisplayBurnMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Burn);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Burn Player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Burn(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Burn Player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayBurnMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformBurn(param1, target, 20.0);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplaySlayMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Burn(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new Float:seconds = 20.0;
|
||||
|
||||
if (args > 1)
|
||||
{
|
||||
decl String:time[20];
|
||||
GetCmdArg(2, time, sizeof(time));
|
||||
if (StringToFloatEx(time, seconds) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
PerformBurn(client, target, seconds);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
167
plugins/basefuncommands/slap.sp
Normal file
167
plugins/basefuncommands/slap.sp
Normal file
@ -0,0 +1,167 @@
|
||||
PerformSlap(client, target, damage)
|
||||
{
|
||||
new String:name[32];
|
||||
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", name);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Slapped player", name);
|
||||
LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
|
||||
SlapPlayer(target, damage, true);
|
||||
}
|
||||
|
||||
DisplaySlapDamageMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_SlapDamage);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Slap Damage", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddMenuItem(menu, "0", "0");
|
||||
AddMenuItem(menu, "1", "1");
|
||||
AddMenuItem(menu, "5", "5");
|
||||
AddMenuItem(menu, "10", "10");
|
||||
AddMenuItem(menu, "20", "20");
|
||||
AddMenuItem(menu, "50", "50");
|
||||
AddMenuItem(menu, "99", "99");
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
DisplaySlapTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Slap);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Slap Player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Slap(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Slap Player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplaySlapDamageMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_SlapDamage(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
g_SlapDamage[param1] = StringToInt(info);
|
||||
|
||||
DisplaySlapTargetMenu(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Slap(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformSlap(param1, target, g_SlapDamage[param1]);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplaySlapTargetMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Slap(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new damage = 0;
|
||||
if (args > 1)
|
||||
{
|
||||
decl String:arg2[20];
|
||||
GetCmdArg(2, arg2, sizeof(arg2));
|
||||
if (StringToIntEx(arg2, damage) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
PerformSlap(client, target, damage);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
112
plugins/basefuncommands/slay.sp
Normal file
112
plugins/basefuncommands/slay.sp
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
PerformSlay(client, target)
|
||||
{
|
||||
decl String:name[32];
|
||||
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", name);
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity(client, "%t", "Slayed player", name);
|
||||
LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
|
||||
ForcePlayerSuicide(target);
|
||||
}
|
||||
|
||||
DisplaySlayMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Slay);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Slay player", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_Slay(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Slay player", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplaySlayMenu(param);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformSlay(param1, target);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
||||
{
|
||||
DisplaySlayMenu(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Slay(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
PerformSlay(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -36,6 +36,9 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Basic Fun Votes",
|
||||
@ -64,7 +67,7 @@ enum voteType
|
||||
slay,
|
||||
alltalk,
|
||||
ff
|
||||
}
|
||||
};
|
||||
|
||||
new voteType:g_voteType = voteType:gravity;
|
||||
|
||||
@ -80,6 +83,14 @@ new g_voteClient[2]; /* Holds the target's client id and user id */
|
||||
#define VOTE_IP 2
|
||||
new String:g_voteInfo[3][65]; /* Holds the target's name, authid, and IP */
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
#include "basefunvotes/votegravity.sp"
|
||||
#include "basefunvotes/voteburn.sp"
|
||||
#include "basefunvotes/voteslay.sp"
|
||||
#include "basefunvotes/votealltalk.sp"
|
||||
#include "basefunvotes/voteff.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -109,279 +120,71 @@ public OnPluginStart()
|
||||
g_Cvar_Show = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Account for late loading */
|
||||
new Handle:topmenu;
|
||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteGravity(client, args)
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
{
|
||||
if (args < 1)
|
||||
/* Block us from being called twice */
|
||||
if (topmenu == hTopMenu)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votegravity <amount> [amount2] ... [amount5]");
|
||||
return Plugin_Handled;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
/* Save the Handle */
|
||||
hTopMenu = topmenu;
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
/* Build the "Voting Commands" category */
|
||||
new TopMenuObject:voting_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_VOTINGCOMMANDS);
|
||||
|
||||
decl String:items[5][64];
|
||||
new count;
|
||||
new len, pos;
|
||||
|
||||
while (pos != -1 && count < 5)
|
||||
{
|
||||
pos = BreakString(text[len], items[count], sizeof(items[]));
|
||||
|
||||
decl Float:temp;
|
||||
if (StringToFloatEx(items[count], temp) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
len += pos;
|
||||
}
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated a gravity vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Gravity");
|
||||
|
||||
g_voteType = voteType:gravity;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (count == 1)
|
||||
if (voting_commands != INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), items[0]);
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Gravity",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteGravity,
|
||||
voting_commands,
|
||||
"sm_votegravity",
|
||||
ADMFLAG_VOTE);
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Change Gravity To");
|
||||
AddMenuItem(g_hVoteMenu, items[0], "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Burn",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteBurn,
|
||||
voting_commands,
|
||||
"sm_voteburn",
|
||||
ADMFLAG_VOTE|ADMFLAG_SLAY);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Slay",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteSlay,
|
||||
voting_commands,
|
||||
"sm_voteslay",
|
||||
ADMFLAG_VOTE|ADMFLAG_SLAY);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote AllTalk",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteAllTalk,
|
||||
voting_commands,
|
||||
"sm_votealltalk",
|
||||
ADMFLAG_VOTE);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote FF",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteFF,
|
||||
voting_commands,
|
||||
"sm_voteff",
|
||||
ADMFLAG_VOTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Gravity Vote");
|
||||
for (new i = 0; i < count; i++)
|
||||
{
|
||||
AddMenuItem(g_hVoteMenu, items[i], items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_VoteBurn(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteburn <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Burn", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:burn;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteburn Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_VoteSlay(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteslay <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a slay vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Slay", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:slay;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteslay Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_VoteAlltalk(client, args)
|
||||
{
|
||||
if (args > 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votealltalk");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated an alltalk vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Alltalk");
|
||||
|
||||
g_voteType = voteType:alltalk;
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (GetConVarBool(g_Cvar_Alltalk))
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Votealltalk Off");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Votealltalk On");
|
||||
}
|
||||
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_VoteFF(client, args)
|
||||
{
|
||||
if (args > 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteff");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated a friendly fire vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote FF");
|
||||
|
||||
g_voteType = voteType:ff;
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (GetConVarBool(g_Cvar_Alltalk))
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Voteff Off");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Voteff On");
|
||||
}
|
||||
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
|
||||
|
71
plugins/basefunvotes/votealltalk.sp
Normal file
71
plugins/basefunvotes/votealltalk.sp
Normal file
@ -0,0 +1,71 @@
|
||||
DisplayVoteAllTalkMenu(client)
|
||||
{
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated an alltalk vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Alltalk");
|
||||
|
||||
g_voteType = voteType:alltalk;
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (GetConVarBool(g_Cvar_Alltalk))
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Votealltalk Off");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Votealltalk On");
|
||||
}
|
||||
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
|
||||
public AdminMenu_VoteAllTalk(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote AllTalk", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayVoteAllTalkMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteAlltalk(client, args)
|
||||
{
|
||||
if (args > 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votealltalk");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
DisplayVoteAllTalkMenu(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
130
plugins/basefunvotes/voteburn.sp
Normal file
130
plugins/basefunvotes/voteburn.sp
Normal file
@ -0,0 +1,130 @@
|
||||
DisplayVoteBurnMenu(client,target,String:name[])
|
||||
{
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Burn", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:burn;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteburn Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
DisplayBurnTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Burn);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Vote Burn", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteBurn(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Burn", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayBurnTargetMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayVoteBurnMenu(param1, target, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteBurn(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteburn <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
DisplayVoteBurnMenu(client, target, arg);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
70
plugins/basefunvotes/voteff.sp
Normal file
70
plugins/basefunvotes/voteff.sp
Normal file
@ -0,0 +1,70 @@
|
||||
DisplayVoteFFMenu(client)
|
||||
{
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated a friendly fire vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote FF");
|
||||
|
||||
g_voteType = voteType:ff;
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (GetConVarBool(g_Cvar_Alltalk))
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Voteff Off");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMenuTitle(g_hVoteMenu, "Voteff On");
|
||||
}
|
||||
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteFF(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote FF", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayVoteFFMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteFF(client, args)
|
||||
{
|
||||
if (args > 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteff");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
DisplayVoteFFMenu(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
106
plugins/basefunvotes/votegravity.sp
Normal file
106
plugins/basefunvotes/votegravity.sp
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
DisplayVoteGravityMenu(client,count,String:items[5][])
|
||||
{
|
||||
LogAction(client, -1, "\"%L\" initiated a gravity vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Gravity");
|
||||
|
||||
g_voteType = voteType:gravity;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), items[0]);
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Change Gravity To");
|
||||
AddMenuItem(g_hVoteMenu, items[0], "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Gravity Vote");
|
||||
for (new i = 0; i < count; i++)
|
||||
{
|
||||
AddMenuItem(g_hVoteMenu, items[i], items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteGravity(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Gravity", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
/* Might need a better way of selecting the list of pre-defined gravity choices */
|
||||
new String:items[5][5] ={"200","400","800","1600","3200"};
|
||||
DisplayVoteGravityMenu(param,5, items);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteGravity(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votegravity <amount> [amount2] ... [amount5]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
decl String:items[5][64];
|
||||
new count;
|
||||
new len, pos;
|
||||
|
||||
while (pos != -1 && count < 5)
|
||||
{
|
||||
pos = BreakString(text[len], items[count], sizeof(items[]));
|
||||
|
||||
decl Float:temp;
|
||||
if (StringToFloatEx(items[count], temp) == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
len += pos;
|
||||
}
|
||||
}
|
||||
|
||||
DisplayVoteGravityMenu(client, count, items);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
0
plugins/basefunvotes/votemap.sp
Normal file
0
plugins/basefunvotes/votemap.sp
Normal file
131
plugins/basefunvotes/voteslay.sp
Normal file
131
plugins/basefunvotes/voteslay.sp
Normal file
@ -0,0 +1,131 @@
|
||||
|
||||
DisplayVoteSlayMenu(client,target,String:name[])
|
||||
{
|
||||
if (!IsPlayerAlive(target))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a slay vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Slay", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:slay;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteslay Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
DisplaySlayTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Slay);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Vote Slay", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteSlay(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Slay", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplaySlayTargetMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayVoteSlayMenu(param1, target, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_VoteSlay(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteslay <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
DisplayVoteSlayMenu(client, target, arg);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -34,6 +34,8 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
@ -79,6 +81,21 @@ new String:g_voteInfo[3][65]; /* Holds the target's name, authid, and IP */
|
||||
new String:g_voteArg[256]; /* Used to hold ban/kick reasons or vote questions */
|
||||
|
||||
|
||||
new Handle:hTopMenu = INVALID_HANDLE;
|
||||
|
||||
new Handle:g_MapList = INVALID_HANDLE;
|
||||
new g_mapFileTime;
|
||||
new g_mapCount;
|
||||
|
||||
new Handle:g_SelectedMaps;
|
||||
new g_SelectedCount;
|
||||
|
||||
new bool:g_VoteMapInUse;
|
||||
|
||||
#include "basevotes/votekick.sp"
|
||||
#include "basevotes/voteban.sp"
|
||||
#include "basevotes/votemap.sp"
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
@ -102,82 +119,66 @@ public OnPluginStart()
|
||||
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
|
||||
|
||||
g_hBanForward = CreateGlobalForward("OnClientBanned", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_String);
|
||||
|
||||
/* Account for late loading */
|
||||
new Handle:topmenu;
|
||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||
{
|
||||
OnAdminMenuReady(topmenu);
|
||||
}
|
||||
|
||||
g_SelectedMaps = CreateArray(33);
|
||||
|
||||
g_MapList = CreateMenu(MenuHandler_Map);
|
||||
SetMenuTitle(g_MapList, "Please select a map");
|
||||
SetMenuExitBackButton(g_MapList, true);
|
||||
}
|
||||
|
||||
public Action:Command_Votemap(client, args)
|
||||
public OnMapStart()
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votemap <mapname> [mapname2] ... [mapname5]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
g_mapCount = LoadMaps(g_MapList);
|
||||
}
|
||||
|
||||
decl String:maps[5][64];
|
||||
new mapCount;
|
||||
new len, pos;
|
||||
|
||||
while (pos != -1 && mapCount < 5)
|
||||
{
|
||||
pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
|
||||
|
||||
if (!IsMapValid(maps[mapCount]))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
mapCount++;
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
len += pos;
|
||||
}
|
||||
}
|
||||
|
||||
LogAction(client, -1, "\"%L\" initiated a map vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Map");
|
||||
|
||||
g_voteType = voteType:map;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (mapCount == 1)
|
||||
public OnAdminMenuReady(Handle:topmenu)
|
||||
{
|
||||
/* Block us from being called twice */
|
||||
if (topmenu == hTopMenu)
|
||||
{
|
||||
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the Handle */
|
||||
hTopMenu = topmenu;
|
||||
|
||||
/* Build the "Voting Commands" category */
|
||||
new TopMenuObject:voting_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_VOTINGCOMMANDS);
|
||||
|
||||
if (voting_commands != INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Kick",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteKick,
|
||||
voting_commands,
|
||||
"sm_votekick",
|
||||
ADMFLAG_VOTE|ADMFLAG_KICK);
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Change Map To");
|
||||
AddMenuItem(g_hVoteMenu, maps[0], "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Ban",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteBan,
|
||||
voting_commands,
|
||||
"sm_voteban",
|
||||
ADMFLAG_VOTE|ADMFLAG_BAN);
|
||||
|
||||
AddToTopMenu(hTopMenu,
|
||||
"Vote Map",
|
||||
TopMenuObject_Item,
|
||||
AdminMenu_VoteMap,
|
||||
voting_commands,
|
||||
"sm_votemap",
|
||||
ADMFLAG_VOTE|ADMFLAG_CHANGEMAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Map Vote");
|
||||
for (new i = 0; i < mapCount; i++)
|
||||
{
|
||||
AddMenuItem(g_hVoteMenu, maps[i], maps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Vote(client, args)
|
||||
@ -245,126 +246,6 @@ public Action:Command_Vote(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Votekick(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votekick <player> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
new len = BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (len != -1)
|
||||
{
|
||||
strcopy(g_voteArg, sizeof(g_voteArg), text[len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
||||
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a kick vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Kick", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:kick;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Votekick Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_Voteban(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteban <player> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
new len = BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (len != -1)
|
||||
{
|
||||
strcopy(g_voteArg, sizeof(g_voteArg), text[len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
}
|
||||
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
||||
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
GetClientAuthString(target, g_voteInfo[VOTE_AUTHID], sizeof(g_voteInfo[]));
|
||||
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a ban vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Ban", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:ban;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteban Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
|
139
plugins/basevotes/voteban.sp
Normal file
139
plugins/basevotes/voteban.sp
Normal file
@ -0,0 +1,139 @@
|
||||
|
||||
DisplayVoteBanMenu(client, target)
|
||||
{
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
||||
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
GetClientAuthString(target, g_voteInfo[VOTE_AUTHID], sizeof(g_voteInfo[]));
|
||||
GetClientIP(target, g_voteInfo[VOTE_IP], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a ban vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Ban", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:ban;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Voteban Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
DisplayBanTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Ban);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Vote Ban", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteBan(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Ban", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayBanTargetMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Ban(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
DisplayVoteBanMenu(param1, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Voteban(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_voteban <player> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
new len = BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (len != -1)
|
||||
{
|
||||
strcopy(g_voteArg, sizeof(g_voteArg), text[len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
}
|
||||
|
||||
DisplayVoteBanMenu(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
138
plugins/basevotes/votekick.sp
Normal file
138
plugins/basevotes/votekick.sp
Normal file
@ -0,0 +1,138 @@
|
||||
|
||||
DisplayVoteKickMenu(client, target)
|
||||
{
|
||||
g_voteClient[VOTE_CLIENTID] = target;
|
||||
g_voteClient[VOTE_USERID] = GetClientUserId(target);
|
||||
|
||||
GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
|
||||
|
||||
LogAction(client, target, "\"%L\" initiated a kick vote against \"%L\"", client, target);
|
||||
ShowActivity(client, "%t", "Initiated Vote Kick", g_voteInfo[VOTE_NAME]);
|
||||
|
||||
g_voteType = voteType:kick;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
SetMenuTitle(g_hVoteMenu, "Votekick Player");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
|
||||
}
|
||||
|
||||
DisplayKickTargetMenu(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Kick);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Vote Kick", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddTargetsToMenu(menu, client, false);
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public AdminMenu_VoteKick(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Kick", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
DisplayKickTargetMenu(param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running */
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
new userid, target;
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
userid = StringToInt(info);
|
||||
|
||||
if ((target = GetClientOfUserId(userid)) == 0)
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
||||
}
|
||||
else if (!CanUserTarget(param1, target))
|
||||
{
|
||||
PrintToChat(param1, "[SM] %t", "Unable to target");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
DisplayVoteKickMenu(param1, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Votekick(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votekick <player> [reason]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256], String:arg[64];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
new len = BreakString(text, arg, sizeof(arg));
|
||||
|
||||
new target = FindTarget(client, arg);
|
||||
if (target == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (len != -1)
|
||||
{
|
||||
strcopy(g_voteArg, sizeof(g_voteArg), text[len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteArg[0] = '\0';
|
||||
}
|
||||
|
||||
DisplayVoteKickMenu(client, target);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
262
plugins/basevotes/votemap.sp
Normal file
262
plugins/basevotes/votemap.sp
Normal file
@ -0,0 +1,262 @@
|
||||
|
||||
DisplayVoteMapMenu(client, mapCount, String:maps[5][])
|
||||
{
|
||||
LogAction(client, -1, "\"%L\" initiated a map vote.", client);
|
||||
ShowActivity(client, "%t", "Initiated Vote Map");
|
||||
|
||||
g_voteType = voteType:map;
|
||||
|
||||
g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
|
||||
|
||||
if (mapCount == 1)
|
||||
{
|
||||
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Change Map To");
|
||||
AddMenuItem(g_hVoteMenu, maps[0], "Yes");
|
||||
AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_voteInfo[VOTE_NAME][0] = '\0';
|
||||
|
||||
SetMenuTitle(g_hVoteMenu, "Map Vote");
|
||||
for (new i = 0; i < mapCount; i++)
|
||||
{
|
||||
AddMenuItem(g_hVoteMenu, maps[i], maps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_hVoteMenu, false);
|
||||
VoteMenuToAll(g_hVoteMenu, 20);
|
||||
}
|
||||
|
||||
ConfirmVote(client)
|
||||
{
|
||||
new Handle:menu = CreateMenu(MenuHandler_Confirm);
|
||||
|
||||
decl String:title[100];
|
||||
Format(title, sizeof(title), "%T:", "Confirm Vote", client);
|
||||
SetMenuTitle(menu, title);
|
||||
SetMenuExitBackButton(menu, true);
|
||||
|
||||
AddMenuItem(menu, "Confirm", "Start the Vote");
|
||||
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
else if (action == MenuAction_Cancel)
|
||||
{
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:maps[5][64];
|
||||
new selectedmaps = GetArraySize(g_SelectedMaps);
|
||||
|
||||
for (new i=0; i<selectedmaps; i++)
|
||||
{
|
||||
GetArrayString(g_SelectedMaps, i, maps[i], sizeof(maps[]));
|
||||
}
|
||||
|
||||
DisplayVoteMapMenu(param1, selectedmaps, maps);
|
||||
|
||||
/* Re-enable the menu option */
|
||||
g_VoteMapInUse = false;
|
||||
}
|
||||
}
|
||||
|
||||
public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2)
|
||||
{
|
||||
if (action == MenuAction_Cancel)
|
||||
{
|
||||
/* Add the removed maps back to the menu */
|
||||
new selectedmaps = GetArraySize(g_SelectedMaps);
|
||||
decl String:mapname[64];
|
||||
|
||||
for (new i=0; i<selectedmaps; i++)
|
||||
{
|
||||
GetArrayString(g_SelectedMaps, i, mapname, sizeof(mapname)) ;
|
||||
AddMenuItem(menu, mapname, mapname);
|
||||
}
|
||||
|
||||
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
||||
{
|
||||
ConfirmVote(param1);
|
||||
}
|
||||
else // no action was selected.
|
||||
{
|
||||
/* Re-enable the menu option */
|
||||
g_VoteMapInUse = false;
|
||||
}
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:info[32], String:name[32];
|
||||
|
||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||
|
||||
/* Remove selected map from global menu and add it to the selected array */
|
||||
RemoveMenuItem(menu, param2);
|
||||
PushArrayString(g_SelectedMaps, info);
|
||||
g_SelectedCount++;
|
||||
|
||||
|
||||
/* Redisplay the list */
|
||||
if (g_SelectedCount < 5)
|
||||
{
|
||||
DisplayMenu(g_MapList, param1, MENU_TIME_FOREVER);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfirmVote(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AdminMenu_VoteMap(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Vote Map", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
g_VoteMapInUse = true;
|
||||
ClearArray(g_SelectedMaps);
|
||||
g_SelectedCount = 0;
|
||||
DisplayMenu(g_MapList, param, MENU_TIME_FOREVER);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
/* disable this option if a vote is already running, theres no maps listed or someone else has already acessed this menu */
|
||||
buffer[0] = (IsVoteInProgress() || g_mapCount < 1 || g_VoteMapInUse) ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Votemap(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_votemap <mapname> [mapname2] ... [mapname5]");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if (!TestVoteDelay(client))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:text[256];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
decl String:maps[5][64];
|
||||
new mapCount;
|
||||
new len, pos;
|
||||
|
||||
while (pos != -1 && mapCount < 5)
|
||||
{
|
||||
pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
|
||||
|
||||
if (!IsMapValid(maps[mapCount]))
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
mapCount++;
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
len += pos;
|
||||
}
|
||||
}
|
||||
|
||||
DisplayVoteMapMenu(client, mapCount, maps);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
LoadMaps(Handle:menu)
|
||||
{
|
||||
decl String:mapPath[256];
|
||||
BuildPath(Path_SM, mapPath, sizeof(mapPath), "configs/menu_maplist.ini");
|
||||
|
||||
if (!FileExists(mapPath))
|
||||
{
|
||||
LogError("Unable to locate menu_maplist, no maps loaded.");
|
||||
|
||||
if (g_MapList != INVALID_HANDLE)
|
||||
{
|
||||
RemoveAllMenuItems(menu);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the file hasn't changed, there's no reason to reload
|
||||
// all of the maps.
|
||||
new fileTime = GetFileTime(mapPath, FileTime_LastChange);
|
||||
if (g_mapFileTime == fileTime)
|
||||
{
|
||||
return GetMenuItemCount(menu);
|
||||
}
|
||||
|
||||
g_mapFileTime = fileTime;
|
||||
|
||||
// Reset the array
|
||||
if (g_MapList != INVALID_HANDLE)
|
||||
{
|
||||
RemoveAllMenuItems(menu);
|
||||
}
|
||||
|
||||
LogMessage("[SM] Loading menu map list file [%s]", mapPath);
|
||||
|
||||
new Handle:file = OpenFile(mapPath, "rt");
|
||||
if (file == INVALID_HANDLE)
|
||||
{
|
||||
LogError("[SM] Could not open file: %s", mapPath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
decl String:buffer[64], len;
|
||||
while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
|
||||
{
|
||||
TrimString(buffer);
|
||||
|
||||
if ((len = StrContains(buffer, ".bsp", false)) != -1)
|
||||
{
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AddMenuItem(menu, buffer, buffer);
|
||||
}
|
||||
|
||||
CloseHandle(file);
|
||||
return GetMenuItemCount(menu);
|
||||
}
|
@ -53,4 +53,12 @@
|
||||
{
|
||||
"en" "Target player is not silenced."
|
||||
}
|
||||
"Gag/Mute Player"
|
||||
{
|
||||
"en" "Gag/Mute Player"
|
||||
}
|
||||
"Choose Type"
|
||||
{
|
||||
"en" "Choose Type"
|
||||
}
|
||||
}
|
@ -74,5 +74,25 @@
|
||||
"#format" "{1:s}"
|
||||
"en" "Turn friendly fire on? {1}"
|
||||
}
|
||||
"Vote Gravity"
|
||||
{
|
||||
"en" "Vote Gravity"
|
||||
}
|
||||
"Vote FF"
|
||||
{
|
||||
"en" "Vote FF"
|
||||
}
|
||||
"Vote Burn"
|
||||
{
|
||||
"en" "Vote Burn"
|
||||
}
|
||||
"Vote AllTalk"
|
||||
{
|
||||
"en" "Vote AllTalk"
|
||||
}
|
||||
"Vote Slay"
|
||||
{
|
||||
"en" "Vote Slay"
|
||||
}
|
||||
|
||||
}
|
@ -64,4 +64,20 @@
|
||||
"#format" "{1:s},{2:s}"
|
||||
"en" "The answer to {1} is: {2}."
|
||||
}
|
||||
"Vote Kick"
|
||||
{
|
||||
"en" "Vote Kick"
|
||||
}
|
||||
"Vote Ban"
|
||||
{
|
||||
"en" "Vote Ban"
|
||||
}
|
||||
"Vote Map"
|
||||
{
|
||||
"en" "Vote Map"
|
||||
}
|
||||
"Confirm Vote"
|
||||
{
|
||||
"en" "Confirm Vote"
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,10 @@
|
||||
"#format" "{1:s}"
|
||||
"en" "Slapped player '{1}'"
|
||||
}
|
||||
"Slay player"
|
||||
{
|
||||
"en" "Slay player"
|
||||
}
|
||||
|
||||
"Slayed player"
|
||||
{
|
||||
@ -276,5 +280,24 @@
|
||||
{
|
||||
"en" "Reload admins"
|
||||
}
|
||||
}
|
||||
|
||||
"Ban Player"
|
||||
{
|
||||
"en" "Ban Player"
|
||||
}
|
||||
"Ban Reason"
|
||||
{
|
||||
"en" "Ban Reason"
|
||||
}
|
||||
"Burn Player"
|
||||
{
|
||||
"en" "Burn Player"
|
||||
}
|
||||
"Slap Player"
|
||||
{
|
||||
"en" "Slap Player"
|
||||
}
|
||||
"Slap Damage"
|
||||
{
|
||||
"en" "Slap Damage"
|
||||
}
|
||||
}
|
@ -74,4 +74,16 @@
|
||||
{
|
||||
"en" "Admin cache has been refreshed."
|
||||
}
|
||||
"Check player access"
|
||||
{
|
||||
"en" "Check player access"
|
||||
}
|
||||
"Choose Map"
|
||||
{
|
||||
"en" "Choose Map"
|
||||
}
|
||||
"Exec CFG"
|
||||
{
|
||||
"en" "Exec CFG"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user