New business stuff
This commit is contained in:
52
scripts/client/business.js
Normal file
52
scripts/client/business.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// ===========================================================================
|
||||||
|
// Vortrex's Roleplay Resource
|
||||||
|
// https://github.com/VortrexFTW/gtac_roleplay
|
||||||
|
// ===========================================================================
|
||||||
|
// FILE: business.js
|
||||||
|
// DESC: Provides business functions and usage
|
||||||
|
// TYPE: Client (JavaScript)
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
class BusinessData() {
|
||||||
|
constructor(index, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||||
|
this.index = index;
|
||||||
|
this.name = name;
|
||||||
|
this.entrancePosition = entrancePosition;
|
||||||
|
this.blipModel = blipModel;
|
||||||
|
this.pickupModel = pickupModel;
|
||||||
|
this.hasInterior = hasInterior;
|
||||||
|
this.hasItems = hasItems;
|
||||||
|
this.blipId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
||||||
|
if(getGame() == VRR_GAME_GTA_IV) {
|
||||||
|
if(getBusinessData(businessId) != false) {
|
||||||
|
if(blipModel == -1) {
|
||||||
|
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
|
||||||
|
businesses.splice(getBusinessData(businessId).index, 1);
|
||||||
|
} else {
|
||||||
|
natives.setBlipCoordinates(getBusinessData(businessId).blipId, getBusinessData(businessId).entrancePosition);
|
||||||
|
natives.changeBlipSprite(getBusinessData(businessId).blipId, getBusinessData(businessId).blipModel);
|
||||||
|
natives.changeBlipNameFromAscii(getBusinessData(businessId).blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(blipModel != -1) {
|
||||||
|
let blipId = natives.addBlipForCoord(entrancePosition);
|
||||||
|
if(blipId) {
|
||||||
|
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
|
||||||
|
tempBusinessData.blipId = blipId;
|
||||||
|
natives.changeBlipSprite(blipId, blipModel);
|
||||||
|
natives.setBlipMarkerLongDistance(blipId, true);
|
||||||
|
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
|
||||||
|
businesses.push(tempBusinessData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
@@ -249,42 +249,51 @@ function renderJobLabel(name, position, jobType) {
|
|||||||
function processLabelRendering() {
|
function processLabelRendering() {
|
||||||
if(renderLabels && areWorldLabelsSupported()) {
|
if(renderLabels && areWorldLabelsSupported()) {
|
||||||
if(localPlayer != null) {
|
if(localPlayer != null) {
|
||||||
let pickups = getElementsByType(ELEMENT_PICKUP);
|
if(!areServerElementsSupported()) {
|
||||||
for(let i in pickups) {
|
//for(let i in businessBlips) {
|
||||||
if(pickups[i].getData("vrr.label.type") != null) {
|
// if(pickups[i].getData("vrr.label.type") != null) {
|
||||||
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
|
// if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
|
||||||
if(!pickups[i].isOnScreen) {
|
|
||||||
let price = "0";
|
// natives.getScreenViewportId
|
||||||
let rentPrice = "0";
|
// natives.getViewportPositionOfCoord
|
||||||
let labelInfoType = VRR_PROPLABEL_INFO_NONE;
|
} else {
|
||||||
if(pickups[i].getData("vrr.label.price") != null) {
|
let pickups = getElementsByType(ELEMENT_PICKUP);
|
||||||
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
|
for(let i in pickups) {
|
||||||
}
|
if(pickups[i].getData("vrr.label.type") != null) {
|
||||||
|
if(getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
|
||||||
if(pickups[i].getData("vrr.label.rentprice") != null) {
|
if(!pickups[i].isOnScreen) {
|
||||||
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
|
let price = "0";
|
||||||
}
|
let rentPrice = "0";
|
||||||
|
let labelInfoType = VRR_PROPLABEL_INFO_NONE;
|
||||||
if(pickups[i].getData("vrr.label.help") != null) {
|
if(pickups[i].getData("vrr.label.price") != null) {
|
||||||
labelInfoType = pickups[i].getData("vrr.label.help");
|
price = makeLargeNumberReadable(pickups[i].getData("vrr.label.price"));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(pickups[i].getData("vrr.label.type")) {
|
if(pickups[i].getData("vrr.label.rentprice") != null) {
|
||||||
case VRR_LABEL_BUSINESS:
|
rentPrice = makeLargeNumberReadable(pickups[i].getData("vrr.label.rentprice"));
|
||||||
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
|
}
|
||||||
break;
|
|
||||||
|
if(pickups[i].getData("vrr.label.help") != null) {
|
||||||
case VRR_LABEL_HOUSE:
|
labelInfoType = pickups[i].getData("vrr.label.help");
|
||||||
renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType);
|
}
|
||||||
break;
|
|
||||||
|
switch(pickups[i].getData("vrr.label.type")) {
|
||||||
case VRR_LABEL_JOB:
|
case VRR_LABEL_BUSINESS:
|
||||||
renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType"));
|
renderPropertyEntranceLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.locked"), true, price, rentPrice, labelInfoType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VRR_LABEL_EXIT:
|
case VRR_LABEL_HOUSE:
|
||||||
renderPropertyExitLabel(pickups[i].position);
|
renderPropertyEntranceLabel("House", pickups[i].position, pickups[i].getData("vrr.label.locked"), false, price, rentPrice, labelInfoType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VRR_LABEL_JOB:
|
||||||
|
renderJobLabel(pickups[i].getData("vrr.label.name"), pickups[i].position, pickups[i].getData("vrr.label.jobType"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VRR_LABEL_EXIT:
|
||||||
|
renderPropertyExitLabel(pickups[i].position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ let forceWantedLevel = 0;
|
|||||||
// Pre-cache all allowed skins
|
// Pre-cache all allowed skins
|
||||||
let allowedSkins = getAllowedSkins(getGame());
|
let allowedSkins = getAllowedSkins(getGame());
|
||||||
|
|
||||||
let businessBlips = {};
|
let businesses = {};
|
||||||
let houseBlips = {};
|
let houses = {};
|
||||||
let jobBlips = {};
|
let jobs = {};
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -14,18 +14,6 @@ function processSync(event, deltaTime) {
|
|||||||
sendNetworkEventToServer("vrr.player.heading", localPlayer.heading);
|
sendNetworkEventToServer("vrr.player.heading", localPlayer.heading);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(game.game == VRR_GAME_GTA_SA) {
|
|
||||||
// let lookAtPos = getLocalPlayerLookAtPosition();
|
|
||||||
// sendNetworkEventToServer("vrr.player.lookat", lookAtPos);
|
|
||||||
// setEntityData(localPlayer, "vrr.headLook", lookAtPos);
|
|
||||||
// let peds = getPeds();
|
|
||||||
// for(let i in peds) {
|
|
||||||
// if(doesEntityDataExist(peds[i], "vrr.headLook")) {
|
|
||||||
// peds[i].lookAt(getEntityData(peds[i], "vrr.headLook"), 99999);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
if(localPlayer.health <= 0) {
|
if(localPlayer.health <= 0) {
|
||||||
if(!calledDeathEvent) {
|
if(!calledDeathEvent) {
|
||||||
logToConsole(LOG_DEBUG, `Local player died`);
|
logToConsole(LOG_DEBUG, `Local player died`);
|
||||||
@@ -391,32 +379,7 @@ function syncElementProperties(element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
|
||||||
|
|
||||||
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
|
|
||||||
if(getGame() == VRR_GAME_GTA_IV) {
|
|
||||||
if(typeof businessBlips[businessId] != "undefined") {
|
|
||||||
if(blipModel == -1) {
|
|
||||||
natives.removeBlipAndClearIndex(businessBlips[businessId]);
|
|
||||||
businessBlips.splice(businessId, 1);
|
|
||||||
} else {
|
|
||||||
natives.setBlipCoordinates(businessBlips[businessId], entrancePosition);
|
|
||||||
natives.changeBlipSprite(businessBlips[businessId], blipModel);
|
|
||||||
natives.changeBlipNameFromAscii(businessBlips[businessId], `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(blipModel != -1) {
|
|
||||||
let blipId = natives.addBlipForCoord(entrancePosition);
|
|
||||||
if(blipId) {
|
|
||||||
businessBlips[businessId] = blipId;
|
|
||||||
natives.changeBlipSprite(blipId, blipModel);
|
|
||||||
natives.setBlipMarkerLongDistance(blipId, true);
|
|
||||||
natives.changeBlipNameFromAscii(blipId, `${name.substr(0, 24)}${(name.length > 24) ? " ...": ""}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user