Ulysses

General => Developers Corner => Topic started by: jacksop on January 06, 2020, 12:13:22 AM

Title: Remove Target parameter
Post 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.

Code: [Select]
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
Title: Re: Remove Target parameter
Post by: Timmy on January 06, 2020, 01:54:03 AM
Code: [Select]
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.
Title: Re: Remove Target parameter
Post by: jacksop on January 06, 2020, 04:00:12 AM
Sweet thanks man I'll give it all a go.
Title: Re: Remove Target parameter
Post by: JamminR on January 06, 2020, 07:58:08 PM
Also, if you've not figured it out already, you never tell the code who/what 'ply' is.
:)
Dangling variables, two of them actually.