Here's an example that allows a command to be only ran by either a specific SteamID or the server itself (RCON also works).
Note that it still requires ROOT access because of
RegAdminCmd.
Code:
#include <sourcemod>
public void OnPluginStart()
{
RegAdminCmd("sm_crash", Command_Crash, ADMFLAG_ROOT);
LoadTranslations("common.phrases");
}
public Action Command_Crash(int client, int args)
{
char[] sAuth = new char[32];
if(client != 0 && !(GetClientAuthId(client, AuthId_Steam3, sAuth, 32) && StrEqual(sAuth, "[U:1:204506329]")))
{
return Plugin_Continue;
}
if(args < 1)
{
ReplyToCommand(client, "sm_crash <target>");
return Plugin_Handled;
}
char[] sArgs = new char[MAX_TARGET_LENGTH];
GetCmdArgString(sArgs, MAX_TARGET_LENGTH);
int target = FindTarget(client, sArgs, true, false);
if(target == -1)
{
return Plugin_Handled;
}
Handle hSayText2 = StartMessageOne("SayText2", target);
if(hSayText2 != null)
{
PbSetInt(hSayText2, "ent_idx", target);
PbSetBool(hSayText2, "chat", false);
PbSetString(hSayText2, "msg_name", "rip");
EndMessage();
}
return Plugin_Handled;
}
__________________