Ulysses
General => Developers Corner => Topic started by: jacksop on January 06, 2020, 12:13:22 AM
-
Hey thanks for the help with my previous post.
I am very new to lua so coding is a little confusing at times.
I looked at this code for almost an hour and i can't work out how to remove the target parameter.
I want to make it so the command is just !content and opens up a window in game on whoever calls it. At the moment, the game asks for a target player, so to use the command i would need to type !content jacksop and then it appears.
local COMMAND_CONTENT = "ULX Commands"
function ulx.content(calling_ply)
ply:SendLua("gui.OpenURL('https://steamcommunity.com/')")
end
local content = ulx.command(COMMAND_CONTENT, "ulx content", ulx.content, "!content", true)
content:addParam{ type=ULib.cmds.PlayerArg }
content:defaultAccess ( ULib.ACCESS_ADMIN )
content:help ("Content link command")
How do i fix this? It's probably a simple answer but better to learn
-
content:addParam{ type=ULib.cmds.PlayerArg }
Remove this if your command does not need a target player.
ULX includes several commands that don't take any parameters. They can be great examples when you are trying to make your own. "ulx thetime (https://github.com/TeamUlysses/ulx/blob/v3.73/lua/ulx/modules/sh/chat.lua#L72)" is one of them.
-
Sweet thanks man I'll give it all a go.
-
Also, if you've not figured it out already, you never tell the code who/what 'ply' is.
:)
Dangling variables, two of them actually.