Merge pull request #934 from alliedmodders/enum-structs

Inauguration of SourcePawn enum structs
This commit is contained in:
David Anderson 2018-12-16 22:43:43 -08:00 committed by GitHub
commit ab7519530e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 203 additions and 188 deletions

View File

@ -73,8 +73,13 @@ Database hDatabase = null; /** Database connection */
int g_sequence = 0; /** Global unique sequence number */
int ConnectLock = 0; /** Connect sequence number */
int RebuildCachePart[3] = {0}; /** Cache part sequence numbers */
int PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */
bool PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */
enum struct PlayerInfo {
int sequencenum; /** Player-specific sequence numbers */
bool authed; /** Whether a player has been "pre-authed" */
}
PlayerInfo playerinfo[MAXPLAYERS+1];
//#define _DEBUG
@ -88,15 +93,15 @@ public void OnMapEnd()
public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
{
PlayerSeq[client] = 0;
PlayerAuth[client] = false;
playerinfo[client].sequencenum = 0;
playerinfo[client].authed = false;
return true;
}
public void OnClientDisconnect(int client)
{
PlayerSeq[client] = 0;
PlayerAuth[client] = false;
playerinfo[client].sequencenum = 0;
playerinfo[client].authed = false;
}
public void OnDatabaseConnect(Database db, const char[] error, any data)
@ -193,7 +198,7 @@ public void OnRebuildAdminCache(AdminCachePart part)
public Action OnClientPreAdminCheck(int client)
{
PlayerAuth[client] = true;
playerinfo[client].authed = true;
/**
* Play nice with other plugins. If there's no database, don't delay the
@ -241,7 +246,7 @@ public void OnReceiveUserGroups(Database db, DBResultSet rs, const char[] error,
/**
* Make sure it's the same client.
*/
if (PlayerSeq[client] != sequence)
if (playerinfo[client].sequencenum != sequence)
{
delete pk;
return;
@ -310,7 +315,7 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
* Check if this is the latest result request.
*/
int sequence = pk.ReadCell();
if (PlayerSeq[client] != sequence)
if (playerinfo[client].sequencenum != sequence)
{
/* Discard everything, since we're out of sequence. */
delete pk;
@ -504,11 +509,11 @@ void FetchUser(Database db, int client)
/**
* Send the actual query.
*/
PlayerSeq[client] = ++g_sequence;
playerinfo[client].sequencenum = ++g_sequence;
DataPack pk = new DataPack();
pk.WriteCell(client);
pk.WriteCell(PlayerSeq[client]);
pk.WriteCell(playerinfo[client].sequencenum);
pk.WriteString(query);
#if defined _DEBUG
@ -522,7 +527,7 @@ void FetchUsersWeCan(Database db)
{
for (int i=1; i<=MaxClients; i++)
{
if (PlayerAuth[i] && GetUserAdmin(i) == INVALID_ADMIN_ID)
if (playerinfo[i].authed && GetUserAdmin(i) == INVALID_ADMIN_ID)
{
FetchUser(db, i);
}

View File

@ -1,4 +1,4 @@
// vim: set noet:
#define NAME_LENGTH 64
#define CMD_LENGTH 255
@ -54,27 +54,27 @@ enum SubMenu_Type
SubMenu_OnOff
}
enum Item
enum struct Item
{
String:Item_cmd[256],
ExecuteType:Item_execute,
ArrayList:Item_submenus
char cmd[256];
ExecuteType execute;
ArrayList submenus;
}
enum Submenu
enum struct Submenu
{
SubMenu_Type:Submenu_type,
String:Submenu_title[32],
PlayerMethod:Submenu_method,
Submenu_listcount,
DataPack:Submenu_listdata
SubMenu_Type type;
char title[32];
PlayerMethod method;
int listcount;
DataPack listdata;
}
ArrayList g_DataArray;
void BuildDynamicMenu()
{
int itemInput[Item];
Item itemInput;
g_DataArray = new ArrayList(sizeof(itemInput));
char executeBuffer[32];
@ -150,70 +150,70 @@ void BuildDynamicMenu()
}
kvMenu.GetString("cmd", itemInput[Item_cmd], sizeof(itemInput[Item_cmd]));
kvMenu.GetString("cmd", itemInput.cmd, sizeof(itemInput.cmd));
kvMenu.GetString("execute", executeBuffer, sizeof(executeBuffer));
if (StrEqual(executeBuffer, "server"))
{
itemInput[Item_execute] = Execute_Server;
itemInput.execute = Execute_Server;
}
else //assume player type execute
{
itemInput[Item_execute] = Execute_Player;
itemInput.execute = Execute_Player;
}
/* iterate all submenus and load data into itemInput[Item_submenus] (ArrayList) */
int count = 1;
char countBuffer[10] = "1";
char inputBuffer[48];
while (kvMenu.JumpToKey(countBuffer))
{
int submenuInput[Submenu];
if (count == 1)
{
itemInput[Item_submenus] = new ArrayList(sizeof(submenuInput));
}
kvMenu.GetString("type", inputBuffer, sizeof(inputBuffer));
if (strncmp(inputBuffer,"group",5)==0)
/* iterate all submenus and load data into itemInput.submenus (ArrayList) */
int count = 1;
char countBuffer[10] = "1";
char inputBuffer[48];
while (kvMenu.JumpToKey(countBuffer))
{
Submenu submenuInput;
if (count == 1)
{
itemInput.submenus = new ArrayList(sizeof(submenuInput));
}
kvMenu.GetString("type", inputBuffer, sizeof(inputBuffer));
if (strncmp(inputBuffer,"group",5)==0)
{
if (StrContains(inputBuffer, "player") != -1)
{
submenuInput[Submenu_type] = SubMenu_GroupPlayer;
submenuInput.type = SubMenu_GroupPlayer;
}
else
{
submenuInput[Submenu_type] = SubMenu_Group;
submenuInput.type = SubMenu_Group;
}
}
else if (StrEqual(inputBuffer,"mapcycle"))
{
submenuInput[Submenu_type] = SubMenu_MapCycle;
submenuInput.type = SubMenu_MapCycle;
kvMenu.GetString("path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt");
submenuInput[Submenu_listdata] = new DataPack();
submenuInput[Submenu_listdata].WriteString(inputBuffer);
submenuInput[Submenu_listdata].Reset();
submenuInput.listdata = new DataPack();
submenuInput.listdata.WriteString(inputBuffer);
submenuInput.listdata.Reset();
}
else if (StrContains(inputBuffer, "player") != -1)
{
submenuInput[Submenu_type] = SubMenu_Player;
submenuInput.type = SubMenu_Player;
}
else if (StrEqual(inputBuffer,"onoff"))
{
submenuInput[Submenu_type] = SubMenu_OnOff;
submenuInput.type = SubMenu_OnOff;
}
else //assume 'list' type
{
submenuInput[Submenu_type] = SubMenu_List;
submenuInput.type = SubMenu_List;
submenuInput[Submenu_listdata] = new DataPack();
submenuInput.listdata = new DataPack();
char temp[6];
char value[64];
@ -242,63 +242,63 @@ void BuildDynamicMenu()
else
{
listcount++;
submenuInput[Submenu_listdata].WriteString(value);
submenuInput[Submenu_listdata].WriteString(text);
submenuInput[Submenu_listdata].WriteString(subadm);
submenuInput.listdata.WriteString(value);
submenuInput.listdata.WriteString(text);
submenuInput.listdata.WriteString(subadm);
}
i++;
} while (more);
submenuInput[Submenu_listdata].Reset();
submenuInput[Submenu_listcount] = listcount;
submenuInput.listdata.Reset();
submenuInput.listcount = listcount;
}
if ((submenuInput[Submenu_type] == SubMenu_Player) || (submenuInput[Submenu_type] == SubMenu_GroupPlayer))
if ((submenuInput.type == SubMenu_Player) || (submenuInput.type == SubMenu_GroupPlayer))
{
kvMenu.GetString("method", inputBuffer, sizeof(inputBuffer));
if (StrEqual(inputBuffer, "clientid"))
{
submenuInput[Submenu_method] = ClientId;
submenuInput.method = ClientId;
}
else if (StrEqual(inputBuffer, "steamid"))
{
submenuInput[Submenu_method] = SteamId;
submenuInput.method = SteamId;
}
else if (StrEqual(inputBuffer, "userid2"))
{
submenuInput[Submenu_method] = UserId2;
submenuInput.method = UserId2;
}
else if (StrEqual(inputBuffer, "userid"))
{
submenuInput[Submenu_method] = UserId;
submenuInput.method = UserId;
}
else if (StrEqual(inputBuffer, "ip"))
{
submenuInput[Submenu_method] = IpAddress;
submenuInput.method = IpAddress;
}
else
{
submenuInput[Submenu_method] = Name;
submenuInput.method = Name;
}
}
kvMenu.GetString("title", inputBuffer, sizeof(inputBuffer));
strcopy(submenuInput[Submenu_title], sizeof(submenuInput[Submenu_title]), inputBuffer);
count++;
Format(countBuffer, sizeof(countBuffer), "%i", count);
itemInput[Item_submenus].PushArray(submenuInput[0]);
kvMenu.GoBack();
}
/* Save this entire item into the global items array and add it to the menu */
int location = g_DataArray.PushArray(itemInput[0]);
strcopy(submenuInput.title, sizeof(submenuInput.title), inputBuffer);
count++;
Format(countBuffer, sizeof(countBuffer), "%i", count);
itemInput.submenus.PushArray(submenuInput);
kvMenu.GoBack();
}
/* Save this entire item into the global items array and add it to the menu */
int location = g_DataArray.PushArray(itemInput);
char locString[10];
IntToString(location, locString, sizeof(locString));
@ -327,9 +327,9 @@ void ParseConfigs()
if (!g_configParser)
g_configParser = new SMCParser();
g_configParser.OnEnterSection = NewSection;
g_configParser.OnKeyValue = KeyValue;
g_configParser.OnLeaveSection = EndSection;
g_configParser.OnEnterSection = NewSection;
g_configParser.OnKeyValue = KeyValue;
g_configParser.OnLeaveSection = EndSection;
delete g_groupList[groupListName];
delete g_groupList[groupListCommand];
@ -416,10 +416,10 @@ public void DynamicMenuItemHandler(TopMenu topmenu,
int location = StringToInt(locString);
int output[Item];
g_DataArray.GetArray(location, output[0]);
Item output;
g_DataArray.GetArray(location, output);
strcopy(g_command[param], sizeof(g_command[]), output[Item_cmd]);
strcopy(g_command[param], sizeof(g_command[]), output.cmd);
g_currentPlace[param][Place_Item] = location;
g_currentPlace[param][Place_ReplaceNum] = 1;
@ -433,10 +433,10 @@ public void ParamCheck(int client)
char buffer[6];
char buffer2[6];
int outputItem[Item];
int outputSubmenu[Submenu];
Item outputItem;
Submenu outputSubmenu;
g_DataArray.GetArray(g_currentPlace[client][Place_Item], outputItem[0]);
g_DataArray.GetArray(g_currentPlace[client][Place_Item], outputItem);
if (g_currentPlace[client][Place_ReplaceNum] < 1)
{
@ -448,12 +448,12 @@ public void ParamCheck(int client)
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
{
outputItem[Item_submenus].GetArray(g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]);
outputItem.submenus.GetArray(g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu);
Menu itemMenu = new Menu(Menu_Selection);
itemMenu.ExitBackButton = true;
if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
if ((outputSubmenu.type == SubMenu_Group) || (outputSubmenu.type == SubMenu_GroupPlayer))
{
char nameBuffer[ARRAY_STRING_LENGTH];
char commandBuffer[ARRAY_STRING_LENGTH];
@ -466,11 +466,11 @@ public void ParamCheck(int client)
}
}
if (outputSubmenu[Submenu_type] == SubMenu_MapCycle)
if (outputSubmenu.type == SubMenu_MapCycle)
{
char path[200];
outputSubmenu[Submenu_listdata].ReadString(path, sizeof(path));
outputSubmenu[Submenu_listdata].Reset();
outputSubmenu.listdata.ReadString(path, sizeof(path));
outputSubmenu.listdata.Reset();
File file = OpenFile(path, "rt");
char readData[128];
@ -488,9 +488,9 @@ public void ParamCheck(int client)
}
}
}
else if ((outputSubmenu[Submenu_type] == SubMenu_Player) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
else if ((outputSubmenu.type == SubMenu_Player) || (outputSubmenu.type == SubMenu_GroupPlayer))
{
PlayerMethod playermethod = outputSubmenu[Submenu_method];
PlayerMethod playermethod = outputSubmenu.method;
char nameBuffer[MAX_NAME_LENGTH];
char infoBuffer[32];
@ -540,7 +540,7 @@ public void ParamCheck(int client)
}
}
}
else if (outputSubmenu[Submenu_type] == SubMenu_OnOff)
else if (outputSubmenu.type == SubMenu_OnOff)
{
itemMenu.AddItem("1", "On");
itemMenu.AddItem("0", "Off");
@ -552,11 +552,11 @@ public void ParamCheck(int client)
char admin[NAME_LENGTH];
for (int i=0; i<outputSubmenu[Submenu_listcount]; i++)
for (int i=0; i<outputSubmenu.listcount; i++)
{
outputSubmenu[Submenu_listdata].ReadString(value, sizeof(value));
outputSubmenu[Submenu_listdata].ReadString(text, sizeof(text));
outputSubmenu[Submenu_listdata].ReadString(admin, sizeof(admin));
outputSubmenu.listdata.ReadString(value, sizeof(value));
outputSubmenu.listdata.ReadString(text, sizeof(text));
outputSubmenu.listdata.ReadString(admin, sizeof(admin));
if (CheckCommandAccess(client, admin, 0))
{
@ -564,10 +564,10 @@ public void ParamCheck(int client)
}
}
outputSubmenu[Submenu_listdata].Reset();
outputSubmenu.listdata.Reset();
}
itemMenu.SetTitle(outputSubmenu[Submenu_title]);
itemMenu.SetTitle(outputSubmenu.title);
itemMenu.Display(client, MENU_TIME_FOREVER);
}
@ -580,7 +580,7 @@ public void ParamCheck(int client)
char unquotedCommand[CMD_LENGTH];
UnQuoteString(g_command[client], unquotedCommand, sizeof(unquotedCommand), "#@");
if (outputItem[Item_execute] == Execute_Player) // assume 'player' type execute option
if (outputItem.execute == Execute_Player) // assume 'player' type execute option
{
FakeClientCommand(client, unquotedCommand);
}

View File

@ -46,11 +46,15 @@ public Plugin myinfo =
url = "http://www.sourcemod.net/"
};
float g_LastTime[MAXPLAYERS + 1] = {0.0, ...}; /* Last time player used say or say_team */
int g_FloodTokens[MAXPLAYERS + 1] = {0, ...}; /* Number of flood tokens player has */
enum struct PlayerInfo {
float lastTime; /* Last time player used say or say_team */
int tokenCount; /* Number of flood tokens player has */
}
PlayerInfo playerinfo[MAXPLAYERS+1];
ConVar sm_flood_time; /* Handle to sm_flood_time convar */
float max_chat;
public void OnPluginStart()
{
sm_flood_time = CreateConVar("sm_flood_time", "0.75", "Amount of time allowed between chat messages");
@ -58,11 +62,10 @@ public void OnPluginStart()
public void OnClientPutInServer(int client)
{
g_LastTime[client] = 0.0;
g_FloodTokens[client] = 0;
playerinfo[client].lastTime = 0.0;
playerinfo[client].tokenCount = 0;
}
float max_chat;
public bool OnClientFloodCheck(int client)
{
@ -74,10 +77,10 @@ public bool OnClientFloodCheck(int client)
return false;
}
if (g_LastTime[client] >= GetGameTime())
if (playerinfo[client].lastTime >= GetGameTime())
{
/* If player has 3 or more flood tokens, block their message */
if (g_FloodTokens[client] >= 3)
if (playerinfo[client].tokenCount >= 3)
{
return true;
}
@ -97,7 +100,7 @@ public void OnClientFloodResult(int client, bool blocked)
float curTime = GetGameTime();
float newTime = curTime + max_chat;
if (g_LastTime[client] >= curTime)
if (playerinfo[client].lastTime >= curTime)
{
/* If the last message was blocked, update their time limit */
if (blocked)
@ -105,16 +108,16 @@ public void OnClientFloodResult(int client, bool blocked)
newTime += 3.0;
}
/* Add one flood token when player goes over chat time limit */
else if (g_FloodTokens[client] < 3)
else if (playerinfo[client].tokenCount < 3)
{
g_FloodTokens[client]++;
playerinfo[client].tokenCount++;
}
}
else if (g_FloodTokens[client] > 0)
else if (playerinfo[client].tokenCount > 0)
{
/* Remove one flood token when player chats within time limit (slow decay) */
g_FloodTokens[client]--;
playerinfo[client].tokenCount--;
}
g_LastTime[client] = newTime;
playerinfo[client].lastTime = newTime;
}

View File

@ -50,11 +50,15 @@ public Plugin myinfo =
TopMenu hTopMenu;
int g_BanTarget[MAXPLAYERS+1];
int g_BanTargetUserId[MAXPLAYERS+1];
int g_BanTime[MAXPLAYERS+1];
enum struct PlayerInfo {
int banTarget;
int banTargetUserId;
int banTime;
int isWaitingForChatReason;
}
PlayerInfo playerinfo[MAXPLAYERS+1];
bool g_IsWaitingForChatReason[MAXPLAYERS+1];
KeyValues g_hKvBanReasons;
char g_BanReasonsPath[PLATFORM_MAX_PATH];
@ -94,7 +98,7 @@ public void OnConfigsExecuted()
public void OnClientDisconnect(int client)
{
g_IsWaitingForChatReason[client] = false;
playerinfo[client].isWaitingForChatReason = false;
}
void LoadBanReasons()
@ -365,9 +369,9 @@ public Action Command_AbortBan(int client, int args)
ReplyToCommand(client, "[SM] %t", "No Access");
return Plugin_Handled;
}
if(g_IsWaitingForChatReason[client])
if(playerinfo[client].isWaitingForChatReason)
{
g_IsWaitingForChatReason[client] = false;
playerinfo[client].isWaitingForChatReason = false;
ReplyToCommand(client, "[SM] %t", "AbortBan applied successfully");
}
else
@ -380,10 +384,10 @@ public Action Command_AbortBan(int client, int args)
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
{
if(g_IsWaitingForChatReason[client])
if(playerinfo[client].isWaitingForChatReason)
{
g_IsWaitingForChatReason[client] = false;
PrepareBan(client, g_BanTarget[client], g_BanTime[client], sArgs);
playerinfo[client].isWaitingForChatReason = false;
PrepareBan(client, playerinfo[client].banTarget, playerinfo[client].banTime, sArgs);
return Plugin_Stop;
}

View File

@ -33,7 +33,7 @@
void PrepareBan(int client, int target, int time, const char[] reason)
{
int originalTarget = GetClientOfUserId(g_BanTargetUserId[client]);
int originalTarget = GetClientOfUserId(playerinfo[client].banTargetUserId);
if (originalTarget != target)
{
@ -106,7 +106,7 @@ void DisplayBanTimeMenu(int client)
Menu menu = new Menu(MenuHandler_BanTimeList);
char title[100];
Format(title, sizeof(title), "%T: %N", "Ban player", client, g_BanTarget[client]);
Format(title, sizeof(title), "%T: %N", "Ban player", client, playerinfo[client].banTarget);
menu.SetTitle(title);
menu.ExitBackButton = true;
@ -126,7 +126,7 @@ void DisplayBanReasonMenu(int client)
Menu menu = new Menu(MenuHandler_BanReasonList);
char title[100];
Format(title, sizeof(title), "%T: %N", "Ban reason", client, g_BanTarget[client]);
Format(title, sizeof(title), "%T: %N", "Ban reason", client, playerinfo[client].banTarget);
menu.SetTitle(title);
menu.ExitBackButton = true;
@ -163,7 +163,7 @@ public void AdminMenu_Ban(TopMenu topmenu,
int maxlength)
{
//Reset chat reason first
g_IsWaitingForChatReason[param] = false;
playerinfo[param].isWaitingForChatReason = false;
if (action == TopMenuAction_DisplayOption)
{
@ -193,7 +193,7 @@ public int MenuHandler_BanReasonList(Menu menu, MenuAction action, int param1, i
if(param2 == 0)
{
//Chat reason
g_IsWaitingForChatReason[param1] = true;
playerinfo[param1].isWaitingForChatReason = true;
PrintToChat(param1, "[SM] %t", "Custom ban reason explanation", "sm_abortban");
}
else
@ -202,7 +202,7 @@ public int MenuHandler_BanReasonList(Menu menu, MenuAction action, int param1, i
menu.GetItem(param2, info, sizeof(info));
PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info);
PrepareBan(param1, playerinfo[param1].banTarget, playerinfo[param1].banTime, info);
}
}
}
@ -238,8 +238,8 @@ public int MenuHandler_BanPlayerList(Menu menu, MenuAction action, int param1, i
}
else
{
g_BanTarget[param1] = target;
g_BanTargetUserId[param1] = userid;
playerinfo[param1].banTarget = target;
playerinfo[param1].banTargetUserId = userid;
DisplayBanTimeMenu(param1);
}
}
@ -263,7 +263,7 @@ public int MenuHandler_BanTimeList(Menu menu, MenuAction action, int param1, int
char info[32];
menu.GetItem(param2, info, sizeof(info));
g_BanTime[param1] = StringToInt(info);
playerinfo[param1].banTime = StringToInt(info);
DisplayBanReasonMenu(param1);
}
@ -309,10 +309,9 @@ public Action Command_Ban(int client, int args)
Arguments[0] = '\0';
}
playerinfo[client].banTargetUserId = GetClientUserId(target);
int time = StringToInt(s_time);
g_BanTargetUserId[client] = GetClientUserId(target);
PrepareBan(client, target, time, Arguments[len]);
return Plugin_Handled;

View File

@ -48,8 +48,13 @@ public Plugin myinfo =
url = "http://www.sourcemod.net/"
};
bool g_Muted[MAXPLAYERS+1]; // Is the player muted?
bool g_Gagged[MAXPLAYERS+1]; // Is the player gagged?
enum struct PlayerState {
bool isMuted; // Is the player muted?
bool isGagged; // Is the player gagged?
int gagTarget;
}
PlayerState playerstate[MAXPLAYERS+1];
ConVar g_Cvar_Deadtalk; // Holds the handle for sm_deadtalk
ConVar g_Cvar_Alltalk; // Holds the handle for sv_alltalk
@ -57,8 +62,6 @@ bool g_Hooked = false; // Tracks if we've hooked events for deadtalk
TopMenu hTopMenu;
int g_GagTarget[MAXPLAYERS+1];
#include "basecomm/gag.sp"
#include "basecomm/natives.sp"
#include "basecomm/forwards.sp"
@ -141,15 +144,15 @@ public void ConVarChange_Deadtalk(ConVar convar, const char[] oldValue, const ch
public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
{
g_Gagged[client] = false;
g_Muted[client] = false;
playerstate[client].isGagged = false;
playerstate[client].isMuted = false;
return true;
}
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
{
if (client && g_Gagged[client])
if (client && playerstate[client].isGagged)
{
return Plugin_Stop;
}
@ -168,7 +171,7 @@ public void ConVarChange_Alltalk(ConVar convar, const char[] oldValue, const cha
continue;
}
if (g_Muted[i])
if (playerstate[i].isMuted)
{
SetClientListeningFlags(i, VOICE_MUTED);
}
@ -199,7 +202,7 @@ public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast
return;
}
if (g_Muted[client])
if (playerstate[client].isMuted)
{
SetClientListeningFlags(client, VOICE_MUTED);
}
@ -218,7 +221,7 @@ public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast
return;
}
if (g_Muted[client])
if (playerstate[client].isMuted)
{
SetClientListeningFlags(client, VOICE_MUTED);
return;

View File

@ -44,15 +44,14 @@ enum CommType
void DisplayGagTypesMenu(int client)
{
Menu menu = new Menu(MenuHandler_GagTypes);
int target = playerstate[client].gagTarget;
char title[100];
Format(title, sizeof(title), "%T: %N", "Choose Type", client, g_GagTarget[client]);
Format(title, sizeof(title), "%T: %N", "Choose Type", client, target);
menu.SetTitle(title);
menu.ExitBackButton = true;
int target = g_GagTarget[client];
if (!g_Muted[target])
if (!playerstate[target].isMuted)
{
AddTranslatedMenuItem(menu, "0", "Mute Player", client);
}
@ -61,7 +60,7 @@ void DisplayGagTypesMenu(int client)
AddTranslatedMenuItem(menu, "1", "UnMute Player", client);
}
if (!g_Gagged[target])
if (!playerstate[target].isGagged)
{
AddTranslatedMenuItem(menu, "2", "Gag Player", client);
}
@ -70,7 +69,7 @@ void DisplayGagTypesMenu(int client)
AddTranslatedMenuItem(menu, "3", "UnGag Player", client);
}
if (!g_Muted[target] || !g_Gagged[target])
if (!playerstate[target].isMuted || !playerstate[target].isGagged)
{
AddTranslatedMenuItem(menu, "4", "Silence Player", client);
}
@ -151,7 +150,7 @@ public int MenuHandler_GagPlayer(Menu menu, MenuAction action, int param1, int p
}
else
{
g_GagTarget[param1] = GetClientOfUserId(userid);
playerstate[param1].gagTarget = GetClientOfUserId(userid);
DisplayGagTypesMenu(param1);
}
}
@ -178,39 +177,41 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
menu.GetItem(param2, info, sizeof(info));
type = view_as<CommType>(StringToInt(info));
int target = playerstate[param1].gagTarget;
char name[MAX_NAME_LENGTH];
GetClientName(g_GagTarget[param1], name, sizeof(name));
GetClientName(target, name, sizeof(name));
switch (type)
{
case CommType_Mute:
{
PerformMute(param1, g_GagTarget[param1]);
PerformMute(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
}
case CommType_UnMute:
{
PerformUnMute(param1, g_GagTarget[param1]);
PerformUnMute(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
}
case CommType_Gag:
{
PerformGag(param1, g_GagTarget[param1]);
PerformGag(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
}
case CommType_UnGag:
{
PerformUnGag(param1, g_GagTarget[param1]);
PerformUnGag(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
}
case CommType_Silence:
{
PerformSilence(param1, g_GagTarget[param1]);
PerformSilence(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
}
case CommType_UnSilence:
{
PerformUnSilence(param1, g_GagTarget[param1]);
PerformUnSilence(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
}
}
@ -219,7 +220,7 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
void PerformMute(int client, int target, bool silent=false)
{
g_Muted[target] = true;
playerstate[target].isMuted = true;
SetClientListeningFlags(target, VOICE_MUTED);
FireOnClientMute(target, true);
@ -232,7 +233,7 @@ void PerformMute(int client, int target, bool silent=false)
void PerformUnMute(int client, int target, bool silent=false)
{
g_Muted[target] = false;
playerstate[target].isMuted = false;
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
{
SetClientListeningFlags(target, VOICE_LISTENALL);
@ -256,7 +257,7 @@ void PerformUnMute(int client, int target, bool silent=false)
void PerformGag(int client, int target, bool silent=false)
{
g_Gagged[target] = true;
playerstate[target].isGagged = true;
FireOnClientGag(target, true);
if (!silent)
@ -267,7 +268,7 @@ void PerformGag(int client, int target, bool silent=false)
void PerformUnGag(int client, int target, bool silent=false)
{
g_Gagged[target] = false;
playerstate[target].isGagged = false;
FireOnClientGag(target, false);
if (!silent)
@ -278,15 +279,15 @@ void PerformUnGag(int client, int target, bool silent=false)
void PerformSilence(int client, int target)
{
if (!g_Gagged[target])
if (!playerstate[target].isGagged)
{
g_Gagged[target] = true;
playerstate[target].isGagged = true;
FireOnClientGag(target, true);
}
if (!g_Muted[target])
if (!playerstate[target].isMuted)
{
g_Muted[target] = true;
playerstate[target].isMuted = true;
SetClientListeningFlags(target, VOICE_MUTED);
FireOnClientMute(target, true);
}
@ -296,15 +297,15 @@ void PerformSilence(int client, int target)
void PerformUnSilence(int client, int target)
{
if (g_Gagged[target])
if (playerstate[target].isGagged)
{
g_Gagged[target] = false;
playerstate[target].isGagged = false;
FireOnClientGag(target, false);
}
if (g_Muted[target])
if (playerstate[target].isMuted)
{
g_Muted[target] = false;
playerstate[target].isMuted = false;
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
{
@ -501,7 +502,7 @@ public Action Command_Unmute(int client, int args)
{
int target = target_list[i];
if (!g_Muted[target])
if (!playerstate[target].isMuted)
{
continue;
}

View File

@ -44,7 +44,7 @@
return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
}
return g_Gagged[client];
return playerstate[client].isGagged;
}
public int Native_IsClientMuted(Handle hPlugin, int numParams)
@ -60,7 +60,7 @@ public int Native_IsClientMuted(Handle hPlugin, int numParams)
return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
}
return g_Muted[client];
return playerstate[client].isMuted;
}
public int Native_SetClientGag(Handle hPlugin, int numParams)
@ -80,7 +80,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
if (gagState)
{
if (g_Gagged[client])
if (playerstate[client].isGagged)
{
return false;
}
@ -89,7 +89,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
}
else
{
if (!g_Gagged[client])
if (!playerstate[client].isGagged)
{
return false;
}
@ -117,7 +117,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
if (muteState)
{
if (g_Muted[client])
if (playerstate[client].isMuted)
{
return false;
}
@ -126,7 +126,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
}
else
{
if (!g_Muted[client])
if (!playerstate[client].isMuted)
{
return false;
}

@ -1 +1 @@
Subproject commit bee3fc51a95a6aab4143779316353ed64531fbf3
Subproject commit 84d47f1a1850f9d134022677d91209985206a07c

@ -1 +1 @@
Subproject commit 7ee59e995de20be62375fad242f6d8413add8a85
Subproject commit 7915dde93cab5f9ce0d2318e3e4578db3a712ab6