Use new optimized vehicle buy check
This commit is contained in:
@@ -1343,10 +1343,31 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function checkVehicleBuying(client) {
|
function checkVehicleBuying(client) {
|
||||||
if(isPlayerInAnyVehicle(client)) {
|
if(!isPlayerLoggedIn(client)) {
|
||||||
if(getPlayerData(client)) {
|
return false;
|
||||||
if(getPlayerData(client).buyingVehicle) {
|
}
|
||||||
if(getPlayerVehicle(client) == getPlayerData(client).buyingVehicle) {
|
|
||||||
|
if(!isPlayerSpawned(client)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!getPlayerData(client)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!getPlayerData(client).buyingVehicle) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isPlayerInAnyVehicle(client)) {
|
||||||
|
if(getPlayerData(client).buyingVehicle != false) {
|
||||||
|
messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!");
|
||||||
|
respawnVehicle(getPlayerData(client).buyingVehicle);
|
||||||
|
getPlayerData(client).buyingVehicle = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
|
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
|
||||||
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
|
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
|
||||||
messagePlayerError(client, "You don't have enough money to buy this vehicle!");
|
messagePlayerError(client, "You don't have enough money to buy this vehicle!");
|
||||||
@@ -1365,15 +1386,10 @@ function checkVehicleBuying(client) {
|
|||||||
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
|
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
|
||||||
getPlayerData(client).buyingVehicle = false;
|
getPlayerData(client).buyingVehicle = false;
|
||||||
messagePlayerSuccess(client, "This vehicle is now yours! It will save wherever you leave it.");
|
messagePlayerSuccess(client, "This vehicle is now yours! It will save wherever you leave it.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!");
|
return false;
|
||||||
respawnVehicle(getPlayerData(client).buyingVehicle);
|
|
||||||
getPlayerData(client).buyingVehicle = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user