Add biz/house toggleable interior lights

This commit is contained in:
Vortrex
2021-08-27 18:45:56 -05:00
parent e17b43bf2f
commit b60b52a2c0
7 changed files with 105 additions and 16 deletions

View File

@@ -92,7 +92,6 @@ function onProcess(event, deltaTime) {
processJobRouteSphere();
forceLocalPlayerEquippedWeaponItem();
processWantedLevelReset();
processGameSpecifics();
}
@@ -120,6 +119,7 @@ function onDrawnHUD(event) {
processItemActionRendering();
processSkinSelectRendering();
processNameTagRendering();
processInteriorLightsRendering();
}
// ===========================================================================

View File

@@ -25,6 +25,7 @@ let renderSmallGameMessage = true;
let renderScoreBoard = true;
let renderHotBar = true;
let renderItemActionDelay = true;
let renderInteriorLights = true;
let logLevel = LOG_ALL;
@@ -50,4 +51,7 @@ let forcedAnimation = null;
let calledDeathEvent = false;
let interiorLightsEnabled = true;
let interiorLightsColour = toColour(0, 0, 0, 150);
// ===========================================================================

View File

@@ -76,19 +76,18 @@ function addAllNetworkHandlers() {
addNetworkHandler("vrr.veh.lights", toggleVehicleLights);
addNetworkHandler("vrr.veh.engine", toggleVehicleEngine);
addNetworkHandler("vrr.veh.repair", repairVehicle);
addNetworkHandler("vrr.veh.sync", syncVehicleProperties);
addNetworkHandler("vrr.civ.sync", syncCivilianProperties);
addNetworkHandler("vrr.plr.sync", syncPlayerProperties);
addNetworkHandler("vrr.obj.sync", syncObjectProperties);
addNetworkHandler("vrr.veh.repair", repairVehicle);
addNetworkHandler("vrr.pedAnim", makePedPlayAnimation);
addNetworkHandler("vrr.hideAllGUI", hideAllGUI);
addNetworkHandler("vrr.gameScript", setGameScriptState);
addNetworkHandler("vrr.clientInfo", serverRequestedClientInfo);
addNetworkHandler("vrr.interiorLights", updateInteriorLightsState);
}
// ===========================================================================
@@ -268,3 +267,15 @@ function setGameScriptState(scriptName, state) {
}
// ===========================================================================
function serverRequestedClientInfo() {
sendServerClientInfo();
}
// ===========================================================================
function updateInteriorLightsState(state) {
interiorLightsEnabled = state;
}
// ===========================================================================

View File

@@ -685,3 +685,15 @@ function getLocalPlayerLookAtPosition() {
return getWorldFromScreenPosition(toVector3(game.width/2, game.height/2, getDistance(centerCameraPos, localPlayer.position)+20));
}
}
// ===========================================================================
function processInteriorLightsRendering() {
if(renderInteriorLights) {
if(!interiorLightsEnabled) {
graphics.drawRectangle(null, toVector2(0.0, 0.0), toVector2(game.width, game.height), interiorLightsColour, interiorLightsColour, interiorLightsColour, interiorLightsColour);
}
}
}
// ===========================================================================

View File

@@ -343,7 +343,7 @@ function setBusinessPublicCommand(command, params, client) {
// ===========================================================================
function lockBusinessCommand(command, params, client) {
function lockUnlockBusinessCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
if(!areParamsEmpty(params)) {
@@ -362,6 +362,33 @@ function lockBusinessCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleBusinessInteriorLightsCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
getBusinessData(businessId).interiorLights = !getBusinessData(houseId).interiorLights;
getBusinessData(businessId).needsSaved = true;
updateBusinessInteriorLightsForOccupants(businessId);
messagePlayerMeAction(client, `turns ${getOnOffFromBool(getBusinessData(businessId).interiorLights)} the business lights`);
}
// ===========================================================================
function setBusinessEntranceFeeCommand(command, params, client) {
let splitParams = params.split(" ");
let entranceFee = toInteger(splitParams[0]) || 0;
@@ -466,7 +493,7 @@ function setBusinessInteriorTypeCommand(command, params, client) {
getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0);
getBusinessData(businessId).exitInterior = 0;
getBusinessData(businessId).hasInterior = false;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}remove business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}interior`);
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}removed business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}interior`);
resetBusinessPickups();
resetBusinessBlips();
@@ -476,7 +503,7 @@ function setBusinessInteriorTypeCommand(command, params, client) {
getBusinessData(businessId).exitInterior = getPlayerInterior(client);
getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart;
getBusinessData(businessId).hasInterior = true;
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}remove business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}interior`);
messageAdmins(`${getInlineChatColourByName("lightGrey")}${getPlayerName(client)} ${getInlineChatColourByName("white")}removed business ${getInlineChatColourByType("businessBlue")}${getBusinessData(businessId).name} ${getInlineChatColourByName("white")}interior`);
resetBusinessPickups();
resetBusinessBlips();
@@ -950,10 +977,11 @@ function saveBusinessToDatabase(businessId) {
["biz_exit_pos_z", tempBusinessData.exitPosition.z],
["biz_exit_rot_z", tempBusinessData.exitRotation],
["biz_exit_int", tempBusinessData.exitInterior],
["biz_exit_vw", tempBusinessData.databaseId+getGlobalConfig().businessDimensionStart],
["biz_exit_vw", tempBusinessData.exitDimension],
["biz_exit_pickup", tempBusinessData.exitPickupModel],
["biz_exit_blip", tempBusinessData.exitBlipModel],
["biz_has_interior", boolToInt(tempBusinessData.hasInterior)],
["biz_interior_lights", boolToInt(tempBusinessData.interiorLights)],
];
let dbQuery = null;
@@ -1031,7 +1059,7 @@ function createBusinessEntranceBlip(businessId) {
blipModelId = getBusinessData(businessId).entranceBlipModel;
}
getBusinessData(businessId).entranceBlip = createGameBlip(blipModelId, getBusinessData(businessId).entrancePosition, 1, getColourByName("businessBlue"));
getBusinessData(businessId).entranceBlip = createGameBlip(getBusinessData(businessId).entrancePosition, blipModelId, 1, getColourByName("businessBlue"));
setElementOnAllDimensions(getBusinessData(businessId).entranceBlip, false);
setElementDimension(getBusinessData(businessId).entranceBlip, getBusinessData(businessId).entranceDimension);
//getBusinessData(businessId).entranceBlip.streamInDistance = 300;
@@ -1082,7 +1110,7 @@ function createBusinessExitBlip(businessId) {
blipModelId = getBusinessData(businessId).exitBlipModel;
}
getBusinessData(businessId).exitBlip = createGameBlip(blipModelId, getBusinessData(businessId).exitPosition, 1, getColourByName("businessBlue"));
getBusinessData(businessId).exitBlip = createGameBlip(getBusinessData(businessId).exitPosition, blipModelId, 1, getColourByName("businessBlue"));
setElementDimension(getBusinessData(businessId).exitBlip, getBusinessData(businessId).entranceDimension);
setElementOnAllDimensions(getBusinessData(businessId).exitBlip, false);
//getBusinessData(businessId).exitBlip.interior = getBusinessData(businessId).exitInterior;
@@ -1638,3 +1666,14 @@ function clearPlayerBusinessGameScripts(client, businessId) {
}
// ===========================================================================
function updateBusinessInteriorLightsForOccupants(businessId) {
let clients = getClients()
for(let i in clients) {
if(getPlayerBusiness(clients[i]) == businessId) {
updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights);
}
}
}
// ===========================================================================

View File

@@ -82,7 +82,8 @@ function loadCommands() {
//commandData("delbizloc", deleteBusinessLocationCommand, "[id]", getStaffFlagValue("manageBusinesses"), true, false),
commandData("bizreloadall", reloadAllBusinessesCommand, "", getStaffFlagValue("manageBusinesses"), true, false, "Reloads all businesses from the database"),
commandData("bizlock", lockBusinessCommand, "", getStaffFlagValue("none"), true, true, "Locks a business"),
commandData("bizlock", lockUnlockBusinessCommand, "", getStaffFlagValue("none"), true, true, "Locks a business"),
commandData("bizlights", toggleBusinessInteriorLightsCommand, "", getStaffFlagValue("none"), true, true, "Turns on/off a business's interior lights"),
commandData("bizbuy", buyBusinessCommand, "", getStaffFlagValue("none"), true, true, "Purchases a business"),
commandData("bizfee", setBusinessEntranceFeeCommand, "<amount>", getStaffFlagValue("none"), true, true, "Sets a fee to charge players when they enter the business."),
commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true, "Shows the business's till (cash register) amount"),
@@ -199,6 +200,7 @@ function loadCommands() {
commandData("housebuy", buyHouseCommand, "", getStaffFlagValue("none"), true, false),
commandData("housedesc", setHouseDescriptionCommand, "", getStaffFlagValue("manageHouses"), true, false),
commandData("houselock", lockUnlockHouseCommand, "", getStaffFlagValue("none"), true, false),
commandData("houselights", toggleHouseInteriorLightsCommand, "", getStaffFlagValue("none"), true, false),
commandData("houseowner", setHouseOwnerCommand, "", getStaffFlagValue("manageHouses"), true, false),
commandData("housebuyprice", setHouseBuyPriceCommand, "", getStaffFlagValue("none"), true, false),
commandData("houserentprice", setHouseRentPriceCommand, "", getStaffFlagValue("none"), true, false),
@@ -295,9 +297,7 @@ function loadCommands() {
commandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("none"), true, false, "Toggles vehicle mouse camera for games that don't have it"),
commandData("yes", playerPromptAnswerYesCommand, "", getStaffFlagValue("none"), true, false, "Answers a prompt with YES"),
commandData("no", playerPromptAnswerNoCommand, "", getStaffFlagValue("none"), true, false, "Answers a prompt with NO"),
commandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("none"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
commandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("none"), true, false, "Shows a list of all available radio stations"),
commandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("none"), true, false, "Sets the radio streaming volume (for your game only)."),
commandData("admins", listOnlineAdminsCommand, "", getStaffFlagValue("none"), true, false, "Shows a list of online admins"),
],
moderation: [
commandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("basicModeration"), true, true, "Kicks a player from the server"),
@@ -335,10 +335,16 @@ function loadCommands() {
commandData("forceskin", forcePlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("basicModeration"), true, true, "Changes a character's skin directly."),
commandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true, "Shows basic info about the specified player"),
commandData("getplrhouse", getAllHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true, "Shows a list of all houses owned by the player"),
commandData("getplrbiz", getAllBusinessesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true, "Shows a list of all businesses owned by the player"),
commandData("getplrveh", getAllVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("basicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
],
radio: [
commandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("none"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
commandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("none"), true, false, "Shows a list of all available radio stations"),
commandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("none"), true, false, "Sets the radio streaming volume (for your game only)."),
],
security: [],
startup: [],
subAccount: [

View File

@@ -153,6 +153,7 @@ function enterExitPropertyCommand(command, params, client) {
clearPlayerHouseGameScripts(client, inHouse.index);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
}, 2000);
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
removeEntityData(client, "vrr.inHouse");
@@ -194,6 +195,7 @@ function enterExitPropertyCommand(command, params, client) {
clearPlayerBusinessGameScripts(client, inBusiness.index);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
}, 2000);
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
removeEntityData(client, "vrr.inBusiness");
@@ -240,6 +242,7 @@ function enterExitPropertyCommand(command, params, client) {
if(doesBusinessHaveAnyItemsToBuy(closestBusinessId)) {
messagePlayerInfo(client, "Use /buy to purchase items from this business");
}
updateInteriorLightsForPlayer(client, closestBusiness.lights);
setTimeout(function() {
if(closestBusiness.streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != closestBusiness.streamingRadioStation) {
@@ -288,6 +291,7 @@ function enterExitPropertyCommand(command, params, client) {
fadeCamera(client, true, 1.0);
}
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
updateInteriorLightsForPlayer(client, closestHouse.lights);
setTimeout(function() {
if(closestHouse.streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != closestHouse.streamingRadioStation) {
@@ -395,3 +399,16 @@ function updateServerGameTime() {
}
// ===========================================================================
function listOnlineAdminsCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(getPlayerData(clients[i])) {
if(getPlayerData(clients[i]).accountData.flags.admin > 0) {
messagePlayerNormal(client, `• [${getPlayerData(clients[i]).accountData.staffTitle}] ${getCharacterFullName(clients[i])}`);
}
}
}
}
// ===========================================================================