• Is this correct coding for tool restriction?
    2 replies, posted
Here is what I have, I got this from someone over at wiremod.org while asking a question about restricting expression2 to people who are admin. They gave me this link: [url]http://wiki.garrysmod.com/?title=Gamemode.CanTool[/url] [code]function UseTool( pl, tr, toolmode ) if toolmode == "remover" or toolmode == "leafblower" or toolmode == "ignite" or toolmode == "rtcamera" or toolmode == "wire_expression" then if pl:IsAdmin() then // Check if the user is admin return true // Let admins use these tools however they wish else return false // Normal players won't be able to use them end end end hook.Add( "CanTool", "UseTool", UseTool );[/code] If this is correct then where would I put this code, do I make a new LUA autorun file and just paste it in?
you can use a table to put the restricted tool, like:[lua]local RestrictedTool = { "remover", "leafblower", "ignite", "rtcamera", "wire_expression" } function UseTool( pl, tr, toolmode ) if table.HasValue(RestrictedTool, toolmode) then return pl:IsAdmin() end end hook.Add( "CanTool", "UseTool", UseTool )[/lua] you need to put it in lua/autorun/server/randomname.lua
Thanks, I will add it on later.
Sorry, you need to Log In to post a reply to this thread.