ULX

Author Topic: Remove Target parameter  (Read 304 times)

0 Members and 1 Guest are viewing this topic.

Offline jacksop

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Remove Target parameter
« 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

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 246
  • Karma: 165
  • Code monkey
    • ULX Unofficial Documentation
Re: Remove Target parameter
« Reply #1 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" is one of them.

Offline jacksop

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Remove Target parameter
« Reply #2 on: January 06, 2020, 04:00:12 AM »
Sweet thanks man I'll give it all a go.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8072
  • Karma: 387
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Remove Target parameter
« Reply #3 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming