Browse Source

Change Commands feature to use configured steamIDs

Previously we've used hardcoded steam ids to test commands on our
servers. Proper priviledge system still wasn't introduced, but
hardcoding ourselves before public release is a shitty idea, so I've
added an alternative crutch instead: server admin can now specify steam
ids of players allowed to use commands in the config.

This is a temporary workaround and to be replaced later.
pull/8/head
Anton Tarasenko 2 years ago
parent
commit
a689e84b8f
  1. 35
      sources/Commands/Commands.uc
  2. 18
      sources/Commands/Commands_Feature.uc

35
sources/Commands/Commands.uc

@ -21,35 +21,58 @@ class Commands extends FeatureConfig
perobjectconfig
config(AcediaSystem);
var public config bool useChatInput;
var public config bool useMutateInput;
var public config string chatCommandPrefix;
var public config bool useChatInput;
var public config bool useMutateInput;
var public config string chatCommandPrefix;
var public config array<string> allowedPlayers;
protected function HashTable ToData()
{
local int i;
local HashTable data;
local ArrayList playerList;
data = __().collections.EmptyHashTable();
data.SetBool(P("useChatInput"), useChatInput, true);
data.SetBool(P("useMutateInput"), useMutateInput, true);
data.SetString(P("chatCommandPrefix"), chatCommandPrefix);
playerList = _.collections.EmptyArrayList();
for (i = 0; i < allowedPlayers.length; i += 1) {
playerList.AddString(allowedPlayers[i]);
}
data.SetItem(P("allowedPlayers"), playerList);
playerList.FreeSelf();
return data;
}
protected function FromData(HashTable source)
{
local int i;
local ArrayList playerList;
if (source == none) {
return;
}
useChatInput = source.GetBool(P("useChatInput"));
useMutateInput = source.GetBool(P("useMutateInput"));
chatCommandPrefix = source.GetString(P("chatCommandPrefix"), "!");
playerList = source.GetArrayList(P("allowedPlayers"));
allowedPlayers.length = 0;
if (playerList == none) {
return;
}
for (i = 0; i < playerList.GetLength(); i += 1) {
allowedPlayers[allowedPlayers.length] = playerList.GetString(i);
}
playerList.FreeSelf();
}
protected function DefaultIt()
{
useChatInput = true;
useMutateInput = true;
chatCommandPrefix = "!";
useChatInput = true;
useMutateInput = true;
chatCommandPrefix = "!";
allowedPlayers.length = 0;
}
defaultproperties

18
sources/Commands/Commands_Feature.uc

@ -46,6 +46,9 @@ var private /*config*/ bool useMutateInput;
// Chat messages, prepended by this prefix will be treated as commands.
// Default is "!". Empty values are also treated as "!".
var private /*config*/ Text chatCommandPrefix;
// List of steam IDs of players allowed to use commands.
// Temporary measure until a better solution is finished.
var private /*config*/ array<string> allowedPlayers;
var LoggerAPI.Definition errCommandDuplicate;
@ -94,6 +97,7 @@ protected function SwapConfig(FeatureConfig config)
}
_.memory.Free(chatCommandPrefix);
chatCommandPrefix = _.text.FromString(newConfig.chatCommandPrefix);
allowedPlayers = newConfig.allowedPlayers;
if (useChatInput != newConfig.useChatInput)
{
useChatInput = newConfig.useChatInput;
@ -423,6 +427,8 @@ public final function array<Text> GetGroupsNames()
*/
public final function HandleInput(Parser parser, EPlayer callerPlayer)
{
local int i;
local bool foundID;
local string steamID;
local PlayerController controller;
local Command commandInstance;
@ -435,11 +441,15 @@ public final function HandleInput(Parser parser, EPlayer callerPlayer)
if (controller == none) return;
steamID = controller.GetPlayerIDHash();
if ( steamID != "76561198025127722"
&& steamID != "76561198044316328"
&& steamID != "76561198003353515"
&& steamID != "76561198281136503")
for (i = 0; i < allowedPlayers.length; i += 1)
{
if (allowedPlayers[i] == steamID)
{
foundID = true;
break;
}
}
if (!foundID) {
return;
}
parser.MUntilMany(commandName, commandDelimiters, true, true);

Loading…
Cancel
Save