I created a custom car dealer but it doesn't support passenger mod for some reasons.
I am not sure why but I think it's because of "prop_vehicle_jeep"
This is the code to create the car.
[lua]
car = ents.Create("prop_vehicle_jeep")
car:SetModel(model)
car:SetPos(rdm.Pos)
car:SetAngles(rdm.Ang)
car:Spawn()
car:Activate()
[/lua]
If anyone has any solutions I am listening, and thank you for bothering reading this.
You can use rp_getvehicles in DarkRP to find the entity to replace prop_vehicle_jeep, then do
[lua]
local vehicle = list.Get("Vehicles")["Entity here"]
ents.Create(vehicle.Class)
[/lua]
I think that worked. Is there any way to test it in sp if it worked ?
I think you can right click while being in an vehicle to see if it works, then it should switch seats.
So I added that but not sure why I am getting this error.
[lua]
[ERROR] addons/passengermod/lua/autorun/passenger.lua:117: attempt to index field 'vehicle' (a nil value)
1. fn - addons/passengermod/lua/autorun/passenger.lua:117
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
[/lua]
This is how I do it.
[lua]
function PLAYER:CreateVehicle(CarID)
local vehicle = list.Get("Vehicles")[CARS.Cars[CarID].Entity]
if not vehicle then print("No vehicle returns this entity!") return end
local spawnID = math.random(1, #CARS.CarSpawns)
car = ents.Create(vehicle.Class)
car:SetModel(vehicle.Model)
if vehicle.KeyValues then
for k, v in pairs(vehicle.KeyValues) do
car:SetKeyValue(k, v)
end
end
car:SetPos(CARS.CarSpawns[spawnID].Pos)
car:SetAngles(CARS.CarSpawns[spawnID].Ang)
car:Spawn()
car:Activate()
car.VehicleName = class
car.VehicleTable = vehicle
car.ClassOverride = vehicle.Class
if vehicle.Members then
table.Merge(car, vehicle.Members)
end
car:Own(self)
self.Car = car
gamemode.Call("PlayerSpawnedVehicle", self, car)
end
[/lua]
I was missing this line. " car.VehicleTable = vehicle"
Thank you very much for the help.
Enjoy! :)
Sorry, you need to Log In to post a reply to this thread.