function main()
repeat wait(0) until isSampAvailable()
while true do
wait(0)
if isCharInAnyCar(playerPed) then
rpcKey = false
rpcCmd = false
else
if isKeyDown(VK_H) and not sampIsChatInputActive() then
carH, plrH = storeClosestEntities(playerPed)
if doesVehicleExist(carH) then
result, id = sampGetVehicleIdByCarHandle(carH)
plrX, plrY, plrZ = getCharCoordinates(playerPed)
vehX, vehY, vehZ = getCarCoordinates(carH)
distVeh = getDistanceBetweenCoords2d(plrX, plrY, vehX, vehY)
if distVeh < 5 then
openVeh(id)
rpcKey = true
addOneOffSound(0, 0, 0, 1147)
wait(200)
else
addOneOffSound(0, 0, 0, 1147)
rpcKey = false
end
end
elseif rpcKey == true then
carH, plrH = storeClosestEntities(playerPed)
if doesVehicleExist(carH) then
result, id = sampGetVehicleIdByCarHandle(carH)
plrX, plrY, plrZ = getCharCoordinates(playerPed)
vehX, vehY, vehZ = getCarCoordinates(carH)
distVeh = getDistanceBetweenCoords2d(plrX, plrY, vehX, vehY)
if distVeh > 10 then
rpcKey = false
addOneOffSound(0, 0, 0, 1138)
end
end
end
end
end
end