• Print

Author Topic: ULX command template  (Read 5895 times)

0 Members and 1 Guest are viewing this topic.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
ULX command template
« on: December 26, 2014, 05:10:41 pm »
Wasn't quite sure where to toss this, so I'll put it here. Feel free to move.

Hi, everyone!

So, I've noticed there's not much by way of a ULX command documentation out there—the way I've had to find out how to use ULX's internal functions was to search around premade plugins and build my own.
I decided to scrap together a reference template for making ULX commands as a result of that—the hunt and build method got a little tiring after a while.

So, here y'all go:
Code: Lua
  1. if SERVER then
  2.         -- serverside things
  3. end
  4.  
  5. if CLIENT then
  6.         -- clientside things
  7. end
  8.  
  9. function ulx.something( calling_ply, target_ply )
  10.         -- do command things
  11. end
  12.  
  13. -- Auto completes, for a list of predefined values for an argument
  14. auto_complete_table = {
  15.         "one",
  16.         "two",
  17.         "three"
  18. }
  19.  
  20. local uniquename = ulx.command( "category", "ulx something", ulx.something, "!something" )
  21. uniquename:addParam( type = type, hint = "hint", completes = auto_complete_table, ULib.cmds.restrictToCompletes )
  22. uniquename:defaultAccess( ULib.ACCESS_ALL )
  23. uniquename:help( "Something about your command." )

The values "uniquename", "something", "category", etc can all be modified, as well as the parameters to the addParam, ulx.command, defaultAcces, and help functions and autocompletes table.

This is just to help out people who know Lua (ish) but want to get started on making ULX commands.

I hope y'all appreciate it. :P
bw81@ulysses-forums ~ % whoami
Homepage

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: ULX command template
« Reply #1 on: January 08, 2015, 12:21:03 pm »
So if I just put... RunConsoleCommand("kill") in the if (CLIENT) then would it run that command?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX command template
« Reply #2 on: January 08, 2015, 04:16:25 pm »
Start a new topic referring to this thread. This is more of a good place holder to refer to than discussion of the many different ways to do something within the template.
But to answer your question, yes. But it would run at lua startup on the client, not during a command function.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print