Context Menu
Last read Never
Hey I've got a question . Players on my server can delete all items via context menu, do you know how to prevent it?
try this:
1.Connect to the FTP.
2.Go to srcds/garrysmod/lua/autorun/client.
3.Create a restrict_contextmenu.lua file.
4.Add the following code in it:
local AllowedGroup = {
["superadmin"] = true,
["admin"] = true,
}
local WeaponBlacklist = {
"dradio",
"tfa_",
"cw_",
}
hook.Add("OnContextMenuOpen", "mTxServ:RestrictContextMenu", function()
local ply = LocalPlayer()
local allow = AllowedGroup[ply:GetUserGroup()]
if ply:Alive() and ply:GetActiveWeapon() and ply:GetActiveWeapon():IsValid() then
local plyweapon = ply:GetActiveWeapon():GetClass()
for k, v in ipairs(WeaponBlacklist) do
if string.sub(plyweapon, 0, string.len(v)) == v then
allow = true
break
end
end
end
if !allow then return false end
end)
5.Add or remove ULX groups that have access to the context menu.
6.Add weapons that need the context menu to the WeaponBlacklist if necessary.
Source: https://mtxserv.com/fr/serveur-gmod/doc/astuce-comment-restreindre-un-context-menu
I love you
Users viewing this thread
Nobody