Disable toolgun on TDM cars

Hello,

Can someone write a little script for me so people can not toolgun their TDMcars anymore?
I know this is really easy but i do not know how :l

Thanks!

Someone posted this somewhere else, can’t remember who, but it worked for my server’s.

[lua]
hook.Add( “PhysgunPickup”, “fuck off”, function( ply, ent )
if ( IsValid( ent ) && string.find( ent:GetClass():lower(), “prop_vehicle” ) ) then
return false
end
end)
[/lua]

Yeah i saw that post, i use it too but that is for not physgunning, i want to disable toolgunning.

Replace PhysgunPickup with CanTool

[lua]
function GM:CanTool( ply, tr, tool )
if ( tool == “remover” and IsValid( tr.Entity ) and tr.Entity:GetClass() == “base_vehicle” ) then
return false
end
end
[/lua]

Im not sure if base_vehicle would work here, but its worth a try. If not, find the base that the TDM cars use.

Why not just do this?



function GM:CanTool( ply, tr, tool )
   if ( tool == "remover" and IsValid( tr.Entity ) and tr.Entity:IsVehicle() ) then
      return false
   end
end


That way you don’t have to worry about it’s class.

Does this enable remover on it but nothing else? Because i want that people can use the easy bodygroup tool on cars.

Yes.

How can i find out tool names, because not every tool has the same name as in the q menu right?



hook.Add( "CanTool", "tool debug", function( ply, ent )
   if IsValid(ply) and then ply:ChatPrint(tostring(tool)) end
end)


Just for testing I guess, but tool names are fairly obvious.

Also, I assume you’re using DarkRP/FPP? I’ve no idea about recently but in the past they’ve returned true on some of there hooks and this kinda sucks and might make these little snippets fail.

Tool names are their file names.

Thank you, nice :wink:

[editline]13th December 2013[/editline]

Thanks mate!

Where do I add this too??

garrysmod/lua/autorun/server/callitwhateveryouwant.lua

[editline]26th January 2014[/editline]

I think…

Ok I will try it thanks for the help