Spawn car script problem

I want to spawn car when player ask for it and remove when player change the job, i tried make this my self but failed!
I wi use this for darkrp
Here my spawn function
[LUA]
concommand.Add( “spawn_fire_car”, function( ply, ent )
if not ply:CanAfford(500) then
ply:ChatPrint(“You cannot afford the vehicle!”)
return “”
else
if (ply.CurrentCar and ply.CurrentCar:IsValid()) then
ply:AddMoney(-500)
ply.CurrentCar:Remove()
ply:ChatPrint(“Your previous car has been deleted.”)
end
local jeep = ents.Create(“prop_vehicle_jeep”)
jeep:SetModel(“models/buggy.mdl”)
jeep:SetKeyValue(“vehiclescript”, “scripts/vehicles/jeep_test.txt”)
jeep:SetPos(Vector(0, 200, 50))
jeep:SetAngles(Angle(0, 270, 0))
jeep.Owner = ply
jeep:Own(ply)
jeep:Spawn()
jeep:Activate()
ply.CurrentCar = jeep
end
end)
[/LUA]

Any errors? Also, thank jebus you put Lua tags around your code.

Everythings is okey with spawn function
I need help with remove function when player change job

Could you rephrase that, I can’t tell what you mean. :words:

I need help with remove function, remove selected car on player change job.

Example:

Player choose fireman job he spawn firetruck then he want to go for another job but his firetruck still spawned

Use player.CurrentCar:Remove() after the DarkRP change job function.

Its seems not clear for me, please hole code

[lua]
concommand.Add( “spawn_fire_car”, function( ply, ent )
if not ply:CanAfford(500) then
ply:ChatPrint(“You cannot afford the vehicle!”)
return “”
else
for k, v in pairs (ents.FindByName(“jeep” … ply:UniqueID())) do
v:Remove()
end
local jeep = ents.Create(“prop_vehicle_jeep”)
jeep:SetModel(“models/buggy.mdl”)
jeep:SetKeyValue(“vehiclescript”, “scripts/vehicles/jeep_test.txt”)
jeep:SetPos(Vector(0, 200, 50))
jeep:SetAngles(Angle(0, 270, 0))
jeep.Owner = ply
jeep:Own(ply)
jeep:Spawn()
jeep:Activate()
jeep:SetName(“jeep” … ply:UniqueID())
end
end)
[/lua]
Used the way I do it in my custom npc.

No problem be happy

Oh, sorry I was just now able to understand your terrible english in the first post.

Dumb post