Fixes for new IV sync
This commit is contained in:
@@ -38,7 +38,7 @@ function initBusinessScript() {
|
||||
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`);
|
||||
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (getBusinessData(businessId) != false) {
|
||||
let businessData = getBusinessData(businessId);
|
||||
businessData.name = name;
|
||||
|
||||
@@ -29,7 +29,7 @@ class HouseData {
|
||||
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.House] Received house ${houseId} (${name}) from server`);
|
||||
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (getHouseData(houseId) != false) {
|
||||
let houseData = getHouseData(houseId);
|
||||
houseData.description = description;
|
||||
|
||||
@@ -140,7 +140,7 @@ function hideJobRouteLocation() {
|
||||
function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, pickupModel) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Job] Received job ${jobId} (${name}) from server`);
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (getJobData(jobId) != false) {
|
||||
let jobData = getJobData(jobId);
|
||||
jobData.jobLocationId = jobLocationId;
|
||||
|
||||
@@ -47,15 +47,15 @@ function processSync(event, deltaTime) {
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleLights(vehicleId, state) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (!state) {
|
||||
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
|
||||
} else {
|
||||
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
|
||||
}
|
||||
} else {
|
||||
getElementFromId(vehicleId).lights = state;
|
||||
}
|
||||
//if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
// if (!state) {
|
||||
// natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
|
||||
// } else {
|
||||
// natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
|
||||
// }
|
||||
//} else {
|
||||
getElementFromId(vehicleId).lights = state;
|
||||
//}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -73,11 +73,12 @@ function syncVehicleProperties(vehicle) {
|
||||
|
||||
if (doesEntityDataExist(vehicle, "agrp.lights")) {
|
||||
let lightStatus = getEntityData(vehicle, "agrp.lights");
|
||||
if (!lightStatus) {
|
||||
vehicle.lightStatus = 2;
|
||||
} else {
|
||||
vehicle.lightStatus = 1;
|
||||
}
|
||||
vehicle.lights = lightStatus;
|
||||
}
|
||||
|
||||
if (doesEntityDataExist(vehicle, "agrp.locked")) {
|
||||
let lockStatus = getEntityData(vehicle, "agrp.locked");
|
||||
vehicle.locked = lockStatus;
|
||||
}
|
||||
|
||||
if (doesEntityDataExist(vehicle, "agrp.invincible")) {
|
||||
|
||||
@@ -2028,7 +2028,7 @@ function createBusinessEntrancePickup(businessId) {
|
||||
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating entrance pickup for business ${businessData.name}`);
|
||||
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
|
||||
let entrancePickup = null;
|
||||
if (isGameFeatureSupported("pickup")) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getGame()].Business;
|
||||
@@ -2105,7 +2105,7 @@ function createBusinessEntranceBlip(businessId) {
|
||||
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating entrance blip for business ${businessData.name} (model ${blipModelId})`);
|
||||
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
|
||||
let entranceBlip = createGameBlip(businessData.entrancePosition, blipModelId, 1, getColourByType("businessBlue"));
|
||||
if (entranceBlip != null) {
|
||||
if (businessData.entranceDimension != -1) {
|
||||
@@ -2875,7 +2875,7 @@ function getBusinessIdFromDatabaseId(databaseId) {
|
||||
|
||||
// Updates all pickup data for a business by businessId
|
||||
function updateBusinessPickupLabelData(businessId) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
sendBusinessToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, getBusinessEntranceBlipModelForNetworkEvent(businessId), getBusinessEntrancePickupModelForNetworkEvent(businessId), getBusinessData(businessId).buyPrice, getBusinessData(businessId).rentPrice, getBusinessData(businessId).hasInterior, getBusinessData(businessId).locked, doesBusinessHaveAnyItemsToBuy(businessId));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ function onPedSpawn(ped) {
|
||||
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} spawned!`);
|
||||
|
||||
//if (ped.type == ELEMENT_PLAYER) {
|
||||
// if (getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
|
||||
// if (getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
// //setTimeout(onPlayerSpawn, 250, getClientFromPlayerElement(ped));
|
||||
// //onPlayerSpawn(getClientFromPlayerElement(ped));
|
||||
// }
|
||||
@@ -454,7 +454,7 @@ async function onPlayerSpawn(client) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) {
|
||||
if (isCustomCameraSupported()) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
|
||||
restorePlayerCamera(client);
|
||||
}
|
||||
@@ -585,11 +585,13 @@ async function onPlayerSpawn(client) {
|
||||
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
|
||||
}
|
||||
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending properties, jobs, and vehicles to ${getPlayerDisplayForConsole(client)} (no server elements)`);
|
||||
sendAllBusinessesToPlayer(client);
|
||||
sendAllHousesToPlayer(client);
|
||||
sendAllJobsToPlayer(client);
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
sendAllJobsToPlayer(client);
|
||||
}
|
||||
requestPlayerPedNetworkId(client);
|
||||
}
|
||||
|
||||
@@ -672,6 +674,10 @@ function onPlayerCommand(event, client, command, params) {
|
||||
function onPedExitedVehicle(event, ped, vehicle, seat) {
|
||||
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} exited vehicle ${vehicle.id} from seat ${seat}!`);
|
||||
|
||||
if (getVehicleData(vehicle) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ped.isType(ELEMENT_PLAYER)) {
|
||||
let client = getClientFromPlayerElement(ped);
|
||||
if (client != null) {
|
||||
@@ -716,10 +722,6 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
vehicle = getVehicleFromIVNetworkId(clientVehicle);
|
||||
}
|
||||
|
||||
if (!getVehicleData(vehicle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1056,7 +1056,7 @@ function createHouseEntrancePickup(houseId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
|
||||
let entrancePickup = null;
|
||||
if (isGameFeatureSupported("pickup")) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
|
||||
@@ -1781,7 +1781,7 @@ function getHouseFromParams(params) {
|
||||
// ===========================================================================
|
||||
|
||||
function updateHousePickupLabelData(houseId) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
|
||||
sendHouseToPlayer(null, houseId, getHouseData(houseId).description, getHouseData(houseId).entrancePosition, getHouseEntranceBlipModelForNetworkEvent(houseId), getHouseEntrancePickupModelForNetworkEvent(houseId), getHouseData(houseId).buyPrice, getHouseData(houseId).rentPrice, getHouseData(houseId).hasInterior, getHouseData(houseId).locked);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -338,15 +338,11 @@ function spawnAllVehicles() {
|
||||
* @return {VehicleData} The vehicles's data (class instance)
|
||||
*/
|
||||
function getVehicleData(vehicle) {
|
||||
if (getGame() != AGRP_GAME_GTA_IV) {
|
||||
if (isVehicleObject(vehicle)) {
|
||||
let dataIndex = getEntityData(vehicle, "agrp.dataSlot");
|
||||
if (typeof getServerData().vehicles[dataIndex] != "undefined") {
|
||||
return getServerData().vehicles[dataIndex];
|
||||
}
|
||||
if (isVehicleObject(vehicle)) {
|
||||
let dataIndex = getEntityData(vehicle, "agrp.dataSlot");
|
||||
if (typeof getServerData().vehicles[dataIndex] != "undefined") {
|
||||
return getServerData().vehicles[dataIndex];
|
||||
}
|
||||
} else {
|
||||
return getServerData().vehicles.find((v) => v.ivNetworkId == vehicle);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user