So if a player were to type [CODE]!exempt <SteamID>[/CODE] I would want to add this [CODE]<SteamID> = true[/CODE] to the table so that it would be the same as typing the following in the config:
[CODE]
Settings.Exempt = {
['<SteamID>'] = true,
}
[/CODE]
I looked on the wiki and found [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/insert]table.insert[/url] but I'm pretty sure that I can't do this using that.
local table = {}
table[ply:SteamID()] = true
[QUOTE=Invule;50150215]local table = {}
table[ply:SteamID()] = true[/QUOTE]
I'm not sure what your saying... I want to add the players SteamID while in-game, so typing the command would result in the following being added to the table without leaving the game: ['<player's steamid>'] = true
yes
[QUOTE=Invule;50150679]yes[/QUOTE]
Would this work?
[CODE]
local functionsTable = {}
functionsTable["exempt"] = function( ply, args )
if IsValid( args[1] ) then
if plyHasPerms( ply ) then
tempTable= {}
tempTable[args[1]]
table.Merge( tempTable, RAS.Settings.Exempt )
return ''
else
RAS.ChatPrint( "You do not have permission to do this!", ply )
return ''
end
else
RAS.ChatPrint( "Target is invalid!", ply )
return ''
end
end
local function CommandFilter( ply, text )
local args = string.Split( text, " " )
if args[1] == "!ras" or args[1] == "/ras" then
local func = functionsTable[args[2]]
if func then
table.remove( args, 1 ) -- There's no need to pass on the "ras" part of it, as we only need it here to call the function
table.remove( args, 1 ) -- There's also no need to pass on the second part of it, as we only need it here to know which function to call exactly
PrintTable( RAS.Settings )
func( ply, args ) -- We pass any additional argument for the function to handle
end
end
end
hook.Add( "PlayerSay", "CheckForChatRASCommand", CommandFilter )
[/CODE]
Sorry, you need to Log In to post a reply to this thread.