Merge remote-tracking branch 'remotes/origin/master' into mapchooser-updates
Conflicts: plugins/nominations.sp plugins/rockthevote.sp
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Admin File Reader",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -46,18 +46,18 @@ public Plugin:myinfo =
|
||||
};
|
||||
|
||||
/** Various parsing globals */
|
||||
new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */
|
||||
new g_ErrorCount = 0; /* Current error count */
|
||||
new g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */
|
||||
new g_CurrentLine = 0; /* Current line we're on */
|
||||
new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
|
||||
bool g_LoggedFileName = false; /* Whether or not the file name has been logged */
|
||||
int g_ErrorCount = 0; /* Current error count */
|
||||
int g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */
|
||||
int g_CurrentLine = 0; /* Current line we're on */
|
||||
char g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
|
||||
|
||||
#include "admin-overrides.sp"
|
||||
#include "admin-groups.sp"
|
||||
#include "admin-users.sp"
|
||||
#include "admin-simple.sp"
|
||||
|
||||
public OnRebuildAdminCache(AdminCachePart:part)
|
||||
public void OnRebuildAdminCache(AdminCachePart part)
|
||||
{
|
||||
if (part == AdminCache_Overrides)
|
||||
{
|
||||
@@ -70,9 +70,9 @@ public OnRebuildAdminCache(AdminCachePart:part)
|
||||
}
|
||||
}
|
||||
|
||||
ParseError(const String:format[], any:...)
|
||||
void ParseError(const char[] format, any ...)
|
||||
{
|
||||
decl String:buffer[512];
|
||||
char buffer[512];
|
||||
|
||||
if (!g_LoggedFileName)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ ParseError(const String:format[], any:...)
|
||||
g_ErrorCount++;
|
||||
}
|
||||
|
||||
InitGlobalStates()
|
||||
void InitGlobalStates()
|
||||
{
|
||||
g_ErrorCount = 0;
|
||||
g_IgnoreLevel = 0;
|
||||
|
||||
@@ -31,18 +31,26 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#define GROUP_STATE_NONE 0
|
||||
#define GROUP_STATE_GROUPS 1
|
||||
#define GROUP_STATE_INGROUP 2
|
||||
#define GROUP_STATE_OVERRIDES 3
|
||||
#define GROUP_PASS_FIRST 1
|
||||
#define GROUP_PASS_SECOND 2
|
||||
enum GroupState
|
||||
{
|
||||
GroupState_None,
|
||||
GroupState_Groups,
|
||||
GroupState_InGroup,
|
||||
GroupState_Overrides,
|
||||
}
|
||||
|
||||
enum GroupPass
|
||||
{
|
||||
GroupPass_Invalid,
|
||||
GroupPass_First,
|
||||
GroupPass_Second,
|
||||
}
|
||||
|
||||
static SMCParser g_hGroupParser;
|
||||
static GroupId:g_CurGrp = INVALID_GROUP_ID;
|
||||
static g_GroupState = GROUP_STATE_NONE;
|
||||
static g_GroupPass = 0;
|
||||
static bool:g_NeedReparse = false;
|
||||
static GroupId g_CurGrp = INVALID_GROUP_ID;
|
||||
static GroupState g_GroupState = GroupState_None;
|
||||
static GroupPass g_GroupPass = GroupPass_Invalid;
|
||||
static bool g_NeedReparse = false;
|
||||
|
||||
public SMCResult ReadGroups_NewSection(SMCParser smc, const char[] name, bool opt_quotes)
|
||||
{
|
||||
@@ -52,24 +60,24 @@ public SMCResult ReadGroups_NewSection(SMCParser smc, const char[] name, bool op
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_GroupState == GROUP_STATE_NONE)
|
||||
if (g_GroupState == GroupState_None)
|
||||
{
|
||||
if (StrEqual(name, "Groups"))
|
||||
{
|
||||
g_GroupState = GROUP_STATE_GROUPS;
|
||||
g_GroupState = GroupState_Groups;
|
||||
} else {
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
} else if (g_GroupState == GROUP_STATE_GROUPS) {
|
||||
} else if (g_GroupState == GroupState_Groups) {
|
||||
if ((g_CurGrp = CreateAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
g_CurGrp = FindAdmGroup(name);
|
||||
}
|
||||
g_GroupState = GROUP_STATE_INGROUP;
|
||||
} else if (g_GroupState == GROUP_STATE_INGROUP) {
|
||||
g_GroupState = GroupState_InGroup;
|
||||
} else if (g_GroupState == GroupState_InGroup) {
|
||||
if (StrEqual(name, "Overrides"))
|
||||
{
|
||||
g_GroupState = GROUP_STATE_OVERRIDES;
|
||||
g_GroupState = GroupState_Overrides;
|
||||
} else {
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
@@ -91,28 +99,28 @@ public SMCResult ReadGroups_KeyValue(SMCParser smc,
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
new AdminFlag:flag;
|
||||
AdminFlag flag;
|
||||
|
||||
if (g_GroupPass == GROUP_PASS_FIRST)
|
||||
if (g_GroupPass == GroupPass_First)
|
||||
{
|
||||
if (g_GroupState == GROUP_STATE_INGROUP)
|
||||
if (g_GroupState == GroupState_InGroup)
|
||||
{
|
||||
if (StrEqual(key, "flags"))
|
||||
{
|
||||
new len = strlen(value);
|
||||
for (new i=0; i<len; i++)
|
||||
int len = strlen(value);
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
if (!FindFlagByChar(value[i], flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAdmGroupAddFlag(g_CurGrp, flag, true);
|
||||
g_CurGrp.SetFlag(flag, true);
|
||||
}
|
||||
} else if (StrEqual(key, "immunity")) {
|
||||
g_NeedReparse = true;
|
||||
}
|
||||
} else if (g_GroupState == GROUP_STATE_OVERRIDES) {
|
||||
new OverrideRule:rule = Command_Deny;
|
||||
} else if (g_GroupState == GroupState_Overrides) {
|
||||
OverrideRule rule = Command_Deny;
|
||||
|
||||
if (StrEqual(value, "allow", false))
|
||||
{
|
||||
@@ -121,29 +129,29 @@ public SMCResult ReadGroups_KeyValue(SMCParser smc,
|
||||
|
||||
if (key[0] == '@')
|
||||
{
|
||||
AddAdmGroupCmdOverride(g_CurGrp, key[1], Override_CommandGroup, rule);
|
||||
g_CurGrp.AddCommandOverride(key[1], Override_CommandGroup, rule);
|
||||
} else {
|
||||
AddAdmGroupCmdOverride(g_CurGrp, key, Override_Command, rule);
|
||||
g_CurGrp.AddCommandOverride(key, Override_Command, rule);
|
||||
}
|
||||
}
|
||||
} else if (g_GroupPass == GROUP_PASS_SECOND
|
||||
&& g_GroupState == GROUP_STATE_INGROUP) {
|
||||
} else if (g_GroupPass == GroupPass_Second
|
||||
&& g_GroupState == GroupState_InGroup) {
|
||||
/* Check for immunity again, core should handle double inserts */
|
||||
if (StrEqual(key, "immunity"))
|
||||
{
|
||||
/* If it's a value we know about, use it */
|
||||
if (StrEqual(value, "*"))
|
||||
{
|
||||
SetAdmGroupImmunityLevel(g_CurGrp, 2);
|
||||
g_CurGrp.ImmunityLevel = 2;
|
||||
} else if (StrEqual(value, "$")) {
|
||||
SetAdmGroupImmunityLevel(g_CurGrp, 1);
|
||||
g_CurGrp.ImmunityLevel = 1;
|
||||
} else {
|
||||
new level;
|
||||
int level;
|
||||
if (StringToIntEx(value, level))
|
||||
{
|
||||
SetAdmGroupImmunityLevel(g_CurGrp, level);
|
||||
g_CurGrp.ImmunityLevel = level;
|
||||
} else {
|
||||
new GroupId:id;
|
||||
GroupId id;
|
||||
if (value[0] == '@')
|
||||
{
|
||||
id = FindAdmGroup(value[1]);
|
||||
@@ -152,7 +160,7 @@ public SMCResult ReadGroups_KeyValue(SMCParser smc,
|
||||
}
|
||||
if (id != INVALID_GROUP_ID)
|
||||
{
|
||||
SetAdmGroupImmuneFrom(g_CurGrp, id);
|
||||
g_CurGrp.AddGroupImmunity(id);
|
||||
} else {
|
||||
ParseError("Unable to find group: \"%s\"", value);
|
||||
}
|
||||
@@ -173,14 +181,14 @@ public SMCResult ReadGroups_EndSection(SMCParser smc)
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_GroupState == GROUP_STATE_OVERRIDES)
|
||||
if (g_GroupState == GroupState_Overrides)
|
||||
{
|
||||
g_GroupState = GROUP_STATE_INGROUP;
|
||||
} else if (g_GroupState == GROUP_STATE_INGROUP) {
|
||||
g_GroupState = GROUP_STATE_GROUPS;
|
||||
g_GroupState = GroupState_InGroup;
|
||||
} else if (g_GroupState == GroupState_InGroup) {
|
||||
g_GroupState = GroupState_Groups;
|
||||
g_CurGrp = INVALID_GROUP_ID;
|
||||
} else if (g_GroupState == GROUP_STATE_GROUPS) {
|
||||
g_GroupState = GROUP_STATE_NONE;
|
||||
} else if (g_GroupState == GroupState_Groups) {
|
||||
g_GroupState = GroupState_None;
|
||||
}
|
||||
|
||||
return SMCParse_Continue;
|
||||
@@ -193,7 +201,7 @@ public SMCResult ReadGroups_CurrentLine(SMCParser smc, const char[] line, int li
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
static InitializeGroupParser()
|
||||
static void InitializeGroupParser()
|
||||
{
|
||||
if (!g_hGroupParser)
|
||||
{
|
||||
@@ -205,11 +213,11 @@ static InitializeGroupParser()
|
||||
}
|
||||
}
|
||||
|
||||
static InternalReadGroups(const String:path[], pass)
|
||||
static void InternalReadGroups(const char[] path, GroupPass pass)
|
||||
{
|
||||
/* Set states */
|
||||
InitGlobalStates();
|
||||
g_GroupState = GROUP_STATE_NONE;
|
||||
g_GroupState = GroupState_None;
|
||||
g_CurGrp = INVALID_GROUP_ID;
|
||||
g_GroupPass = pass;
|
||||
g_NeedReparse = false;
|
||||
@@ -227,16 +235,16 @@ static InternalReadGroups(const String:path[], pass)
|
||||
}
|
||||
}
|
||||
|
||||
ReadGroups()
|
||||
void ReadGroups()
|
||||
{
|
||||
InitializeGroupParser();
|
||||
|
||||
BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admin_groups.cfg");
|
||||
|
||||
InternalReadGroups(g_Filename, GROUP_PASS_FIRST);
|
||||
InternalReadGroups(g_Filename, GroupPass_First);
|
||||
if (g_NeedReparse)
|
||||
{
|
||||
InternalReadGroups(g_Filename, GROUP_PASS_SECOND);
|
||||
InternalReadGroups(g_Filename, GroupPass_Second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,16 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#define OVERRIDE_STATE_NONE 0
|
||||
#define OVERRIDE_STATE_LEVELS 1
|
||||
#define OVERRIDE_STATE_OVERRIDES 2
|
||||
enum OverrideState
|
||||
{
|
||||
OverrideState_None,
|
||||
OverrideState_Levels,
|
||||
OverrideState_Overrides,
|
||||
}
|
||||
|
||||
static SMCParser g_hOldOverrideParser;
|
||||
static SMCParser g_hNewOverrideParser;
|
||||
static g_OverrideState = OVERRIDE_STATE_NONE;
|
||||
static OverrideState g_OverrideState = OverrideState_None;
|
||||
|
||||
public SMCResult ReadOldOverrides_NewSection(SMCParser smc, const char[] name, bool opt_quotes)
|
||||
{
|
||||
@@ -48,18 +51,18 @@ public SMCResult ReadOldOverrides_NewSection(SMCParser smc, const char[] name, b
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_OverrideState == OVERRIDE_STATE_NONE)
|
||||
if (g_OverrideState == OverrideState_None)
|
||||
{
|
||||
if (StrEqual(name, "Levels"))
|
||||
{
|
||||
g_OverrideState = OVERRIDE_STATE_LEVELS;
|
||||
g_OverrideState = OverrideState_Levels;
|
||||
} else {
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
} else if (g_OverrideState == OVERRIDE_STATE_LEVELS) {
|
||||
} else if (g_OverrideState == OverrideState_Levels) {
|
||||
if (StrEqual(name, "Overrides"))
|
||||
{
|
||||
g_OverrideState = OVERRIDE_STATE_OVERRIDES;
|
||||
g_OverrideState = OverrideState_Overrides;
|
||||
} else {
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
@@ -78,11 +81,11 @@ public SMCResult ReadNewOverrides_NewSection(SMCParser smc, const char[] name, b
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_OverrideState == OVERRIDE_STATE_NONE)
|
||||
if (g_OverrideState == OverrideState_None)
|
||||
{
|
||||
if (StrEqual(name, "Overrides"))
|
||||
{
|
||||
g_OverrideState = OVERRIDE_STATE_OVERRIDES;
|
||||
g_OverrideState = OverrideState_Overrides;
|
||||
} else {
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
@@ -99,7 +102,7 @@ public SMCResult ReadOverrides_KeyValue(SMCParser smc,
|
||||
bool key_quotes,
|
||||
bool value_quotes)
|
||||
{
|
||||
if (g_OverrideState != OVERRIDE_STATE_OVERRIDES || g_IgnoreLevel)
|
||||
if (g_OverrideState != OverrideState_Overrides || g_IgnoreLevel)
|
||||
{
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
@@ -125,12 +128,12 @@ public SMCResult ReadOldOverrides_EndSection(SMCParser smc)
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_OverrideState == OVERRIDE_STATE_LEVELS)
|
||||
if (g_OverrideState == OverrideState_Levels)
|
||||
{
|
||||
g_OverrideState = OVERRIDE_STATE_NONE;
|
||||
} else if (g_OverrideState == OVERRIDE_STATE_OVERRIDES) {
|
||||
g_OverrideState = OverrideState_None;
|
||||
} else if (g_OverrideState == OverrideState_Overrides) {
|
||||
/* We're totally done parsing */
|
||||
g_OverrideState = OVERRIDE_STATE_LEVELS;
|
||||
g_OverrideState = OverrideState_Levels;
|
||||
return SMCParse_Halt;
|
||||
}
|
||||
|
||||
@@ -146,9 +149,9 @@ public SMCResult ReadNewOverrides_EndSection(SMCParser smc)
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_OverrideState == OVERRIDE_STATE_OVERRIDES)
|
||||
if (g_OverrideState == OverrideState_Overrides)
|
||||
{
|
||||
g_OverrideState = OVERRIDE_STATE_NONE;
|
||||
g_OverrideState = OverrideState_None;
|
||||
}
|
||||
|
||||
return SMCParse_Continue;
|
||||
@@ -161,7 +164,7 @@ public SMCResult ReadOverrides_CurrentLine(SMCParser smc, const char[] line, int
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
static InitializeOverrideParsers()
|
||||
static void InitializeOverrideParsers()
|
||||
{
|
||||
if (!g_hOldOverrideParser)
|
||||
{
|
||||
@@ -181,13 +184,13 @@ static InitializeOverrideParsers()
|
||||
}
|
||||
}
|
||||
|
||||
InternalReadOverrides(SMCParser parser, const char[] file)
|
||||
void InternalReadOverrides(SMCParser parser, const char[] file)
|
||||
{
|
||||
BuildPath(Path_SM, g_Filename, sizeof(g_Filename), file);
|
||||
|
||||
/* Set states */
|
||||
InitGlobalStates();
|
||||
g_OverrideState = OVERRIDE_STATE_NONE;
|
||||
g_OverrideState = OverrideState_None;
|
||||
|
||||
SMCError err = parser.ParseFile(g_Filename);
|
||||
if (err != SMCError_Okay)
|
||||
@@ -202,7 +205,7 @@ InternalReadOverrides(SMCParser parser, const char[] file)
|
||||
}
|
||||
}
|
||||
|
||||
ReadOverrides()
|
||||
void ReadOverrides()
|
||||
{
|
||||
InitializeOverrideParsers();
|
||||
InternalReadOverrides(g_hOldOverrideParser, "configs/admin_levels.cfg");
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
public ReadSimpleUsers()
|
||||
public void ReadSimpleUsers()
|
||||
{
|
||||
BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini");
|
||||
|
||||
@@ -90,7 +90,7 @@ public ReadSimpleUsers()
|
||||
|
||||
|
||||
|
||||
DecodeAuthMethod(const String:auth[], String:method[32], &offset)
|
||||
void DecodeAuthMethod(const char[] auth, char method[32], int &offset)
|
||||
{
|
||||
if ((StrContains(auth, "STEAM_") == 0) || (strncmp("0:", auth, 2) == 0) || (strncmp("1:", auth, 2) == 0))
|
||||
{
|
||||
@@ -119,13 +119,13 @@ DecodeAuthMethod(const String:auth[], String:method[32], &offset)
|
||||
}
|
||||
}
|
||||
|
||||
ReadAdminLine(const String:line[])
|
||||
void ReadAdminLine(const char[] line)
|
||||
{
|
||||
new bool:is_bound;
|
||||
new AdminId:admin;
|
||||
new String:auth[64];
|
||||
decl String:auth_method[32];
|
||||
new idx, cur_idx, auth_offset;
|
||||
bool is_bound;
|
||||
AdminId admin;
|
||||
char auth[64];
|
||||
char auth_method[32];
|
||||
int idx, cur_idx, auth_offset;
|
||||
|
||||
if ((cur_idx = BreakString(line, auth, sizeof(auth))) == -1)
|
||||
{
|
||||
@@ -148,16 +148,16 @@ ReadAdminLine(const String:line[])
|
||||
}
|
||||
|
||||
/* Read flags */
|
||||
new String:flags[64];
|
||||
char flags[64];
|
||||
cur_idx = BreakString(line[idx], flags, sizeof(flags));
|
||||
idx += cur_idx;
|
||||
|
||||
/* Read immunity level, if any */
|
||||
new level, flag_idx;
|
||||
int level, flag_idx;
|
||||
|
||||
if ((flag_idx = StringToIntEx(flags, level)) > 0)
|
||||
{
|
||||
SetAdminImmunityLevel(admin, level);
|
||||
admin.ImmunityLevel = level;
|
||||
if (flags[flag_idx] == ':')
|
||||
{
|
||||
flag_idx++;
|
||||
@@ -166,41 +166,41 @@ ReadAdminLine(const String:line[])
|
||||
|
||||
if (flags[flag_idx] == '@')
|
||||
{
|
||||
new GroupId:gid = FindAdmGroup(flags[flag_idx + 1]);
|
||||
GroupId gid = FindAdmGroup(flags[flag_idx + 1]);
|
||||
if (gid == INVALID_GROUP_ID)
|
||||
{
|
||||
ParseError("Invalid group detected: %s", flags[flag_idx + 1]);
|
||||
return;
|
||||
}
|
||||
AdminInheritGroup(admin, gid);
|
||||
admin.InheritGroup(gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
new len = strlen(flags[flag_idx]);
|
||||
new bool:is_default = false;
|
||||
for (new i=0; i<len; i++)
|
||||
int len = strlen(flags[flag_idx]);
|
||||
bool is_default = false;
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
if (!level && flags[flag_idx + i] == '$')
|
||||
{
|
||||
SetAdminImmunityLevel(admin, 1);
|
||||
admin.ImmunityLevel = 1;
|
||||
} else {
|
||||
new AdminFlag:flag;
|
||||
AdminFlag flag;
|
||||
|
||||
if (!FindFlagByChar(flags[flag_idx + i], flag))
|
||||
{
|
||||
ParseError("Invalid flag detected: %c", flags[flag_idx + i]);
|
||||
continue;
|
||||
}
|
||||
SetAdminFlag(admin, flag, true);
|
||||
admin.SetFlag(flag, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_default)
|
||||
{
|
||||
new GroupId:gid = FindAdmGroup("Default");
|
||||
GroupId gid = FindAdmGroup("Default");
|
||||
if (gid != INVALID_GROUP_ID)
|
||||
{
|
||||
AdminInheritGroup(admin, gid);
|
||||
admin.InheritGroup(gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,15 +208,15 @@ ReadAdminLine(const String:line[])
|
||||
/* Lastly, is there a password? */
|
||||
if (cur_idx != -1)
|
||||
{
|
||||
decl String:password[64];
|
||||
char password[64];
|
||||
BreakString(line[idx], password, sizeof(password));
|
||||
SetAdminPassword(admin, password);
|
||||
admin.SetPassword(password);
|
||||
}
|
||||
|
||||
/* Now, bind the identity to something */
|
||||
if (!is_bound)
|
||||
{
|
||||
if (!BindAdminIdentity(admin, auth_method, auth[auth_offset]))
|
||||
if (!admin.BindIdentity(auth_method, auth[auth_offset]))
|
||||
{
|
||||
/* We should never reach here */
|
||||
RemoveAdmin(admin);
|
||||
|
||||
@@ -31,21 +31,24 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#define USER_STATE_NONE 0
|
||||
#define USER_STATE_ADMINS 1
|
||||
#define USER_STATE_INADMIN 2
|
||||
enum UserState
|
||||
{
|
||||
UserState_None,
|
||||
UserState_Admins,
|
||||
UserState_InAdmin,
|
||||
}
|
||||
|
||||
static SMCParser g_hUserParser;
|
||||
static g_UserState = USER_STATE_NONE;
|
||||
static String:g_CurAuth[64];
|
||||
static String:g_CurIdent[64];
|
||||
static String:g_CurName[64];
|
||||
static String:g_CurPass[64];
|
||||
static Handle:g_GroupArray;
|
||||
static g_CurFlags;
|
||||
static g_CurImmunity;
|
||||
static UserState g_UserState = UserState_None;
|
||||
static char g_CurAuth[64];
|
||||
static char g_CurIdent[64];
|
||||
static char g_CurName[64];
|
||||
static char g_CurPass[64];
|
||||
static ArrayList g_GroupArray;
|
||||
static int g_CurFlags;
|
||||
static int g_CurImmunity;
|
||||
|
||||
public SMCResult:ReadUsers_NewSection(Handle:smc, const String:name[], bool:opt_quotes)
|
||||
public SMCResult ReadUsers_NewSection(SMCParser smc, const char[] name, bool opt_quotes)
|
||||
{
|
||||
if (g_IgnoreLevel)
|
||||
{
|
||||
@@ -53,25 +56,25 @@ public SMCResult:ReadUsers_NewSection(Handle:smc, const String:name[], bool:opt_
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_UserState == USER_STATE_NONE)
|
||||
if (g_UserState == UserState_None)
|
||||
{
|
||||
if (StrEqual(name, "Admins"))
|
||||
{
|
||||
g_UserState = USER_STATE_ADMINS;
|
||||
g_UserState = UserState_Admins;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_IgnoreLevel++;
|
||||
}
|
||||
}
|
||||
else if (g_UserState == USER_STATE_ADMINS)
|
||||
else if (g_UserState == UserState_Admins)
|
||||
{
|
||||
g_UserState = USER_STATE_INADMIN;
|
||||
g_UserState = UserState_InAdmin;
|
||||
strcopy(g_CurName, sizeof(g_CurName), name);
|
||||
g_CurAuth[0] = '\0';
|
||||
g_CurIdent[0] = '\0';
|
||||
g_CurPass[0] = '\0';
|
||||
ClearArray(g_GroupArray);
|
||||
g_GroupArray.Clear();
|
||||
g_CurFlags = 0;
|
||||
g_CurImmunity = 0;
|
||||
}
|
||||
@@ -83,13 +86,13 @@ public SMCResult:ReadUsers_NewSection(Handle:smc, const String:name[], bool:opt_
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
public SMCResult:ReadUsers_KeyValue(Handle:smc,
|
||||
const String:key[],
|
||||
const String:value[],
|
||||
bool:key_quotes,
|
||||
bool:value_quotes)
|
||||
public SMCResult ReadUsers_KeyValue(SMCParser smc,
|
||||
const char[] key,
|
||||
const char[] value,
|
||||
bool key_quotes,
|
||||
bool value_quotes)
|
||||
{
|
||||
if (g_UserState != USER_STATE_INADMIN || g_IgnoreLevel)
|
||||
if (g_UserState != UserState_InAdmin || g_IgnoreLevel)
|
||||
{
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
@@ -108,20 +111,20 @@ public SMCResult:ReadUsers_KeyValue(Handle:smc,
|
||||
}
|
||||
else if (StrEqual(key, "group"))
|
||||
{
|
||||
new GroupId:id = FindAdmGroup(value);
|
||||
GroupId id = FindAdmGroup(value);
|
||||
if (id == INVALID_GROUP_ID)
|
||||
{
|
||||
ParseError("Unknown group \"%s\"", value);
|
||||
}
|
||||
|
||||
PushArrayCell(g_GroupArray, id);
|
||||
g_GroupArray.Push(id);
|
||||
}
|
||||
else if (StrEqual(key, "flags"))
|
||||
{
|
||||
new len = strlen(value);
|
||||
new AdminFlag:flag;
|
||||
int len = strlen(value);
|
||||
AdminFlag flag;
|
||||
|
||||
for (new i = 0; i < len; i++)
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (!FindFlagByChar(value[i], flag))
|
||||
{
|
||||
@@ -141,7 +144,7 @@ public SMCResult:ReadUsers_KeyValue(Handle:smc,
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
public SMCResult:ReadUsers_EndSection(Handle:smc)
|
||||
public SMCResult ReadUsers_EndSection(SMCParser smc)
|
||||
{
|
||||
if (g_IgnoreLevel)
|
||||
{
|
||||
@@ -149,13 +152,14 @@ public SMCResult:ReadUsers_EndSection(Handle:smc)
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
if (g_UserState == USER_STATE_INADMIN)
|
||||
if (g_UserState == UserState_InAdmin)
|
||||
{
|
||||
/* Dump this user to memory */
|
||||
if (g_CurIdent[0] != '\0' && g_CurAuth[0] != '\0')
|
||||
{
|
||||
decl AdminFlag:flags[26];
|
||||
new AdminId:id, i, num_groups, num_flags;
|
||||
AdminFlag flags[26];
|
||||
AdminId id;
|
||||
int i, num_groups, num_flags;
|
||||
|
||||
if ((id = FindAdminByIdentity(g_CurAuth, g_CurIdent)) == INVALID_ADMIN_ID)
|
||||
{
|
||||
@@ -168,10 +172,10 @@ public SMCResult:ReadUsers_EndSection(Handle:smc)
|
||||
}
|
||||
}
|
||||
|
||||
num_groups = GetArraySize(g_GroupArray);
|
||||
num_groups = g_GroupArray.Length;
|
||||
for (i = 0; i < num_groups; i++)
|
||||
{
|
||||
AdminInheritGroup(id, GetArrayCell(g_GroupArray, i));
|
||||
AdminInheritGroup(id, g_GroupArray.Get(i));
|
||||
}
|
||||
|
||||
SetAdminPassword(id, g_CurPass);
|
||||
@@ -191,24 +195,24 @@ public SMCResult:ReadUsers_EndSection(Handle:smc)
|
||||
ParseError("Failed to create admin: did you forget either the auth or identity properties?");
|
||||
}
|
||||
|
||||
g_UserState = USER_STATE_ADMINS;
|
||||
g_UserState = UserState_Admins;
|
||||
}
|
||||
else if (g_UserState == USER_STATE_ADMINS)
|
||||
else if (g_UserState == UserState_Admins)
|
||||
{
|
||||
g_UserState = USER_STATE_NONE;
|
||||
g_UserState = UserState_None;
|
||||
}
|
||||
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
public SMCResult:ReadUsers_CurrentLine(Handle:smc, const String:line[], lineno)
|
||||
public SMCResult ReadUsers_CurrentLine(SMCParser smc, const char[] line, int lineno)
|
||||
{
|
||||
g_CurrentLine = lineno;
|
||||
|
||||
return SMCParse_Continue;
|
||||
}
|
||||
|
||||
static InitializeUserParser()
|
||||
static void InitializeUserParser()
|
||||
{
|
||||
if (!g_hUserParser)
|
||||
{
|
||||
@@ -222,7 +226,7 @@ static InitializeUserParser()
|
||||
}
|
||||
}
|
||||
|
||||
ReadUsers()
|
||||
void ReadUsers()
|
||||
{
|
||||
InitializeUserParser();
|
||||
|
||||
@@ -230,7 +234,7 @@ ReadUsers()
|
||||
|
||||
/* Set states */
|
||||
InitGlobalStates();
|
||||
g_UserState = USER_STATE_NONE;
|
||||
g_UserState = UserState_None;
|
||||
|
||||
SMCError err = g_hUserParser.ParseFile(g_Filename);
|
||||
if (err != SMCError_Okay)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "SQL Admins (Prefetch)",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -45,7 +45,7 @@ public Plugin:myinfo =
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
public OnRebuildAdminCache(AdminCachePart:part)
|
||||
public void OnRebuildAdminCache(AdminCachePart part)
|
||||
{
|
||||
/* First try to get a database connection */
|
||||
char error[255];
|
||||
@@ -97,7 +97,7 @@ void FetchUsers(Database db)
|
||||
char name[80];
|
||||
int immunity;
|
||||
AdminId adm;
|
||||
GroupId gid;
|
||||
GroupId grp;
|
||||
int id;
|
||||
|
||||
/* Keep track of a mapping from admin DB IDs to internal AdminIds to
|
||||
@@ -120,7 +120,7 @@ void FetchUsers(Database db)
|
||||
if ((adm = FindAdminByIdentity(authtype, identity)) == INVALID_ADMIN_ID)
|
||||
{
|
||||
adm = CreateAdmin(name);
|
||||
if (!BindAdminIdentity(adm, authtype, identity))
|
||||
if (!adm.BindIdentity(authtype, identity))
|
||||
{
|
||||
LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity);
|
||||
continue;
|
||||
@@ -136,22 +136,22 @@ void FetchUsers(Database db)
|
||||
/* See if this admin wants a password */
|
||||
if (password[0] != '\0')
|
||||
{
|
||||
SetAdminPassword(adm, password);
|
||||
adm.SetPassword(password);
|
||||
}
|
||||
|
||||
/* Apply each flag */
|
||||
int len = strlen(flags);
|
||||
AdminFlag flag;
|
||||
for (new i=0; i<len; i++)
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
if (!FindFlagByChar(flags[i], flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAdminFlag(adm, flag, true);
|
||||
adm.SetFlag(flag, true);
|
||||
}
|
||||
|
||||
SetAdminImmunityLevel(adm, immunity);
|
||||
adm.ImmunityLevel = immunity;
|
||||
}
|
||||
|
||||
delete rs;
|
||||
@@ -173,13 +173,13 @@ void FetchUsers(Database db)
|
||||
|
||||
if (htAdmins.GetValue(key, adm))
|
||||
{
|
||||
if ((gid = FindAdmGroup(group)) == INVALID_GROUP_ID)
|
||||
if ((grp = FindAdmGroup(group)) == INVALID_GROUP_ID)
|
||||
{
|
||||
/* Group wasn't found, don't bother with it. */
|
||||
continue;
|
||||
}
|
||||
|
||||
AdminInheritGroup(adm, gid);
|
||||
adm.InheritGroup(grp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ void FetchUsers(Database db)
|
||||
delete htAdmins;
|
||||
}
|
||||
|
||||
FetchGroups(Database db)
|
||||
void FetchGroups(Database db)
|
||||
{
|
||||
char query[255];
|
||||
DBResultSet rs;
|
||||
@@ -218,26 +218,26 @@ FetchGroups(Database db)
|
||||
#endif
|
||||
|
||||
/* Find or create the group */
|
||||
GroupId gid;
|
||||
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
GroupId grp;
|
||||
if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
gid = CreateAdmGroup(name);
|
||||
grp = CreateAdmGroup(name);
|
||||
}
|
||||
|
||||
/* Add flags from the database to the group */
|
||||
int num_flag_chars = strlen(flags);
|
||||
for (new i=0; i<num_flag_chars; i++)
|
||||
for (int i=0; i<num_flag_chars; i++)
|
||||
{
|
||||
decl AdminFlag:flag;
|
||||
AdminFlag flag;
|
||||
if (!FindFlagByChar(flags[i], flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAdmGroupAddFlag(gid, flag, true);
|
||||
grp.SetFlag(flag, true);
|
||||
}
|
||||
|
||||
/* Set the immunity level this group has */
|
||||
SetAdmGroupImmunityLevel(gid, immunity);
|
||||
grp.ImmunityLevel = immunity;
|
||||
}
|
||||
|
||||
delete rs;
|
||||
@@ -245,7 +245,7 @@ FetchGroups(Database db)
|
||||
/**
|
||||
* Get immunity in a big lump. This is a nasty query but it gets the job done.
|
||||
*/
|
||||
new len = 0;
|
||||
int len = 0;
|
||||
len += Format(query[len], sizeof(query)-len, "SELECT g1.name, g2.name FROM sm_group_immunity gi");
|
||||
len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g1 ON g1.id = gi.group_id ");
|
||||
len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g2 ON g2.id = gi.other_id");
|
||||
@@ -263,20 +263,20 @@ FetchGroups(Database db)
|
||||
{
|
||||
char group1[80];
|
||||
char group2[80];
|
||||
GroupId gid1, gid2;
|
||||
GroupId grp, other;
|
||||
|
||||
rs.FetchString(0, group1, sizeof(group1));
|
||||
rs.FetchString(1, group2, sizeof(group2));
|
||||
|
||||
if (((gid1 = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|
||||
|| (gid2 = FindAdmGroup(group2)) == INVALID_GROUP_ID)
|
||||
if (((grp = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|
||||
|| (other = FindAdmGroup(group2)) == INVALID_GROUP_ID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SetAdmGroupImmuneFrom(gid1, gid2);
|
||||
grp.AddGroupImmunity(other);
|
||||
#if defined _DEBUG
|
||||
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", gid1, gid2);
|
||||
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", grp, other);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -306,8 +306,8 @@ FetchGroups(Database db)
|
||||
rs.FetchString(2, cmd, sizeof(cmd));
|
||||
rs.FetchString(3, access, sizeof(access));
|
||||
|
||||
GroupId gid;
|
||||
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
GroupId grp;
|
||||
if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -325,16 +325,16 @@ FetchGroups(Database db)
|
||||
}
|
||||
|
||||
#if defined _DEBUG
|
||||
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", gid, cmd, o_type, o_rule);
|
||||
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", grp, cmd, o_type, o_rule);
|
||||
#endif
|
||||
|
||||
AddAdmGroupCmdOverride(gid, cmd, o_type, o_rule);
|
||||
grp.AddCommandOverride(cmd, o_type, o_rule);
|
||||
}
|
||||
|
||||
delete rs;
|
||||
}
|
||||
|
||||
FetchOverrides(Database db)
|
||||
void FetchOverrides(Database db)
|
||||
{
|
||||
char query[255];
|
||||
DBResultSet rs;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "SQL Admins (Threaded)",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -68,15 +68,15 @@ public Plugin:myinfo =
|
||||
*/
|
||||
|
||||
Database hDatabase = null; /** Database connection */
|
||||
new g_sequence = 0; /** Global unique sequence number */
|
||||
new ConnectLock = 0; /** Connect sequence number */
|
||||
new RebuildCachePart[3] = {0}; /** Cache part sequence numbers */
|
||||
new PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */
|
||||
new bool:PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */
|
||||
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" */
|
||||
|
||||
//#define _DEBUG
|
||||
|
||||
public OnMapEnd()
|
||||
public void OnMapEnd()
|
||||
{
|
||||
/**
|
||||
* Clean up on map end just so we can start a fresh connection when we need it later.
|
||||
@@ -84,14 +84,14 @@ public OnMapEnd()
|
||||
delete hDatabase;
|
||||
}
|
||||
|
||||
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
||||
public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
|
||||
{
|
||||
PlayerSeq[client] = 0;
|
||||
PlayerAuth[client] = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public OnClientDisconnect(client)
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
PlayerSeq[client] = 0;
|
||||
PlayerAuth[client] = false;
|
||||
@@ -128,22 +128,22 @@ public void OnDatabaseConnect(Database db, const char[] error, any data)
|
||||
/**
|
||||
* See if we need to get any of the cache stuff now.
|
||||
*/
|
||||
new sequence;
|
||||
if ((sequence = RebuildCachePart[_:AdminCache_Overrides]) != 0)
|
||||
int sequence;
|
||||
if ((sequence = RebuildCachePart[AdminCache_Overrides]) != 0)
|
||||
{
|
||||
FetchOverrides(hDatabase, sequence);
|
||||
}
|
||||
if ((sequence = RebuildCachePart[_:AdminCache_Groups]) != 0)
|
||||
if ((sequence = RebuildCachePart[AdminCache_Groups]) != 0)
|
||||
{
|
||||
FetchGroups(hDatabase, sequence);
|
||||
}
|
||||
if ((sequence = RebuildCachePart[_:AdminCache_Admins]) != 0)
|
||||
if ((sequence = RebuildCachePart[AdminCache_Admins]) != 0)
|
||||
{
|
||||
FetchUsersWeCan(hDatabase);
|
||||
}
|
||||
}
|
||||
|
||||
RequestDatabaseConnection()
|
||||
void RequestDatabaseConnection()
|
||||
{
|
||||
ConnectLock = ++g_sequence;
|
||||
if (SQL_CheckConfig("admins"))
|
||||
@@ -154,7 +154,7 @@ RequestDatabaseConnection()
|
||||
}
|
||||
}
|
||||
|
||||
public OnRebuildAdminCache(AdminCachePart part)
|
||||
public void OnRebuildAdminCache(AdminCachePart part)
|
||||
{
|
||||
/**
|
||||
* Mark this part of the cache as being rebuilt. This is used by the
|
||||
@@ -162,7 +162,7 @@ public OnRebuildAdminCache(AdminCachePart part)
|
||||
* used.
|
||||
*/
|
||||
int sequence = ++g_sequence;
|
||||
RebuildCachePart[_:part] = sequence;
|
||||
RebuildCachePart[part] = sequence;
|
||||
|
||||
/**
|
||||
* If we don't have a database connection, we can't do any lookups just yet.
|
||||
@@ -189,7 +189,7 @@ public OnRebuildAdminCache(AdminCachePart part)
|
||||
}
|
||||
}
|
||||
|
||||
public Action OnClientPreAdminCheck(client)
|
||||
public Action OnClientPreAdminCheck(int client)
|
||||
{
|
||||
PlayerAuth[client] = true;
|
||||
|
||||
@@ -209,7 +209,7 @@ public Action OnClientPreAdminCheck(client)
|
||||
* the user's normal connection flow. The database will soon auth the user
|
||||
* normally.
|
||||
*/
|
||||
if (RebuildCachePart[_:AdminCache_Admins] != 0)
|
||||
if (RebuildCachePart[AdminCache_Admins] != 0)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@@ -272,22 +272,22 @@ public void OnReceiveUserGroups(Database db, DBResultSet rs, const char[] error,
|
||||
}
|
||||
|
||||
char name[80];
|
||||
GroupId gid;
|
||||
GroupId grp;
|
||||
|
||||
while (rs.FetchRow())
|
||||
{
|
||||
rs.FetchString(0, name, sizeof(name));
|
||||
|
||||
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined _DEBUG
|
||||
PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, gid);
|
||||
PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, grp);
|
||||
#endif
|
||||
|
||||
AdminInheritGroup(adm, gid);
|
||||
adm.InheritGroup(grp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +350,7 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
|
||||
/**
|
||||
* Cache user info -- [0] = db id, [1] = cache id, [2] = groups
|
||||
*/
|
||||
char[][] user_lookup = new char[num_accounts][3];
|
||||
int[][] user_lookup = new int[num_accounts][3];
|
||||
int total_users = 0;
|
||||
|
||||
while (rs.FetchRow())
|
||||
@@ -370,14 +370,14 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
|
||||
}
|
||||
|
||||
adm = CreateAdmin(name);
|
||||
if (!BindAdminIdentity(adm, authtype, identity))
|
||||
if (!adm.BindIdentity(authtype, identity))
|
||||
{
|
||||
LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity);
|
||||
continue;
|
||||
}
|
||||
|
||||
user_lookup[total_users][0] = id;
|
||||
user_lookup[total_users][1] = _:adm;
|
||||
user_lookup[total_users][1] = view_as<int>(adm);
|
||||
user_lookup[total_users][2] = rs.FetchInt(6);
|
||||
total_users++;
|
||||
|
||||
@@ -388,21 +388,21 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
|
||||
/* See if this admin wants a password */
|
||||
if (password[0] != '\0')
|
||||
{
|
||||
SetAdminPassword(adm, password);
|
||||
adm.SetPassword(password);
|
||||
}
|
||||
|
||||
SetAdminImmunityLevel(adm, immunity);
|
||||
adm.ImmunityLevel = immunity;
|
||||
|
||||
/* Apply each flag */
|
||||
int len = strlen(flags);
|
||||
AdminFlag flag;
|
||||
for (new i=0; i<len; i++)
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
if (!FindFlagByChar(flags[i], flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAdminFlag(adm, flag, true);
|
||||
adm.SetFlag(flag, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,9 +415,9 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
|
||||
id = 0;
|
||||
|
||||
|
||||
for (new i=0; i<total_users; i++)
|
||||
for (int i=0; i<total_users; i++)
|
||||
{
|
||||
if (user_lookup[i][1] == _:adm)
|
||||
if (user_lookup[i][1] == view_as<int>(adm))
|
||||
{
|
||||
id = user_lookup[i][0];
|
||||
group_count = user_lookup[i][2];
|
||||
@@ -449,16 +449,16 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
|
||||
pk.Reset();
|
||||
pk.WriteCell(client);
|
||||
pk.WriteCell(sequence);
|
||||
pk.WriteCell(_:adm);
|
||||
pk.WriteCell(adm);
|
||||
pk.WriteString(query);
|
||||
|
||||
db.Query(OnReceiveUserGroups, query, pk, DBPrio_High);
|
||||
}
|
||||
|
||||
FetchUser(Database db, client)
|
||||
void FetchUser(Database db, int client)
|
||||
{
|
||||
char name[65];
|
||||
char safe_name[140];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char safe_name[(MAX_NAME_LENGTH * 2) - 1];
|
||||
char steamid[32];
|
||||
char steamidalt[32];
|
||||
char ipaddr[24];
|
||||
@@ -484,7 +484,7 @@ FetchUser(Database db, client)
|
||||
* Construct the query using the information the user gave us.
|
||||
*/
|
||||
char query[512];
|
||||
new len = 0;
|
||||
int len = 0;
|
||||
|
||||
len += Format(query[len], sizeof(query)-len, "SELECT a.id, a.authtype, a.identity, a.password, a.flags, a.name, COUNT(ag.group_id), immunity");
|
||||
len += Format(query[len], sizeof(query)-len, " FROM sm_admins a LEFT JOIN sm_admins_groups ag ON a.id = ag.admin_id WHERE ");
|
||||
@@ -516,7 +516,7 @@ FetchUser(Database db, client)
|
||||
db.Query(OnReceiveUser, query, pk, DBPrio_High);
|
||||
}
|
||||
|
||||
FetchUsersWeCan(Database db)
|
||||
void FetchUsersWeCan(Database db)
|
||||
{
|
||||
for (int i=1; i<=MaxClients; i++)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ FetchUsersWeCan(Database db)
|
||||
/**
|
||||
* This round of updates is done. Go in peace.
|
||||
*/
|
||||
RebuildCachePart[_:AdminCache_Admins] = 0;
|
||||
RebuildCachePart[AdminCache_Admins] = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err
|
||||
* Check if this is the latest result request.
|
||||
*/
|
||||
int sequence = pk.ReadCell();
|
||||
if (RebuildCachePart[_:AdminCache_Groups] != sequence)
|
||||
if (RebuildCachePart[AdminCache_Groups] != sequence)
|
||||
{
|
||||
/* Discard everything, since we're out of sequence. */
|
||||
delete pk;
|
||||
@@ -569,28 +569,28 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err
|
||||
{
|
||||
char group1[80];
|
||||
char group2[80];
|
||||
GroupId gid1, gid2;
|
||||
GroupId grp, other;
|
||||
|
||||
rs.FetchString(0, group1, sizeof(group1));
|
||||
rs.FetchString(1, group2, sizeof(group2));
|
||||
|
||||
if (((gid1 = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|
||||
|| (gid2 = FindAdmGroup(group2)) == INVALID_GROUP_ID)
|
||||
if (((grp = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|
||||
|| (other = FindAdmGroup(group2)) == INVALID_GROUP_ID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SetAdmGroupImmuneFrom(gid1, gid2);
|
||||
grp.AddGroupImmunity(other);
|
||||
#if defined _DEBUG
|
||||
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", gid1, gid2);
|
||||
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", grp, other);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Clear the sequence so another connect doesn't refetch */
|
||||
RebuildCachePart[_:AdminCache_Groups] = 0;
|
||||
RebuildCachePart[AdminCache_Groups] = 0;
|
||||
}
|
||||
|
||||
public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data)
|
||||
public void OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data)
|
||||
{
|
||||
DataPack pk = view_as<DataPack>(data);
|
||||
pk.Reset();
|
||||
@@ -599,7 +599,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
* Check if this is the latest result request.
|
||||
*/
|
||||
int sequence = pk.ReadCell();
|
||||
if (RebuildCachePart[_:AdminCache_Groups] != sequence)
|
||||
if (RebuildCachePart[AdminCache_Groups] != sequence)
|
||||
{
|
||||
/* Discard everything, since we're out of sequence. */
|
||||
delete pk;
|
||||
@@ -626,7 +626,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
char type[16];
|
||||
char command[64];
|
||||
char access[16];
|
||||
GroupId gid;
|
||||
GroupId grp;
|
||||
while (rs.FetchRow())
|
||||
{
|
||||
rs.FetchString(0, name, sizeof(name));
|
||||
@@ -635,7 +635,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
rs.FetchString(3, access, sizeof(access));
|
||||
|
||||
/* Find the group. This is actually faster than doing the ID lookup. */
|
||||
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
/* Oh well, just ignore it. */
|
||||
continue;
|
||||
@@ -654,10 +654,10 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
}
|
||||
|
||||
#if defined _DEBUG
|
||||
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", gid, command, o_type, o_rule);
|
||||
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", grp, command, o_type, o_rule);
|
||||
#endif
|
||||
|
||||
AddAdmGroupCmdOverride(gid, command, o_type, o_rule);
|
||||
grp.AddCommandOverride(command, o_type, o_rule);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -676,7 +676,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
db.Query(OnReceiveGroupImmunity, query, pk, DBPrio_High);
|
||||
}
|
||||
|
||||
public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data)
|
||||
public void OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data)
|
||||
{
|
||||
DataPack pk = view_as<DataPack>(data);
|
||||
pk.Reset();
|
||||
@@ -685,7 +685,7 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
|
||||
* Check if this is the latest result request.
|
||||
*/
|
||||
int sequence = pk.ReadCell();
|
||||
if (RebuildCachePart[_:AdminCache_Groups] != sequence)
|
||||
if (RebuildCachePart[AdminCache_Groups] != sequence)
|
||||
{
|
||||
/* Discard everything, since we're out of sequence. */
|
||||
delete pk;
|
||||
@@ -722,25 +722,25 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
|
||||
#endif
|
||||
|
||||
/* Find or create the group */
|
||||
GroupId gid;
|
||||
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
GroupId grp;
|
||||
if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
|
||||
{
|
||||
gid = CreateAdmGroup(name);
|
||||
grp = CreateAdmGroup(name);
|
||||
}
|
||||
|
||||
/* Add flags from the database to the group */
|
||||
int num_flag_chars = strlen(flags);
|
||||
for (int i=0; i<num_flag_chars; i++)
|
||||
{
|
||||
decl AdminFlag:flag;
|
||||
AdminFlag flag;
|
||||
if (!FindFlagByChar(flags[i], flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAdmGroupAddFlag(gid, flag, true);
|
||||
grp.SetFlag(flag, true);
|
||||
}
|
||||
|
||||
SetAdmGroupImmunityLevel(gid, immunity);
|
||||
grp.ImmunityLevel = immunity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -758,7 +758,7 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
|
||||
db.Query(OnReceiveGroupOverrides, query, pk, DBPrio_High);
|
||||
}
|
||||
|
||||
void FetchGroups(Database db, sequence)
|
||||
void FetchGroups(Database db, int sequence)
|
||||
{
|
||||
char query[255];
|
||||
|
||||
@@ -780,7 +780,7 @@ public void OnReceiveOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
* Check if this is the latest result request.
|
||||
*/
|
||||
int sequence = pk.ReadCell();
|
||||
if (RebuildCachePart[_:AdminCache_Overrides] != sequence)
|
||||
if (RebuildCachePart[AdminCache_Overrides] != sequence)
|
||||
{
|
||||
/* Discard everything, since we're out of sequence. */
|
||||
delete pk;
|
||||
@@ -829,10 +829,10 @@ public void OnReceiveOverrides(Database db, DBResultSet rs, const char[] error,
|
||||
}
|
||||
|
||||
/* Clear the sequence so another connect doesn't refetch */
|
||||
RebuildCachePart[_:AdminCache_Overrides] = 0;
|
||||
RebuildCachePart[AdminCache_Overrides] = 0;
|
||||
}
|
||||
|
||||
void FetchOverrides(Database db, sequence)
|
||||
void FetchOverrides(Database db, int sequence)
|
||||
{
|
||||
char query[255];
|
||||
|
||||
|
||||
+16
-16
@@ -37,7 +37,7 @@
|
||||
|
||||
#define COMMANDS_PER_PAGE 10
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Admin Help",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -46,7 +46,7 @@ public Plugin:myinfo =
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
public OnPluginStart()
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("adminhelp.phrases");
|
||||
@@ -54,11 +54,11 @@ public OnPluginStart()
|
||||
RegConsoleCmd("sm_searchcmd", HelpCmd, "Searches SourceMod commands");
|
||||
}
|
||||
|
||||
public Action:HelpCmd(client, args)
|
||||
public Action HelpCmd(int client, int args)
|
||||
{
|
||||
decl String:arg[64], String:CmdName[20];
|
||||
new PageNum = 1;
|
||||
new bool:DoSearch;
|
||||
char arg[64], CmdName[20];
|
||||
int PageNum = 1;
|
||||
bool DoSearch;
|
||||
|
||||
GetCmdArg(0, CmdName, sizeof(CmdName));
|
||||
|
||||
@@ -76,17 +76,17 @@ public Action:HelpCmd(client, args)
|
||||
ReplyToCommand(client, "[SM] %t", "See console for output");
|
||||
}
|
||||
|
||||
decl String:Name[64];
|
||||
decl String:Desc[255];
|
||||
decl String:NoDesc[128];
|
||||
new Flags;
|
||||
new Handle:CmdIter = GetCommandIterator();
|
||||
char Name[64];
|
||||
char Desc[255];
|
||||
char NoDesc[128];
|
||||
int Flags;
|
||||
Handle CmdIter = GetCommandIterator();
|
||||
|
||||
FormatEx(NoDesc, sizeof(NoDesc), "%T", "No description available", client);
|
||||
|
||||
if (DoSearch)
|
||||
{
|
||||
new i = 1;
|
||||
int i = 1;
|
||||
while (ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)))
|
||||
{
|
||||
if ((StrContains(Name, arg, false) != -1) && CheckCommandAccess(client, Name, Flags))
|
||||
@@ -105,8 +105,8 @@ public Action:HelpCmd(client, args)
|
||||
/* Skip the first N commands if we need to */
|
||||
if (PageNum > 1)
|
||||
{
|
||||
new i;
|
||||
new EndCmd = (PageNum-1) * COMMANDS_PER_PAGE - 1;
|
||||
int i;
|
||||
int EndCmd = (PageNum-1) * COMMANDS_PER_PAGE - 1;
|
||||
for (i=0; ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && i<EndCmd; )
|
||||
{
|
||||
if (CheckCommandAccess(client, Name, Flags))
|
||||
@@ -124,8 +124,8 @@ public Action:HelpCmd(client, args)
|
||||
}
|
||||
|
||||
/* Start printing the commands to the client */
|
||||
new i;
|
||||
new StartCmd = (PageNum-1) * COMMANDS_PER_PAGE;
|
||||
int i;
|
||||
int StartCmd = (PageNum-1) * COMMANDS_PER_PAGE;
|
||||
for (i=0; ReadCommandIterator(CmdIter, Name, sizeof(Name), Flags, Desc, sizeof(Desc)) && i<COMMANDS_PER_PAGE; )
|
||||
{
|
||||
if (CheckCommandAccess(client, Name, Flags))
|
||||
|
||||
+27
-27
@@ -36,7 +36,7 @@
|
||||
#include <sourcemod>
|
||||
#include <topmenus>
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Admin Menu",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -46,8 +46,8 @@ public Plugin:myinfo =
|
||||
};
|
||||
|
||||
/* Forwards */
|
||||
new Handle:hOnAdminMenuReady = null;
|
||||
new Handle:hOnAdminMenuCreated = null;
|
||||
Handle hOnAdminMenuReady = null;
|
||||
Handle hOnAdminMenuCreated = null;
|
||||
|
||||
/* Menus */
|
||||
TopMenu hAdminMenu;
|
||||
@@ -59,7 +59,7 @@ TopMenuObject obj_votingcmds = INVALID_TOPMENUOBJECT;
|
||||
|
||||
#include "adminmenu/dynamicmenu.sp"
|
||||
|
||||
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
|
||||
CreateNative("AddTargetsToMenu", __AddTargetsToMenu);
|
||||
@@ -68,7 +68,7 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public OnPluginStart()
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("adminmenu.phrases");
|
||||
@@ -79,10 +79,10 @@ public OnPluginStart()
|
||||
RegAdminCmd("sm_admin", Command_DisplayMenu, ADMFLAG_GENERIC, "Displays the admin menu");
|
||||
}
|
||||
|
||||
public OnConfigsExecuted()
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
decl String:error[256];
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
char error[256];
|
||||
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/adminmenu_sorting.txt");
|
||||
|
||||
@@ -93,12 +93,12 @@ public OnConfigsExecuted()
|
||||
}
|
||||
}
|
||||
|
||||
public OnMapStart()
|
||||
public void OnMapStart()
|
||||
{
|
||||
ParseConfigs();
|
||||
}
|
||||
|
||||
public OnAllPluginsLoaded()
|
||||
public void OnAllPluginsLoaded()
|
||||
{
|
||||
hAdminMenu = new TopMenu(DefaultCategoryHandler);
|
||||
|
||||
@@ -117,12 +117,12 @@ public OnAllPluginsLoaded()
|
||||
Call_Finish();
|
||||
}
|
||||
|
||||
public DefaultCategoryHandler(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
public void DefaultCategoryHandler(Handle topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject object_id,
|
||||
int param,
|
||||
char[] buffer,
|
||||
int maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayTitle)
|
||||
{
|
||||
@@ -160,14 +160,14 @@ public DefaultCategoryHandler(Handle:topmenu,
|
||||
}
|
||||
}
|
||||
|
||||
public __GetAdminTopMenu(Handle:plugin, numParams)
|
||||
public int __GetAdminTopMenu(Handle plugin, int numParams)
|
||||
{
|
||||
return _:hAdminMenu;
|
||||
return view_as<int>(hAdminMenu);
|
||||
}
|
||||
|
||||
public __AddTargetsToMenu(Handle:plugin, numParams)
|
||||
public int __AddTargetsToMenu(Handle plugin, int numParams)
|
||||
{
|
||||
new bool:alive_only = false;
|
||||
bool alive_only = false;
|
||||
|
||||
if (numParams >= 4)
|
||||
{
|
||||
@@ -177,12 +177,12 @@ public __AddTargetsToMenu(Handle:plugin, numParams)
|
||||
return UTIL_AddTargetsToMenu(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), alive_only);
|
||||
}
|
||||
|
||||
public __AddTargetsToMenu2(Handle:plugin, numParams)
|
||||
public int __AddTargetsToMenu2(Handle plugin, int numParams)
|
||||
{
|
||||
return UTIL_AddTargetsToMenu2(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
|
||||
}
|
||||
|
||||
public Action:Command_DisplayMenu(int client, int args)
|
||||
public Action Command_DisplayMenu(int client, int args)
|
||||
{
|
||||
if (client == 0)
|
||||
{
|
||||
@@ -194,15 +194,15 @@ public Action:Command_DisplayMenu(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
stock int UTIL_AddTargetsToMenu2(Menu menu, source_client, flags)
|
||||
stock int UTIL_AddTargetsToMenu2(Menu menu, int source_client, int flags)
|
||||
{
|
||||
char user_id[12];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char display[MAX_NAME_LENGTH+12];
|
||||
|
||||
new num_clients;
|
||||
int num_clients;
|
||||
|
||||
for (new i = 1; i <= MaxClients; i++)
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (!IsClientConnected(i) || IsClientInKickQueue(i))
|
||||
{
|
||||
@@ -249,9 +249,9 @@ stock int UTIL_AddTargetsToMenu2(Menu menu, source_client, flags)
|
||||
return num_clients;
|
||||
}
|
||||
|
||||
stock UTIL_AddTargetsToMenu(Menu menu, source_client, bool:in_game_only, bool:alive_only)
|
||||
stock int UTIL_AddTargetsToMenu(Menu menu, int source_client, bool in_game_only, bool alive_only)
|
||||
{
|
||||
new flags = 0;
|
||||
int flags = 0;
|
||||
|
||||
if (!in_game_only)
|
||||
{
|
||||
|
||||
+114
-119
@@ -6,12 +6,12 @@
|
||||
|
||||
enum GroupCommands
|
||||
{
|
||||
Handle:groupListName,
|
||||
Handle:groupListCommand
|
||||
ArrayList:groupListName,
|
||||
ArrayList:groupListCommand
|
||||
};
|
||||
|
||||
new g_groupList[GroupCommands];
|
||||
new g_groupCount;
|
||||
int g_groupList[GroupCommands];
|
||||
int g_groupCount;
|
||||
|
||||
SMCParser g_configParser;
|
||||
|
||||
@@ -19,11 +19,11 @@ enum Places
|
||||
{
|
||||
Place_Category,
|
||||
Place_Item,
|
||||
Place_ReplaceNum
|
||||
Place_ReplaceNum
|
||||
};
|
||||
|
||||
new String:g_command[MAXPLAYERS+1][CMD_LENGTH];
|
||||
new g_currentPlace[MAXPLAYERS+1][Places];
|
||||
char g_command[MAXPLAYERS+1][CMD_LENGTH];
|
||||
int g_currentPlace[MAXPLAYERS+1][Places];
|
||||
|
||||
/**
|
||||
* What to put in the 'info' menu field (for PlayerList and Player_Team menus only)
|
||||
@@ -58,7 +58,7 @@ enum Item
|
||||
{
|
||||
String:Item_cmd[256],
|
||||
ExecuteType:Item_execute,
|
||||
Handle:Item_submenus
|
||||
ArrayList:Item_submenus
|
||||
}
|
||||
|
||||
enum Submenu
|
||||
@@ -67,12 +67,12 @@ enum Submenu
|
||||
String:Submenu_title[32],
|
||||
PlayerMethod:Submenu_method,
|
||||
Submenu_listcount,
|
||||
Handle:Submenu_listdata
|
||||
DataPack:Submenu_listdata
|
||||
}
|
||||
|
||||
new Handle:g_DataArray;
|
||||
ArrayList g_DataArray;
|
||||
|
||||
BuildDynamicMenu()
|
||||
void BuildDynamicMenu()
|
||||
{
|
||||
int itemInput[Item];
|
||||
g_DataArray = CreateArray(sizeof(itemInput));
|
||||
@@ -98,15 +98,15 @@ BuildDynamicMenu()
|
||||
|
||||
FileToKeyValues(kvMenu, file);
|
||||
|
||||
new String:name[NAME_LENGTH];
|
||||
new String:buffer[NAME_LENGTH];
|
||||
char name[NAME_LENGTH];
|
||||
char buffer[NAME_LENGTH];
|
||||
|
||||
if (!kvMenu.GotoFirstSubKey())
|
||||
return;
|
||||
|
||||
decl String:admin[30];
|
||||
char admin[30];
|
||||
|
||||
new TopMenuObject:categoryId;
|
||||
TopMenuObject categoryId;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -124,7 +124,7 @@ BuildDynamicMenu()
|
||||
|
||||
}
|
||||
|
||||
decl String:category_name[NAME_LENGTH];
|
||||
char category_name[NAME_LENGTH];
|
||||
strcopy(category_name, sizeof(category_name), buffer);
|
||||
|
||||
if (!kvMenu.GotoFirstSubKey())
|
||||
@@ -143,7 +143,7 @@ BuildDynamicMenu()
|
||||
//No 'admin' keyvalue was found
|
||||
//Use the first argument of the 'cmd' string instead
|
||||
|
||||
decl String:temp[64];
|
||||
char temp[64];
|
||||
kvMenu.GetString("cmd", temp, sizeof(temp),"");
|
||||
|
||||
BreakString(temp, admin, sizeof(admin));
|
||||
@@ -162,16 +162,16 @@ BuildDynamicMenu()
|
||||
itemInput[Item_execute] = Execute_Player;
|
||||
}
|
||||
|
||||
/* iterate all submenus and load data into itemInput[Item_submenus] (adt array handle) */
|
||||
/* iterate all submenus and load data into itemInput[Item_submenus] (ArrayList) */
|
||||
|
||||
new count = 1;
|
||||
decl String:countBuffer[10] = "1";
|
||||
int count = 1;
|
||||
char countBuffer[10] = "1";
|
||||
|
||||
decl String:inputBuffer[48];
|
||||
char inputBuffer[48];
|
||||
|
||||
while (kvMenu.JumpToKey(countBuffer))
|
||||
{
|
||||
new submenuInput[Submenu];
|
||||
int submenuInput[Submenu];
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
@@ -198,8 +198,8 @@ BuildDynamicMenu()
|
||||
kvMenu.GetString("path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt");
|
||||
|
||||
submenuInput[Submenu_listdata] = CreateDataPack();
|
||||
WritePackString(submenuInput[Submenu_listdata], inputBuffer);
|
||||
ResetPack(submenuInput[Submenu_listdata]);
|
||||
submenuInput[Submenu_listdata].WriteString(inputBuffer);
|
||||
submenuInput[Submenu_listdata].Reset();
|
||||
}
|
||||
else if (StrContains(inputBuffer, "player") != -1)
|
||||
{
|
||||
@@ -215,14 +215,14 @@ BuildDynamicMenu()
|
||||
|
||||
submenuInput[Submenu_listdata] = CreateDataPack();
|
||||
|
||||
new String:temp[6];
|
||||
new String:value[64];
|
||||
new String:text[64];
|
||||
new String:subadm[30]; // same as "admin", cf. line 110
|
||||
new i=1;
|
||||
new bool:more = true;
|
||||
char temp[6];
|
||||
char value[64];
|
||||
char text[64];
|
||||
char subadm[30]; // same as "admin", cf. line 110
|
||||
int i=1;
|
||||
bool more = true;
|
||||
|
||||
new listcount = 0;
|
||||
int listcount = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -242,16 +242,16 @@ BuildDynamicMenu()
|
||||
else
|
||||
{
|
||||
listcount++;
|
||||
WritePackString(submenuInput[Submenu_listdata], value);
|
||||
WritePackString(submenuInput[Submenu_listdata], text);
|
||||
WritePackString(submenuInput[Submenu_listdata], subadm);
|
||||
submenuInput[Submenu_listdata].WriteString(value);
|
||||
submenuInput[Submenu_listdata].WriteString(text);
|
||||
submenuInput[Submenu_listdata].WriteString(subadm);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
} while (more);
|
||||
|
||||
ResetPack(submenuInput[Submenu_listdata]);
|
||||
submenuInput[Submenu_listdata].Reset();
|
||||
submenuInput[Submenu_listcount] = listcount;
|
||||
}
|
||||
|
||||
@@ -291,16 +291,16 @@ BuildDynamicMenu()
|
||||
count++;
|
||||
Format(countBuffer, sizeof(countBuffer), "%i", count);
|
||||
|
||||
PushArrayArray(itemInput[Item_submenus], submenuInput[0]);
|
||||
itemInput[Item_submenus].PushArray(submenuInput[0]);
|
||||
|
||||
kvMenu.GoBack();
|
||||
}
|
||||
|
||||
/* Save this entire item into the global items array and add it to the menu */
|
||||
|
||||
new location = PushArrayArray(g_DataArray, itemInput[0]);
|
||||
int location = g_DataArray.PushArray(itemInput[0]);
|
||||
|
||||
decl String:locString[10];
|
||||
char locString[10];
|
||||
IntToString(location, locString, sizeof(locString));
|
||||
|
||||
if (hAdminMenu.AddItem(buffer,
|
||||
@@ -322,7 +322,7 @@ BuildDynamicMenu()
|
||||
delete kvMenu;
|
||||
}
|
||||
|
||||
ParseConfigs()
|
||||
void ParseConfigs()
|
||||
{
|
||||
if (!g_configParser)
|
||||
g_configParser = new SMCParser();
|
||||
@@ -331,20 +331,13 @@ ParseConfigs()
|
||||
g_configParser.OnKeyValue = KeyValue;
|
||||
g_configParser.OnLeaveSection = EndSection;
|
||||
|
||||
if (g_groupList[groupListName] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_groupList[groupListName]);
|
||||
}
|
||||
|
||||
if (g_groupList[groupListCommand] != null)
|
||||
{
|
||||
CloseHandle(g_groupList[groupListCommand]);
|
||||
}
|
||||
delete g_groupList[groupListName];
|
||||
delete g_groupList[groupListCommand];
|
||||
|
||||
g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH);
|
||||
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
|
||||
|
||||
decl String:configPath[256];
|
||||
char configPath[256];
|
||||
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
|
||||
if (FileExists(configPath))
|
||||
{
|
||||
@@ -367,7 +360,7 @@ ParseConfigs()
|
||||
SMCError err = g_configParser.ParseFile(configPath, line);
|
||||
if (err != SMCError_Okay)
|
||||
{
|
||||
decl String:error[256];
|
||||
char error[256];
|
||||
SMC_GetErrorString(err, error, sizeof(error));
|
||||
LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
|
||||
LogError("Parser encountered error: %s", error);
|
||||
@@ -383,48 +376,48 @@ public SMCResult NewSection(SMCParser smc, const char[] name, bool opt_quotes)
|
||||
|
||||
public SMCResult KeyValue(SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes)
|
||||
{
|
||||
PushArrayString(g_groupList[groupListName], key);
|
||||
PushArrayString(g_groupList[groupListCommand], value);
|
||||
g_groupList[groupListName].PushString(key);
|
||||
g_groupList[groupListCommand].PushString(value);
|
||||
}
|
||||
|
||||
public SMCResult EndSection(SMCParser smc)
|
||||
{
|
||||
g_groupCount = GetArraySize(g_groupList[groupListName]);
|
||||
g_groupCount = g_groupList[groupListName].Length;
|
||||
}
|
||||
|
||||
public DynamicMenuCategoryHandler(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
public void DynamicMenuCategoryHandler(TopMenu topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject object_id,
|
||||
int param,
|
||||
char[] buffer,
|
||||
int maxlength)
|
||||
{
|
||||
if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption))
|
||||
{
|
||||
GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
|
||||
topmenu.GetObjName(object_id, buffer, maxlength);
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicMenuItemHandler(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
public void DynamicMenuItemHandler(TopMenu topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject object_id,
|
||||
int param,
|
||||
char[] buffer,
|
||||
int maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
|
||||
topmenu.GetObjName(object_id, buffer, maxlength);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
new String:locString[10];
|
||||
GetTopMenuInfoString(topmenu, object_id, locString, sizeof(locString));
|
||||
char locString[10];
|
||||
topmenu.GetInfoString(object_id, locString, sizeof(locString));
|
||||
|
||||
new location = StringToInt(locString);
|
||||
int location = StringToInt(locString);
|
||||
|
||||
new output[Item];
|
||||
GetArrayArray(g_DataArray, location, output[0]);
|
||||
int output[Item];
|
||||
g_DataArray.GetArray(location, output[0]);
|
||||
|
||||
strcopy(g_command[param], sizeof(g_command[]), output[Item_cmd]);
|
||||
|
||||
@@ -435,15 +428,15 @@ public DynamicMenuItemHandler(Handle:topmenu,
|
||||
}
|
||||
}
|
||||
|
||||
public ParamCheck(client)
|
||||
public void ParamCheck(int client)
|
||||
{
|
||||
new String:buffer[6];
|
||||
new String:buffer2[6];
|
||||
char buffer[6];
|
||||
char buffer2[6];
|
||||
|
||||
new outputItem[Item];
|
||||
new outputSubmenu[Submenu];
|
||||
int outputItem[Item];
|
||||
int outputSubmenu[Submenu];
|
||||
|
||||
GetArrayArray(g_DataArray, g_currentPlace[client][Place_Item], outputItem[0]);
|
||||
g_DataArray.GetArray(g_currentPlace[client][Place_Item], outputItem[0]);
|
||||
|
||||
if (g_currentPlace[client][Place_ReplaceNum] < 1)
|
||||
{
|
||||
@@ -455,29 +448,29 @@ public ParamCheck(client)
|
||||
|
||||
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
|
||||
{
|
||||
GetArrayArray(outputItem[Item_submenus], g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]);
|
||||
outputItem[Item_submenus].GetArray(g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]);
|
||||
|
||||
Menu itemMenu = CreateMenu(Menu_Selection);
|
||||
itemMenu.ExitBackButton = true;
|
||||
|
||||
if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
|
||||
{
|
||||
decl String:nameBuffer[ARRAY_STRING_LENGTH];
|
||||
decl String:commandBuffer[ARRAY_STRING_LENGTH];
|
||||
char nameBuffer[ARRAY_STRING_LENGTH];
|
||||
char commandBuffer[ARRAY_STRING_LENGTH];
|
||||
|
||||
for (new i = 0; i<g_groupCount; i++)
|
||||
for (int i = 0; i<g_groupCount; i++)
|
||||
{
|
||||
GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer));
|
||||
GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer));
|
||||
g_groupList[groupListName].GetString(i, nameBuffer, sizeof(nameBuffer));
|
||||
g_groupList[groupListCommand].GetString(i, commandBuffer, sizeof(commandBuffer));
|
||||
itemMenu.AddItem(commandBuffer, nameBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (outputSubmenu[Submenu_type] == SubMenu_MapCycle)
|
||||
{
|
||||
decl String:path[200];
|
||||
ReadPackString(outputSubmenu[Submenu_listdata], path, sizeof(path));
|
||||
ResetPack(outputSubmenu[Submenu_listdata]);
|
||||
char path[200];
|
||||
outputSubmenu[Submenu_listdata].ReadString(path, sizeof(path));
|
||||
outputSubmenu[Submenu_listdata].Reset();
|
||||
|
||||
File file = OpenFile(path, "rt");
|
||||
char readData[128];
|
||||
@@ -497,30 +490,30 @@ public ParamCheck(client)
|
||||
}
|
||||
else if ((outputSubmenu[Submenu_type] == SubMenu_Player) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer))
|
||||
{
|
||||
new PlayerMethod:playermethod = outputSubmenu[Submenu_method];
|
||||
PlayerMethod playermethod = outputSubmenu[Submenu_method];
|
||||
|
||||
new String:nameBuffer[32];
|
||||
new String:infoBuffer[32];
|
||||
new String:temp[4];
|
||||
char nameBuffer[MAX_NAME_LENGTH];
|
||||
char infoBuffer[32];
|
||||
char temp[4];
|
||||
|
||||
//loop through players. Add name as text and name/userid/steamid as info
|
||||
for (new i=1; i<=MaxClients; i++)
|
||||
for (int i=1; i<=MaxClients; i++)
|
||||
{
|
||||
if (IsClientInGame(i))
|
||||
{
|
||||
GetClientName(i, nameBuffer, 31);
|
||||
GetClientName(i, nameBuffer, sizeof(nameBuffer));
|
||||
|
||||
switch (playermethod)
|
||||
{
|
||||
case UserId:
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
int userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
|
||||
itemMenu.AddItem(infoBuffer, nameBuffer);
|
||||
}
|
||||
case UserId2:
|
||||
{
|
||||
new userid = GetClientUserId(i);
|
||||
int userid = GetClientUserId(i);
|
||||
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
|
||||
itemMenu.AddItem(infoBuffer, nameBuffer);
|
||||
}
|
||||
@@ -554,16 +547,16 @@ public ParamCheck(client)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:value[64];
|
||||
new String:text[64];
|
||||
char value[64];
|
||||
char text[64];
|
||||
|
||||
new String:admin[NAME_LENGTH];
|
||||
char admin[NAME_LENGTH];
|
||||
|
||||
for (new i=0; i<outputSubmenu[Submenu_listcount]; i++)
|
||||
for (int i=0; i<outputSubmenu[Submenu_listcount]; i++)
|
||||
{
|
||||
ReadPackString(outputSubmenu[Submenu_listdata], value, sizeof(value));
|
||||
ReadPackString(outputSubmenu[Submenu_listdata], text, sizeof(text));
|
||||
ReadPackString(outputSubmenu[Submenu_listdata], admin, sizeof(admin));
|
||||
outputSubmenu[Submenu_listdata].ReadString(value, sizeof(value));
|
||||
outputSubmenu[Submenu_listdata].ReadString(text, sizeof(text));
|
||||
outputSubmenu[Submenu_listdata].ReadString(admin, sizeof(admin));
|
||||
|
||||
if (CheckCommandAccess(client, admin, 0))
|
||||
{
|
||||
@@ -571,7 +564,7 @@ public ParamCheck(client)
|
||||
}
|
||||
}
|
||||
|
||||
ResetPack(outputSubmenu[Submenu_listdata]);
|
||||
outputSubmenu[Submenu_listdata].Reset();
|
||||
}
|
||||
|
||||
itemMenu.SetTitle(outputSubmenu[Submenu_title]);
|
||||
@@ -584,7 +577,7 @@ public ParamCheck(client)
|
||||
|
||||
hAdminMenu.Display(client, TopMenuPosition_LastCategory);
|
||||
|
||||
decl String:unquotedCommand[CMD_LENGTH];
|
||||
char unquotedCommand[CMD_LENGTH];
|
||||
UnQuoteString(g_command[client], unquotedCommand, sizeof(unquotedCommand), "#@");
|
||||
|
||||
if (outputItem[Item_execute] == Execute_Player) // assume 'player' type execute option
|
||||
@@ -602,7 +595,7 @@ public ParamCheck(client)
|
||||
}
|
||||
}
|
||||
|
||||
public Menu_Selection(Menu menu, MenuAction action, int param1, int param2)
|
||||
public int Menu_Selection(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
if (action == MenuAction_End)
|
||||
{
|
||||
@@ -611,22 +604,22 @@ public Menu_Selection(Menu menu, MenuAction action, int param1, int param2)
|
||||
|
||||
if (action == MenuAction_Select)
|
||||
{
|
||||
new String:unquotedinfo[NAME_LENGTH];
|
||||
char unquotedinfo[NAME_LENGTH];
|
||||
|
||||
/* Get item info */
|
||||
new bool:found = menu.GetItem(param2, unquotedinfo, sizeof(unquotedinfo));
|
||||
bool found = menu.GetItem(param2, unquotedinfo, sizeof(unquotedinfo));
|
||||
|
||||
if (!found)
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
new String:info[NAME_LENGTH*2+1];
|
||||
char info[NAME_LENGTH*2+1];
|
||||
QuoteString(unquotedinfo, info, sizeof(info), "#@");
|
||||
|
||||
|
||||
new String:buffer[6];
|
||||
new String:infobuffer[NAME_LENGTH+2];
|
||||
char buffer[6];
|
||||
char infobuffer[NAME_LENGTH+2];
|
||||
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
|
||||
|
||||
Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
|
||||
@@ -648,15 +641,17 @@ public Menu_Selection(Menu menu, MenuAction action, int param1, int param2)
|
||||
//client exited we should go back to submenu i think
|
||||
hAdminMenu.Display(param1, TopMenuPosition_LastCategory);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
stock bool:QuoteString(String:input[], String:output[], maxlen, String:quotechars[])
|
||||
stock bool QuoteString(char[] input, char[] output, int maxlen, char[] quotechars)
|
||||
{
|
||||
new count = 0;
|
||||
new len = strlen(input);
|
||||
int count = 0;
|
||||
int len = strlen(input);
|
||||
|
||||
for (new i=0; i<len; i++)
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
output[count] = input[i];
|
||||
count++;
|
||||
@@ -688,14 +683,14 @@ stock bool:QuoteString(String:input[], String:output[], maxlen, String:quotechar
|
||||
return true;
|
||||
}
|
||||
|
||||
stock bool:UnQuoteString(String:input[], String:output[], maxlen, String:quotechars[])
|
||||
stock bool UnQuoteString(char[] input, char[] output, int maxlen, char[] quotechars)
|
||||
{
|
||||
new count = 1;
|
||||
new len = strlen(input);
|
||||
int count = 1;
|
||||
int len = strlen(input);
|
||||
|
||||
output[0] = input[0];
|
||||
|
||||
for (new i=1; i<len; i++)
|
||||
for (int i=1; i<len; i++)
|
||||
{
|
||||
output[count] = input[i];
|
||||
count++;
|
||||
|
||||
@@ -49,7 +49,7 @@ PrepareBan(client, target, time, const String:reason[])
|
||||
return;
|
||||
}
|
||||
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
if (!time)
|
||||
|
||||
@@ -201,7 +201,7 @@ public Action:Command_Nextmap(client, args)
|
||||
if (client && !IsClientInGame(client))
|
||||
return Plugin_Handled;
|
||||
|
||||
decl String:map[64];
|
||||
decl String:map[PLATFORM_MAX_PATH];
|
||||
|
||||
GetNextMap(map, sizeof(map));
|
||||
|
||||
@@ -289,7 +289,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
|
||||
}
|
||||
else if (strcmp(sArgs, "nextmap", false) == 0)
|
||||
{
|
||||
char map[32];
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
GetNextMap(map, sizeof(map));
|
||||
|
||||
if (g_Cvar_TriggerShow.IntValue)
|
||||
|
||||
@@ -109,7 +109,7 @@ public MenuHandler_Confirm(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else if (action == MenuAction_Select)
|
||||
{
|
||||
decl String:maps[5][64];
|
||||
decl String:maps[5][PLATFORM_MAX_PATH];
|
||||
new selectedmaps = GetArraySize(g_SelectedMaps);
|
||||
|
||||
for (new i = 0; i < selectedmaps; i++)
|
||||
@@ -233,7 +233,7 @@ public Action:Command_Votemap(client, args)
|
||||
decl String:text[256];
|
||||
GetCmdArgString(text, sizeof(text));
|
||||
|
||||
decl String:maps[5][64];
|
||||
decl String:maps[5][PLATFORM_MAX_PATH];
|
||||
new mapCount;
|
||||
new len, pos;
|
||||
|
||||
@@ -283,7 +283,7 @@ int LoadMapList(Menu menu)
|
||||
|
||||
RemoveAllMenuItems(menu);
|
||||
|
||||
char map_name[64];
|
||||
char map_name[PLATFORM_MAX_PATH];
|
||||
new map_count = GetArraySize(g_map_array);
|
||||
|
||||
for (new i = 0; i < map_count; i++)
|
||||
|
||||
@@ -184,7 +184,7 @@ public MenuHandler_Beacon(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformBeacon(param1, target);
|
||||
|
||||
@@ -208,7 +208,7 @@ public MenuHandler_Amount(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformBlind(param1, target, amount);
|
||||
|
||||
@@ -265,7 +265,7 @@ public MenuHandler_Drug(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformDrug(param1, target, 2);
|
||||
|
||||
@@ -125,7 +125,7 @@ public Action:Timer_FireBomb(Handle:timer, any:value)
|
||||
|
||||
SetEntityRenderColor(client, 255, color, color, 255);
|
||||
|
||||
char name[64];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTime[client]);
|
||||
|
||||
@@ -304,7 +304,7 @@ public MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformBurn(param1, target, 20.0);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
|
||||
@@ -349,7 +349,7 @@ public MenuHandler_FireBomb(Menu menu, MenuAction action, int param1, int param2
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFireBomb(param1, target);
|
||||
|
||||
@@ -165,7 +165,7 @@ public MenuHandler_GravityAmount(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformGravity(param1, target, amount);
|
||||
|
||||
@@ -246,7 +246,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value)
|
||||
|
||||
SetEntityRenderColor(client, color, color, 255, 255);
|
||||
|
||||
char name[64];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTime[client]);
|
||||
|
||||
@@ -418,7 +418,7 @@ public MenuHandler_Freeze(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFreeze(param1, target, g_Cvar_FreezeDuration.IntValue);
|
||||
@@ -464,7 +464,7 @@ public MenuHandler_FreezeBomb(Menu menu, MenuAction action, int param1, int para
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFreezeBomb(param1, target);
|
||||
|
||||
@@ -109,7 +109,7 @@ public MenuHandler_NoClip(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformNoClip(param1, target);
|
||||
|
||||
@@ -118,7 +118,7 @@ public Action:Timer_TimeBomb(Handle:timer, any:value)
|
||||
|
||||
SetEntityRenderColor(client, 255, 128, color, 255);
|
||||
|
||||
char name[64];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTime[client]);
|
||||
|
||||
@@ -275,7 +275,7 @@ public MenuHandler_TimeBomb(Menu menu, MenuAction action, int param1, int param2
|
||||
}
|
||||
else
|
||||
{
|
||||
new String:name[32];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformTimeBomb(param1, target);
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ VoteSelect(Handle:menu, param1, param2 = 0)
|
||||
{
|
||||
if (GetConVarInt(g_Cvar_VoteShow) == 1)
|
||||
{
|
||||
decl String:voter[64], String:junk[64], String:choice[64];
|
||||
decl String:voter[MAX_NAME_LENGTH], String:junk[64], String:choice[64];
|
||||
GetClientName(param1, voter, sizeof(voter));
|
||||
menu.GetItem(param2, junk, sizeof(junk), _, choice, sizeof(choice));
|
||||
PrintToChatAll("[SM] %T", "Vote Select", LANG_SERVER, voter, choice);
|
||||
|
||||
+204
-59
@@ -168,21 +168,174 @@ enum AdminCachePart
|
||||
AdminCache_Admins = 2, /**< All admins */
|
||||
};
|
||||
|
||||
methodmap AdminId {
|
||||
// Retrieves an admin's user name as made with CreateAdmin().
|
||||
//
|
||||
// @note This function can return UTF-8 strings, and will safely chop UTF-8 strings.
|
||||
//
|
||||
// @param name String buffer to store name.
|
||||
// @param maxlength Maximum size of string buffer.
|
||||
// @return Number of bytes written.
|
||||
public native void GetUsername(char[] name, int maxlength);
|
||||
|
||||
// Binds an admin to an identity for fast lookup later on. The bind must be unique.
|
||||
//
|
||||
// @param authMethod Auth method to use, predefined or from RegisterAuthIdentType().
|
||||
// @param ident String containing the arbitrary, unique identity.
|
||||
// @return True on success, false if the auth method was not found,
|
||||
// ident was already taken, or ident invalid for auth method.
|
||||
public native bool BindIdentity(const char[] authMethod, const char[] ident);
|
||||
|
||||
// Sets whether or not a flag is enabled on an admin.
|
||||
//
|
||||
// @param flag Admin flag to use.
|
||||
// @param enabled True to enable, false to disable.
|
||||
public native void SetFlag(AdminFlag flag, bool enabled);
|
||||
|
||||
// Returns whether or not a flag is enabled on an admin.
|
||||
//
|
||||
// @param flag Admin flag to use.
|
||||
// @param mode Access mode to check.
|
||||
// @return True if enabled, false otherwise.
|
||||
public native bool HasFlag(AdminFlag flag, AdmAccessMode mode=Access_Effective);
|
||||
|
||||
// Returns the bitstring of access flags on an admin.
|
||||
//
|
||||
// @param mode Access mode to use.
|
||||
// @return A bitstring containing which flags are enabled.
|
||||
public native int GetFlags(AdmAccessMode mode);
|
||||
|
||||
// Adds a group to an admin's inherited group list. Any flags the group has
|
||||
// will be added to the admin's effective flags.
|
||||
//
|
||||
// @param gid GroupId index of the group.
|
||||
// @return True on success, false on invalid input or duplicate membership.
|
||||
public native bool InheritGroup(GroupId gid);
|
||||
|
||||
// Returns group information from an admin.
|
||||
//
|
||||
// @param index Group number to retrieve, from 0 to N-1, where N
|
||||
// is the value of the GroupCount property.
|
||||
// @param name Buffer to store the group's name.
|
||||
// Note: This will safely chop UTF-8 strings.
|
||||
// @param maxlength Maximum size of the output name buffer.
|
||||
// @return A GroupId index and a name pointer, or
|
||||
// INVALID_GROUP_ID and NULL if an error occurred.
|
||||
public native GroupId GetGroup(int index, const char[] name, int maxlength);
|
||||
|
||||
// Sets a password on an admin.
|
||||
//
|
||||
// @param password String containing the password.
|
||||
public native void SetPassword(const char[] password);
|
||||
|
||||
// Gets an admin's password.
|
||||
//
|
||||
// @param buffer Optional buffer to store the admin's password.
|
||||
// @param maxlength Maximum size of the output name buffer.
|
||||
// Note: This will safely chop UTF-8 strings.
|
||||
// @return True if there was a password set, false otherwise.
|
||||
public native bool GetPassword(char[] buffer="", maxlength=0);
|
||||
|
||||
// Tests whether one admin can target another.
|
||||
//
|
||||
// The heuristics for this check are as follows:
|
||||
// 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
|
||||
// 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
|
||||
// 2. If the targeted AdminId is the same as the targeting AdminId,
|
||||
// (self) targeting succeeds.
|
||||
// 3. If the targeting admin is root, targeting succeeds.
|
||||
// 4. If the targeted admin has access higher (as interpreted by
|
||||
// (sm_immunity_mode) than the targeting admin, then targeting fails.
|
||||
// 5. If the targeted admin has specific immunity from the
|
||||
// targeting admin via group immunities, targeting fails.
|
||||
// 6. Targeting succeeds.
|
||||
//
|
||||
// @param target Target admin (may be INVALID_ADMIN_ID).
|
||||
// @return True if targetable, false if immune.
|
||||
public native bool CanTarget(AdminId other);
|
||||
|
||||
// The number of groups of which this admin is a member.
|
||||
property int GroupCount {
|
||||
public native get();
|
||||
}
|
||||
|
||||
// Immunity level used for targetting.
|
||||
property int ImmunityLevel {
|
||||
public native get();
|
||||
public native set(int level);
|
||||
}
|
||||
}
|
||||
|
||||
methodmap GroupId {
|
||||
// Gets whether or not a flag is enabled on a group's flag set.
|
||||
//
|
||||
// @param flag Admin flag to retrieve.
|
||||
// @return True if enabled, false otherwise,
|
||||
public native bool HasFlag(AdminFlag flag);
|
||||
|
||||
// Adds or removes a flag from a group's flag set.
|
||||
//
|
||||
// @param flag Admin flag to toggle.
|
||||
// @param enabled True to set the flag, false to unset/disable.
|
||||
public native void SetFlag(AdminFlag flag, bool enabled);
|
||||
|
||||
// Returns the flag set that is added to users from this group.
|
||||
//
|
||||
// @return Bitstring containing the flags enabled.
|
||||
public native int GetFlags();
|
||||
|
||||
// Returns a group that this group is immune to given an index.
|
||||
//
|
||||
// @param number Index from 0 to N-1, from GroupImmunitiesCount.
|
||||
// @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
|
||||
public native GroupId GetGroupImmunity(int index);
|
||||
|
||||
// Adds immunity to a specific group.
|
||||
//
|
||||
// @param other Group id to receive immunity to.
|
||||
public native void AddGroupImmunity(GroupId other);
|
||||
|
||||
// Retrieves a group-specific command override.
|
||||
//
|
||||
// @param name String containing command name (case sensitive).
|
||||
// @param type Override type (specific command or group).
|
||||
// @param rule Optional pointer to store allow/deny setting.
|
||||
// @return True if an override exists, false otherwise.
|
||||
public native bool GetCommandOverride(const char[] name, OverrideType type, OverrideRule &rule);
|
||||
|
||||
// Adds a group-specific override type.
|
||||
//
|
||||
// @param name String containing command name (case sensitive).
|
||||
// @param type Override type (specific command or group).
|
||||
// @param rule Override allow/deny setting.
|
||||
public native void AddCommandOverride(const char[] name, OverrideType type, OverrideRule rule);
|
||||
|
||||
// Number of specific group immunities
|
||||
property int GroupImmunitiesCount {
|
||||
public native get();
|
||||
}
|
||||
|
||||
// Immunity level used for targetting.
|
||||
property int ImmunityLevel {
|
||||
public native get();
|
||||
public native set(int level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when part of the cache needs to be rebuilt.
|
||||
*
|
||||
* @param part Part of the admin cache to rebuild.
|
||||
*/
|
||||
forward OnRebuildAdminCache(AdminCachePart:part);
|
||||
forward void OnRebuildAdminCache(AdminCachePart part);
|
||||
|
||||
/**
|
||||
* Tells the admin system to dump a portion of the cache.
|
||||
*
|
||||
* @param part Part of the cache to dump. Specifying groups also dumps admins.
|
||||
* @param rebuild If true, the rebuild forwards will fire.
|
||||
* @noreturn
|
||||
*/
|
||||
native DumpAdminCache(AdminCachePart:part, bool:rebuild);
|
||||
native void DumpAdminCache(AdminCachePart part, bool rebuild);
|
||||
|
||||
/**
|
||||
* Adds a global command flag override. Any command registered with this name
|
||||
@@ -191,9 +344,8 @@ native DumpAdminCache(AdminCachePart:part, bool:rebuild);
|
||||
* @param cmd String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param flags New admin flag.
|
||||
* @noreturn
|
||||
*/
|
||||
native AddCommandOverride(const String:cmd[], OverrideType:type, flags);
|
||||
native void AddCommandOverride(const char[] cmd, OverrideType type, int flags);
|
||||
|
||||
/**
|
||||
* Returns a command override.
|
||||
@@ -203,16 +355,15 @@ native AddCommandOverride(const String:cmd[], OverrideType:type, flags);
|
||||
* @param flags By-reference cell to store the flag (undefined if not found).
|
||||
* @return True if there is an override, false otherwise.
|
||||
*/
|
||||
native bool:GetCommandOverride(const String:cmd[], OverrideType:type, &flags);
|
||||
native bool GetCommandOverride(const char[] cmd, OverrideType type, int &flags);
|
||||
|
||||
/**
|
||||
* Unsets a command override.
|
||||
*
|
||||
* @param cmd String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @noreturn
|
||||
*/
|
||||
native UnsetCommandOverride(const String:cmd[], OverrideType:type);
|
||||
native void UnsetCommandOverride(const char[] cmd, OverrideType type);
|
||||
|
||||
/**
|
||||
* Adds a new group. Name must be unique.
|
||||
@@ -220,7 +371,7 @@ native UnsetCommandOverride(const String:cmd[], OverrideType:type);
|
||||
* @param group_name String containing the group name.
|
||||
* @return A new group id, INVALID_GROUP_ID if it already exists.
|
||||
*/
|
||||
native GroupId:CreateAdmGroup(const String:group_name[]);
|
||||
native GroupId CreateAdmGroup(const char[] group_name);
|
||||
|
||||
/**
|
||||
* Finds a group by name.
|
||||
@@ -228,7 +379,7 @@ native GroupId:CreateAdmGroup(const String:group_name[]);
|
||||
* @param group_name String containing the group name.
|
||||
* @return A group id, or INVALID_GROUP_ID if not found.
|
||||
*/
|
||||
native GroupId:FindAdmGroup(const String:group_name[]);
|
||||
native GroupId FindAdmGroup(const char[] group_name);
|
||||
|
||||
/**
|
||||
* Adds or removes a flag from a group's flag set.
|
||||
@@ -237,9 +388,8 @@ native GroupId:FindAdmGroup(const String:group_name[]);
|
||||
* @param id Group id.
|
||||
* @param flag Admin flag to toggle.
|
||||
* @param enabled True to set the flag, false to unset/disable.
|
||||
* @noreturn
|
||||
*/
|
||||
native SetAdmGroupAddFlag(GroupId:id, AdminFlag:flag, bool:enabled);
|
||||
native void SetAdmGroupAddFlag(GroupId id, AdminFlag flag, bool enabled);
|
||||
|
||||
/**
|
||||
* Gets the set value of an add flag on a group's flag set.
|
||||
@@ -249,7 +399,7 @@ native SetAdmGroupAddFlag(GroupId:id, AdminFlag:flag, bool:enabled);
|
||||
* @param flag Admin flag to retrieve.
|
||||
* @return True if enabled, false otherwise,
|
||||
*/
|
||||
native bool:GetAdmGroupAddFlag(GroupId:id, AdminFlag:flag);
|
||||
native bool GetAdmGroupAddFlag(GroupId id, AdminFlag flag);
|
||||
|
||||
/**
|
||||
* Returns the flag set that is added to a user from their group.
|
||||
@@ -258,28 +408,27 @@ native bool:GetAdmGroupAddFlag(GroupId:id, AdminFlag:flag);
|
||||
* @param id GroupId of the group.
|
||||
* @return Bitstring containing the flags enabled.
|
||||
*/
|
||||
native GetAdmGroupAddFlags(GroupId:id);
|
||||
native int GetAdmGroupAddFlags(GroupId id);
|
||||
|
||||
/**
|
||||
* @deprecated Functionality removed.
|
||||
*/
|
||||
#pragma deprecated Use SetAdmGroupImmunityLevel() instead.
|
||||
native SetAdmGroupImmunity(GroupId:id, ImmunityType:type, bool:enabled);
|
||||
native void SetAdmGroupImmunity(GroupId id, ImmunityType type, bool enabled);
|
||||
|
||||
/**
|
||||
* @deprecated Functionality removed.
|
||||
*/
|
||||
#pragma deprecated Use GetAdmGroupImmunityLevel() instead.
|
||||
native bool:GetAdmGroupImmunity(GroupId:id, ImmunityType:type);
|
||||
native bool GetAdmGroupImmunity(GroupId id, ImmunityType type);
|
||||
|
||||
/**
|
||||
* Adds immunity to a specific group.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param other_id Group id to receive immunity to.
|
||||
* @noreturn
|
||||
*/
|
||||
native SetAdmGroupImmuneFrom(GroupId:id, GroupId:other_id);
|
||||
native void SetAdmGroupImmuneFrom(GroupId id, GroupId other_id);
|
||||
|
||||
/**
|
||||
* Returns the number of specific group immunities.
|
||||
@@ -287,7 +436,7 @@ native SetAdmGroupImmuneFrom(GroupId:id, GroupId:other_id);
|
||||
* @param id Group id.
|
||||
* @return Number of group immunities.
|
||||
*/
|
||||
native GetAdmGroupImmuneCount(GroupId:id);
|
||||
native int GetAdmGroupImmuneCount(GroupId id);
|
||||
|
||||
/**
|
||||
* Returns a group that this group is immune to given an index.
|
||||
@@ -296,7 +445,7 @@ native GetAdmGroupImmuneCount(GroupId:id);
|
||||
* @param number Index from 0 to N-1, from GetAdmGroupImmuneCount().
|
||||
* @return GroupId that this group is immune to, or INVALID_GROUP_ID on failure.
|
||||
*/
|
||||
native GroupId:GetAdmGroupImmuneFrom(GroupId:id, number);
|
||||
native GroupId GetAdmGroupImmuneFrom(GroupId id, int number);
|
||||
|
||||
/**
|
||||
* Adds a group-specific override type.
|
||||
@@ -305,9 +454,8 @@ native GroupId:GetAdmGroupImmuneFrom(GroupId:id, number);
|
||||
* @param name String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param rule Override allow/deny setting.
|
||||
* @noreturn
|
||||
*/
|
||||
native AddAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, OverrideRule:rule);
|
||||
native void AddAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule rule);
|
||||
|
||||
/**
|
||||
* Retrieves a group-specific command override.
|
||||
@@ -318,16 +466,15 @@ native AddAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type
|
||||
* @param rule Optional pointer to store allow/deny setting.
|
||||
* @return True if an override exists, false otherwise.
|
||||
*/
|
||||
native bool:GetAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType:type, &OverrideRule:rule);
|
||||
native bool GetAdmGroupCmdOverride(GroupId id, const char[] name, OverrideType type, OverrideRule &rule);
|
||||
|
||||
/**
|
||||
* Registers an authentication identity type. You normally never need to call this except for
|
||||
* very specific systems.
|
||||
*
|
||||
* @param name Codename to use for your authentication type.
|
||||
* @noreturn
|
||||
*/
|
||||
native RegisterAuthIdentType(const String:name[]);
|
||||
native void RegisterAuthIdentType(const char[] name);
|
||||
|
||||
/**
|
||||
* Creates a new admin entry in the permissions cache.
|
||||
@@ -335,7 +482,7 @@ native RegisterAuthIdentType(const String:name[]);
|
||||
* @param name Name for this entry (does not have to be unique).
|
||||
* Specify an empty string for an anonymous admin.
|
||||
*/
|
||||
native AdminId:CreateAdmin(const String:name[]="");
|
||||
native AdminId CreateAdmin(const char[] name="");
|
||||
|
||||
/**
|
||||
* Retrieves an admin's user name as made with CreateAdmin().
|
||||
@@ -347,7 +494,7 @@ native AdminId:CreateAdmin(const String:name[]="");
|
||||
* @param maxlength Maximum size of string buffer.
|
||||
* @return Number of bytes written.
|
||||
*/
|
||||
native GetAdminUsername(AdminId:id, String:name[], maxlength);
|
||||
native int GetAdminUsername(AdminId id, char[] name, int maxlength);
|
||||
|
||||
/**
|
||||
* Binds an admin to an identity for fast lookup later on. The bind must be unique.
|
||||
@@ -358,7 +505,7 @@ native GetAdminUsername(AdminId:id, String:name[], maxlength);
|
||||
* @return True on success, false if the auth method was not found,
|
||||
* ident was already taken, or ident invalid for auth method.
|
||||
*/
|
||||
native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:ident[]);
|
||||
native bool BindAdminIdentity(AdminId id, const char[] auth, const char[] ident);
|
||||
|
||||
/**
|
||||
* Sets whether or not a flag is enabled on an admin.
|
||||
@@ -366,9 +513,8 @@ native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:iden
|
||||
* @param id AdminId index of the admin.
|
||||
* @param flag Admin flag to use.
|
||||
* @param enabled True to enable, false to disable.
|
||||
* @noreturn
|
||||
*/
|
||||
native SetAdminFlag(AdminId:id, AdminFlag:flag, bool:enabled);
|
||||
native void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled);
|
||||
|
||||
/**
|
||||
* Returns whether or not a flag is enabled on an admin.
|
||||
@@ -378,7 +524,7 @@ native SetAdminFlag(AdminId:id, AdminFlag:flag, bool:enabled);
|
||||
* @param mode Access mode to check.
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
native bool:GetAdminFlag(AdminId:id, AdminFlag:flag, AdmAccessMode:mode=Access_Effective);
|
||||
native bool GetAdminFlag(AdminId id, AdminFlag flag, AdmAccessMode mode=Access_Effective);
|
||||
|
||||
/**
|
||||
* Returns the bitstring of access flags on an admin.
|
||||
@@ -387,7 +533,7 @@ native bool:GetAdminFlag(AdminId:id, AdminFlag:flag, AdmAccessMode:mode=Access_E
|
||||
* @param mode Access mode to use.
|
||||
* @return A bitstring containing which flags are enabled.
|
||||
*/
|
||||
native GetAdminFlags(AdminId:id, AdmAccessMode:mode);
|
||||
native int GetAdminFlags(AdminId id, AdmAccessMode mode);
|
||||
|
||||
/**
|
||||
* Adds a group to an admin's inherited group list. Any flags the group has
|
||||
@@ -397,7 +543,7 @@ native GetAdminFlags(AdminId:id, AdmAccessMode:mode);
|
||||
* @param gid GroupId index of the group.
|
||||
* @return True on success, false on invalid input or duplicate membership.
|
||||
*/
|
||||
native bool:AdminInheritGroup(AdminId:id, GroupId:gid);
|
||||
native bool AdminInheritGroup(AdminId id, GroupId gid);
|
||||
|
||||
/**
|
||||
* Returns the number of groups this admin is a member of.
|
||||
@@ -405,7 +551,7 @@ native bool:AdminInheritGroup(AdminId:id, GroupId:gid);
|
||||
* @param id AdminId index of the admin.
|
||||
* @return Number of groups this admin is a member of.
|
||||
*/
|
||||
native GetAdminGroupCount(AdminId:id);
|
||||
native int GetAdminGroupCount(AdminId id);
|
||||
|
||||
/**
|
||||
* Returns group information from an admin.
|
||||
@@ -418,17 +564,16 @@ native GetAdminGroupCount(AdminId:id);
|
||||
* @param maxlength Maximum size of the output name buffer.
|
||||
* @return A GroupId index and a name pointer, or
|
||||
* INVALID_GROUP_ID and NULL if an error occurred.
|
||||
*/
|
||||
native GroupId:GetAdminGroup(AdminId:id, index, const String:name[], maxlength);
|
||||
*/
|
||||
native GroupId GetAdminGroup(AdminId id, int index, const char[] name, int maxlength);
|
||||
|
||||
/**
|
||||
* Sets a password on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param password String containing the password.
|
||||
* @noreturn
|
||||
*/
|
||||
native SetAdminPassword(AdminId:id, const String:password[]);
|
||||
native void SetAdminPassword(AdminId id, const char[] password);
|
||||
|
||||
/**
|
||||
* Gets an admin's password.
|
||||
@@ -439,7 +584,7 @@ native SetAdminPassword(AdminId:id, const String:password[]);
|
||||
* Note: This will safely chop UTF-8 strings.
|
||||
* @return True if there was a password set, false otherwise.
|
||||
*/
|
||||
native bool:GetAdminPassword(AdminId:id, String:buffer[]="", maxlength=0);
|
||||
native bool GetAdminPassword(AdminId id, char buffer[]="", int maxlength=0);
|
||||
|
||||
/**
|
||||
* Attempts to find an admin by an auth method and an identity.
|
||||
@@ -448,7 +593,7 @@ native bool:GetAdminPassword(AdminId:id, String:buffer[]="", maxlength=0);
|
||||
* @param identity Identity string to look up.
|
||||
* @return An AdminId index if found, INVALID_ADMIN_ID otherwise.
|
||||
*/
|
||||
native AdminId:FindAdminByIdentity(const String:auth[], const String:identity[]);
|
||||
native AdminId FindAdminByIdentity(const char[] auth, const char[] identity);
|
||||
|
||||
/**
|
||||
* Removes an admin entry from the cache.
|
||||
@@ -458,7 +603,7 @@ native AdminId:FindAdminByIdentity(const String:auth[], const String:identity[])
|
||||
* @param id AdminId index to remove/invalidate.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool:RemoveAdmin(AdminId:id);
|
||||
native bool RemoveAdmin(AdminId id);
|
||||
|
||||
/**
|
||||
* Converts a flag bit string to a bit array.
|
||||
@@ -468,7 +613,7 @@ native bool:RemoveAdmin(AdminId:id);
|
||||
* @param maxSize Maximum number of flags the array can store.
|
||||
* @return Number of flags written.
|
||||
*/
|
||||
native FlagBitsToBitArray(bits, bool:array[], maxSize);
|
||||
native int FlagBitsToBitArray(int bits, bool[] array, int maxSize);
|
||||
|
||||
/**
|
||||
* Converts a flag array to a bit string.
|
||||
@@ -477,7 +622,7 @@ native FlagBitsToBitArray(bits, bool:array[], maxSize);
|
||||
* @param maxSize Maximum size of the flag array.
|
||||
* @return A bit string composed of the array bits.
|
||||
*/
|
||||
native FlagBitArrayToBits(const bool:array[], maxSize);
|
||||
native int FlagBitArrayToBits(const bool[] array, int maxSize);
|
||||
|
||||
/**
|
||||
* Converts an array of flags to bits.
|
||||
@@ -486,7 +631,7 @@ native FlagBitArrayToBits(const bool:array[], maxSize);
|
||||
* @param numFlags Number of flags in the array.
|
||||
* @return A bit string composed of the array flags.
|
||||
*/
|
||||
native FlagArrayToBits(const AdminFlag:array[], numFlags);
|
||||
native int FlagArrayToBits(const AdminFlag[] array, int numFlags);
|
||||
|
||||
/**
|
||||
* Converts a bit string to an array of flags.
|
||||
@@ -496,7 +641,7 @@ native FlagArrayToBits(const AdminFlag:array[], numFlags);
|
||||
* @param maxSize Maximum size of the flag array.
|
||||
* @return Number of flags written.
|
||||
*/
|
||||
native FlagBitsToArray(bits, AdminFlag:array[], maxSize);
|
||||
native int FlagBitsToArray(int bits, AdminFlag[] array, int maxSize);
|
||||
|
||||
/**
|
||||
* Finds a flag by its string name.
|
||||
@@ -505,7 +650,7 @@ native FlagBitsToArray(bits, AdminFlag:array[], maxSize);
|
||||
* @param flag Variable to store flag in.
|
||||
* @return True on success, false if not found.
|
||||
*/
|
||||
native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
|
||||
native bool FindFlagByName(const char[] name, AdminFlag &flag);
|
||||
|
||||
/**
|
||||
* Finds a flag by a given character.
|
||||
@@ -514,7 +659,7 @@ native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
|
||||
* @param flag Variable to store flag in.
|
||||
* @return True on success, false if not found.
|
||||
*/
|
||||
native bool:FindFlagByChar(c, &AdminFlag:flag);
|
||||
native bool FindFlagByChar(int c, AdminFlag &flag);
|
||||
|
||||
/**
|
||||
* Finds a flag char by a gived admin flag.
|
||||
@@ -523,7 +668,7 @@ native bool:FindFlagByChar(c, &AdminFlag:flag);
|
||||
* @param c Variable to store flag char.
|
||||
* @return True on success, false if not found.
|
||||
*/
|
||||
native bool:FindFlagChar(AdminFlag:flag, &c);
|
||||
native bool FindFlagChar(AdminFlag flag, int &c);
|
||||
|
||||
/**
|
||||
* Converts a string of flag characters to a bit string.
|
||||
@@ -532,7 +677,7 @@ native bool:FindFlagChar(AdminFlag:flag, &c);
|
||||
* @param numchars Optional variable to store the number of bytes read.
|
||||
* @return Bit string of ADMFLAG values.
|
||||
*/
|
||||
native ReadFlagString(const String:flags[], &numchars=0);
|
||||
native int ReadFlagString(const char[] flags, int &numchars=0);
|
||||
|
||||
/**
|
||||
* Tests whether one admin can target another.
|
||||
@@ -553,7 +698,7 @@ native ReadFlagString(const String:flags[], &numchars=0);
|
||||
* @param target Target admin (may be INVALID_ADMIN_ID).
|
||||
* @return True if targetable, false if immune.
|
||||
*/
|
||||
native CanAdminTarget(AdminId:admin, AdminId:target);
|
||||
native bool CanAdminTarget(AdminId admin, AdminId target);
|
||||
|
||||
/**
|
||||
* Creates an admin auth method. This does not need to be called more than once
|
||||
@@ -562,7 +707,7 @@ native CanAdminTarget(AdminId:admin, AdminId:target);
|
||||
* @param method Name of the authentication method.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
native bool:CreateAuthMethod(const String:method[]);
|
||||
native bool CreateAuthMethod(const char[] method);
|
||||
|
||||
/**
|
||||
* Sets a group's immunity level.
|
||||
@@ -571,7 +716,7 @@ native bool:CreateAuthMethod(const String:method[]);
|
||||
* @param level Immunity level value.
|
||||
* @return Old immunity level value.
|
||||
*/
|
||||
native SetAdmGroupImmunityLevel(GroupId:gid, level);
|
||||
native int SetAdmGroupImmunityLevel(GroupId gid, int level);
|
||||
|
||||
/**
|
||||
* Gets a group's immunity level (defaults to 0).
|
||||
@@ -579,7 +724,7 @@ native SetAdmGroupImmunityLevel(GroupId:gid, level);
|
||||
* @param gid Group Id.
|
||||
* @return Immunity level value.
|
||||
*/
|
||||
native GetAdmGroupImmunityLevel(GroupId:gid);
|
||||
native int GetAdmGroupImmunityLevel(GroupId gid);
|
||||
|
||||
/**
|
||||
* Sets an admin's immunity level.
|
||||
@@ -588,7 +733,7 @@ native GetAdmGroupImmunityLevel(GroupId:gid);
|
||||
* @param level Immunity level value.
|
||||
* @return Old immunity level value.
|
||||
*/
|
||||
native SetAdminImmunityLevel(AdminId:id, level);
|
||||
native int SetAdminImmunityLevel(AdminId id, int level);
|
||||
|
||||
/**
|
||||
* Gets an admin's immunity level.
|
||||
@@ -596,7 +741,7 @@ native SetAdminImmunityLevel(AdminId:id, level);
|
||||
* @param id Admin Id.
|
||||
* @return Immunity level value.
|
||||
*/
|
||||
native GetAdminImmunityLevel(AdminId:id);
|
||||
native int GetAdminImmunityLevel(AdminId id);
|
||||
|
||||
/**
|
||||
* Converts a flag to its single bit.
|
||||
@@ -604,9 +749,9 @@ native GetAdminImmunityLevel(AdminId:id);
|
||||
* @param flag Flag to convert.
|
||||
* @return Bit representation of the flag.
|
||||
*/
|
||||
stock FlagToBit(AdminFlag:flag)
|
||||
stock int FlagToBit(AdminFlag flag)
|
||||
{
|
||||
return (1<<_:flag);
|
||||
return (1 << view_as<int>(flag));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -616,9 +761,9 @@ stock FlagToBit(AdminFlag:flag)
|
||||
* @param flag Stores the converted flag by reference.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
stock bool:BitToFlag(bit, &AdminFlag:flag)
|
||||
stock bool BitToFlag(int bit, AdminFlag &flag)
|
||||
{
|
||||
new AdminFlag:array[1];
|
||||
AdminFlag array[1];
|
||||
|
||||
if (FlagBitsToArray(bit, array, 1))
|
||||
{
|
||||
|
||||
@@ -63,17 +63,15 @@
|
||||
* the Handle or add categories.
|
||||
*
|
||||
* @param topmenu Handle to the admin menu's TopMenu.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnAdminMenuCreated(Handle topmenu);
|
||||
forward void OnAdminMenuCreated(Handle topmenu);
|
||||
|
||||
/**
|
||||
* Called when the admin menu is ready to have items added.
|
||||
*
|
||||
* @param topmenu Handle to the admin menu's TopMenu.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnAdminMenuReady(Handle topmenu);
|
||||
forward void OnAdminMenuReady(Handle topmenu);
|
||||
|
||||
/**
|
||||
* Retrieves the Handle to the admin top menu.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -29,14 +29,14 @@
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
|
||||
#if defined _adt_array_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _adt_array_included
|
||||
|
||||
/**
|
||||
* Given a maximum string size (including the null terminator),
|
||||
* Given a maximum string size (including the null terminator),
|
||||
* returns the number of cells required to fit that string.
|
||||
*
|
||||
* @param size Number of bytes.
|
||||
@@ -52,16 +52,16 @@ stock ByteCountToCells(size)
|
||||
methodmap ArrayList < Handle {
|
||||
// Creates a dynamic global cell array. While slower than a normal array,
|
||||
// it can be used globally AND dynamically, which is otherwise impossible.
|
||||
//
|
||||
// The contents of the array are uniform; i.e. storing a string at index X
|
||||
//
|
||||
// The contents of the array are uniform; i.e. storing a string at index X
|
||||
// and then retrieving it as an integer is NOT the same as StringToInt()!
|
||||
// The "blocksize" determines how many cells each array slot has; it cannot
|
||||
// be changed after creation.
|
||||
//
|
||||
// @param blocksize The number of cells each member of the array can
|
||||
// @param blocksize The number of cells each member of the array can
|
||||
// hold. For example, 32 cells is equivalent to:
|
||||
// new Array[X][32]
|
||||
// @param startsize Initial size of the array. Note that data will
|
||||
// @param startsize Initial size of the array. Note that data will
|
||||
// NOT be auto-intialized.
|
||||
// @return New Handle to the array object.
|
||||
public native ArrayList(int blocksize=1, int startsize=0);
|
||||
@@ -106,7 +106,7 @@ methodmap ArrayList < Handle {
|
||||
//
|
||||
// @param values Block of values to copy.
|
||||
// @param size If not set, the number of elements copied from the array
|
||||
// will be equal to the blocksize. If set higher than the
|
||||
// will be equal to the blocksize. If set higher than the
|
||||
// blocksize, the operation will be truncated.
|
||||
// @return Index of the new entry.
|
||||
public native int PushArray(const any[] values, int size=-1);
|
||||
@@ -168,15 +168,15 @@ methodmap ArrayList < Handle {
|
||||
// @error Invalid index.
|
||||
public native void SetArray(int index, const any[] values, int size=-1);
|
||||
|
||||
// Shifts an array up. All array contents after and including the given
|
||||
// index are shifted up by one, and the given index is then "free."
|
||||
// Shifts an array up. All array contents after and including the given
|
||||
// index are shifted up by one, and the given index is then "free."
|
||||
// After shifting, the contents of the given index is undefined.
|
||||
//
|
||||
// @param index Index in the array to shift up from.
|
||||
// @error Invalid index.
|
||||
public native void ShiftUp(int index);
|
||||
|
||||
// Removes an array index, shifting the entire array down from that position
|
||||
// Removes an array index, shifting the entire array down from that position
|
||||
// on. For example, if item 8 of 10 is removed, the last 3 items will then be
|
||||
// (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged.
|
||||
//
|
||||
@@ -197,13 +197,15 @@ methodmap ArrayList < Handle {
|
||||
// @param item String to search for
|
||||
// @return Array index, or -1 on failure
|
||||
public native int FindString(const char[] item);
|
||||
|
||||
|
||||
// Returns the index for the first occurance of the provided value. If the
|
||||
// value cannot be located, -1 will be returned.
|
||||
//
|
||||
// @param item Value to search for
|
||||
// @param block Optionally which block to search in
|
||||
// @return Array index, or -1 on failure
|
||||
public native int FindValue(any item);
|
||||
// @error Invalid block index
|
||||
public native int FindValue(any item, int block=0);
|
||||
|
||||
// Retrieve the size of the array.
|
||||
property int Length {
|
||||
@@ -214,16 +216,16 @@ methodmap ArrayList < Handle {
|
||||
/**
|
||||
* Creates a dynamic global cell array. While slower than a normal array,
|
||||
* it can be used globally AND dynamically, which is otherwise impossible.
|
||||
*
|
||||
* The contents of the array are uniform; i.e. storing a string at index X
|
||||
*
|
||||
* The contents of the array are uniform; i.e. storing a string at index X
|
||||
* and then retrieving it as an integer is NOT the same as StringToInt()!
|
||||
* The "blocksize" determines how many cells each array slot has; it cannot
|
||||
* be changed after creation.
|
||||
*
|
||||
* @param blocksize The number of cells each member of the array can
|
||||
* @param blocksize The number of cells each member of the array can
|
||||
* hold. For example, 32 cells is equivalent to:
|
||||
* new Array[X][32]
|
||||
* @param startsize Initial size of the array. Note that data will
|
||||
* @param startsize Initial size of the array. Note that data will
|
||||
* NOT be auto-intialized.
|
||||
* @return New Handle to the array object.
|
||||
*/
|
||||
@@ -300,7 +302,7 @@ native int PushArrayString(Handle array, const char[] value);
|
||||
* @param array Array Handle.
|
||||
* @param values Block of values to copy.
|
||||
* @param size If not set, the number of elements copied from the array
|
||||
* will be equal to the blocksize. If set higher than the
|
||||
* will be equal to the blocksize. If set higher than the
|
||||
* blocksize, the operation will be truncated.
|
||||
* @return Index of the new entry.
|
||||
* @error Invalid Handle or out of memory.
|
||||
@@ -383,8 +385,8 @@ native int SetArrayString(Handle array, int index, const char[] value);
|
||||
native int SetArrayArray(Handle array, int index, const any[] values, int size=-1);
|
||||
|
||||
/**
|
||||
* Shifts an array up. All array contents after and including the given
|
||||
* index are shifted up by one, and the given index is then "free."
|
||||
* Shifts an array up. All array contents after and including the given
|
||||
* index are shifted up by one, and the given index is then "free."
|
||||
* After shifting, the contents of the given index is undefined.
|
||||
*
|
||||
* @param array Array Handle.
|
||||
@@ -394,7 +396,7 @@ native int SetArrayArray(Handle array, int index, const any[] values, int size=-
|
||||
native void ShiftArrayUp(Handle array, int index);
|
||||
|
||||
/**
|
||||
* Removes an array index, shifting the entire array down from that position
|
||||
* Removes an array index, shifting the entire array down from that position
|
||||
* on. For example, if item 8 of 10 is removed, the last 3 items will then be
|
||||
* (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged.
|
||||
*
|
||||
@@ -424,14 +426,15 @@ native void SwapArrayItems(Handle array, int index1, int index2);
|
||||
* @error Invalid Handle
|
||||
*/
|
||||
native int FindStringInArray(Handle array, const char[] item);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index for the first occurance of the provided value. If the value
|
||||
* cannot be located, -1 will be returned.
|
||||
*
|
||||
* @param array Array Handle.
|
||||
* @param item Value to search for
|
||||
* @param block Optionally which block to search in
|
||||
* @return Array index, or -1 on failure
|
||||
* @error Invalid Handle
|
||||
* @error Invalid Handle or invalid block
|
||||
*/
|
||||
native int FindValueInArray(Handle array, any item);
|
||||
native int FindValueInArray(Handle array, any item, int block=0);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
* @param client Client index
|
||||
* @param muteState True if client was muted, false otherwise
|
||||
*/
|
||||
forward BaseComm_OnClientMute(client, bool:muteState);
|
||||
forward void BaseComm_OnClientMute(client, bool:muteState);
|
||||
|
||||
/**
|
||||
* Called when a client is gagged or ungagged
|
||||
@@ -49,7 +49,7 @@
|
||||
* @param client Client index
|
||||
* @param gagState True if client was gaged, false otherwise
|
||||
*/
|
||||
forward BaseComm_OnClientGag(client, bool:gagState);
|
||||
forward void BaseComm_OnClientGag(client, bool:gagState);
|
||||
|
||||
/**
|
||||
* Returns whether or not a client is gagged
|
||||
|
||||
@@ -156,7 +156,7 @@ native bool:AreClientCookiesCached(client);
|
||||
*
|
||||
* @param client Client index.
|
||||
*/
|
||||
forward OnClientCookiesCached(client);
|
||||
forward void OnClientCookiesCached(client);
|
||||
|
||||
/**
|
||||
* Cookie Menu Callback prototype
|
||||
|
||||
@@ -67,9 +67,6 @@ enum AuthIdType
|
||||
/**
|
||||
* MAXPLAYERS is not the same as MaxClients.
|
||||
* MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server.
|
||||
*
|
||||
* Both GetMaxClients() and MaxClients are only available once the map is loaded, and should
|
||||
* not be used in OnPluginStart().
|
||||
*/
|
||||
|
||||
#define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */
|
||||
|
||||
@@ -144,7 +144,7 @@ forward Action:CS_OnBuyCommand(client, const String:weapon[]);
|
||||
/**
|
||||
* Called when CSWeaponDrop is called
|
||||
* Return Plugin_Continue to allow the call or return a
|
||||
* higher action to deny.
|
||||
* higher action to block.
|
||||
*
|
||||
* @param client Client index
|
||||
* @param weaponIndex Weapon index
|
||||
|
||||
@@ -477,15 +477,13 @@ stock Database SQLite_UseDatabase(const char[] database,
|
||||
char[] error,
|
||||
maxlength)
|
||||
{
|
||||
Handle kv, db;
|
||||
KeyValues kv = CreateKeyValues("");
|
||||
kv.SetString("driver", "sqlite");
|
||||
kv.SetString("database", database);
|
||||
|
||||
kv = CreateKeyValues("");
|
||||
KvSetString(kv, "driver", "sqlite");
|
||||
KvSetString(kv, "database", database);
|
||||
Database db = SQL_ConnectCustom(kv, error, maxlength, false);
|
||||
|
||||
db = SQL_ConnectCustom(kv, error, maxlength, false);
|
||||
|
||||
CloseHandle(kv);
|
||||
delete kv;
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
@@ -318,10 +318,10 @@ native Call_PushString(const String:value[]);
|
||||
* @param value String to push.
|
||||
* @param length Length of string buffer.
|
||||
* @param szflags Flags determining how string should be handled.
|
||||
* See SP_PARAM_STRING_* constants for details.
|
||||
* See SM_PARAM_STRING_* constants for details.
|
||||
* The default (0) is to push ASCII.
|
||||
* @param cpflags Whether or not changes should be copied back to the input array.
|
||||
* See SP_PARAM_* constants for details.
|
||||
* See SM_PARAM_* constants for details.
|
||||
* @noreturn
|
||||
* @error Called before a call has been started.
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ enum EngineVersion
|
||||
Engine_Blade, /**< Blade Symphony */
|
||||
Engine_Insurgency, /**< Insurgency (2013 Retail version)*/
|
||||
Engine_Contagion, /**< Contagion */
|
||||
Engine_BlackMesa, /**< Black Mesa Multiplayer */
|
||||
};
|
||||
|
||||
#define INVALID_ENT_REFERENCE 0xFFFFFFFF
|
||||
@@ -323,7 +324,7 @@ native PrintToChat(client, const String:format[], any:...);
|
||||
*/
|
||||
stock PrintToChatAll(const String:format[], any:...)
|
||||
{
|
||||
decl String:buffer[192];
|
||||
decl String:buffer[254];
|
||||
|
||||
for (new i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
@@ -356,7 +357,7 @@ native PrintCenterText(client, const String:format[], any:...);
|
||||
*/
|
||||
stock PrintCenterTextAll(const String:format[], any:...)
|
||||
{
|
||||
decl String:buffer[192];
|
||||
decl String:buffer[254];
|
||||
|
||||
for (new i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
@@ -389,7 +390,7 @@ native PrintHintText(client, const String:format[], any:...);
|
||||
*/
|
||||
stock PrintHintTextToAll(const String:format[], any:...)
|
||||
{
|
||||
decl String:buffer[192];
|
||||
decl String:buffer[254];
|
||||
|
||||
for (new i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
stock FormatUserLogText(client, String:buffer[], maxlength)
|
||||
{
|
||||
decl String:auth[32];
|
||||
decl String:name[40];
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
|
||||
new userid = GetClientUserId(client);
|
||||
if (!GetClientAuthString(client, auth, sizeof(auth)))
|
||||
@@ -107,7 +107,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
|
||||
if (pattern[0] == '#') {
|
||||
int input = StringToInt(pattern[1]);
|
||||
if (!input) {
|
||||
char name[65];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
for (int i=1; i<=MaxClients; i++) {
|
||||
if (!IsClientInGame(i))
|
||||
continue;
|
||||
@@ -126,7 +126,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
|
||||
}
|
||||
}
|
||||
|
||||
char name[65];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
for (int i=1; i<=MaxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
|
||||
@@ -72,7 +72,7 @@ enum MenuAction
|
||||
/** Default menu actions */
|
||||
#define MENU_ACTIONS_DEFAULT MenuAction_Select|MenuAction_Cancel|MenuAction_End
|
||||
/** All menu actions */
|
||||
#define MENU_ACTIONS_ALL MenuAction:0xFFFFFFFF
|
||||
#define MENU_ACTIONS_ALL view_as<MenuAction>(0xFFFFFFFF)
|
||||
|
||||
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
|
||||
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
|
||||
@@ -371,7 +371,7 @@ methodmap Menu < Handle
|
||||
int[] players = new int[MaxClients];
|
||||
for (int i = 1; i <= MaxClients; i++) {
|
||||
if (!IsClientInGame(i) || IsFakeClient(i))
|
||||
continue
|
||||
continue;
|
||||
players[total++] = i;
|
||||
}
|
||||
return this.DisplayVote(players, total, time, flags);
|
||||
|
||||
@@ -172,7 +172,7 @@ stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension:__ext_regex =
|
||||
public Extension __ext_regex =
|
||||
{
|
||||
name = "Regex Extension",
|
||||
file = "regex.ext",
|
||||
|
||||
@@ -299,17 +299,15 @@ typeset SDKHookCB
|
||||
*
|
||||
* @param entity Entity index
|
||||
* @param classname Class name
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnEntityCreated(entity, const String:classname[]);
|
||||
forward void OnEntityCreated(int entity, const char[] classname);
|
||||
|
||||
/**
|
||||
* @brief When an entity is destroyed
|
||||
*
|
||||
* @param entity Entity index
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnEntityDestroyed(entity);
|
||||
forward void OnEntityDestroyed(int entity);
|
||||
|
||||
/**
|
||||
* @brief When the game description is retrieved
|
||||
@@ -317,18 +315,18 @@ forward OnEntityDestroyed(entity);
|
||||
* @note Not supported on ep2v.
|
||||
*
|
||||
* @param gameDesc Game description
|
||||
* @noreturn
|
||||
* @return Plugin_Changed if gameDesc has been edited, else no change.
|
||||
*/
|
||||
forward Action:OnGetGameDescription(String:gameDesc[64]);
|
||||
forward Action OnGetGameDescription(char gameDesc[64]);
|
||||
|
||||
/**
|
||||
* @brief When the level is initialized
|
||||
*
|
||||
* @param mapName Name of the map
|
||||
* @param mapEntities Entities of the map
|
||||
* @noreturn
|
||||
* @return Plugin_Changed if mapEntities has been edited, else no change.
|
||||
*/
|
||||
forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
|
||||
forward Action OnLevelInit(const char[] mapName, char mapEntities[2097152]);
|
||||
|
||||
/**
|
||||
* @brief Hooks an entity
|
||||
@@ -336,9 +334,8 @@ forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
|
||||
* @param entity Entity index
|
||||
* @param type Type of function to hook
|
||||
* @param callback Function to call when hook is called
|
||||
* @noreturn
|
||||
*/
|
||||
native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
native void SDKHook(int entity, SDKHookType type, SDKHookCB callback);
|
||||
|
||||
/**
|
||||
* @brief Hooks an entity
|
||||
@@ -348,7 +345,7 @@ native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
* @param callback Function to call when hook is called
|
||||
* @return bool Hook Successful
|
||||
*/
|
||||
native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
native bool SDKHookEx(int entity, SDKHookType type, SDKHookCB callback);
|
||||
|
||||
/**
|
||||
* @brief Unhooks an entity
|
||||
@@ -356,9 +353,8 @@ native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
* @param entity Entity index
|
||||
* @param type Type of function to unhook
|
||||
* @param callback Callback function to unhook
|
||||
* @noreturn
|
||||
*/
|
||||
native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback);
|
||||
|
||||
/**
|
||||
* @brief Applies damage to an entity
|
||||
@@ -373,9 +369,10 @@ native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
|
||||
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
|
||||
* @param damageForce Velocity of damage force
|
||||
* @param damagePosition Origin of damage
|
||||
* @noreturn
|
||||
*/
|
||||
native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR);
|
||||
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
|
||||
float damage, int damageType=DMG_GENERIC, int weapon=-1,
|
||||
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR);
|
||||
|
||||
/**
|
||||
* @brief Forces a client to drop the specified weapon
|
||||
@@ -384,15 +381,15 @@ native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType
|
||||
* @param weapon Weapon entity index.
|
||||
* @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
|
||||
* @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
|
||||
* @noreturn
|
||||
* @error Invalid client or weapon entity, weapon not owned by client.
|
||||
*/
|
||||
native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
|
||||
native void SDKHooks_DropWeapon(int client, int weapon, const float vecTarget[3]=NULL_VECTOR,
|
||||
const float vecVelocity[3]=NULL_VECTOR);
|
||||
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension:__ext_sdkhooks =
|
||||
public Extension __ext_sdkhooks =
|
||||
{
|
||||
name = "SDKHooks",
|
||||
file = "sdkhooks.ext",
|
||||
|
||||
@@ -259,6 +259,15 @@ native SetTeamScore(index, value);
|
||||
*/
|
||||
native GetTeamClientCount(index);
|
||||
|
||||
/**
|
||||
* Returns the entity index of a team.
|
||||
*
|
||||
* @param teamIndex Team index.
|
||||
* @return Entity index of team.
|
||||
* @error Invalid team index.
|
||||
*/
|
||||
native int GetTeamEntity(int teamIndex);
|
||||
|
||||
/**
|
||||
* Sets the model to a given entity.
|
||||
*
|
||||
@@ -332,6 +341,15 @@ native ActivateEntity(entity);
|
||||
*/
|
||||
native SetClientInfo(client, const String:key[], const String:value[]);
|
||||
|
||||
/**
|
||||
* Changes a client's name.
|
||||
*
|
||||
* @param client Player's index.
|
||||
* @param name New name.
|
||||
* @error Invalid client index, or client not connected.
|
||||
*/
|
||||
native void SetClientName(int client, const char[] name);
|
||||
|
||||
/**
|
||||
* Gives ammo of a certain type to a player.
|
||||
* This natives obeys the maximum amount of ammo a player can carry per ammo type.
|
||||
|
||||
@@ -221,6 +221,48 @@ native EmitSound(const clients[],
|
||||
Float:soundtime = 0.0,
|
||||
any:...);
|
||||
|
||||
/**
|
||||
* Emits a sound or game sound to a list of clients using the latest version of the engine sound interface.
|
||||
* This native is only available in engines that are greater than or equal to Portal 2.
|
||||
*
|
||||
* @param clients Array of client indexes.
|
||||
* @param numClients Number of clients in the array.
|
||||
* @param soundEntry Sound entry name.
|
||||
* @param sample Sound file name relative to the "sounds" folder.
|
||||
* @param entity Entity to emit from.
|
||||
* @param channel Channel to emit with.
|
||||
* @param level Sound level.
|
||||
* @param seed Sound seed.
|
||||
* @param flags Sound flags.
|
||||
* @param volume Sound volume.
|
||||
* @param pitch Sound pitch.
|
||||
* @param speakerentity Unknown.
|
||||
* @param origin Sound origin.
|
||||
* @param dir Sound direction.
|
||||
* @param updatePos Unknown (updates positions?)
|
||||
* @param soundtime Alternate time to play sound for.
|
||||
* @param ... Optional list of Float[3] arrays to specify additional origins.
|
||||
* @noreturn
|
||||
* @error Invalid client index.
|
||||
*/
|
||||
native EmitSoundEntry(const clients[],
|
||||
numClients,
|
||||
const String:soundEntry[],
|
||||
const String:sample[],
|
||||
entity = SOUND_FROM_PLAYER,
|
||||
channel = SNDCHAN_AUTO,
|
||||
level = SNDLEVEL_NORMAL,
|
||||
seed = 0,
|
||||
flags = SND_NOFLAGS,
|
||||
Float:volume = SNDVOL_NORMAL,
|
||||
pitch = SNDPITCH_NORMAL,
|
||||
speakerentity = -1,
|
||||
const Float:origin[3] = NULL_VECTOR,
|
||||
const Float:dir[3] = NULL_VECTOR,
|
||||
bool:updatePos = true,
|
||||
Float:soundtime = 0.0,
|
||||
any:...);
|
||||
|
||||
/**
|
||||
* Emits a sentence to a list of clients.
|
||||
*
|
||||
@@ -307,6 +349,8 @@ typedef AmbientSHook = function Action (
|
||||
* @param level Sound level.
|
||||
* @param pitch Sound pitch.
|
||||
* @param flags Sound flags.
|
||||
* @param soundEntry Game sound entry name. (Used in engines newer than Portal 2)
|
||||
* @param seed Sound seed. (Used in engines newer than Portal 2)
|
||||
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
|
||||
* Plugin_Changed when any parameter has been modified.
|
||||
*/
|
||||
@@ -319,7 +363,9 @@ typedef NormalSHook = function Action (
|
||||
float &volume,
|
||||
int &level,
|
||||
int &pitch,
|
||||
int &flags
|
||||
int &flags,
|
||||
char soundEntry[PLATFORM_MAX_PATH],
|
||||
int &seed
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -226,3 +226,21 @@ stock TE_SendToClient(client, Float:delay=0.0)
|
||||
|
||||
return TE_Send(players, 1, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the current TE to all clients that are in
|
||||
* visible or audible range of the origin.
|
||||
* @note See TE_Start().
|
||||
* @note See GetClientsInRange()
|
||||
*
|
||||
* @param origin Coordinates from which to test range.
|
||||
* @param rangeType Range type to use for filtering clients.
|
||||
* @param delay Delay in seconds to send the TE.
|
||||
* @noreturn
|
||||
*/
|
||||
stock TE_SendToAllInRange(float origin[3], ClientRangeType rangeType, float delay=0.0)
|
||||
{
|
||||
int[] clients = new int[MaxClients];
|
||||
int total = GetClientsInRange(origin, rangeType, clients, MaxClients);
|
||||
return TE_Send(clients, total, delay);
|
||||
}
|
||||
@@ -92,10 +92,6 @@ enum APLRes
|
||||
* If any run-time error is thrown during this callback, the plugin will be marked
|
||||
* as failed.
|
||||
*
|
||||
* It is not necessary to close any handles or remove hooks in this function.
|
||||
* SourceMod guarantees that plugin shutdown automatically and correctly releases
|
||||
* all resources.
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward void OnPluginStart();
|
||||
@@ -132,6 +128,10 @@ forward APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
|
||||
/**
|
||||
* Called when the plugin is about to be unloaded.
|
||||
*
|
||||
* It is not necessary to close any handles or remove hooks in this function.
|
||||
* SourceMod guarantees that plugin shutdown automatically and correctly releases
|
||||
* all resources.
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward void OnPluginEnd();
|
||||
@@ -643,8 +643,7 @@ enum NumberType
|
||||
|
||||
enum Address
|
||||
{
|
||||
Address_Null = 0, //a typical invalid result when an address lookup fails
|
||||
Address_MinimumValid = 0x10000 //addresses below this value are considered invalid to use for Load/Store
|
||||
Address_Null = 0, // a typical invalid result when an address lookup fails
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+4
-10
@@ -399,32 +399,26 @@ native TF2_RemoveWearable(client, wearable);
|
||||
*
|
||||
* @param client Index of the client to which the conditon is being added.
|
||||
* @param condition Condition that is being added.
|
||||
* @noreturn
|
||||
*/
|
||||
forward TF2_OnConditionAdded(client, TFCond:condition);
|
||||
forward void TF2_OnConditionAdded(client, TFCond:condition);
|
||||
|
||||
/**
|
||||
* Called after a condition is removed from a player
|
||||
*
|
||||
* @param client Index of the client to which the condition is being removed.
|
||||
* @param condition Condition that is being removed.
|
||||
* @noreturn
|
||||
*/
|
||||
forward TF2_OnConditionRemoved(client, TFCond:condition);
|
||||
forward void TF2_OnConditionRemoved(client, TFCond:condition);
|
||||
|
||||
/**
|
||||
* Called when the server enters the Waiting for Players round state
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward TF2_OnWaitingForPlayersStart();
|
||||
forward void TF2_OnWaitingForPlayersStart();
|
||||
|
||||
/**
|
||||
* Called when the server exits the Waiting for Players round state
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward TF2_OnWaitingForPlayersEnd();
|
||||
forward void TF2_OnWaitingForPlayersEnd();
|
||||
|
||||
/**
|
||||
* Called when a player attempts to use a teleporter to decide if the player should be allowed to teleport.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -262,7 +262,7 @@ enum
|
||||
TFWeaponSlot_Building,
|
||||
TFWeaponSlot_PDA,
|
||||
TFWeaponSlot_Item1,
|
||||
TFWeaponSlot_Item2
|
||||
TFWeaponSlot_Item2
|
||||
};
|
||||
|
||||
// Identifiers for the eventtype property on the teamplay_flag_event event
|
||||
@@ -279,12 +279,12 @@ enum TFResourceType
|
||||
TFResource_Ping,
|
||||
TFResource_Score,
|
||||
TFResource_Deaths,
|
||||
TFResource_TotalScore,
|
||||
TFResource_TotalScore,
|
||||
TFResource_Captures,
|
||||
TFResource_Defenses,
|
||||
TFResource_Dominations,
|
||||
TFResource_Revenge,
|
||||
TFResource_BuildingsDestroyed,
|
||||
TFResource_BuildingsDestroyed,
|
||||
TFResource_Headshots,
|
||||
TFResource_Backstabs,
|
||||
TFResource_HealPoints,
|
||||
@@ -320,7 +320,7 @@ static const String:TFResourceNames[TFResourceType][] =
|
||||
|
||||
/**
|
||||
* Gets a client's current team.
|
||||
*
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return Current TFTeam of client.
|
||||
* @error Invalid client index.
|
||||
@@ -330,6 +330,19 @@ stock TFTeam:TF2_GetClientTeam(client)
|
||||
return TFTeam:GetClientTeam(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes a client's current team.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param team TFTeam team symbol.
|
||||
* @noreturn
|
||||
* @error Invalid client index.
|
||||
*/
|
||||
stock TF2_ChangeClientTeam(client, TFTeam:team)
|
||||
{
|
||||
ChangeClientTeam(client, _:team);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a client's current class.
|
||||
*
|
||||
@@ -357,7 +370,7 @@ stock TFClassType:TF2_GetPlayerClass(client)
|
||||
stock TF2_SetPlayerClass(client, TFClassType:classType, bool:weapons=true, bool:persistent=true)
|
||||
{
|
||||
SetEntProp(client, Prop_Send, "m_iClass", _:classType);
|
||||
|
||||
|
||||
if (persistent)
|
||||
{
|
||||
SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:classType);
|
||||
@@ -377,23 +390,23 @@ stock TF2_GetPlayerResourceData(client, TFResourceType:type)
|
||||
{
|
||||
if (!IsClientConnected(client))
|
||||
{
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
||||
|
||||
|
||||
if (offset < 1)
|
||||
{
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
new entity = TF2_GetResourceEntity();
|
||||
|
||||
|
||||
if (entity == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return GetEntData(entity, offset + (client*4));
|
||||
}
|
||||
|
||||
@@ -413,26 +426,26 @@ stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
|
||||
{
|
||||
if (!IsClientConnected(client))
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
||||
|
||||
|
||||
if (offset < 1)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
new entity = TF2_GetResourceEntity();
|
||||
|
||||
|
||||
if (entity == -1)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SetEntData(entity, offset + (client*4), value);
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -510,7 +523,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit)
|
||||
{
|
||||
return true;
|
||||
@@ -540,7 +553,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -554,12 +567,12 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
|
||||
stock TFObjectType:TF2_GetObjectType(entity)
|
||||
{
|
||||
new offset = GetEntSendPropOffs(entity, "m_iObjectType");
|
||||
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
ThrowError("Entity index %d is not an object", entity);
|
||||
}
|
||||
|
||||
|
||||
return TFObjectType:GetEntData(entity, offset);
|
||||
}
|
||||
|
||||
@@ -573,11 +586,11 @@ stock TFObjectType:TF2_GetObjectType(entity)
|
||||
stock TFObjectMode:TF2_GetObjectMode(entity)
|
||||
{
|
||||
new offset = GetEntSendPropOffs(entity, "m_iObjectMode");
|
||||
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
ThrowError("Entity index %d is not an object", entity);
|
||||
}
|
||||
|
||||
|
||||
return TFObjectMode:GetEntData(entity, offset);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ native Handle:CreateTimer(Float:interval, Timer:func, any:data=INVALID_HANDLE, f
|
||||
* @param autoClose If autoClose is true, the data that was passed to CreateTimer() will
|
||||
* be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified.
|
||||
* @noreturn
|
||||
* @error Invalid handles will cause a run time error.
|
||||
*/
|
||||
native KillTimer(Handle:timer, bool:autoClose=false);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ enum TopMenuObject:
|
||||
* @noreturn
|
||||
*/
|
||||
typedef TopMenuHandler = function void (
|
||||
Handle topmenu,
|
||||
TopMenu topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject topobj_id,
|
||||
int param,
|
||||
@@ -406,7 +406,7 @@ native void SetTopMenuTitleCaching(Handle topmenu, bool cache_titles);
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension:__ext_topmenus =
|
||||
public Extension __ext_topmenus =
|
||||
{
|
||||
name = "TopMenus",
|
||||
file = "topmenus.ext",
|
||||
|
||||
@@ -151,19 +151,39 @@ native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0);
|
||||
native EndMessage();
|
||||
|
||||
/**
|
||||
* Called when a message is hooked
|
||||
*
|
||||
* @param msg_id Message index.
|
||||
* @param msg Handle to the input bit buffer or protobuf.
|
||||
* @param players Array containing player indexes.
|
||||
* @param playersNum Number of players in the array.
|
||||
* @param reliable True if message is reliable, false otherwise.
|
||||
* @param init True if message is an initmsg, false otherwise.
|
||||
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
||||
* blocks the message from being sent, and Plugin_Continue
|
||||
* resumes normal functionality.
|
||||
*/
|
||||
typedef MsgHook = function Action (UserMsg msg_id, Handle msg, const int[] players, int playersNum, bool reliable, bool init);
|
||||
* Hook function types for user messages.
|
||||
*/
|
||||
typeset MsgHook
|
||||
{
|
||||
/**
|
||||
* Called when a bit buffer based usermessage is hooked
|
||||
*
|
||||
* @param msg_id Message index.
|
||||
* @param msg Handle to the input bit buffer.
|
||||
* @param players Array containing player indexes.
|
||||
* @param playersNum Number of players in the array.
|
||||
* @param reliable True if message is reliable, false otherwise.
|
||||
* @param init True if message is an initmsg, false otherwise.
|
||||
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
||||
* blocks the message from being sent, and Plugin_Continue
|
||||
* resumes normal functionality.
|
||||
*/
|
||||
function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init);
|
||||
/**
|
||||
* Called when a protobuf based usermessage is hooked
|
||||
*
|
||||
* @param msg_id Message index.
|
||||
* @param msg Handle to the input protobuf.
|
||||
* @param players Array containing player indexes.
|
||||
* @param playersNum Number of players in the array.
|
||||
* @param reliable True if message is reliable, false otherwise.
|
||||
* @param init True if message is an initmsg, false otherwise.
|
||||
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
||||
* blocks the message from being sent, and Plugin_Continue
|
||||
* resumes normal functionality.
|
||||
*/
|
||||
function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init);
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when a message hook has completed.
|
||||
|
||||
@@ -64,6 +64,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
|| StrEqual(game, "garrysmod", false)
|
||||
|| StrEqual(game, "swarm", false)
|
||||
|| StrEqual(game, "dota", false)
|
||||
|| StrEqual(game, "bms", false)
|
||||
|| GetEngineVersion() == Engine_Insurgency)
|
||||
{
|
||||
strcopy(error, err_max, "Nextmap is incompatible with this game");
|
||||
|
||||
@@ -234,7 +234,7 @@ public Action Command_Nominate(int client, int args)
|
||||
|
||||
g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
char name[MAX_NAME_LENGTH+1];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
PrintToChatAll("[SM] %t", "Map Nominated", name, mapname);
|
||||
|
||||
@@ -312,8 +312,8 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
{
|
||||
case MenuAction_Select:
|
||||
{
|
||||
char map[PLATFORM_MAX_PATH], name[MAX_NAME_LENGTH+1];
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
char map[PLATFORM_MAX_PATH], name[MAX_NAME_LENGTH];
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
|
||||
GetClientName(param1, name, sizeof(name));
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ public Plugin:myinfo =
|
||||
TopMenu hTopMenu;
|
||||
|
||||
/* Used to get the SDK / Engine version. */
|
||||
/* This is used in sm_rename and sm_changeteam */
|
||||
new EngineVersion:g_ModVersion = Engine_Unknown;
|
||||
|
||||
#include "playercommands/slay.sp"
|
||||
#include "playercommands/slap.sp"
|
||||
#include "playercommands/rename.sp"
|
||||
@@ -65,8 +62,6 @@ 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_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>");
|
||||
|
||||
g_ModVersion = GetEngineVersion();
|
||||
|
||||
/* Account for late loading */
|
||||
TopMenu topmenu;
|
||||
|
||||
@@ -37,22 +37,8 @@ PerformRename(client, target)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]);
|
||||
|
||||
/* Used on OB / L4D engine */
|
||||
if (g_ModVersion != Engine_SourceSDK2006)
|
||||
{
|
||||
SetClientInfo(target, "name", g_NewName[target]);
|
||||
}
|
||||
else /* Used on CSS and EP1 / older engine */
|
||||
{
|
||||
if (!IsPlayerAlive(target)) /* Lets tell them about the player renamed on the next round since they're dead. */
|
||||
{
|
||||
decl String:m_TargetName[MAX_NAME_LENGTH];
|
||||
SetClientName(target, g_NewName[target]);
|
||||
|
||||
GetClientName(target, m_TargetName, sizeof(m_TargetName));
|
||||
ReplyToCommand(client, "[SM] %t", "Dead Player Rename", m_TargetName);
|
||||
}
|
||||
ClientCommand(target, "name %s", g_NewName[target]);
|
||||
}
|
||||
g_NewName[target][0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
decl String:name[32];
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformSlap(param1, target, g_SlapDamage[param1]);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name);
|
||||
|
||||
@@ -103,7 +103,7 @@ public MenuHandler_Slay(Menu menu, MenuAction action, param1, param2)
|
||||
}
|
||||
else
|
||||
{
|
||||
decl String:name[32];
|
||||
decl String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformSlay(param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name);
|
||||
|
||||
@@ -211,7 +211,7 @@ void AttemptRTV(int client)
|
||||
return;
|
||||
}
|
||||
|
||||
char name[MAX_NAME_LENGTH+1];
|
||||
new String:name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
|
||||
g_Votes++;
|
||||
|
||||
Reference in New Issue
Block a user