job spawn car how to ?

Hey trying to get a job to spawn a car
have the job working and all
but have a problem in my spawn code i cant figger out

i think my problem is in this bit of code




	if SERVER then

		local TowModels
			TowModels = {
			"wheelchair",
		}
		local function IsTow (model)
			return TowModels (model)
		end
		local function IsTowDriver (ply)
			return ply:Team() == TEAM_MEKANIKER
		end
		local function SendNotifId (ply, id)
			net.Start(addon_name)
				net.WriteUInt(id, 4)
			net.Send(ply)
		end
		
		
		
-- Allow driver to spawn truck: *********************************************************
		hook.Add('PlayerSpawnVehicle', addon_name, function (ply, model, name) 
			if IsTowDriver(ply) and IsTow(model) then
				for _,veh in pairs(ents.FindByClass("prop_vehicle*")) do
					if veh[addon_name] == ply then
						SendNotifId(ply, 1)
						return 
					end
				end
				return not ply:isArrested()
			end
		end)
		hook.Add('PlayerSpawnedVehicle', addon_name, function (ply, veh)
			if IsValid(veh) and IsTowDriver(ply) and IsTow(veh:GetModel()) then
				veh:keysOwn(ply)
				veh[addon_name] = ply
			end
		end)
-- ***************************************************************************************		


Hope someone will help me Trying to understand this lua coding :slight_smile:

Your IsTow function should throw an error, you need to use square brackets to look up a key in a table.



return TowModels [model]


There is another problem, the structure of your TowModels table; you are adding the value “wheelchair” to index 1.
You want to set the “wheelchair” key to true.



TowModels = {
    ["wheelchair"] = true
}


now no errors but it says a have to be admin to spawn the wheelchair ??
here is my job



TEAM_MEKANIKER = DarkRP.createJob("Mekaniker", {
		color = Color(238, 99, 99, 255),
		model = "models/player/group01/male_03.mdl",
		description = "Du er mekaniker spawn en Tow-truck i din Q menu.",
		weapons = {},
		command = "Mekaniker",
		max = 6,
		salary = 100,
		admin = 0,
		vote = false,
		hasLicense = false,
		candemote = false,
		sortOrder = 1,
	})


Got it to work thanks Teklatea :goodjob: