General > Developers Corner

Remove Target parameter

(1/1)

jacksop:
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.


--- Code: ---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")

--- End code ---


How do i fix this? It's probably a simple answer but better to learn

Timmy:

--- Code: ---content:addParam{ type=ULib.cmds.PlayerArg }
--- End code ---

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" is one of them.

jacksop:
Sweet thanks man I'll give it all a go.

JamminR:
Also, if you've not figured it out already, you never tell the code who/what 'ply' is.
:)
Dangling variables, two of them actually.

Navigation

[0] Message Index

Go to full version