I'm still relatively new to lua, and I've been trying to use ULib.cmds.StringArg but I'm having some trouble getting the data from the string to be passed into the command. I made a table for the completes argument and its appearing in game but i cant get the data from the string to work with my command. Whats the easiest way to get the data from the string into the command?
------------------------------ Force --------------------------------
ulx.role = {}
local function updateRoles()
table.Empty( ulx.role ) -- Don't reassign so we don't lose our refs
table.insert(ulx.role,"traitor") -- Add "traitor" to the table.
table.insert(ulx.role,"detective") -- Add "detective" to the table.
table.insert(ulx.role,"innocent") -- Add "innocent" to the table.
end
hook.Add( ULib.HOOK_UCLCHANGED, "ULXRoleNamesUpdate", updateRoles )
updateRoles() -- Init
function ulx.force( calling_ply, target_plys, role )
if role == "traitor" then role == ROLE_TRAITOR end
if role == "detective" then role == ROLE_DETECTIVE end
if role == "innocent" then role == ROLE_INNOCENT end
for i=1, #target_plys do
local v = target_plys[ i ]
v:SetRole(role)
end
SendFullStateUpdate()
ulx.fancyLogAdmin( calling_ply, true, "#A set #T to #s", target_plys, role )
end
local force = ulx.command( CATEGORY_NAME, "ulx force", ulx.force )
force:addParam{ type=ULib.cmds.PlayerArg }
force:addParam{ type=ULib.cmds.StringArg, completes=ulx.role, hint="Role", error="invalid role \"%s\" specified", ULib.cmds.restrictToCompletes }
force:defaultAccess( ULib.ACCESS_SUPERADMIN )
force:help( "Force a role onto a player." )
error
[ERROR] addons/terror town commands/lua/ulx/modules/sh/ttt.lua:65: 'then' expected near '=='
1. unknown - addons/terror town commands/lua/ulx/modules/sh/ttt.lua:0