Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sittting in Spectator: I have no idea why this is still a rule
#10
(10-24-2020, 10:26 PM)TheUltraFish Wrote: What would probably be better would be to not have spectator as a  team to join other than staff. Just like how some commands and other things are only accessible by staff.

This script will kick whoever joins spectator out if they are not in the groups table after one second when placed in the lua/autorun folder. The original plan for this was to actually go into the fretta gamemode and disable the spectator button from showing to people other than staff, but B0T convinced me to use something not so.. ad-hoc. He also told me which hook to use :>

Download

Code:
groups = {
    "trusted",
    "dtmod",
    "moderator",
    "adm",
    "admin",
    "superadmin",
    "operator",
    "superdonor"
}

function checkTableValue(table, value)
    for k, v in pairs(table) do
        if v == value then return true end
    end
return false end

hook.Add("PlayerChangedTeam", "RestrictSpectator", function(ply, oldTeam, newTeam)
    if newTeam == TEAM_SPECTATOR then
        if not checkTableValue(groups, ply:GetUserGroup()) then
            timer.Create("SwitchSpectator", 1, 1,
                function()
                    GAMEMODE:PlayerJoinTeam(ply, oldTeam)
                    ply:PrintMessage(HUD_PRINTTALK, "This team is reserved for staff members.")
                end)
        end
    end
end)


Messages In This Thread
RE: Sittting in Spectator: I have no idea why this is still a rule - by RussEfarmer - 10-25-2020, 03:35 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)

About Us
    This is Dinkleberg's GMod, a gaming community based in Garry's Mod. We have a Trouble in Terrorist Town, Prop Hunt, Murder, and Deathrun Server. Come check them out sometime.