Author Topic: Give Access to a single rcon command?  (Read 11441 times)

0 Members and 1 Guest are viewing this topic.

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Give Access to a single rcon command?
« on: January 02, 2013, 06:32:40 PM »
Any idea how i can give admins access to a single rcon command?

In this case, the command is: ttt_print_damagelog

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Give Access to a single rcon command?
« Reply #1 on: January 02, 2013, 06:46:54 PM »
See http://forums.ulyssesmod.net/index.php/topic,5889.0.html
Not sure it ever got answered fully, but we sure tried to help.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Give Access to a single rcon command?
« Reply #2 on: January 02, 2013, 08:55:17 PM »
In case you don't want to have a separate command for it, you can in fact limit rcon commands. It works best in XGUI, but you can see the access tag equivalent in the chat:


.. It's not very forgiving in terms of needing to be spelled out EXACTLY, but, it works:
Code: [Select]
] ulx rcon "ulx slap sti"
(SILENT) You ran rcon command: ulx slap sti
(Console) slapped You with 0 damage
] ulx rcon disconnect
Command "ulx rcon", argument #1: invalid string
] ulx rcon "say 'bob'"
(SILENT) You ran rcon command: say 'bob'
Console: 'bob'
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Give Access to a single rcon command?
« Reply #3 on: January 02, 2013, 09:29:03 PM »
to do this the clean way for at least the ttt command you would edit the logic for who can use the command
some place there should be a  if statement
if  ply:is superadmin then
     ttt logs go here
end


im no lazy to find it right now  be back tomorow hopefully
screw it i did  its the admin.lua file in ttt/gamemode/admin.lua
*falls asleep*
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Give Access to a single rcon command?
« Reply #4 on: January 03, 2013, 04:49:52 PM »
ok a bump im geting pissed about this i tried doing this and got it to work just not with a  not alive  aswell so im going to copy paste my code
Code: [Select]
local function PrintDamageLog(ply)
   local pr = GetPrintFn(ply)

   if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE then
ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console"))
      pr("*** Damage log:\n")

      if not dmglog_console:GetBool() then
         pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
      end

      for k, txt in ipairs(GAMEMODE.DamageLog) do
         pr(txt)
      end

      pr("*** Damage log end.")
   
   end
   if not ply:alive() then
   if ply:IsUserGroup("admin") or ply:IsUserGroup("moderator") then
ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console"))
      pr("*** Damage log:\n")

      if not dmglog_console:GetBool() then
         pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
      end

      for k, txt in ipairs(GAMEMODE.DamageLog) do
         pr(txt)
      end

      pr("*** Damage log end.")
 
   end
else
      if IsValid(ply) then
         pr("You do not appear to be RCON or a superadmin, nor are we in the post-round phase!")
      end
   end
   end
concommand.Add("ttt_print_damagelog", PrintDamageLog)
vinnila code is here
Code: [Select]
local function PrintDamageLog(ply)
   local pr = GetPrintFn(ply)

   if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE then
      ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console"))
      pr("*** Damage log:\n")

      if not dmglog_console:GetBool() then
         pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
      end

      for k, txt in ipairs(GAMEMODE.DamageLog) do
         pr(txt)
      end

      pr("*** Damage log end.")
   else
      if IsValid(ply) then
         pr("You do not appear to be RCON or a superadmin, nor are we in the post-round phase!")
      end
   end
end
concommand.Add("ttt_print_damagelog", PrintDamageLog)
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Give Access to a single rcon command?
« Reply #5 on: January 03, 2013, 05:22:45 PM »
So you're trying to allow this TTT command while not just dead, but also while alive?
I'm guessing if someone is alive, which means they are in an active round, they can't run it.
Then this is your catch ... "GetRoundState() != ROUND_ACTIVE"
GetRoundState NOT EQUAL to ACTIVE = Don't show if server is in a round.

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

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Give Access to a single rcon command?
« Reply #6 on: January 04, 2013, 09:45:32 AM »
So you're trying to allow this TTT command while not just dead, but also while alive?
I'm guessing if someone is alive, which means they are in an active round, they can't run it.
Then this is your catch ... "GetRoundState() != ROUND_ACTIVE"
GetRoundState NOT EQUAL to ACTIVE = Don't show if server is in a round.
ok to some respects you are correct if the user is super admin they can run it when ever because they are to be trusted but admins and lower or who else i want to be able to see logs when dead during a round would  be  geting output via the else if unless i coded this wrong
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Give Access to a single rcon command?
« Reply #7 on: January 04, 2013, 04:02:37 PM »
I'm pretty sure Gmod functions are case-sensitive, just like rest of Lua.
You're using 'ply:alive()' instead of ply:Alive()'.
But, that's all my flu symptom addled and sore brain can see at the moment.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Give Access to a single rcon command?
« Reply #8 on: January 07, 2013, 10:02:22 AM »
this should work *UNTESTED WILL BREAK LOGS IF DOESNT WORK*
Code: [Select]
local function PrintDamageLog(ply)
   local pr = GetPrintFn(ply)
    if (not IsValid(ply)) or ply:IsSuperAdmin() or ply:IsUserGroup("admin") or ply:IsUserGroup("moderator") or GetRoundState() != ROUND_ACTIVE then
        if ply:Alive() and GetRoundState() = ROUND_ACTIVE and (ply:IsUserGroup("admin") or ply:IsUserGroup("moderator")) then
            pr("You do not appear to be dead, nor are we in the post-round phase!")
            return
        end
        ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console"))
        pr("*** Damage log:\n")

        if not dmglog_console:GetBool() then
         pr("Damage logging for console disabled. Enable with ttt_log_damage_for_console 1.")
        end

        for k, txt in ipairs(GAMEMODE.DamageLog) do
         pr(txt)
        end

        pr("*** Damage log end.")
else
      if IsValid(ply) then
         pr("You do not appear to be RCON or a superadmin, nor are we in the post-round phase!")
      end
   end
end
concommand.Add("ttt_print_damagelog", PrintDamageLog)
update yeah this doesnt work need help
« Last Edit: January 07, 2013, 05:59:19 PM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: Give Access to a single rcon command?
« Reply #9 on: January 14, 2013, 06:59:57 PM »
this doesnt work just make a duplicate command in the admin.lua for the  printing dammage logs and  remove the if arguments and call that via ulx
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: Give Access to a single rcon command?
« Reply #10 on: February 05, 2013, 02:34:40 PM »
In case you don't want to have a separate command for it, you can in fact limit rcon commands. It works best in XGUI, but you can see the access tag equivalent in the chat:

I dont see the restrict command on my XGUI and im using the latest ULIB+ULX

« Last Edit: February 05, 2013, 02:37:02 PM by PAL-18 »

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Give Access to a single rcon command?
« Reply #11 on: February 05, 2013, 05:30:06 PM »
Holly crap something i can help with! anyway theres an easy way to do this without ulx your going to want to go to "gamemodes\terrortown\gamemode and open admin.lua.

Find
Code: [Select]
if (not IsValid(ply)) or ply:IsSuperAdmin() or GetRoundState() != ROUND_ACTIVE then
      ServerLog(Format("%s used ttt_print_damagelog\n", IsValid(ply) and ply:Nick() or "console"))
      pr("*** Damage log:\n")

and change
Code: [Select]
ply:IsSuperAdmin() to
Code: [Select]
ply:IsAdmin() from that all admins will be able to use the ttt_print_damagelog command at anytime from the console.
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: Give Access to a single rcon command?
« Reply #12 on: February 06, 2013, 12:12:16 AM »
@bender180 Awesome, thanks!

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Give Access to a single rcon command?
« Reply #13 on: February 06, 2013, 01:03:46 PM »
I dont see the restrict command on my XGUI and im using the latest ULIB+ULX

Are you sure you clicked on "ulx rcon" in the middle there? It looks like it hasn't been selected. The side menu (as seen in my screenshot above) should pop out when you do.
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline sal101

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Give Access to a single rcon command?
« Reply #14 on: March 07, 2013, 03:21:22 PM »
Are you sure you clicked on "ulx rcon" in the middle there? It looks like it hasn't been selected. The side menu (as seen in my screenshot above) should pop out when you do.

I run a deathrun on my server, and I'm trying to let my players enable third person through RCON but limiting them from every other rcon command, when I get home Ill try this, would there be any other way to do it though?

Sal