Hi, I'm trying to get my command running but I got this error.
[ERROR] addons/ulx/lua/ulx/modules/sh/mycommands.lua:42: 'end' expected (to close 'if' at line 37) near '<eof>'
and this one.
[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.
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." )