Hello, I am new to LUA and trying to code a simple script to prevent non admins from using a specific STOOL. I realize there is probably a better way to do this (and if you know how besides ASSMOD i would be interested... I know, wrong section, sorry) but i meant it as a learning exercise
[code]local function WeaponEquip(wep)
function checkAdmin(ply)
if ply:IsAdmin() then
end
else
if wep:GetClass() == "tool_cratemaker" then
wep:Remove()
Player:Give("gmod_tool");
end
end
hook.Add( "WeaponEquip", WeaponEquip )[/code]
I also get this error in console
[code]autorun/test.lua:7: 'end' expected (to close 'function' at line 3) near 'else'[/code]
Any help would be appreciated
change [code]if ply:IsAdmin() then
end
else
[/code] to [code]if ply:IsAdmin() then
else
[/code]
Can't have ends before an else statement, afaik.
[CODE]if ply:IsAdmin() then return false else[/CODE]
[CODE]
function RestrictTool(ply,tr,tool)
if(tool == "tool_cratemaker" && !ply:IsAdmin()) then
return false
end
end
hook.Add("CanTool","RestrictCratemaker",RestrictTool)
[/CODE]
hope that helps
Sorry, you need to Log In to post a reply to this thread.