Hello everyone, long time no see
I am currently running into a issue with ULX where I created a command with all parameters being optional ( the first one is a optional player parameter ), but when the console uses the command without parameters it doesn't even attempt to run the function, as the player parameter gets run trough "ulx.getUniqueIDForPlayer", which causes a error as the console is ( you guessed it ) not a player. Here is the lua error:
[ERROR] addons/ulib/lua/ulib/shared/player.lua:121: Tried to use a NULL entity!
1. indexFn - [C]:-1
2. getUniqueIDForPlayer - addons/ulib/lua/ulib/shared/player.lua:121
3. parseAndValidate - addons/ulib/lua/ulib/shared/commands.lua:515
4. __fn - addons/ulib/lua/ulib/shared/commands.lua:916
5. execute - addons/ulib/lua/ulib/shared/commands.lua:1323
6. unknown - addons/ulib/lua/ulib/shared/commands.lua:1351
7. unknown - lua/includes/modules/concommand.lua:54
My question is if there is something I can do without injecting into ULX code ( which I really want to avoid ) ?
Is there some kind of hidden parameter that I don't know yet which isn't documented?
Example:
local exampleFunction = function(calling_ply, target_ply)
-- It doesn't even go in here
end
local exampleCommand= ulx.command( "Example", "example_command", exampleFunction, "!example" )
exampleCommand:addParam{ type=ULib.cmds.PlayerArg, hint="player", ULib.cmds.optional}
exampleCommand:defaultAccess( ULib.ACCESS_SUPERADMIN )
exampleCommand:help( "Example command to demonstrate how the console will not be able to run this command without parameters" )
Now when you run this command "example_command" from the console without parameters, you will recieve a error message and the command function won't be executed at all.
If you know a solution, I am happy to hear about it.
Thank you for reading my rambling,
~cap