Hello everyone,
I have been trying to learn all of this lua coding to have my server run the way I want it. I am trying to make a lua code that will restrict the use of a stool and weapons to certain user groups.
I would like to have it so that others may use my codes and maybe turn it into an addon. That will come later, so here we go.
We will start with the stool restrictions 1st then progress.
My User Groups
SuperAdmin, Admin, Moderator, VIP, Respected, Regulars, and Guest. (in that order)
stools to be restricted: anti-noclip, light including wire, lamp including wire, ignite including wire, rt cam, trails including wire, balloons, smart weld, emitter including wire, stacker, turret including wire, dynamite including wire.
Group allows:
SuperAdmin/Admin: all restricted stools above
Moderator:
VIP: Balloons, smart weld, wire ignite, emitter.
Respected: Stacker, turret including wire, dynamite including wire.
Regulars:
Guest:
My code:
function UseTool( ply, tr, toolmode )
if toolmode == "rt_antinoclip" or toolmode == "light" or toolmode == "lamp" or toolmode == "ignite" // put the FILE NAME of the tool
or toolmode == "rtcamera" or toolmode == "trails" or toolmode == "wire_light" or toolmode == "wire_lamp" then //
if ( ply:IsAdmin() or ply:IsSuperAdmin() )then
return true
else
if !ply:IsAdmin() and !ply:IsSuperAdmin() then
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to Admins" )
return false
end
end
end
end
hook.Add( "CanTool", "UseTools", UseTool )
function UseTool( ply, tr, toolmode )
if toolmode == "balloon" or toolmode == "smartwelder" or toolmode == "wire_igniter" or toolmode == "emitter" then // put the FILE NAME of the tool
if ( ply:IsAdmin() or ply:IsSuperAdmin() or ply:IsUserGroup("moderator") or ply:IsUserGroup("vip") )then
return true
else
if !ply:IsAdmin() and !ply:IsSuperAdmin() !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") then
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to Admins, Moderators, and VIPs." )
return false
end
end
end
end
hook.Add( "CanTool", "UseTools", UseTool )
function UseTool( ply, tr, toolmode )
if toolmode == "stacker" or toolmode == "turret" or toolmode == "dynamite" or toolmode == "wire_turret" or toolmode == "wire_explosive" then // put the FILE NAME of the tool
if ( ply:IsAdmin() or ply:IsSuperAdmin() or ply:IsUserGroup("moderator") or ply:IsUserGroup("vip") or ply:IsUserGroup("respected") )then
return true
else
if !ply:IsAdmin() and !ply:IsSuperAdmin() !ply:IsUserGroup("moderator") and !ply:IsUserGroup("vip") and !ply:IsUserGroup("respected") then
ply:PrintMessage( HUD_PRINTTALK, "This tool is restricted to Respected Players and above." )
return false
end
end
end
end
hook.Add( "CanTool", "UseTools", UseTool )
Let me know what you think,
Saint Mark