Hello there internet! I just added a new thing to my server. A thing so you cant material vehicles. But when i start the server i get lua errors. Wich says. GM is nil value. please help.
This is what the code is like:
function GM:CanTool( ply, tr, tool )
if ( tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_vehicle_jeep" ) then
return false
end
end
OMG, stop recreating your threads. Be patient or get help yourself. You should start by googling "gmod hook.Add"
[QUOTE=Dexyer;44059712]Hello there internet! I just added a new thing to my server. A thing so you cant material vehicles. But when i start the server i get lua errors. Wich says. GM is nil value. please help.
This is what the code is like:
function GM:CanTool( ply, tr, tool )
if ( tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_vehicle_jeep" ) then
return false
end
end[/QUOTE]
First off, you should use [noparse][code] [/code][/noparse] tags for writing code on the forum
Second, you're doing it wrong. You need to use a hook rather than actually using GM:function() - those are defined by the gamemode itself and can't be accessed by other addons.
This is what you want to do:
[code]function CanMaterialVehicles( ply, tr, tool )
if ( tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_vehicle_jeep" ) then
ply:ChatPrint("You're not allowed to use "..tool.." on "..tr.Entity:GetClass()..".")
return false
end
end
hook.Add("CanTool","CanMaterialVehicles",CanMaterialVehicles)
[/code]
[QUOTE=Robotboy655;44059851]OMG, stop recreating your threads. Be patient or get help yourself. You should start by googling "gmod hook.Add"[/QUOTE]
This.
If you look at all three of the threads, they're practically the same question all posted within the same day.
[IMG]http://puu.sh/7bIW4/8d6c4c7135.png[/IMG]
Shouldn't really encourage this.
Thank you all for your answears! Really helped me out! Thanks! :D
Sorry, you need to Log In to post a reply to this thread.