• Making "Entities" superadmin only
    16 replies, posted
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: [url]http://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnSENT[/url]
[QUOTE=highvoltage;45762263]Look at the example on the bottom of this page: [url]http://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnSENT[/url][/QUOTE] 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?
[QUOTE=Zackyo;45767851]Do you know how to do it Arizard?[/QUOTE] 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 [URL="http://wiki.garrysmod.com/page/hook/Add"]this[/URL] [CODE]hook.Add( string eventName, any identifier, function func )[/CODE] 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 [URL="http://wiki.garrysmod.com/page/Player/IsUserGroup"]ply:IsUserGroup( groupname )[/URL] function
[QUOTE=circuitbawx;45767928]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 [URL="http://wiki.garrysmod.com/page/hook/Add"]this[/URL] [CODE]hook.Add( string eventName, any identifier, function func )[/CODE] 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 [URL="http://wiki.garrysmod.com/page/Player/IsUserGroup"]ply:IsUserGroup( groupname )[/URL] function[/QUOTE] 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, [URL="http://tylerneylon.com/a/learn-lua/"]core stuff[/URL] first Placing the script in lua/autorun/server should do, as PlayerSpawnSENT is called serverside. [CODE] 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 ) [/CODE] 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.
[QUOTE=bluebull107;45770721]Hooks arent basic lua.....just to let you guys know for newbies.[/QUOTE] 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*
[QUOTE=bluebull107;45771485]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*[/QUOTE] 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
[QUOTE=bluebull107;45771618]To us its not difficult, but to people who dont even know how to set permissions on a tool, its a little difficult[/QUOTE] 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
Sorry, you need to Log In to post a reply to this thread.