Making "Entities" superadmin only

Hi! Does someone know how to make the “Entities” tab be superadmin only? It’s really frustraiting, when players can spawn thumpers, bouncy balls, combine mine (Which makes a ugly noice on the map) and those things?

Don’t make these players admin…

I haven’t done that? Everyone in the server can spawn entities. It’s really frustraiting that everyone can spawn bouncy balls and combine mine and stuff in the entities, and i want it to become admin/superadmin only.

Look at the example on the bottom of this page:

Player’s can still spawn entities ;( I putted it in lua/autorun/server tho.

you need to hook it don’t you?

Do you know how to do it Arizard?

It’s fairly straightforward if you’re gonna use PlayerSpawnSENT to do it

The wiki page tells you that you need to return a bool, true to allow the SENT to be spawned and false to disallow the player from spawning it

Shit, I missed hooking it

The syntax for adding a hook goes something like this


hook.Add( string eventName, any identifier, function func )

You need an event name (in your case “PlayerSpawnSENT”) to hook onto, a unique string ident for your hook and then a function that will run when the hook is called, the arguments for which are the arguments passed in PlayerSpawnSENT

If you only want superadmins to be able to spawn entities you could make use of the ply:IsUserGroup( groupname ) function

Like this? And should it be in lua/autorun/server?
hook.Add( string PlayerSpawnSENT, any identifier, function func )
function GM:PlayerSpawnSENT( ply, class )
if ( not ply:IsAdmin() then
return false
end
end

I suggest you read up on Lua, start with basic stuff like variables and functions, core stuff first

Placing the script in lua/autorun/server should do, as PlayerSpawnSENT is called serverside.



hook.Add( "PlayerSpawnSENT", "EXAMPLE_PlayerSpawnSENT", function( ply, class )
    if ( not ply:IsAdmin() ) then
        -- Alternatively, you could replace ply:IsAdmin() with ply:IsUserGroup( "superadmin" ) or pass whatever group name you prefer
        return false
    end
end )


hook.Add takes these three arguments, a string (wrapped in “” or ‘’) event name, a unique hook name, and then a function that takes both arguments that PlayerSpawnSENT is called with

So whenever someone spawns a SENT, the PlayerSpawnSENT event will run, and all hooks that hook the event will run as well.

Also remember to close all open parentheses

There’s a metamethod for checking if the player is a superadmin, which “should” be used instead of IsUserGroup. Example:
[lua]
hook.Add(“PlayerSpawnSENT”, “PreventAdminSENTSpawn”, function(ply) return ply:IsSuperAdmin() end)
[/lua]

Hooks arent basic lua…just to let you guys know for newbies.

uhm, yes they are.

So, coming from people who know how to code and have been doing it for a while, they are an easy thing to understand…thats not biased at all. sarcasm

You’re setting your function to run with an event. It’s not that difficult

To us its not difficult, but to people who dont even know how to set permissions on a tool, its a little difficult

You said hooks aren’t basic lua, that’s what we’re referring to. The capability of a server owner with even the basic extents of lua are much more than one without.

Hooks are basic lua