So I googled a little and found hook to disable context menu so players cant drive giant props and proptrap people and made little script.
[lua]
local clrtext = Color(255,255,255)
local clrgrey = Color(150,150,150,255)
local intro = "[Server] "
hook.Add( "ContextMenuOpen", "blockContext", function()
if LocalPlayer():IsSuperAdmin() then
chat.AddText(
clrgrey, intro,
clrtext,"access to context menu granted."
)
return true
else
chat.AddText(
clrgrey, intro,
clrtext,"access to context menu is temporary disabled for users."
)
return false
end
end )
[/lua]
Problem is I still want players to be able to change playermodel, physgun color and manipulate ragdoll bones but problem is this hook will entirely block context menu.
Then I found [url]https://wiki.garrysmod.com/page/SANDBOX/CanProperty[/url] but the only example is
[lua]
hook.Add( "CanProperty", "block_remover_property", function( ply, property, ent )
if ( !ply:IsAdmin() && property == "remover" ) then return false end
end )
[/lua]
Where I can find full list of all properties? Maybe somebody coded addon that makes restricting certain properties easier?
I'm also using workshop addon "Extended properties" and would like to block some of them too like "Mount gun" but specificaly on airboat because its very op for pvp server I assume I will have to search through addon code to find properties but then how to restrict it for specific vechile?
The first code won't actually stop anyone from doing anything.
CanProperty is what you want.
To find out the "list", you can just do print(property) in the hook and use the properties you wish to block, they will be put into your server console.
[QUOTE=Robotboy655;52120889]The first code won't actually stop anyone from doing anything.
CanProperty is what you want.
To find out the "list", you can just do print(property) in the hook and use the properties you wish to block, they will be put into your server console.[/QUOTE]
Really? but now users cant open context menu it just shows that message in chat how could they bypass it?
[QUOTE=Ramirex5;52120900]Really? but now users cant open context menu it just shows that message in chat how could they bypass it?[/QUOTE]
They can run Lua code that imitates the context menu.
ok anyone wants to teach some lua basics?
how do I block every property in array
what I mean:
[lua]
anythingInArray = {"drive", "rb655_vehicle_add_gun"}
hook.Add( "CanProperty", "propertyBlocker", function( ply, property, ent )
if ( !ply:IsSuperAdmin() ) then
if (property == anythingInArray ) then
return false
end
end
end )
[/lua]
local array = {drive = true, rb655_vehicle_add_gun = true}
if (array[property]) then return false end
-
[QUOTE=txike;52121430]local array = {drive = true, rb655_vehicle_add_gun = true}
if (array[property]) then return false end[/QUOTE]
Thanks your solution worked.
This is example script with some properties blocked already. It wont give any error message if you dont have access they simply wont appear in context properties for non superadmins.
[lua]
-- /lua/autorun/context.lua
local restricted = {drive = true, persist = true, rb655_vehicle_exit = true, rb655_healthcharger_recharge = true, pickupitem = true, rb655_suitcharger_recharge = true, rb655_vehicle_enter = true, ignite = true, rb655_vehicle_add_gun = true}
hook.Add( "CanProperty", "propertyBlocker", function( ply, property, ent )
if !ply:IsSuperAdmin() and restricted[property] then
return false
elseif ply:IsSuperAdmin() then
return true
end
end )
[/lua]
[URL="https://pastebin.com/Y6iZKRxb"]This is[/URL] list of properties printed into console when I printed them all including [URL="http://steamcommunity.com/sharedfiles/filedetails/?id=104607712"]Extended Properties[/URL] all custom properties are prefixed with rb655_. However some things didn't print like "ignite" but if you try to block it works.
Sorry, you need to Log In to post a reply to this thread.