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