diff --git a/sources/Commands/Commands.uc b/sources/Commands/Commands.uc index d87c564..be4a6c2 100644 --- a/sources/Commands/Commands.uc +++ b/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 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 diff --git a/sources/Commands/Commands_Feature.uc b/sources/Commands/Commands_Feature.uc index e905a9f..93ac435 100644 --- a/sources/Commands/Commands_Feature.uc +++ b/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 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 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);