ULX

Author Topic: Is there ANY way to restrict a console command to a certain rank?  (Read 1914 times)

0 Members and 1 Guest are viewing this topic.

Offline jamysaurus

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
A server i play in has just added GCompute for ingame lua editing so the owner himself has an easier job to code, and the coders.
But the problem is, everyone can use it right now--how would he go about blocking it only for some ranks?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Is there ANY way to restrict a console command to a certain rank?
« Reply #1 on: August 15, 2013, 10:48:15 AM »
He is a coder and yet needs to know how to restrict a command to admin only? :D

The easiest way would be to have him open the file for the addon that has the command in it and add this to the top of the function.

if not ply:IsAdmin() then return end


^in this example I assume the function passes the player calling the function as ply. If not, change as appropriate.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Is there ANY way to restrict a console command to a certain rank?
« Reply #2 on: August 15, 2013, 02:24:23 PM »
And just to be clear, MrPresident's way wouldn't even require ULib or uLX.
Would work on any server where a player had 'admin' group access.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Is there ANY way to restrict a console command to a certain rank?
« Reply #3 on: August 15, 2013, 07:27:56 PM »
And just to be clear, MrPresident's way wouldn't even require ULib or uLX.
Would work on any server where a player had 'admin' group access.

and what else is other than ulx, evolve :p ?
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Is there ANY way to restrict a console command to a certain rank?
« Reply #4 on: August 15, 2013, 07:34:35 PM »
and what else is other than ulx, evolve :p ?
100% Vanilla Console.
Something which I wish more people learned before ever installing an admin mod.
:)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming