only admins will able to spawn things from Q menu

how to make that only custom ranks from ulx would be able to spawn things from the Q menu?

You can use the PlayerSpawnProp from the sandbox hooks to control if a player can spawn a prop.

If you want to set “VIP” props you will need a table of allowed props

For a single rank use:



hook.Add("PlayerSpawnProp", "CanSpawnProps", function(ply)
    if ply:IsUserGroup("admin") then
        return true
    else
        return false
    end
end)


For multiple ranks use:



local ranks = {["admin"] = true, ["superadmin"] = true}

hook.Add("PlayerSpawnProp", "CanSpawnProps", function(ply)
    return ranks[ply:GetUserGroup()] || false
end)


Thanks to the post below for correcting me as I haven’t been very active in lua lately.

snip :boxhide: (also, create table outside of the hook)

Don’t forget that PlayerSpawnProp is only for regular items passed through



gm_spawn "blah.mdl"


You’re still able to spawn scripted entities, weapons, etc through their respective gm_spawn* commands.

SANDBOX:PlayerSpawnVehicle

SANDBOX:PlayerSpawnSWEP

SANDBOX:PlayerSpawnSENT

SANDBOX:PlayerSpawnRagdoll

SANDBOX:PlayerSpawnProp

SANDBOX:PlayerSpawnObject

SANDBOX:PlayerSpawnNPC

SANDBOX:PlayerSpawnEffect

You’ll need to apply that check (you can make the check into it’s own function for simplicity) to these.

Good that you mentioned that, I won’t edit my examples though. Only in the hope that the OP will attempt to implement this and learn some programming, if he or she doesn’t already have that knowledge.

Was just wondering if you already went in that direction, why not



hook.Add("PlayerSpawnProp", "CanSpawnProps", function(ply)
   return ply:IsUserGroup("admin")
end)


There’s always tons of ways to code the same thing. His example is easier to understand for a beginner coder, whereas yours is a bit more efficient but may be harder to understand for a beginner.

As bilbasio explained, I figured the OP could understand that example because you can pretty much read the “if” statement as a sentence.

You should never return true in that hook. Only disallow, never explicitly allow. This will break other addons.