diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index 0051fa2f..b2b7d076 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -420,6 +420,28 @@ function processLocalPlayerVehicleControlState() { // =========================================================================== +function processLocalPlayerSphereEntryExitHandling() { + let position = getLocalPlayerPosition(); + + if(areMarkersSupported()) { + getElementsByType(ELEMENT_MARKER).forEach(function(sphere) { + if(getDistance(position, sphere.position) <= sphere.radius) { + if(!inSphere) { + inSphere = sphere; + triggerEvent("OnLocalPlayerEnterSphere", null, sphere); + } + } else { + if(inSphere) { + inSphere = false; + triggerEvent("OnLocalPlayerExitSphere", null, sphere); + } + } + }); + } +} + +// =========================================================================== + function processJobRouteSphere() { if(getGame() == VRR_GAME_GTA_SA) { let position = getLocalPlayerPosition(); @@ -469,6 +491,24 @@ function getLocalPlayerPosition() { // =========================================================================== +function processLocalPlayerVehicleEntryExitHandling() { + if(localPlayer.vehicle) { + if(!inVehicle) { + inVehicle = localPlayer.vehicle; + inVehicleSeat = getLocalPlayerVehicleSeat(); + triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat); + } + } else { + if(inVehicle) { + triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat); + inVehicle = false; + inVehicleSeat = false; + } + } +} + +// =========================================================================== + function getVehicleForNetworkEvent(vehicle) { if(getGame() == VRR_GAME_GTA_IV) { return natives.getNetworkIdFromVehicle(vehicle);