No physgun vehicles script

I was wondering if anyone could make me a script so players can’t physgun-toolgun-context menu cars, if you can please give me one, or let me know if its to hard
Thanks c:

It’s a very simple thing to do.
Would require less than 7 lines of code and minor ability to script.

Physgun toolgun and context menu on cars in 6 or less lines?

hook physgun
if car dont be naughty
end
hook toolgun
if car dont be naught
end

That’s 6, what about context! (hook physgun if car dont be naughty end) would just be ugly and naughty to do.

That been said this is extremely simple, however why don’t you look use an already built prop protection system? FPP can do all you’ve requested, although it isn’t the most friendly resource wise tbh.

This should work fine I would assume:


hook.Add("PhysgunPickup", "No Vehicle Pickup", function(ply, ent)
	if ent:IsVehicle() then
		return false
	end 
end)

hook.Add("CanTool", "No Vehicle Tooling", function(ply, trace, tool)
	if trace.Entity and trace.Entity:IsVehicle() then
		return false
	end 
end)

It’s quite simple, here take a look at this:
[lua]local function NoPhysgunCars(ply,ent) – making the function
if ent:IsVehicle() then – checking the entity you’re trying to pick up is a vehicle or not
return false – then saying, if it is, don’t allow it
end
end

hook.Add(“PhysgunPickup”, “NoPhysgunCars”, NoPhysgunCars) – then telling it to run this every time someone tries to pick something up.[/lua]

or if you want to allow admins only to pick it up, try this:
[lua]local function NoPhysgunCars(ply,ent)
if !ply:IsSuperAdmin() then
if ent:IsVehicle() then
return false
end
end
end

hook.Add(“PhysgunPickup”, “NoPhysgunCars”, NoPhysgunCars)[/lua]

–snip-- acidentally posted in wrong thread >.<