Linking some LUA with an entity in hammer?

So basically I gave up with scars due to the f load of bugs they had so now I’ve decided to use TDM cars for my server. Problem is when I make them in hammer it’s fine selecting the model and vehicle script file for the entity’s properties but in the autorun files for the vehicles there’s a bit about passenger mod too which I want to include the code for when spawning them in hammer otherwise only one person can get in it at a time just like the default Jeep. So how would I do this, in my gamemode’s LUA file somewhere? The code is as follows:


local V = {
			Name = "Volvo 850 R", 
			Class = "prop_vehicle_jeep",
			Category = "TDM Cars",
			Author = "TheDanishMaster, Turn 10",
			Information = "A drivable Volvo 850 R by TheDanishMaster",
				Model = "models/tdmcars/vol_850r.mdl",
							KeyValues = {
							vehiclescript	=	"scripts/vehicles/TDMCars/850r.txt"
							}
			}
list.Set("Vehicles", "vol850rtdm", V)
 if SERVER then
hook.Add("Think", "TDMBoost_850R", function()
for _, ent in pairs(ents.FindByClass("prop_vehicle_jeep*")) do
if ent:GetModel() == "models/tdmcars/vol_850r.mdl" then
local Pwr = 0
if IsValid(ent:GetDriver()) then
if ent:GetDriver():KeyDown(IN_FORWARD) then Pwr = 1 end
end
ent.Cars_Power = Lerp(0.2, ent.Cars_Power or 0, Pwr)
ent:SetPoseParameter("boost_gauge", ent.Cars_Power)
end
end
end)
end

It’s just the bit starting with “list.set” that I need to include to the car.

That code has nothing to do passenger mod.
It should kick-in automatically anyway.

Ok thanks, but then why is it that if I spawn a vehicle with the sandbox menu it allows multiple people to get in but if spawned as an entity with hammer it doesn’t yet I still see the passenger mod eject, lock doors etc buttons so it’s definitely working on them.

And the vehicle script file and models are both working correctly linked.

Maybe your passenger mod is kind of crap and only properly kicks in if spawned through spawnmenu?

I use OnEntityCreated hook for my vehicle mod, not sure what about the one you use.

It’s the one on the workshop called “( Official ) Passenger Mod” but I’ve tried others. Maybe it’s the fact that the vehicle initializes before the passenger addon does. Is there any way to create a delay in the creation of an entity? I only know how to kill it on delay not create.

Edit: No way at all then? You have to set them up in LUA making all their coordinates and crap? That’s awful :frowning:

Second edit: Ok I tried env_entity_maker and still the copies it makes aren’t working with passenger mod :confused:

bump

Come on is there or is there not a way of setting LUA code for an entity you spawned using hammer?

Not that I’m aware of. Just spawn in the vehicles through lua on map load instead of baking them into the map.

But wouldn’t that mean defining the xyz position of all of them on the map and then for each map they would be in different places and urgh…

Soooo it’s no different than baking the vehicle into the map? Except with lua you can change the positioning and not have to wait for the map to recompile :v:

Also to help you out you can stand where you want the vehicle and use getpos in console to get the vector of your headpos. Ignore anything after ;setang though. The first 3 floats are the xyz you want.

He also needs to get his angle though.

I suggest organizing your spawning into several files under a directory. When you read the files to get the vector/ang tables, simply use the map’s name as a key.