--***********************************************************
--**     KI5 did this / bikinihorst is not to blame        **
--***********************************************************

DAMN = DAMN or {};
DEV84 = DEV84 or {};

function DEV84.pvFixCheck()
	local vanillaEnter = ISEnterVehicle["start"];

	ISEnterVehicle["start"] = function(self)

		local vehicle = self.vehicle
			local vehicle = self.vehicle
			if 	vehicle and (
				string.find( vehicle:getScriptName(), "84cadillacDeVille" )) then

				self.character:SetVariable("damnVehicle", "True")
			end
		
	vanillaEnter(self);
		
		local seat = self.seat
    		if not seat then return end
				if seat == 0 then		
					self.character:SetVariable("damnPosition", "driver_low")
				else		
					self.character:SetVariable("damnPosition", "passenger_low")
			end
	end
end

function DEV84.pvFixSwitch(player)
	local player = getPlayer()
	local vehicle = player:getVehicle()
		if 	vehicle and (
			string.find( vehicle:getScriptName(), "84cadillacDeVille" )) then

			player:SetVariable("damnVehicle", "True")

			local seat = vehicle:getSeat(player)
	    		if not seat then return end
					if seat == 0 then		
						player:SetVariable("damnPosition", "driver_low")
					else
						player:SetVariable("damnPosition", "passenger_low")
					end

	end
end

function DEV84.pvFixFallback(player)
	local player = getPlayer()
	local vehicle = player:getVehicle()
		if vehicle and (
			string.find( vehicle:getScriptName(), "84cadillacDeVille" )) then

			player:SetVariable("damnVehicle", "True")

			local seat = vehicle:getSeat(player)
	    		if not seat then return end
					if seat == 0 then		
						player:SetVariable("damnPosition", "driver_low")
					else		
						player:SetVariable("damnPosition", "passenger_low")
				end

	end
end

function DEV84.pvFixClear(player)

		player:SetVariable("damnVehicle", "False")
end

Events.OnPlayerUpdate.Add(DEV84.pvFixFallback);
Events.OnGameStart.Add(DEV84.pvFixCheck);
Events.OnGameStart.Add(DEV84.pvFixSwitch);
Events.OnExitVehicle.Add(DEV84.pvFixClear);
Events.OnSwitchVehicleSeat.Add(DEV84.pvFixSwitch);