• Print

Author Topic: Custom command to promote  (Read 4959 times)

0 Members and 1 Guest are viewing this topic.

Offline Best Wukong NA

  • Newbie
  • *
  • Posts: 3
  • Karma: 2
Custom command to promote
« on: November 06, 2015, 12:57:31 pm »
What code would I use to make a customcommand, for example when saying '!example' you get a certain rank, like superadmin (just an example) without needing the adduser permission?

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Re: Custom command to promote
« Reply #1 on: November 06, 2015, 03:08:52 pm »
Hopefully someone with a computer can add in the tabs to this code, but this will make it so if you type !admin it gives you admin. The second code is !rank NAME RANK

Code: Lua
  1. local CATEGORY_NAME = "Bleh"
  2.  
  3. function ulx.admin( ply )
  4. RunConsoleCommand( "ulx", "adduser", ply, "admin" ) -- Insert a tab before the RunConsoleCommand and ULX.fancylogadmin
  5. ulx.fancyLogAdmin( ply, "#A is now an admin!" )
  6. end
  7. local admin = ulx.command( CATEGORY_NAME, "ulx admin", ulx.admin, "!admin" )
  8. admin:defaultAccess( ULib.ACCESS_ALL ) -- Don't be a dummy, change all to admin if you want admins to be able to use it, SUPERADMIN as well. Do not change this to the group name.
  9. admin:help( "Makes you an admin!" )
  10.  

!rank NAME GROUP
Code: Lua
  1. local CATEGORY_NAME = "bleh"
  2.  
  3. function ulx.rank( ply, target, group )
  4. RunConsoleCommand( "ulx", "adduser", target, group )
  5. ulx.fancyLogAdmin( ply, "#A has made #T a #s.", target, group )
  6. end
  7. local rank = ulx.command( CATEGORY_NAME, "ulx rank", ulx.rank, "!rank" )
  8. rank:defaultAccess( ULib.ACCESS_ADMIN )
  9. rank:addParam{ type = ULib.cmds.PlayerArg }
  10. rank:addParam{ type = ULib.cmds.StringArg }
  11. rank:help( "Assign a target<s> to a group." )
  12.  

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom command to promote
« Reply #2 on: November 06, 2015, 07:45:20 pm »
Hopefully someone with a computer can add in the tabs to this code, but this will make it so if you type !admin it gives you admin. The second code is !rank NAME RANK

Code: Lua
  1. local CATEGORY_NAME = "Bleh"
  2.  
  3. function ulx.admin( ply )
  4. RunConsoleCommand( "ulx", "adduser", ply, "admin" ) -- Insert a tab before the RunConsoleCommand and ULX.fancylogadmin
  5. ulx.fancyLogAdmin( ply, "#A is now an admin!" )
  6. end
  7. local admin = ulx.command( CATEGORY_NAME, "ulx admin", ulx.admin, "!admin" )
  8. admin:defaultAccess( ULib.ACCESS_ALL ) -- Don't be a dummy, change all to admin if you want admins to be able to use it, SUPERADMIN as well. Do not change this to the group name.
  9. admin:help( "Makes you an admin!" )
  10.  

!rank NAME GROUP
Code: Lua
  1. local CATEGORY_NAME = "bleh"
  2.  
  3. function ulx.rank( ply, target, group )
  4. RunConsoleCommand( "ulx", "adduser", target, group )
  5. ulx.fancyLogAdmin( ply, "#A has made #T a #s.", target, group )
  6. end
  7. local rank = ulx.command( CATEGORY_NAME, "ulx rank", ulx.rank, "!rank" )
  8. rank:defaultAccess( ULib.ACCESS_ADMIN )
  9. rank:addParam{ type = ULib.cmds.PlayerArg }
  10. rank:addParam{ type = ULib.cmds.StringArg }
  11. rank:help( "Assign a target<s> to a group." )
  12.  
Wispy, I know you're tryin', mate, but you're just not quite grasping it.

Code: Lua
  1. local CATEGORY_NAME = "" -- Insert your desired category here
  2.                          -- This will determine where your command
  3.                          -- ends up in XGUI, ie under which submenu
  4.  
  5. local rank = "" -- Insert your desired rank here
  6.                 -- The command and all relevant text will be
  7.                 -- updated to match this
  8.  
  9. function ulx.giverank( calling_ply )
  10.   if SERVER then -- Redundant? Maybe. But it doesn't hurt to check.
  11.     RunConsoleCommand( "ulx", "adduser", calling_ply:Name(), rank )
  12.   end
  13.   ulx.fancyLogAdmin( calling_ply, "#A is now a #s!", rank )
  14. end
  15.               -- ulx.command( string category, string concommand, function cmd, string chatcommand)
  16. local giverank = ulx.command( CATEGORY_NAME,   "ulx " .. rank,    ulx.giverank, "!" .. rank )
  17. cmd:defaultAccess( ULib.ACCESS_ALL ) -- Set access level - ALL = everyone,
  18.                                      -- ADMIN = admin group and inheritants,
  19.                                      -- SUPERADMIN = superadmin group and inheritants
  20.  
  21. cmd:help("Makes you a " .. rank .. "!") -- Set relevant hint text
  22.                                         -- Feel free to change this

The second one is literally just ulx adduser, just with a say command.
« Last Edit: November 06, 2015, 08:25:20 pm by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom command to promote
« Reply #3 on: November 06, 2015, 08:37:33 pm »
Wispy, as project developers, we love when the community supports itself, without need for us to assist.
However, I'd recommend at this time you test your code before posting.

If I were a new coder and asking questions that I've seen you attempt to assist with, I'd end up more confused.
I mean no negative connotation to you personally re: this request - I just believe you have a bit more experience to gain before working "off the cuff".
Now, mind you, every dev here has made mistakes in working off the cuff - but leaving out major requirements of code, including standard Lua, GLua, and our library itself, only shows more experience is needed.
Thanks for trying to help, and please continue practicing and asking questions here in your topics of Dev corner.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Custom command to promote
« Reply #4 on: November 07, 2015, 01:38:32 am »
Wispy, as project developers, we love when the community supports itself, without need for us to assist.
However, I'd recommend at this time you test your code before posting.

If I were a new coder and asking questions that I've seen you attempt to assist with, I'd end up more confused.
I mean no negative connotation to you personally re: this request - I just believe you have a bit more experience to gain before working "off the cuff".
Now, mind you, every dev here has made mistakes in working off the cuff - but leaving out major requirements of code, including standard Lua, GLua, and our library itself, only shows more experience is needed.
Thanks for trying to help, and please continue practicing and asking questions here in your topics of Dev corner.
+1

Also, try not to post code with a mobile device (implied in your post). It makes code...messy.
Once you get to know me, you'll find you'll have never met me at all.

  • Print