Check if dev server before loading/save
This commit is contained in:
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
function initBusinessScript() {
|
function initBusinessScript() {
|
||||||
logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ...");
|
logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ...");
|
||||||
getServerData().businesses = loadBusinessesFromDatabase();
|
if(!getServerConfig().devServer) {
|
||||||
|
getServerData().businesses = loadBusinessesFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
createAllBusinessPickups();
|
createAllBusinessPickups();
|
||||||
createAllBusinessBlips();
|
createAllBusinessBlips();
|
||||||
@@ -151,7 +153,7 @@ function createBusinessCommand(command, params, client) {
|
|||||||
let businessId = getServerData().businesses.push(tempBusinessData);
|
let businessId = getServerData().businesses.push(tempBusinessData);
|
||||||
setAllBusinessIndexes();
|
setAllBusinessIndexes();
|
||||||
|
|
||||||
saveAllBusinessesToDatabase();
|
saveBusinessesToDatabase();
|
||||||
|
|
||||||
createBusinessEntrancePickup(businessId-1);
|
createBusinessEntrancePickup(businessId-1);
|
||||||
createBusinessExitPickup(businessId-1);
|
createBusinessExitPickup(businessId-1);
|
||||||
@@ -1571,7 +1573,11 @@ function getPlayerBusiness(client) {
|
|||||||
* @return {Boolean} Whether or not the businesses were saved
|
* @return {Boolean} Whether or not the businesses were saved
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function saveAllBusinessesToDatabase() {
|
function saveBusinessesToDatabase() {
|
||||||
|
if(getServerConfig().devServer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for(let i in getServerData().businesses) {
|
for(let i in getServerData().businesses) {
|
||||||
if(getServerData().businesses[i].needsSaved) {
|
if(getServerData().businesses[i].needsSaved) {
|
||||||
saveBusinessToDatabase(i);
|
saveBusinessToDatabase(i);
|
||||||
@@ -1722,11 +1728,19 @@ function createBusinessEntrancePickup(businessId) {
|
|||||||
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
|
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getBusinessData(businessId).entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].business);
|
let entrancePickup = createGamePickup(pickupModelId, getBusinessData(businessId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].business);
|
||||||
setElementOnAllDimensions(getBusinessData(businessId).entrancePickup, false);
|
if(entrancePickup != null) {
|
||||||
setElementDimension(getBusinessData(businessId).entrancePickup, getBusinessData(businessId).entranceDimension);
|
setElementOnAllDimensions(entrancePickup, false);
|
||||||
updateBusinessPickupLabelData(businessId);
|
setElementDimension(entrancePickup, getBusinessData(businessId).entranceDimension);
|
||||||
addToWorld(getBusinessData(businessId).entrancePickup);
|
setElementOnAllDimensions(entrancePickup, false);
|
||||||
|
setElementStreamInDistance(entrancePickup, getGlobalConfig().houseBlipStreamInDistance);
|
||||||
|
setElementStreamOutDistance(entrancePickup, getGlobalConfig().houseBlipStreamOutDistance);
|
||||||
|
setElementTransient(entrancePickup, false);
|
||||||
|
addToWorld(entrancePickup);
|
||||||
|
|
||||||
|
getBusinessData(businessId).entrancePickup = entrancePickup;
|
||||||
|
updateBusinessPickupLabelData(businessId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sendBusinessToPlayer(null, businessId, getBusinessData(businessId), getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
|
sendBusinessToPlayer(null, businessId, getBusinessData(businessId), getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
|
||||||
}
|
}
|
||||||
@@ -1765,10 +1779,20 @@ function createBusinessEntranceBlip(businessId) {
|
|||||||
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
|
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getBusinessData(businessId).entranceBlip = createGameBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
|
let entranceBlip = createGameBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||||
setElementOnAllDimensions(getBusinessData(businessId).entranceBlip, false);
|
if(entranceBlip != null) {
|
||||||
setElementDimension(getBusinessData(businessId).entranceBlip, getBusinessData(businessId).entranceDimension);
|
setElementOnAllDimensions(entranceBlip, false);
|
||||||
addToWorld(getBusinessData(businessId).entranceBlip);
|
setElementDimension(entranceBlip, getBusinessData(businessId).entranceDimension);
|
||||||
|
setElementDimension(entranceBlip, getBusinessData(businessId).entranceDimension);
|
||||||
|
setElementOnAllDimensions(entranceBlip, false);
|
||||||
|
setElementStreamInDistance(entranceBlip, getGlobalConfig().businessBlipStreamInDistance);
|
||||||
|
setElementStreamOutDistance(entranceBlip, getGlobalConfig().businessBlipStreamOutDistance);
|
||||||
|
setElementTransient(entranceBlip, false);
|
||||||
|
addToWorld(entranceBlip);
|
||||||
|
|
||||||
|
getBusinessData(businessId).entranceBlip = entranceBlip;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sendBusinessToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, blipModelId, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
|
sendBusinessToPlayer(null, businessId, getBusinessData(businessId).name, getBusinessData(businessId).entrancePosition, blipModelId, getBusinessData(businessId).entrancePickupModel, getBusinessData(businessId).hasInterior, false);
|
||||||
}
|
}
|
||||||
@@ -1800,11 +1824,18 @@ function createBusinessExitPickup(businessId) {
|
|||||||
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
|
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${getBusinessData(businessId).name} (model ${pickupModelId})`);
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getBusinessData(businessId).exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business);
|
let exitPickup = createGamePickup(pickupModelId, getBusinessData(businessId).exitPosition, getGameConfig().pickupTypes[getServerGame()].business);
|
||||||
setElementDimension(getBusinessData(businessId).exitPickup, getBusinessData(businessId).exitDimension);
|
if(exitPickup != null) {
|
||||||
setElementOnAllDimensions(getBusinessData(businessId).exitPickup, false);
|
setElementDimension(exitPickup, getBusinessData(businessId).exitDimension);
|
||||||
updateBusinessPickupLabelData(businessId);
|
setElementOnAllDimensions(exitPickup, false);
|
||||||
addToWorld(getBusinessData(businessId).exitPickup);
|
setElementStreamInDistance(exitPickup, getGlobalConfig().businessPickupStreamInDistance);
|
||||||
|
setElementStreamOutDistance(exitPickup, getGlobalConfig().businessPickupStreamOutDistance);
|
||||||
|
setElementTransient(exitPickup, false);
|
||||||
|
addToWorld(exitPickup);
|
||||||
|
|
||||||
|
getBusinessData(businessId).exitPickup = exitPickup;
|
||||||
|
updateBusinessPickupLabelData(businessId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1835,13 +1866,17 @@ function createBusinessExitBlip(businessId) {
|
|||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
|
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${getBusinessData(businessId).name} (model ${blipModelId})`);
|
||||||
|
|
||||||
getBusinessData(businessId).exitBlip = createGameBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
|
let exitBlip = createGameBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
|
||||||
setElementDimension(getBusinessData(businessId).exitBlip, getBusinessData(businessId).entranceDimension);
|
if(exitBlip != null) {
|
||||||
setElementOnAllDimensions(getBusinessData(businessId).exitBlip, false);
|
setElementDimension(exitBlip, getBusinessData(businessId).exitDimension);
|
||||||
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
|
setElementOnAllDimensions(exitBlip, false);
|
||||||
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.type", VRR_BLIP_BUSINESS_EXIT, false);
|
setElementStreamInDistance(exitBlip, getGlobalConfig().businessBlipStreamInDistance);
|
||||||
//setEntityData(getBusinessData(businessId).exitBlip, "vrr.owner.id", businessId, false);
|
setElementStreamOutDistance(exitBlip, getGlobalConfig().businessBlipStreamOutDistance);
|
||||||
addToWorld(getBusinessData(businessId).exitBlip);
|
setElementTransient(exitBlip, false);
|
||||||
|
addToWorld(exitBlip);
|
||||||
|
|
||||||
|
getBusinessData(businessId).exitBlip = exitBlip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2255,7 +2290,7 @@ function buyFromBusinessCommand(command, params, client) {
|
|||||||
let keyData = getPlayerKeyBindForCommand("inv");
|
let keyData = getPlayerKeyBindForCommand("inv");
|
||||||
messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`));
|
messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}${getKeyNameFromId(keyData.key)}{MAINCOLOUR}`));
|
||||||
} else {
|
} else {
|
||||||
messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryKeyPressTip", `{ALTCOLOUR}/inv{MAINCOLOUR}`));
|
messagePlayerNewbieTip(client, getLocaleString(client, "ViewInventoryCommandTip", `{ALTCOLOUR}/inv{MAINCOLOUR}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
function initHouseScript() {
|
function initHouseScript() {
|
||||||
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
|
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
|
||||||
getServerData().houses = loadHousesFromDatabase();
|
if(!getServerConfig().devServer) {
|
||||||
|
getServerData().houses = loadHousesFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
if(getServerConfig().createHousePickups) {
|
if(getServerConfig().createHousePickups) {
|
||||||
createAllHousePickups();
|
createAllHousePickups();
|
||||||
@@ -718,7 +720,11 @@ function getPlayerHouse(client) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function saveAllHousesToDatabase() {
|
function saveHousesToDatabase() {
|
||||||
|
if(getServerConfig().devServer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
|
logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
|
||||||
for(let i in getServerData().houses) {
|
for(let i in getServerData().houses) {
|
||||||
if(getServerData().houses[i].needsSaved) {
|
if(getServerData().houses[i].needsSaved) {
|
||||||
@@ -878,14 +884,20 @@ function createHouseEntrancePickup(houseId) {
|
|||||||
pickupModelId = getHouseData(houseId).entrancePickupModel;
|
pickupModelId = getHouseData(houseId).entrancePickupModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getHouseData(houseId).entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
|
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
|
||||||
setElementOnAllDimensions(getHouseData(houseId).entrancePickup, false);
|
if(entrancePickup != null) {
|
||||||
setElementDimension(getHouseData(houseId).entrancePickup, getHouseData(houseId).entranceDimension);
|
setElementOnAllDimensions(entrancePickup, false);
|
||||||
setElementStreamInDistance(getBusinessData(businessId).entrancePickup, getGlobalConfig().housePickupStreamInDistance);
|
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
|
||||||
setElementStreamOutDistance(getBusinessData(businessId).entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
|
setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance);
|
||||||
setElementTransient(getHouseData(houseId).entrancePickup, false);
|
setElementStreamOutDistance(entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
|
||||||
addToWorld(getHouseData(houseId).entrancePickup);
|
setElementTransient(entrancePickup, false);
|
||||||
|
addToWorld(entrancePickup);
|
||||||
|
|
||||||
|
getHouseData(houseId).entrancePickup = entrancePickup;
|
||||||
|
updateHousePickupLabelData(houseId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -904,15 +916,19 @@ function createHouseEntranceBlip(houseId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getHouseData(houseId).entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
let entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
|
||||||
setElementDimension(getHouseData(houseId).entranceBlip, getHouseData(houseId).entranceDimension);
|
if(entranceBlip != null) {
|
||||||
setElementOnAllDimensions(getHouseData(houseId).entranceBlip, false);
|
setElementDimension(entranceBlip, getHouseData(houseId).entranceDimension);
|
||||||
setElementStreamInDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
|
setElementOnAllDimensions(entranceBlip, false);
|
||||||
setElementStreamOutDistance(getBusinessData(businessId).entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
|
setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
|
||||||
setElementTransient(getHouseData(houseId).entranceBlip, false);
|
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
|
||||||
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
|
setElementTransient(entranceBlip, false);
|
||||||
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.id", houseId, false);
|
setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
|
||||||
addToWorld(getHouseData(houseId).entranceBlip);
|
setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
|
||||||
|
addToWorld(entranceBlip);
|
||||||
|
|
||||||
|
getHouseData(houseId).entranceBlip = entranceBlip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -933,15 +949,19 @@ function createHouseExitPickup(houseId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getHouseData(houseId).exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
|
let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
|
||||||
setElementDimension(getHouseData(houseId).exitPickup, getHouseData(houseId).exitDimension);
|
if(exitPickup != null) {
|
||||||
setElementOnAllDimensions(getHouseData(houseId).exitPickup, false);
|
setElementDimension(exitPickup, getHouseData(houseId).exitDimension);
|
||||||
setElementStreamInDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamInDistance);
|
setElementOnAllDimensions(exitPickup, false);
|
||||||
setElementStreamOutDistance(getBusinessData(businessId).exitPickup, getGlobalConfig().housePickupStreamOutDistance);
|
setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance);
|
||||||
setElementTransient(getHouseData(houseId).exitPickup, false);
|
setElementStreamOutDistance(exitPickup, getGlobalConfig().housePickupStreamOutDistance);
|
||||||
addToWorld(getHouseData(houseId).exitPickup);
|
setElementTransient(exitPickup, false);
|
||||||
|
addToWorld(exitPickup);
|
||||||
|
|
||||||
|
getHouseData(houseId).exitPickup = exitPickup;
|
||||||
|
updateHousePickupLabelData(houseId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateHousePickupLabelData(houseId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -962,15 +982,19 @@ function createHouseExitBlip(houseId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(areServerElementsSupported()) {
|
if(areServerElementsSupported()) {
|
||||||
getHouseData(houseId).exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
|
let exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
|
||||||
setElementDimension(getHouseData(houseId).exitBlip, getHouseData(houseId).entranceDimension);
|
if(exitBlip != null) {
|
||||||
setElementOnAllDimensions(getHouseData(houseId).exitBlip, false);
|
setElementDimension(exitBlip, getHouseData(houseId).entranceDimension);
|
||||||
setElementStreamInDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamInDistance);
|
setElementOnAllDimensions(exitBlip, false);
|
||||||
setElementStreamOutDistance(getBusinessData(businessId).exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
|
setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance);
|
||||||
setElementTransient(getHouseData(houseId).exitBlip, false);
|
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
|
||||||
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
|
setElementTransient(exitBlip, false);
|
||||||
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.id", houseId, false);
|
setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
|
||||||
addToWorld(getHouseData(houseId).exitBlip);
|
setEntityData(exitBlip, "vrr.owner.id", houseId, false);
|
||||||
|
addToWorld(exitBlip);
|
||||||
|
|
||||||
|
getHouseData(houseId).exitBlip = exitBlip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,12 @@
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function initNPCScript() {
|
function initNPCScript() {
|
||||||
getServerData().npcs = loadNPCsFromDatabase();
|
if(!getServerConfig().devServer) {
|
||||||
setAllNPCDataIndexes();
|
getServerData().npcs = loadNPCsFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
spawnAllNPCs();
|
setNPCDataIndexes();
|
||||||
|
spawnNPCs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -44,15 +46,8 @@ function createNPCCommand(client, command, params) {
|
|||||||
|
|
||||||
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
|
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
|
||||||
|
|
||||||
let tempNPCData = new NPCData(false);
|
let npcId = createNPC(skinId, position, getPlayerHeading(client));
|
||||||
tempNPCData.position = position;
|
messageAdmins(`${client.name}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
|
||||||
tempNPCData.heading = getPlayerHeading(client);
|
|
||||||
tempNPCData.skin = skinId;
|
|
||||||
|
|
||||||
let npcIndex = getServerData().npcs.push(tempNPCData);
|
|
||||||
|
|
||||||
spawnNPC(npcIndex-1);
|
|
||||||
setAllNPCDataIndexes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -156,7 +151,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function saveAllNPCsToDatabase() {
|
function saveNPCsToDatabase() {
|
||||||
|
if(getServerConfig().devServer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for(let i in getServerData().npcs) {
|
for(let i in getServerData().npcs) {
|
||||||
saveNPCToDatabase(i);
|
saveNPCToDatabase(i);
|
||||||
}
|
}
|
||||||
@@ -250,7 +249,7 @@ function saveNPCToDatabase(npcDataId) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function setAllNPCDataIndexes() {
|
function setNPCDataIndexes() {
|
||||||
for(let i in getServerData().npcs) {
|
for(let i in getServerData().npcs) {
|
||||||
getServerData().npcs[i].index = i;
|
getServerData().npcs[i].index = i;
|
||||||
|
|
||||||
@@ -277,14 +276,16 @@ function spawnNPC(npcIndex) {
|
|||||||
let civilian = createGameCivilian(getNPCData(npcIndex).model, getNPCData(npcIndex).spawnPosition, getNPCData(npcIndex).spawnRotation);
|
let civilian = createGameCivilian(getNPCData(npcIndex).model, getNPCData(npcIndex).spawnPosition, getNPCData(npcIndex).spawnRotation);
|
||||||
if(civilian) {
|
if(civilian) {
|
||||||
civilian.setData("vrr.dataIndex", npcIndex);
|
civilian.setData("vrr.dataIndex", npcIndex);
|
||||||
civilian.setData("vrr.animation", getNPCData(npcIndex).animationName);
|
if(getNPCData(npcIndex).animationName != "") {
|
||||||
|
civilian.setData("vrr.animation", getNPCData(npcIndex).animationName);
|
||||||
|
}
|
||||||
getNPCData(npcIndex).ped = civilian;
|
getNPCData(npcIndex).ped = civilian;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function spawnAllNPCs() {
|
function spawnNPCs() {
|
||||||
for(let i in getServerData().npcs) {
|
for(let i in getServerData().npcs) {
|
||||||
spawnNPC(npcIndex);
|
spawnNPC(npcIndex);
|
||||||
}
|
}
|
||||||
@@ -308,7 +309,7 @@ function deleteNPCCommand(command, params, client) {
|
|||||||
let npcName = getNPCData(closestNPC).name;
|
let npcName = getNPCData(closestNPC).name;
|
||||||
|
|
||||||
deleteNPC(closestNPC);
|
deleteNPC(closestNPC);
|
||||||
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`)
|
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -323,7 +324,7 @@ function deleteNPC(npcId) {
|
|||||||
getServerData().npcs.splice(npcId, 1);
|
getServerData().npcs.splice(npcId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAllNPCDataIndexes();
|
setNPCDataIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -360,10 +361,9 @@ function setNPCAnimationCommand(command, params, client) {
|
|||||||
makePedPlayAnimation(getNPCData(closestNPC).ped, animationId, animationPositionOffset);
|
makePedPlayAnimation(getNPCData(closestNPC).ped, animationId, animationPositionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getClosestHospital(position) {
|
function getClosestNPC(position) {
|
||||||
let npcs = getServerData().npcs;
|
let npcs = getServerData().npcs;
|
||||||
let closest = 0;
|
let closest = 0;
|
||||||
for(let i in npcs) {
|
for(let i in npcs) {
|
||||||
@@ -375,4 +375,21 @@ function getClosestHospital(position) {
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function createNPC(skinIndex, position, heading) {
|
||||||
|
let tempNPCData = new NPCData(false);
|
||||||
|
tempNPCData.position = position;
|
||||||
|
tempNPCData.heading = heading;
|
||||||
|
tempNPCData.skin = skinIndex;
|
||||||
|
tempNPCData.animationName = "";
|
||||||
|
|
||||||
|
let npcIndex = getServerData().npcs.push(tempNPCData);
|
||||||
|
|
||||||
|
spawnNPC(npcIndex-1);
|
||||||
|
setNPCDataIndexes();
|
||||||
|
|
||||||
|
return npcIndex-1;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -9,7 +9,10 @@
|
|||||||
|
|
||||||
function initRadioScript() {
|
function initRadioScript() {
|
||||||
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
|
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
|
||||||
getServerData().radioStations = loadRadioStationsFromDatabase();
|
if(!getServerConfig().devServer) {
|
||||||
|
getServerData().radioStations = loadRadioStationsFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
setRadioStationIndexes();
|
setRadioStationIndexes();
|
||||||
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
|
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
|
|
||||||
function initVehicleScript() {
|
function initVehicleScript() {
|
||||||
logToConsole(LOG_INFO, "[VRR.Vehicle]: Initializing vehicle script ...");
|
logToConsole(LOG_INFO, "[VRR.Vehicle]: Initializing vehicle script ...");
|
||||||
getServerData().vehicles = loadVehiclesFromDatabase();
|
if(!getServerConfig().devServer) {
|
||||||
|
getServerData().vehicles = loadVehiclesFromDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
spawnAllVehicles();
|
spawnAllVehicles();
|
||||||
setAllVehicleIndexes();
|
setAllVehicleIndexes();
|
||||||
logToConsole(LOG_INFO, "[VRR.Vehicle]: Vehicle script initialized successfully!");
|
logToConsole(LOG_INFO, "[VRR.Vehicle]: Vehicle script initialized successfully!");
|
||||||
@@ -42,7 +45,11 @@ function loadVehiclesFromDatabase() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function saveAllVehiclesToDatabase() {
|
function saveVehiclesToDatabase() {
|
||||||
|
if(getServerConfig().devServer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
logToConsole(LOG_INFO, "[VRR.Vehicle]: Saving all server vehicles to database ...");
|
logToConsole(LOG_INFO, "[VRR.Vehicle]: Saving all server vehicles to database ...");
|
||||||
let vehicles = getServerData().vehicles;
|
let vehicles = getServerData().vehicles;
|
||||||
for(let i in vehicles) {
|
for(let i in vehicles) {
|
||||||
@@ -1263,7 +1270,7 @@ function spawnVehicle(vehicleData) {
|
|||||||
|
|
||||||
if(typeof vehicle.locked != "undefined") {
|
if(typeof vehicle.locked != "undefined") {
|
||||||
setVehicleLocked(vehicle, intToBool(vehicleData.locked));
|
setVehicleLocked(vehicle, intToBool(vehicleData.locked));
|
||||||
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s lock state to ${toUpperCase(getOnOffFromBool(getVehicleLockState(vehicle)))}`);
|
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Setting vehicle ${vehicle.id}'s lock state to ${toUpperCase(getOnOffFromBool(getVehicleLocked(vehicle)))}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setElementDimension(vehicle.dimension, vehicleData.dimension);
|
setElementDimension(vehicle.dimension, vehicleData.dimension);
|
||||||
|
|||||||
Reference in New Issue
Block a user