Author Topic: I need help with permissions per team  (Read 1876 times)

0 Members and 1 Guest are viewing this topic.

Offline KiddleyWiffers

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
I need help with permissions per team
« on: August 12, 2018, 05:06:40 PM »
Hello. I opened a Breach server, and made a custom command that allows people to open Gate A as the newest version of the map broke the command. The only problem is the people. I recently found out that anyone can open Gate A using the command. Is there a way I could make my command only available to the following teams.

TEAM_GUARD
TEAM_CHAOS

Thanks in advance for whoever helps me figure this out.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: I need help with permissions per team
« Reply #1 on: August 12, 2018, 06:57:19 PM »
For this you need the function to check a player's team.

but in your code you could do something like this..


Code: [Select]
if ply:GetPlayerTeam() == "TEAM_GUARD" or ply:GetPlayerTeam() == "TEAM_CHAOS" then
   >>code to open gate here<<
end

Obviously you need to replace the ply:GetPlayerTeam() with the function provided by the gamemode for getting their team.

Offline KiddleyWiffers

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: I need help with permissions per team
« Reply #2 on: August 18, 2018, 06:54:16 PM »
For this you need the function to check a player's team.

but in your code you could do something like this..


Code: [Select]
if ply:GetPlayerTeam() == "TEAM_GUARD" or ply:GetPlayerTeam() == "TEAM_CHAOS" then
   >>code to open gate here<<
end

Obviously you need to replace the ply:GetPlayerTeam() with the function provided by the gamemode for getting their team.

I have been messing with this for a few days and still can't get it to work. This is what I have so far.
Code: [Select]
---[Open gate a]-------------------------------------------------------------------------
function ulx.opengatea(calling_play, should_silent)
    if ply:GTeam() == TEAM_GUARD or ply:GTeam() == TEAM_CHAOS then // Team check for the gamemode
        game.ConsoleCommand("ulx ent_fire gate_containment_door_r open\n") // The two commands I used to open Gate A
        game.ConsoleCommand("ulx ent_fire gate_containment_door_l open\n")
    end
end

local opengatea = ulx.command(CATEGORY_NAME, "ulx opengatea", ulx.opengatea, "!opengatea")
opengatea:defaultAccess(ULib.ACCESS_SUPERADMIN)
opengatea:help("Open Gate A (ONLY MTF and CI).")
---[End]----------------------------------------------------------------------------------------
---[Admin Open gate a]-------------------------------------------------------------------------
function ulx.adminopengatea(calling_play)
        game.ConsoleCommand("ulx ent_fire gate_containment_door_r open\n")
        game.ConsoleCommand("ulx ent_fire gate_containment_door_l open")
    end

local adminopengatea = ulx.command(CATEGORY_NAME, "ulx adminopengatea", ulx.adminopengatea, "!adminopengatea")
adminopengatea:defaultAccess(ULib.ACCESS_SUPERADMIN)
adminopengatea:help("Open Gate A as any class.")
---[End]----------------------------------------------------------------------------------------
The command worked before, but not even adminopengatea is working now, which is just a copy and past of my first command. The ent_fire command opens it when I use it on its own, and the door opens, but the actual commands I have set up for it don't work.