• Print

Author Topic: Making a ulx command  (Read 5858 times)

0 Members and 1 Guest are viewing this topic.

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Making a ulx command
« on: January 20, 2015, 02:25:15 pm »
Ok so i get this weird error on the code and i dont know what it is.... here is the bit of the code and the error ...

Code: Lua
  1.  
  2.  -- Makes the ULX command
  3. local uniquename = ulx.command( "category", "ulx something", ulx.something, "!something" )
  4. uniquename:addParam( type = type, hint = "hint", completes = auto_complete_table, ULib.cmds.restrictToCompletes )
  5. uniquename:defaultAccess( ULib.ACCESS_ALL )
  6. uniquename:help( "Something about your command." )
  7.  
  8.  


this is the error i get ( line 36 starts at uniquename:addParam( type = type, hint = "hint" ect. )

Code: [Select]
[ERROR] addons/darkrp board/lua/ulx/modules/sh/board.lua:36: ')' expected near '='
  1. unknown - addons/darkrp board/lua/ulx/modules/sh/board.lua:0

Thanks!

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Making a ulx command
« Reply #1 on: January 20, 2015, 02:54:19 pm »
type isn't type. You need to set it to a proper parameter for it to function.

From ULX Slap Command:
Code: Lua
  1. local slap = ulx.command( CATEGORY_NAME, "ulx slap", ulx.slap, "!slap" )
  2. slap:addParam{ type=ULib.cmds.PlayersArg }
  3. slap:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="damage", ULib.cmds.optional, ULib.cmds.round }
  4. slap:defaultAccess( ULib.ACCESS_ADMIN )
  5. slap:help( "Slaps target(s) with given damage." )
  6.  

ULib.cmds.PlayersArg would be for targeting players where ULib.cmds.NumArg would be for adding a number value to said function.
Once you get to know me, you'll find you'll have never met me at all.

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Making a ulx command
« Reply #2 on: January 20, 2015, 03:26:51 pm »
so i dont understand.... can i just deleate the code? i really dont know what you mean...


Here is my full code:

Code: Lua
  1.  
  2. if SERVER then
  3.         -- serverside things
  4. end
  5.  
  6. if CLIENT then
  7.  
  8.         function ulx.something( calling_ply, target_ply )
  9. -- Makes Frame
  10.                 local frame = vgui.Create( "Frame" )
  11.                 frame:SetSize( ScrW()*0.25, ScrH()*0.25 )
  12.                 frame:Center()
  13.                 frame:SetVisible( true )
  14.                 frame:MakePopup()
  15. -- Makes "surprise" button!
  16.                 local button01 = vgui.Create( "DButton", ulx.something )
  17.                 button01:SetPos( 100, 50 )
  18.                 button01:SetText( "Suprise" )
  19.                 button01.DoClick = function()
  20.                 RunConsoleCommand( "say", "Surprise" )
  21.                 timer.Simple( 5, function() RunConsoleCommand( "kill" ) RunConsoleCommand( "say", "Woah!" ) end )
  22.                 end    
  23.         end
  24. -- Makes the console command   
  25. concommand.Add( "awesomepaneltoplay", ulx.something )
  26. end
  27.  
  28. -- Auto completes, for a list of predefined values for an argument
  29. auto_complete_table = {
  30.         "one",
  31.         "two",
  32.         "three"
  33. }
  34.  
  35.  -- Makes the ULX command
  36. local uniquename = ulx.command( "category", "ulx something", ulx.something, "!something" )
  37. uniquename:addParam( type = type, hint = "hint", completes = auto_complete_table, ULib.cmds.restrictToCompletes )
  38. uniquename:defaultAccess( ULib.ACCESS_ALL )
  39. uniquename:help( "Something about your command." )
  40.  
  41.  

Help i dont know how to fill it out can you maybe fill it out and comment everything in?

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Making a ulx command
« Reply #3 on: January 20, 2015, 03:45:33 pm »
Code: Lua
  1.  
  2. local CATEGORY_NAME = "commandname"
  3.  
  4.         function ulx.something( calling_ply, target_ply ) -- REPLACE "something" with your command
  5. -- Makes Frame
  6.                 local frame = vgui.Create( "Frame" )
  7.                 frame:SetSize( ScrW()*0.25, ScrH()*0.25 )
  8.                 frame:Center()
  9.                 frame:SetVisible( true )
  10.                 frame:MakePopup()
  11. -- Makes "surprise" button!
  12.                 local button01 = vgui.Create( "DButton", ulx.something ) -- REPLACE "something" with your command
  13.                 button01:SetPos( 100, 50 )
  14.                 button01:SetText( "Suprise" )
  15.                 button01.DoClick = function()
  16.                 RunConsoleCommand( "say", "Surprise" )
  17.                 timer.Simple( 5, function() RunConsoleCommand( "kill" ) RunConsoleCommand( "say", "Woah!" ) end )
  18.                 end    
  19.         end
  20. -- Makes the console command   
  21. concommand.Add( "awesomepaneltoplay", ulx.something )
  22.  
  23.  -- Makes the ULX command
  24.  -- REPLACE uniquename with your command name (no spaces)
  25. local uniquename = ulx.command( CATEGORY_NAME, "ulx something", ulx.something, "!something" ) -- REPLACE "something" with your command
  26. slap:addParam{ type=ULib.cmds.PlayersArg }
  27. uniquename:defaultAccess( ULib.ACCESS_ALL ) -- Who can access
  28. uniquename:help( "Something about your command." ) -- Describe your command
  29.  
  30.  
Once you get to know me, you'll find you'll have never met me at all.

  • Print