Author Topic: Problem running my command  (Read 1802 times)

0 Members and 1 Guest are viewing this topic.

Offline jvicu_2001

  • Newbie
  • *
  • Posts: 3
  • Karma: -1
Problem running my command
« on: December 25, 2015, 06:44:40 PM »
Hi, I'm trying to get my command running but I got this error.
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/mycommands.lua:42: 'end' expected (to close 'if' at line 37) near '<eof>'and this one.
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/mycommands.lua:48: bad argument #2 to ULib.cmds.TranslateCommand (function expected)
           1. error - [C]:-1
            2. checkArg - addons/ulib/lua/ulib/shared/misc.lua:520
             3. instantiate - addons/ulib/lua/ulib/shared/commands.lua:1078
              4. ulxCommand - addons/ulib/lua/ulib/shared/misc.lua:843
               5. command - addons/ulx/lua/ulx/sh_base.lua:43
                6. unknown - addons/ulx/lua/ulx/modules/sh/mycommands.lua:48

Why this is happening? here is the code I'm trying to run.
Code: [Select]
function roll ( diceSides )
local calling_ply
local rollResult
if diceSides < 2 then
timer.Simple (1, function() ULib.tsay( "The number has to be above 1", true ) end)

elseif diceSides > 128 then
timer.Simple(1, function() ULib.tsay( "The number has to be under 129", true ) end)
end
ulx.fancyLogAdmin( calling_ply, true, "#A throw the dice" )
rollResult = math.random(2, diceSides)
ulx.fancyLogAdmin( calling_ply, true, "#A got ", rollResult, " of ", diceSides)
end

local roll = ulx.command( CATEGORY_NAME, "ulx roll", ulx.roll, "!roll" )
roll:addParam{ type=ULib.cmds.NumArg, min=2, max=128, default=6, hint="number", ULib.cmds.round }
roll:defaultAccess( ULib.ACCESS_ALL )
roll:help( "Rolls the dice." )

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Problem running my command
« Reply #1 on: December 25, 2015, 08:09:21 PM »
Try changing your function's name to ulx.roll
In your "local roll = ulx.command..." line you reference ulx.roll despite your function being named roll