Car Dealer to DarkRP

Hello. I made a car dealer npc. It works fine, but when I buy a car it spawns, but I don’t own it. It’s unowned. Is there any way that I can make it ownable by the person that bought the car, as it is in DarkRP?

Here is the Car script for Golf:
[lua]
function SpawnCarGolf()
local golf = ents.Create(“prop_vehicle_jeep_old”)
golf:SetModel(“models/golf/golf.mdl”)
golf:SetKeyValue(“vehiclescript”, “scripts/vehicles/golf.txt”)
golf:SetPos(table.Random(CarGolfSpawn))
golf:Spawn()
golf:Activate()
end
concommand.Add(“buy_golf”, SpawnCarGolf)
[/lua]

Perhaps this is what you’re looking for, I’m not sure though
**[Entity.SetOwner

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetOwner)**

Maybe, but the problem is that it is DarkRP, which set’s it to ownable I think.

Well you could have a look at the entities which come with DarkRP and see what sets it there.

Yeah, could try.

Please post if you find it, I’m interested.

Haven’t found it yet. I could try pm’ing FPtje about it.

It takes two seconds to read through any of the DarkRP entities.



car:SetNWEntity("owning_ent", ply)


Thanks!

[editline]06:58PM[/editline]

Well, the NPC dealer is in darkrp/entities/npc_car_dealer/ So when I did ply:AddMoney(-300) it didn’t take those money from me. So I don’t think that car:SetNWEntity(“owning_ent”, ply) will work there

If you use the .onUse function then you do get a player entity returned.