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

DAMN = DAMN or {};
RNG91 = RNG91 or {};

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

	ISEnterVehicle["start"] = function(self)

		local vehicle = self.vehicle
			if 	vehicle and (
				string.find( vehicle:getScriptName(), "91fordRanger" )) 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")
				else		
					self.character:SetVariable("damnPosition", "passenger")
			end
	end
end

function RNG91.pvFixSwitch(player)
	local player = getPlayer()
	local vehicle = player:getVehicle()
		if 	vehicle and (
			string.find( vehicle:getScriptName(), "91fordRanger" )) then

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

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

	end
end

function RNG91.pvFixFallback(player)
	local player = getPlayer()
	local vehicle = player:getVehicle()
		if vehicle and (
			string.find( vehicle:getScriptName(), "91fordRanger" )) then

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

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

	end
end

function RNG91.pvFixClear(player)

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

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