A question about vehicles.

I am writing a game mode, and want to make it so you can not create vehicles with anything but the game mode system for it, to prevent errors. I need to stop the entity from being created at all, is there any way to do that?

Derive it from base or use these* functions

You can return it false.

I do not want the vehicle to be added to the spawn list. My game mode requires some specific data be in the vehicle tables, and it will look for it no matter what.

Vehicles not props

If it’s a sandboxish gamemode you can use

[lua]
hook.Add( “PlayerSpawnVehicle”, “svs”, function(ply,model,vehicle)
return false
end)

–or

hook.Add( “PlayerSpawnVehicle”, “svs”, function(ply,model,vehicle)
–You could use
if vehicle == “some_car” then – some_car being the entity name
return false – stops it spawning
end
end)
[/lua]

To stop them spawning from the q menu vehicles and use
in
sandbox/gamemode/spawnmenu/creationmenu/vehicles
I don’t know why they put WeaponTable Maybe just an copy and paste fail and forgot to change the name
But try that, people should stop seeing it in the q menu vehicles tab.
[lua]
for k, WeaponTable in SortedPairsByMemberValue( v, “Name” ) do
if WeaponTable.__ClassName == “some vehicle” then return end[/lua]

It calls entities too, lrn2read.
GM:PlayerSpawnedProp( Player ply, String model, Entity ent)
[lua]
function GM:PlayerSpawnProp(player,model,ent)
if ent:GetClass() == “prop_vehicle_jeep” then
ent:Remove()
end
end
[/lua]
As simple as that.

It’s mean for Props, Now get an suntan, white boi.

Oh my god, this is really sad, read the functions main arguments for gods sakes, it says ENTITY, meaning ENTITY as in ENTITY.

Hook Name PlayerSpawnProp
Syntax GM:PlayerSpawnProp( Player ply, String mdl )
Description Called when a player spawns a prop

Additional Notes

Return true to allow spawning the Prop, false for not allowing it
This hook gets called just before the prop is spawned.

Stop acting smart as well all know what you really are :smug:

I used the wrong function, look at my original post, big meech.
Let me recode it;
[lua]
function GM:PlayerSpawnedProp(player,model,ent)
if ent:GetClass() == “prop_vehicle_jeep” then
return false
end
end
[/lua]
I’m done arguing with you.

I need to stop any vehicle from being spawned in any way, including through addons which use ent.create or some other means to do it. I would like to prevent it from being added to the server’s list of spawnable entities is that possible?

ents.Create is server side there is no other way so just use

[lua]
hook.Add( “PlayerSpawnVehicle”, “svs”, function(ply,model,vehicle)
return false
end)[/lua]

To stop every spawn vehicle from spawning

Don’t both using jrj996 method as you’ll be there all day filtering out new entity’s and old one