Skip to content

restrict palm city buttons to admin only - #13

Merged
plally merged 4 commits into
mainfrom
feature/restrict-palm-city
Oct 25, 2026
Merged

plally merged 4 commits into
mainfrom
feature/restrict-palm-city

Conversation

@plally

@plally plally commented Oct 14, 2026

Copy link
Copy Markdown
Member

No description provided.

@plally
plally marked this pull request as draft October 14, 2026 16:47
@greyliterature

Copy link
Copy Markdown
hook.Add("InitPostEntity", "BlockPalmCityButtons", function()
    if game.GetMap() ~= "gm_palm_city" then return end
    local function CanPlayerPressButton(ply, button)
        -- cami here instead of ply:IsAdmin()?
        return ply:IsAdmin()
    end

    local ButtonToNiceName = {
        -- according to mapcreationid
        [7706] = "Track1",
        [7707] = "Track2",
        [7708] = "Track3",
        [7709] = "Track4",
        [7710] = "Track5",
        [7743] = "Track6",
        [7737] = "Track1",
        [7738] = "Track2",
        [7739] = "Track3",
        [7740] = "Track4",
        [7741] = "Track5",
        [7748] = "Track6",
        [7773] = "Track1",
        [7774] = "Track2",
        [7775] = "Track3",
        [7776] = "Track4",
        [7777] = "Track5",
        [7793] = "Track6",
        [7790] = "Track1",
        [7791] = "Track2",
        [7792] = "Track3",
        [7818] = "Track1",
        [7819] = "Track2",
        [7820] = "Track3",
        [7821] = "Track4",
        [7822] = "Track5",
        [7838] = "Track6",
        [7835] = "Track1",
        [7836] = "Track2",
        [7837] = "Track3",
        [7716] = "Racemode"
    }

    -- other buttons:
    --[[
    [2748] = "Garage door", -- -12293.000000 95.000000 210.000000
    [7843] = "StartRaceCanals" -- 1360.000000 -5328.000000 20.000000
    [7848] = "StopRaceCanals" -- 1040.000000 -4768.000000 432.000000
    for _, ent in ipairs(ents.FindByClass("func_button")) do
        if not ButtonToNiceName[ent:MapCreationID()] then print(ent:GetPos()) end
    end
    --]]
    hook.Add("AcceptInput", "BlockPalmCityButtons", function(ent, input, _, caller)
        if ent:GetClass() ~= "func_button" then return end
        if input ~= "Use" then return end
        local MapCreationId = ent:MapCreationID()
        --print("[" .. MapCreationId .. "]" .. " = \"Track1\",")
        if CanPlayerPressButton(caller, ent) == false then --
            return true
        elseif ButtonToNiceName[MapCreationId] then
            -- this should have a delay on it to prevent spamming chat
            PrintMessage(HUD_PRINTTALK, caller:Nick() .. " pressed the " .. ButtonToNiceName[MapCreationId] .. " button")
        end
    end)
end)

@plally
plally marked this pull request as ready for review October 25, 2026 20:11
Restrict race control usage to admins only if entity is above a certain height.
@plally
plally merged commit e855594 into main Oct 25, 2026
1 check passed
@plally
plally deleted the feature/restrict-palm-city branch October 25, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants