Author Topic: String arg  (Read 4662 times)

0 Members and 1 Guest are viewing this topic.

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
String arg
« on: May 10, 2013, 08:53:50 AM »
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?

Code: [Select]
------------------------------ 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
Code: [Select]
[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

« Last Edit: May 10, 2013, 12:01:53 PM by bender180 »
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given