Fix for null veh data in rent timer

This commit is contained in:
Vortrex
2020-12-18 19:05:43 -06:00
parent 6a1f02b88e
commit a591eb3191

View File

@@ -41,14 +41,16 @@ function initTimers() {
function vehicleRentCheck() {
for(let i in getServerData().vehicles) {
if(getServerData().vehicles[i].rentPrice > 0) {
if(getServerData().vehicles[i].rentedBy) {
let rentedBy = getServerData().vehicles[i].rentedBy;
if(getClientData(rentedBy).cash < getServerData().vehicles[i].rentPrice) {
messageClientAlert(rentedBy, `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(rentedBy);
} else {
getClientData(rentedBy).cash -= getServerData().vehicles[i].rentPrice;
if(getServerData().vehicles[i] != null) {
if(getServerData().vehicles[i].rentPrice > 0) {
if(getServerData().vehicles[i].rentedBy) {
let rentedBy = getServerData().vehicles[i].rentedBy;
if(getClientData(rentedBy).cash < getServerData().vehicles[i].rentPrice) {
messageClientAlert(rentedBy, `You do not have enough money to continue renting this vehicle!`);
stopRentingVehicle(rentedBy);
} else {
getClientData(rentedBy).cash -= getServerData().vehicles[i].rentPrice;
}
}
}
}