Offload vehicle purchase logic to clientside

This commit is contained in:
Vortrex
2021-12-03 10:19:43 -06:00
parent 6b1063dc51
commit 4e39061c71
4 changed files with 37 additions and 0 deletions

View File

@@ -819,4 +819,34 @@ function processGameSpecifics() {
destroyAutoCreatedPickups();
}
// ===========================================================================
function processVehiclePurchasing() {
if(vehiclePurchaseState == VRR_VEHBUYSTATE_TESTDRIVE) {
if(inVehicle == false) {
vehiclePurchaseState = VRR_VEHBUYSTATE_EXITEDVEH;
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_EXITEDVEH);
return false;
} else {
if(vehiclePurchasing.id == inVehicle) {
if(getDistance(inVehicle.position, vehiclePurchasePosition) >= 25) {
vehiclePurchaseState = VRR_VEHBUYSTATE_FARENOUGH;
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_FARENOUGH);
}
} else {
vehiclePurchaseState = VRR_VEHBUYSTATE_WRONGVEH;
triggerNetworkEvent("vrr.vehBuyState", VRR_VEHBUYSTATE_WRONGVEH);
}
}
}
}
// ===========================================================================
function setVehiclePurchaseState(state, vehicle, position) {
vehiclePurchaseState = state;
vehiclePurchasePosition = position;
vehiclePurchasing = vehicle;
}
// ===========================================================================