Merge branch 'nightly' into ragemp

This commit is contained in:
Vortrex
2022-12-10 01:55:10 -06:00
31 changed files with 475 additions and 272 deletions

View File

@@ -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;

View File

@@ -84,6 +84,15 @@ let profanityFilterEnabled = false;
let localLocaleId = 0; let localLocaleId = 0;
/**
* @typedef {Object} ServerData
* @property {Array.<HouseData>} houses
* @property {Array.<BusinessData>} businesses
* @property {Array.<VehicleData>} vehicles
* @property {Array} localeStrings
* @property {Array} localeOptions
* @property {Object} cvars
*/
let serverData = { let serverData = {
houses: [], houses: [],
businesses: [], businesses: [],
@@ -91,6 +100,7 @@ let serverData = {
localeOptions: [], localeOptions: [],
vehicles: [], vehicles: [],
jobs: [], jobs: [],
cvars: {},
}; };
let localPlayerMoney = 0; let localPlayerMoney = 0;

View File

@@ -176,10 +176,10 @@ function onPedExitedVehicle(event, ped, vehicle, seat) {
if (areServerElementsSupported()) { if (areServerElementsSupported()) {
if (inVehicleSeat == 0) { if (inVehicleSeat == 0) {
//setVehicleEngine(vehicle.id, false); //setVehicleEngine(vehicle.id, false);
if (!inVehicle.engine) { //if (!inVehicle.engine) {
parkedVehiclePosition = false; // parkedVehiclePosition = false;
parkedVehicleHeading = false; // parkedVehicleHeading = false;
} //}
} }
} }
} }
@@ -216,7 +216,7 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
//parkedVehiclePosition = inVehicle.position; //parkedVehiclePosition = inVehicle.position;
//parkedVehicleHeading = inVehicle.heading; //parkedVehicleHeading = inVehicle.heading;
if (doesEntityDataExist(vehicle, "agrp.server") == true) { if (doesEntityDataExist(vehicle, "agrp.server") == true) {
setVehicleEngine(vehicle.id, false); //setVehicleEngine(vehicle.id, false);
setVehicleEngine(vehicle.id, getEntityData(vehicle, "agrp.engine")); setVehicleEngine(vehicle.id, getEntityData(vehicle, "agrp.engine"));
//setLocalPlayerControlState(false, false); //setLocalPlayerControlState(false, false);
} }

View File

@@ -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;

View File

@@ -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;

View File

@@ -464,4 +464,10 @@ function updatePlayerPing(playerName, ping) {
playerPing[playerName] = ping; playerPing[playerName] = ping;
} }
// ===========================================================================
function receiveClientVariablesFromServer(clientVariablesString) {
serverData.cvars = JSON.parse(clientVariablesString);
}
// =========================================================================== // ===========================================================================

View File

@@ -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")) {

View File

@@ -224,13 +224,16 @@ function setLocalPlayerInterior(interior) {
// =========================================================================== // ===========================================================================
function setSnowState(falling, ground) { function setSnowState(falling, ground, forceGround) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting falling snow to ${falling} and ground snow to ${ground}`); logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting falling snow to ${falling} and ground snow to ${ground}`);
snowing = falling; snowing = falling;
if (ground) { //snow.force = ground;
forceSnowing(false); //if (forceGround == true) {
forceSnowing(ground); // forceSnowing(forceGround);
} // groundSnow.flush();
//} else {
// snow.enabled = ground;
//}
} }
// =========================================================================== // ===========================================================================
@@ -602,7 +605,7 @@ function updateLocalPlayerMoney() {
} }
if (getGame() == AGRP_GAME_GTA_IV) { if (getGame() == AGRP_GAME_GTA_IV) {
natives.setMultiplayerHudCash(amount); natives.setMultiplayerHudCash(localPlayerMoney);
} }
} }

View File

@@ -2017,7 +2017,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;
@@ -2094,7 +2094,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) {
@@ -2864,7 +2864,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;
} }

View File

@@ -225,7 +225,7 @@ function privateMessageCommand(command, params, client) {
getPlayerData(targetClient).privateMessageReplyTo = client; getPlayerData(targetClient).privateMessageReplyTo = client;
messagePlayerPrivateMessage(targetClient, client, messageText); messagePlayerPrivateMessage(targetClient, client, messageText);
if (hasPlayerSeenActionTip(targetClient, "ReplyToDirectMessage")) { if (!hasPlayerSeenActionTip(targetClient, "ReplyToDirectMessage")) {
messagePlayerTip(targetClient, getGroupedLocaleString(targetClient, "ActionTips", "ReplyToDirectMessage", "{ALTCOLOUR}/reply{MAINCOLOUR}")); messagePlayerTip(targetClient, getGroupedLocaleString(targetClient, "ActionTips", "ReplyToDirectMessage", "{ALTCOLOUR}/reply{MAINCOLOUR}"));
} }
} }

View File

@@ -115,7 +115,7 @@ class ClientData {
// Misc // Misc
this.changingCharacterName = false; this.changingCharacterName = false;
this.currentPickup = false; this.currentPickup = null;
this.usingSkinSelect = false; this.usingSkinSelect = false;
this.keyBinds = []; this.keyBinds = [];
this.incomingDamageMultiplier = 1; this.incomingDamageMultiplier = 1;
@@ -228,7 +228,7 @@ function initClient(client) {
sendPlayerCurrencyString(client); sendPlayerCurrencyString(client);
sendPlayerGUIColours(client); sendPlayerGUIColours(client);
sendPlayerGUIInit(client); sendPlayerGUIInit(client);
updatePlayerSnowState(client); updatePlayerSnowState(client, getServerConfig().groundSnow);
//logToConsole(LOG_DEBUG, `[AGRP.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`); //logToConsole(LOG_DEBUG, `[AGRP.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
//showConnectCameraToPlayer(client); //showConnectCameraToPlayer(client);

View File

@@ -81,6 +81,8 @@ function loadCommands() {
new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"), new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"),
new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"), new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"), new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
//new CommandData("resetkeybinds", resetKeyBindsCommand, "", getStaffFlagValue("None"), true, false, "Resets all your keybinds to default"),
//new CommandData("copykeybinds", copyKeyBindsToServerCommand, "<server id>", getStaffFlagValue("None"), true, false, "Copies all your current keybinds to another server"),
//new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"), //new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"),
], ],
ammunation: [], ammunation: [],
@@ -593,6 +595,7 @@ function loadCommands() {
new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"), new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"), new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"), new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
//new CommandData("clearchat", clearChatCommand, "", getStaffFlagValue("None"), true, true, "Clears the chat"),
], ],
startup: [], startup: [],
subAccount: [ subAccount: [
@@ -719,6 +722,9 @@ function addAllCommandHandlers() {
// =========================================================================== // ===========================================================================
/**
* @return {CommandData} command
*/
function getCommand(command) { function getCommand(command) {
let commandGroups = getCommands() let commandGroups = getCommands()
for (let i in commandGroups) { for (let i in commandGroups) {
@@ -735,6 +741,9 @@ function getCommand(command) {
// =========================================================================== // ===========================================================================
/**
* @return {CommandData} command
*/
function getCommandData(command) { function getCommandData(command) {
return getCommand(command); return getCommand(command);
} }
@@ -1029,10 +1038,10 @@ function cacheAllCommandsAliases() {
// =========================================================================== // ===========================================================================
function getCommandAliasesNames(command) { function getCommandAliasesNames(commandData) {
let commandAliases = []; let commandAliases = [];
for (let i in command.aliases) { for (let i in commandData.aliases) {
commandAliases.push(command.aliases[i].name); commandAliases.push(commandData.aliases[i].name);
} }
return commandAliases; return commandAliases;

View File

@@ -387,7 +387,7 @@ function applyConfigToServer(tempServerConfig) {
if (isWeatherSupported()) { if (isWeatherSupported()) {
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`); logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
game.forceWeather(tempServerConfig.weather); game.forceWeather(getWeatherData(tempServerConfig.weather).weatherId);
} }
updateServerRules(); updateServerRules();
@@ -583,19 +583,19 @@ function setWeatherCommand(command, params, client) {
return false; return false;
} }
let weatherId = getWeatherFromParams(getParam(params, " ", 1)); let weatherIndex = getWeatherFromParams(getParam(params, " ", 1));
if (!weatherId) { if (!getWeatherData(weatherIndex)) {
messagePlayerError(client, `That weather ID or name is invalid!`); messagePlayerError(client, `That weather ID or name is invalid!`);
return false; return false;
} }
game.forceWeather(toInteger(weatherId)); game.forceWeather(getWeatherData(weatherIndex).weatherId);
getServerConfig().weather = weatherId; getServerConfig().weather = weatherIndex;
getServerConfig().needsSaved = true; getServerConfig().needsSaved = true;
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getGame()][toInteger(weatherId)]); announceAdminAction("ServerWeatherSet", getPlayerName(client), getWeatherData(weatherIndex).name);
updateServerRules(); updateServerRules();
return true; return true;
} }

View File

@@ -8,9 +8,9 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
let scriptVersion = "1.2"; let scriptVersion = "1.3";
let serverStartTime = 0; let serverStartTime = 0;
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE; // LOG_ERROR|LOG_WARN; let logLevel = LOG_INFO | LOG_ERROR | LOG_WARN;
let playerResourceReady = new Array(server.maxClients).fill(false); let playerResourceReady = new Array(server.maxClients).fill(false);
let playerResourceStarted = new Array(server.maxClients).fill(false); let playerResourceStarted = new Array(server.maxClients).fill(false);

View File

@@ -205,12 +205,6 @@ function onPedExitingVehicle(event, ped, vehicle) {
let client = getClientFromPlayerElement(ped); let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGVEHICLE; getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGVEHICLE;
} }
if (!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
} }
// =========================================================================== // ===========================================================================
@@ -247,16 +241,16 @@ function onResourceStop(event, resource) {
function onPedEnteredSphere(event, ped, sphere) { function onPedEnteredSphere(event, ped, sphere) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} entered sphere ${sphere.id}!`); logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} entered sphere ${sphere.id}!`);
if (ped.isType(ELEMENT_PLAYER)) { //if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped); // let client = getClientFromPlayerElement(ped);
// Handled client-side since server spheres aren't showing on GTAC atm (bug) // Handled client-side since server spheres aren't showing on GTAC atm (bug)
//if (isPlayerOnJobRoute(client)) { //if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) { // if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
// playerArrivedAtJobRouteLocation(client); // playerArrivedAtJobRouteLocation(client);
// } // }
//} //}
} //}
} }
// =========================================================================== // ===========================================================================
@@ -286,6 +280,7 @@ function onPedPickupPickedUp(event, ped, pickup) {
// =========================================================================== // ===========================================================================
/*
function onPedWasted(event, ped, killerPed, weapon, pedPiece) { function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} wasted by ped ${killerPed.id}!`); logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} wasted by ped ${killerPed.id}!`);
@@ -297,6 +292,7 @@ function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
onPlayerWasted(getClientFromPlayerElement(ped), killerClient, weapon, pedPiece); onPlayerWasted(getClientFromPlayerElement(ped), killerClient, weapon, pedPiece);
} }
} }
*/
// =========================================================================== // ===========================================================================
@@ -396,12 +392,12 @@ function onPlayerDeath(client, killer, weapon, pedPiece) {
function onPedSpawn(ped) { 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, ped); // //setTimeout(onPlayerSpawn, 250, getClientFromPlayerElement(ped));
//onPlayerSpawn(); // //onPlayerSpawn(getClientFromPlayerElement(ped));
} // }
} //}
} }
// =========================================================================== // ===========================================================================
@@ -458,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);
} }
@@ -509,10 +505,10 @@ async function onPlayerSpawn(client) {
setPlayer2DRendering(client, true, true, true, true, true, true); setPlayer2DRendering(client, true, true, true, true, true, true);
} }
if (isGameFeatureSupported("snow")) { //if (isGameFeatureSupported("snow")) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`); // logToConsole(LOG_DEBUG, `[AGRP.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
updatePlayerSnowState(client); // updatePlayerSnowState(client, true);
} //}
if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) { if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`); logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
@@ -589,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);
} }
@@ -629,7 +627,9 @@ async function onPlayerSpawn(client) {
if (areServerElementsSupported()) { if (areServerElementsSupported()) {
if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) { if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) {
getPlayerPed(client).netFlags.distanceStreaming = false; //getPlayerPed(client).netFlags.distanceStreaming = false;
setElementStreamInDistance(getPlayerPed(client), 99999);
setElementStreamOutDistance(getPlayerPed(client), 99999);
} else { } else {
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance); setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance); setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
@@ -676,11 +676,21 @@ 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) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY; getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
if (getVehicleData(vehicle).spawnLocked == false && canPlayerManageVehicle(client, vehicle) == true) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
stopRadioStreamForPlayer(client); stopRadioStreamForPlayer(client);
if (!getVehicleData(vehicle)) { if (!getVehicleData(vehicle)) {
@@ -714,10 +724,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;
} }

View File

@@ -348,22 +348,23 @@ function showCommandHelpMessage(client, commandName) {
commandName = commandName.slice(1); commandName = commandName.slice(1);
} }
let command = getCommandData(commandName); let commandData = getCommandData(commandName);
let aliases = getCommandAliasesNames(command); let aliases = getCommandAliasesNames(commandData);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName))); messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${commandData.helpDescription}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usage: /${commandData.command} ${commandData.syntaxString}`);
if (aliases.length > 0) { if (aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.map(alias => `/${alias.command}`).join(", ")}`);
} else { } else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`); messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
} }
//messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`); //messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(commandData.allowOnDiscord)}`);
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) { //if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`); // messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(commandData.allowOnDiscord)}`);
//} //}
} }

View File

@@ -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;
} }

View File

@@ -106,14 +106,14 @@ function copyKeyBindsToServerCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function addPlayerKeyBind(client, keys, command, params, tempKey = false) { function addPlayerKeyBind(client, keyId, command, params, tempKey = false) {
let keyBindData = new KeyBindData(false, keys, `${command} ${params}`); let keyBindData = new KeyBindData(false, keys, `${command} ${params}`);
if (tempKey == true) { if (tempKey == true) {
keyBindData.databaseId = -1; keyBindData.databaseId = -1;
} }
getPlayerData(client).keyBinds.push(keyBindData); getPlayerData(client).keyBinds.push(keyBindData);
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? AGRP_KEYSTATE_COMBO : AGRP_KEYSTATE_UP); sendAddAccountKeyBindToClient(client, keyId, AGRP_KEYSTATE_UP);
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) { if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter"); let keyId = getPlayerKeyBindForCommand(client, "enter");

View File

@@ -297,7 +297,7 @@ async function translateMessage(messageText, translateFrom = getGlobalConfig().l
// =========================================================================== // ===========================================================================
function getLocaleFromCountryISO(isoCode) { function getLocaleFromCountryISO(isoCode = "US") {
for (let i in getLocales()) { for (let i in getLocales()) {
for (let j in getLocales()[i].countries) { for (let j in getLocales()[i].countries) {
if (toLowerCase(getLocales()[i].countries[j]) == toLowerCase(isoCode)) { if (toLowerCase(getLocales()[i].countries[j]) == toLowerCase(isoCode)) {

View File

@@ -232,7 +232,8 @@ function messagePlayersInRace(raceId, message) {
// =========================================================================== // ===========================================================================
function messagePlayerPrivateMessage(toClient, fromClient, messageText) { function messagePlayerPrivateMessage(toClient, fromClient, messageText) {
messagePlayerNormal(toClient, `{yellow}[DM] ${getCharacterFullName(fromClient)}{MAINCOLOUR}says: {ALTCOLOUR}${messageText}`); messagePlayerNormal(toClient, `📥 {yellow}DM from ${getCharacterFullName(fromClient)}{MAINCOLOUR}: ${messageText}`);
messagePlayerNormal(fromClient, `📤 {yellow}DM to ${getCharacterFullName(toClient)}{MAINCOLOUR}: ${messageText}`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -211,42 +211,52 @@ function enterExitPropertyCommand(command, params, client) {
return false; return false;
} }
let position = getPlayerPosition(client);
let dimension = getPlayerDimension(client);
/*
// The player's currentPickup wasn't always being set. This prevented entering/exiting a property. // The player's currentPickup wasn't always being set. This prevented entering/exiting a property.
// Needs further testing and tweaks. // Needs further testing and tweaks.
if (!getPlayerData(client).currentPickup) { if (getPlayerData(client).currentPickup != null) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type"); if (getDistance(getPlayerData(client).currentPickup.position, getPlayerPosition(client)) <= 2) {
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id"); let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id");
switch (ownerType) { switch (ownerType) {
case AGRP_PICKUP_BUSINESS_ENTRANCE: case AGRP_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true; isBusiness = true;
isEntrance = true; isEntrance = true;
closestProperty = getServerData().businesses[ownerId]; closestProperty = getServerData().businesses[ownerId];
break; break;
case AGRP_PICKUP_BUSINESS_EXIT: case AGRP_PICKUP_BUSINESS_EXIT:
isBusiness = true; isBusiness = true;
isEntrance = false; isEntrance = false;
closestProperty = getServerData().businesses[ownerId]; closestProperty = getServerData().businesses[ownerId];
break; break;
case AGRP_PICKUP_HOUSE_ENTRANCE: case AGRP_PICKUP_HOUSE_ENTRANCE:
isBusiness = false; isBusiness = false;
isEntrance = true; isEntrance = true;
closestProperty = getServerData().houses[ownerId]; closestProperty = getServerData().houses[ownerId];
break; break;
case AGRP_PICKUP_HOUSE_EXIT: case AGRP_PICKUP_HOUSE_EXIT:
isBusiness = false; isBusiness = false;
isEntrance = false; isEntrance = false;
closestProperty = getServerData().houses[ownerId]; closestProperty = getServerData().houses[ownerId];
break; break;
default: default:
return false; return false;
}
} else {
getPlayerData(client).currentPickup = null;
} }
} }
*/
/*
// Check businesses first // Check businesses first
if (closestProperty == null) { if (closestProperty == null) {
let businessIndex = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); let businessIndex = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
@@ -284,6 +294,48 @@ function enterExitPropertyCommand(command, params, client) {
closestProperty = getServerData().houses[houseIndex]; closestProperty = getServerData().houses[houseIndex];
} }
} }
*/
// Check businesses first
if (closestProperty == null) {
for (let i in getServerData().businesses) {
if (getServerData().businesses[i].entranceDimension == dimension) {
if (getDistance(position, getServerData().businesses[i].entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[i];
}
} else {
if (getServerData().businesses[i].exitDimension == dimension) {
if (getDistance(position, getServerData().businesses[i].exitPosition) <= getGlobalConfig().exitPropertyDistance) {
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[i];
}
}
}
}
}
if (closestProperty == null) {
for (let i in getServerData().houses) {
if (getServerData().houses[i].entranceDimension == dimension) {
if (getDistance(position, getServerData().houses[i].entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[i];
}
} else {
if (getServerData().houses[i].exitDimension == dimension) {
if (getDistance(position, getServerData().houses[i].exitPosition) <= getGlobalConfig().exitPropertyDistance) {
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[i];
}
}
}
}
}
if (closestProperty == null) { if (closestProperty == null) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is null`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is null`);
@@ -293,7 +345,7 @@ function enterExitPropertyCommand(command, params, client) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`);
let englishId = getLocaleFromParams("English"); let englishId = getLocaleFromParams("English");
let typeString = (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House"); let typeString = (isBusiness) ? getLanguageLocaleString(englishId, "Business") : getLanguageLocaleString(englishId, "House");
let nameString = (isBusiness) ? closestProperty.name : closestProperty.description; let nameString = (isBusiness) ? closestProperty.name : closestProperty.description;
if (isEntrance) { if (isEntrance) {

View File

@@ -193,9 +193,9 @@ function getVehicleHeading(vehicle) {
// =========================================================================== // ===========================================================================
function setVehicleHeading(vehicle, heading) { function setVehicleHeading(vehicle, heading) {
if (getGame() == AGRP_GAME_GTA_IV) { //if (getGame() == AGRP_GAME_GTA_IV) {
return sendNetworkEventToPlayer("agrp.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading); // return sendNetworkEventToPlayer("agrp.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
} //}
return vehicle.heading = heading; return vehicle.heading = heading;
} }
@@ -227,12 +227,12 @@ function getVehicleSyncer(vehicle) {
// =========================================================================== // ===========================================================================
function getVehicleForNetworkEvent(vehicle) { function getVehicleForNetworkEvent(vehicle) {
if (getGame() == AGRP_GAME_GTA_IV) { //if (getGame() == AGRP_GAME_GTA_IV) {
if (getVehicleData(vehicle).ivNetworkId != -1) { // if (getVehicleData(vehicle).ivNetworkId != -1) {
return getVehicleData(vehicle).ivNetworkId; // return getVehicleData(vehicle).ivNetworkId;
} // }
return -1; // return -1;
} //}
return vehicle.id; return vehicle.id;
} }
@@ -588,14 +588,17 @@ function setVehicleLights(vehicle, lights) {
// =========================================================================== // ===========================================================================
function setVehicleEngine(vehicle, engine) { function setVehicleEngine(vehicle, engine) {
vehicle.engine = engine; //vehicle.engine = engine;
setEntityData(vehicle, "agrp.engine", engine, true); setEntityData(vehicle, "agrp.engine", engine, true);
sendNetworkEventToPlayer("agrp.veh.engine", null, vehicle.id, engine);
} }
// =========================================================================== // ===========================================================================
function setVehicleLocked(vehicle, locked) { function setVehicleLocked(vehicle, locked) {
vehicle.locked = locked; vehicle.locked = locked;
setEntityData(vehicle, "agrp.locked", locked, true);
sendNetworkEventToPlayer("agrp.veh.locked", null, vehicle.id, locked);
} }
// =========================================================================== // ===========================================================================
@@ -1112,9 +1115,9 @@ function getClosestCivilian(position) {
// =========================================================================== // ===========================================================================
function getVehiclesInRange(position, range) { function getVehiclesInRange(position, range) {
if (getGame() == AGRP_GAME_GTA_IV) { //if (getGame() == AGRP_GAME_GTA_IV) {
return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j); // return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j);
} //}
return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range); return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range);
} }
@@ -1241,11 +1244,11 @@ function getPlayerPed(client) {
return null; return null;
} }
if (getGame() == AGRP_GAME_GTA_IV) { //if (getGame() == AGRP_GAME_GTA_IV) {
return getPlayerData(client).ped; // return getPlayerData(client).ped;
} else { //} else {
return client.player; return client.player;
} //}
} }
// =========================================================================== // ===========================================================================

View File

@@ -222,10 +222,10 @@ function syncPlayerProperties(client) {
// =========================================================================== // ===========================================================================
function updatePlayerSnowState(client) { function updatePlayerSnowState(client, forceGroundSnow = false) {
if (isSnowSupported(getGame())) { if (isSnowSupported(getGame())) {
logToConsole(LOG_DEBUG, `[AGRP.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`); logToConsole(LOG_DEBUG, `[AGRP.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`);
sendNetworkEventToPlayer("agrp.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); sendNetworkEventToPlayer("agrp.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow, forceGroundSnow);
} }
} }
@@ -1317,4 +1317,10 @@ function fadePlayerCamera(client, fadeIn, time, colour = toColour(0, 0, 0, 255))
sendNetworkEventToPlayer("agrp.fadeCamera", client, fadeIn, time, colour); sendNetworkEventToPlayer("agrp.fadeCamera", client, fadeIn, time, colour);
} }
// ==========================================================================
function sendClientVariablesToClient(client) {
sendNetworkEventToPlayer("agrp.cvar", client, JSON.stringify(clientVariables));
}
// ========================================================================== // ==========================================================================

View File

@@ -245,7 +245,22 @@ function playerPromptAnswerYes(client) {
} }
case AGRP_PROMPT_RESETKEYBINDS: { case AGRP_PROMPT_RESETKEYBINDS: {
messagePlayerSuccess(client, getLocaleString(client, "KeyBindsReset")); // TODO: Needs database query!
//for (let i in getPlayerData(client).keyBinds) {
// removePlayerKeyBind(client, getPlayerData(client).keyBinds[i].key)
//}
//for (let i in getGlobalConfig().keyBind.defaultKeyBinds) {
// let tempKeyBindData = new KeyBindData(false);
// tempKeyBindData.databaseId = -1;
// tempKeyBindData.key = getKeyIdFromParams(getGlobalConfig().keyBind.defaultKeyBinds[i].keyName);
// tempKeyBindData.commandString = getGlobalConfig().keyBind.defaultKeyBinds[i].commandString;
// tempKeyBindData.keyState = getGlobalConfig().keyBind.defaultKeyBinds[i].keyState;
// getPlayerData(client).keyBinds.push(tempKeyBindData);
//}
//messagePlayerSuccess(client, getLocaleString(client, "KeyBindsReset"));
break; break;
} }

View File

@@ -517,22 +517,9 @@ function selectCharacter(client, characterId = -1) {
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
getPlayerData(client).pedState = AGRP_PEDSTATE_SPAWNING; getPlayerData(client).pedState = AGRP_PEDSTATE_SPAWNING;
if (getGame() <= AGRP_GAME_GTA_SA) { if (getGame() <= AGRP_GAME_GTA_IV_EFLC) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
onPlayerSpawn(client); onPlayerSpawn(client);
} else if (getGame() == AGRP_GAME_GTA_IV) {
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
clearPlayerWeapons(client);
setPlayerPosition(client, spawnPosition);
setPlayerHeading(client, spawnHeading);
//setPlayerInterior(client, spawnInterior);
//setPlayerDimension(client, spawnDimension);
restorePlayerCamera(client);
setPlayerSkin(client, skin);
setTimeout(function () {
onPlayerSpawn(client);
//stopRadioStreamForPlayer(client);
}, 500);
} else if (getGame() == AGRP_GAME_MAFIA_ONE) { } else if (getGame() == AGRP_GAME_MAFIA_ONE) {
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]); //spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]);
//logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`); //logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`);

View File

@@ -134,11 +134,18 @@ function thirtyMinuteTimerFunction() {
checkPayDays(); checkPayDays();
} }
checkInactiveVehicleRespawns();
if (isGameFeatureSupported("snow")) { if (isGameFeatureSupported("snow")) {
checkSnowChance(); setSnowWithChance();
} }
checkInactiveVehicleRespawns(); if (isGameFeatureSupported("weather")) {
setRandomWeather();
}
updateServerRules();
saveServerDataToDatabase(); saveServerDataToDatabase();
} }
@@ -330,7 +337,7 @@ function checkInactiveVehicleRespawns() {
if (getVehicleData(vehicles[i]).lastActiveTime != false) { if (getVehicleData(vehicles[i]).lastActiveTime != false) {
if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) { if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]); respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false; //getVehicleData(vehicles[i]).lastActiveTime = false;
} }
} }
} else { } else {
@@ -342,13 +349,31 @@ function checkInactiveVehicleRespawns() {
// =========================================================================== // ===========================================================================
function checkSnowChance() { function setSnowWithChance() {
let date = new Date(); let date = new Date();
let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonths()]); let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonth()]);
getServerConfig().groundSnow = shouldBeSnowing; getServerConfig().groundSnow = shouldBeSnowing;
getServerConfig().fallingSnow = shouldBeSnowing; getServerConfig().fallingSnow = shouldBeSnowing;
updatePlayerSnowState(null);
updatePlayerSnowState(null, false);
}
// ===========================================================================
function setRandomWeather() {
let randomWeatherIndex = getRandom(0, getGameConfig().weather[getGame()].length - 1);
if (getServerConfig().fallingSnow == true) {
while (getWeatherData(randomWeatherIndex).allowWithSnow == false) {
randomWeatherIndex = getRandom(0, getGameConfig().weather[getGame()].length - 1);
}
}
game.forceWeather(getWeatherData(randomWeatherIndex).weatherId);
getServerConfig().weather = randomWeatherIndex;
getServerConfig().needsSaved = true;
} }
// =========================================================================== // ===========================================================================

View File

@@ -101,8 +101,8 @@ function updateServerRules() {
if (isWeatherSupported()) { if (isWeatherSupported()) {
if (getServerConfig() != false) { if (getServerConfig() != false) {
if (typeof getGameConfig().weatherNames[getGame()] != "undefined") { if (getWeatherData(getServerConfig().weather) != false) {
let tempText = getGameConfig().weatherNames[getGame()][getServerConfig().weather]; let tempText = getWeatherData(getServerConfig().weather).name;
timeWeatherRule.push(tempText); timeWeatherRule.push(tempText);
} }
} }
@@ -124,14 +124,16 @@ function updateServerRules() {
function getWeatherFromParams(params) { function getWeatherFromParams(params) {
if (isNaN(params)) { if (isNaN(params)) {
for (let i in getGameConfig().weatherNames[getGame()]) { for (let i in getGameConfig().weather[getGame()]) {
if (toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) { if (toLowerCase(getGameConfig().weather[getGame()][i].name).indexOf(toLowerCase(params)) != -1) {
return i; return i;
} }
} }
} else { } else {
if (typeof getGameConfig().weatherNames[getGame()][params] != "undefined") { for (let i in getGameConfig().weather[getGame()]) {
return toInteger(params); if (typeof getGameConfig().weather[getGame()][i].weatherId != "undefined") {
return toInteger(i);
}
} }
} }
@@ -439,11 +441,13 @@ function isClientInitialized(client) {
// =========================================================================== // ===========================================================================
function getPedForNetworkEvent(ped) { function getPedForNetworkEvent(ped) {
if (getGame() == AGRP_GAME_GTA_IV) { //if (getGame() == AGRP_GAME_GTA_IV) {
return ped; // return ped;
} else { //} else {
return ped.id; // return ped.id;
} //}
return ped.id;
} }
// =========================================================================== // ===========================================================================
@@ -638,6 +642,10 @@ function processPlayerEnteringExitingProperty(client) {
// =========================================================================== // ===========================================================================
function getPlayerCountryISOCode(client) { function getPlayerCountryISOCode(client) {
if (getPlayerIP(client) == "127.0.0.1" || getPlayerIP(client).indexOf("192.168.") != -1) {
return "US";
}
return module.geoip.getCountryISO(getGlobalConfig().geoIPCountryDatabaseFilePath, getPlayerIP(client)); return module.geoip.getCountryISO(getGlobalConfig().geoIPCountryDatabaseFilePath, getPlayerIP(client));
} }

View File

@@ -19,14 +19,6 @@ const AGRP_VEHOWNER_BIZ = 6; // Owned by a business (also i
// =========================================================================== // ===========================================================================
// Vehicle Seats
const AGRP_VEHSEAT_DRIVER = 0;
const AGRP_VEHSEAT_FRONTPASSENGER = 1;
const AGRP_VEHSEAT_REARLEFTPASSENGER = 2;
const AGRP_VEHSEAT_REARRIGHTPASSENGER = 3;
// ===========================================================================
/** /**
* @class Representing a vehicle's data. Loaded and saved in the database * @class Representing a vehicle's data. Loaded and saved in the database
* @property {Array.<Number>} trunkItemCache * @property {Array.<Number>} trunkItemCache
@@ -165,6 +157,14 @@ class VehicleData {
this.licensePlate = toInteger(dbAssoc["veh_license_plate"]); this.licensePlate = toInteger(dbAssoc["veh_license_plate"]);
} }
} }
saveToDatabase() {
saveVehicleToDatabase(this);
}
respawn() {
respawnVehicle(this.vehicle);
}
}; };
// =========================================================================== // ===========================================================================
@@ -327,8 +327,8 @@ function spawnAllVehicles() {
let vehicle = spawnVehicle(getServerData().vehicles[i]); let vehicle = spawnVehicle(getServerData().vehicles[i]);
getServerData().vehicles[i].vehicle = vehicle; getServerData().vehicles[i].vehicle = vehicle;
setEntityData(vehicle, "agrp.dataSlot", i, false); setEntityData(vehicle, "agrp.dataSlot", i, false);
setAllVehicleIndexes();
} }
setAllVehicleIndexes();
} }
// =========================================================================== // ===========================================================================
@@ -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;
@@ -428,11 +424,11 @@ function getNearbyVehiclesCommand(command, params, client) {
} }
let vehiclesList = nearbyVehicles.map(function (x) { let vehiclesList = nearbyVehicles.map(function (x) {
return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {mediumGrey}(${toFloat(getDistance(getPlayerPosition(client), getVehiclePosition(x)), 2)} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections", getCardinalDirectionName(getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))))}`; return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {mediumGrey}(${toFloat(getDistance(getPlayerPosition(client), getVehiclePosition(x))).toFixed(2)} ${toLowerCase(getLocaleString(client, "Meters"))} ${toLowerCase(getGroupedLocaleString(client, "CardinalDirections", getCardinalDirectionName(getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x)))))})`;
}); });
let chunkedList = splitArrayIntoChunks(vehiclesList, 4); let chunkedList = splitArrayIntoChunks(vehiclesList, 4);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList", `${distance} ${getLocaleString(client, "Meters")} `))); messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList", `${distance} ${toLowerCase(getLocaleString(client, "Meters"))}`)));
for (let i in chunkedList) { for (let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", ")); messagePlayerInfo(client, chunkedList[i].join(", "));
} }
@@ -609,8 +605,8 @@ function vehicleAdminColourCommand(command, params, client) {
let colour1 = toInteger(getParam(params, " ", 1)) || 0; let colour1 = toInteger(getParam(params, " ", 1)) || 0;
let colour2 = toInteger(getParam(params, " ", 2)) || 0; let colour2 = toInteger(getParam(params, " ", 2)) || 0;
takePlayerCash(client, getGlobalConfig().resprayVehicleCost); //takePlayerCash(client, getGlobalConfig().resprayVehicleCost);
updatePlayerCash(client); //updatePlayerCash(client);
vehicle.colour1 = colour1; vehicle.colour1 = colour1;
vehicle.colour2 = colour2; vehicle.colour2 = colour2;
getVehicleData(vehicle).colour1 = colour1; getVehicleData(vehicle).colour1 = colour1;
@@ -618,7 +614,7 @@ function vehicleAdminColourCommand(command, params, client) {
getVehicleData(vehicle).needsSaved = true; getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`); //meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`);
} }
// =========================================================================== // ===========================================================================
@@ -639,10 +635,10 @@ function vehicleAdminRepairCommand(command, params, client) {
} }
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} repaired their ${getVehicleName(vehicle)} vehicle`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} repaired their ${getVehicleName(vehicle)} vehicle`);
takePlayerCash(client, getGlobalConfig().repairVehicleCost); //takePlayerCash(client, getGlobalConfig().repairVehicleCost);
repairVehicle(vehicle); repairVehicle(vehicle);
getVehicleData(vehicle).needsSaved = true; getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}`); //meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}`);
} }
// =========================================================================== // ===========================================================================
@@ -660,10 +656,10 @@ function vehicleAdminLiveryCommand(command, params, client) {
return false; return false;
} }
if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) { //if (getPlayerCurrentSubAccount(client).cash < getGlobalConfig().repairVehicleCost) {
messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need ${getCurrencyString(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`); // messagePlayerError(client, `You don't have enough money to change the vehicle's livery (need ${getCurrencyString(getGlobalConfig().resprayVehicleCost - getPlayerCurrentSubAccount(client).cash)} more!)`);
return false; // return false;
} //}
let livery = toInteger(params) || 3; let livery = toInteger(params) || 3;
@@ -675,7 +671,7 @@ function vehicleAdminLiveryCommand(command, params, client) {
setEntityData(vehicle, "agrp.livery", livery, true); setEntityData(vehicle, "agrp.livery", livery, true);
forcePlayerToSyncElementProperties(null, vehicle); forcePlayerToSyncElementProperties(null, vehicle);
meActionToNearbyPlayers(client, `sets the ${getVehicleName(vehicle)}'s livery/paintjob'`); //meActionToNearbyPlayers(client, `sets the ${getVehicleName(vehicle)}'s livery/paintjob'`);
} }
// =========================================================================== // ===========================================================================
@@ -698,6 +694,11 @@ function buyVehicleCommand(command, params, client) {
return false; return false;
} }
if (doesPlayerOwnVehicle(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "AlreadyOwnVehicle"));
return false;
}
if (getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) { if (getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney")); messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
return false; return false;
@@ -845,7 +846,7 @@ function doesPlayerHaveVehicleKeys(client, vehicle) {
// =========================================================================== // ===========================================================================
function doesClientOwnVehicle(client, vehicle) { function canPlayerManageVehicle(client, vehicle) {
let vehicleData = getVehicleData(vehicle); let vehicleData = getVehicleData(vehicle);
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
@@ -866,6 +867,40 @@ function doesClientOwnVehicle(client, vehicle) {
} }
} }
if (vehicleData.ownerType == AGRP_VEHOWNER_BIZ) {
if (canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(vehicleData.ownerId))) {
return true;
}
}
return false;
}
// ===========================================================================
function doesPlayerOwnVehicle(client, vehicle) {
let vehicleData = getVehicleData(vehicle);
if (vehicleData.ownerType == AGRP_VEHOWNER_PLAYER) {
if (vehicleData.ownerId == getPlayerData(client).accountData.databaseId) {
return true;
}
}
if (vehicleData.ownerType == AGRP_VEHOWNER_CLAN) {
if (vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) {
if (doesPlayerHaveClanPermission(client, "ManageVehicles") || doesPlayerHaveClanPermission(client, "owner")) {
return true;
}
}
}
if (vehicleData.ownerType == AGRP_VEHOWNER_BIZ) {
if (canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(vehicleData.ownerId))) {
return true;
}
}
return false; return false;
} }
@@ -1079,9 +1114,10 @@ function setVehicleRentPriceCommand(command, params, client) {
return false; return false;
} }
if (!doesClientOwnVehicle(client, vehicle)) { if (!canPlayerManageVehicle(client, vehicle)) {
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
messagePlayerError(client, "You can't set the rent price for this vehicle!"); messagePlayerError(client, "You can't set the rent price for this vehicle!");
return false;
} }
} }
@@ -1108,9 +1144,10 @@ function setVehicleBuyPriceCommand(command, params, client) {
return false; return false;
} }
if (!doesClientOwnVehicle(client, vehicle)) { if (!canPlayerManageVehicle(client, vehicle)) {
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) { if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
messagePlayerError(client, "You can't set the buy price for this vehicle!"); messagePlayerError(client, "You can't set the buy price for this vehicle!");
return false;
} }
} }
@@ -1666,7 +1703,6 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim
setEntityData(vehicle, "agrp.dataSlot", slot - 1, false); setEntityData(vehicle, "agrp.dataSlot", slot - 1, false);
} }
return vehicle; return vehicle;
} }

View File

@@ -138,3 +138,9 @@ const AGRP_NPC_ACTION_SPRINTTO = 4;
const AGRP_NPC_ACTION_FOLLOW = 5; const AGRP_NPC_ACTION_FOLLOW = 5;
const AGRP_NPC_ACTION_DEFEND = 6; const AGRP_NPC_ACTION_DEFEND = 6;
const AGRP_NPC_ACTION_GUARD_AREA = 7; const AGRP_NPC_ACTION_GUARD_AREA = 7;
// Vehicle Seats
const AGRP_VEHSEAT_DRIVER = 0;
const AGRP_VEHSEAT_FRONTPASSENGER = 1;
const AGRP_VEHSEAT_REARLEFTPASSENGER = 2;
const AGRP_VEHSEAT_REARRIGHTPASSENGER = 3;

View File

@@ -29,6 +29,16 @@ class AnimationData {
// =========================================================================== // ===========================================================================
class WeatherData {
constructor(weatherId, name, allowWithSnow) {
this.weatherId = weatherId;
this.name = name;
this.allowWithSnow = allowWithSnow;
}
}
// ===========================================================================
let supportedFeatures = { let supportedFeatures = {
// Invalid, GTAIII, GTAVC, GTASA, Invalid, GTAIV, Invalid, Invalid, Invalid, M1, M2, M3, M1DE // Invalid, GTAIII, GTAVC, GTASA, Invalid, GTAIV, Invalid, Invalid, Invalid, M1, M2, M3, M1DE
time: { time: {
@@ -55,8 +65,8 @@ let supportedFeatures = {
[AGRP_GAME_GTA_III]: true, [AGRP_GAME_GTA_III]: true,
[AGRP_GAME_GTA_VC]: true, [AGRP_GAME_GTA_VC]: true,
[AGRP_GAME_GTA_SA]: true, [AGRP_GAME_GTA_SA]: true,
[AGRP_GAME_GTA_IV]: false, [AGRP_GAME_GTA_IV]: true,
[AGRP_GAME_GTA_IV_EFLC]: false, [AGRP_GAME_GTA_IV_EFLC]: true,
[AGRP_GAME_MAFIA_ONE]: true, [AGRP_GAME_MAFIA_ONE]: true,
[AGRP_GAME_MAFIA_TWO]: true, [AGRP_GAME_MAFIA_TWO]: true,
[AGRP_GAME_MAFIA_THREE]: true [AGRP_GAME_MAFIA_THREE]: true
@@ -126,8 +136,8 @@ let supportedFeatures = {
[AGRP_GAME_GTA_III]: true, [AGRP_GAME_GTA_III]: true,
[AGRP_GAME_GTA_VC]: true, [AGRP_GAME_GTA_VC]: true,
[AGRP_GAME_GTA_SA]: true, [AGRP_GAME_GTA_SA]: true,
[AGRP_GAME_GTA_IV]: false, [AGRP_GAME_GTA_IV]: true,
[AGRP_GAME_GTA_IV_EFLC]: false, [AGRP_GAME_GTA_IV_EFLC]: true,
[AGRP_GAME_MAFIA_ONE]: false, [AGRP_GAME_MAFIA_ONE]: false,
[AGRP_GAME_MAFIA_TWO]: false, [AGRP_GAME_MAFIA_TWO]: false,
[AGRP_GAME_MAFIA_THREE]: false [AGRP_GAME_MAFIA_THREE]: false
@@ -563,77 +573,79 @@ let gameData = {
} }
}, },
weatherNames: { weather: {
[AGRP_GAME_GTA_III]: [ // GTA III [AGRP_GAME_GTA_III]: [ // GTA III
"Clear", new WeatherData(0, "Clear", true),
"Overcast", new WeatherData(1, "Overcast", false),
"Thunderstorm", new WeatherData(2, "Thunderstorm", false),
"Fog", new WeatherData(3, "Fog", true),
"Clear", new WeatherData(4, "Clear", false),
"Rainy", new WeatherData(5, "Rainy", false),
"Dark/Cloudy", new WeatherData(6, "Dark/Cloudy", false),
"Light/Cloudy", new WeatherData(7, "Light/Cloudy", false),
"Overcast/Cloudy", new WeatherData(8, "Overcast/Cloudy", true),
"Grey/Cloudy" new WeatherData(9, "Grey/Cloudy", false),
], ],
[AGRP_GAME_GTA_VC]: [ // GTA Vice City [AGRP_GAME_GTA_VC]: [ // GTA Vice City
"Partly Cloudy", new WeatherData(0, "Clear", true),
"Overcast", new WeatherData(1, "Overcast", false),
"Thunderstorm", new WeatherData(2, "Thunderstorm", false),
"Fog", new WeatherData(3, "Fog", true),
"Sunny", new WeatherData(4, "Sunny", false),
"Hurricane", new WeatherData(5, "Hurricane", false),
"Dark/Cloudy", new WeatherData(6, "Dark/Cloudy", false),
"Light/Cloudy", new WeatherData(7, "Light/Cloudy", false),
"Overcast/Cloudy", new WeatherData(8, "Overcast/Cloudy", true),
"Grey/Cloudy" new WeatherData(9, "Grey/Cloudy", false),
], ],
[AGRP_GAME_GTA_SA]: [ // GTA San Andreas [AGRP_GAME_GTA_SA]: [ // GTA San Andreas
"Blue Skies", new WeatherData(0, "Blue Skies", false),
"Blue Skies", new WeatherData(1, "Blue Skies", false),
"Blue Skies", new WeatherData(2, "Blue Skies", false),
"Blue Skies", new WeatherData(3, "Blue Skies", false),
"Blue Skies", new WeatherData(4, "Blue Skies", false),
"Blue Skies", new WeatherData(5, "Blue Skies", false),
"Blue Skies", new WeatherData(6, "Blue Skies", false),
"Blue Skies", new WeatherData(7, "Blue Skies", false),
"Thunderstorm", new WeatherData(8, "Thunderstorm", false),
"Cloudy/Foggy", new WeatherData(9, "Cloudy/Foggy", true),
"Clear Blue Skies", new WeatherData(10, "Clear Blue Skies", false),
"Heatwave", new WeatherData(11, "Heatwave", false),
"Dull/Colorless", new WeatherData(12, "Dull/Colorless", false),
"Dull/Colorless", new WeatherData(13, "Dull/Colorless", false),
"Dull/Colorless", new WeatherData(14, "Dull/Colorless", false),
"Dull/Colorless", new WeatherData(15, "Dull/Colorless", false),
"Dull/Rainy", new WeatherData(16, "Dull/Rainy", false),
"Heatwave", new WeatherData(17, "Heatwave", false),
"Heatwave", new WeatherData(18, "Heatwave", false),
"Sandstorm", new WeatherData(19, "Sandstorm", false),
"Greenish/Foggy" new WeatherData(20, "Greenish/Foggy", false),
], ],
[AGRP_GAME_GTA_IV]: [ // GTA IV [AGRP_GAME_GTA_IV]: [ // GTA IV
"Extra Sunny", new WeatherData(1, "Blue Skies", false),
"Sunny", new WeatherData(2, "Extra Sunny", false),
"Sunny/Windy", new WeatherData(3, "Sunny", false),
"Cloudy", new WeatherData(4, "Sunny/Windy", false),
"Rain", new WeatherData(5, "Cloudy", false),
"Light Rain", new WeatherData(6, "Rain", false),
"Foggy", new WeatherData(7, "Light Rain", false),
"Thunderstorm", new WeatherData(8, "Foggy", false),
"Extra Sunny", new WeatherData(9, "Thunderstorm", false),
"Sunny/Windy", new WeatherData(10, "Extra Sunny", false),
new WeatherData(11, "Sunny/Windy", false),
], ],
[AGRP_GAME_GTA_IV_EFLC]: [ // GTA IV EFLC [AGRP_GAME_GTA_IV_EFLC]: [ // GTA IV EFLC
"Extra Sunny", new WeatherData(1, "Blue Skies", false),
"Sunny", new WeatherData(2, "Extra Sunny", false),
"Sunny/Windy", new WeatherData(3, "Sunny", false),
"Cloudy", new WeatherData(4, "Sunny/Windy", false),
"Rain", new WeatherData(5, "Cloudy", false),
"Light Rain", new WeatherData(6, "Rain", false),
"Foggy", new WeatherData(7, "Light Rain", false),
"Thunderstorm", new WeatherData(8, "Foggy", false),
"Extra Sunny", new WeatherData(9, "Thunderstorm", false),
"Sunny/Windy", new WeatherData(10, "Extra Sunny", false),
new WeatherData(11, "Sunny/Windy", false),
], ],
[AGRP_GAME_GTA_V]: [ [AGRP_GAME_GTA_V]: [

View File

@@ -1121,7 +1121,7 @@ let profanityFilterWords = [
"anus", "anus",
"apeshit", "apeshit",
"arsehole", "arsehole",
"ass", //"ass",
"asshole", "asshole",
"assmunch", "assmunch",
"autoerotic", "autoerotic",
@@ -1697,7 +1697,7 @@ function isGTAIV() {
// =========================================================================== // ===========================================================================
function areServerElementsSupported() { function areServerElementsSupported() {
return supportedFeatures.serverElements[getGame()]; return isGameFeatureSupported("serverElements")
} }
// =========================================================================== // ===========================================================================
@@ -1818,7 +1818,7 @@ function getSkinIndexFromName(name, gameId = getGame()) {
function getObjectModelIndexFromName(model, gameId = getGame()) { function getObjectModelIndexFromName(model, gameId = getGame()) {
let objects = getGameConfig().objects[gameId]; let objects = getGameConfig().objects[gameId];
for (let i in objects) { for (let i in objects) {
if (toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) { if (toLowerCase(objects[i][1]).indexOf(toLowerCase(model)) != -1) {
return i; return i;
} }
} }
@@ -1831,7 +1831,7 @@ function getObjectModelIndexFromName(model, gameId = getGame()) {
function getObjectModelIndexFromModel(model, gameId = getGame()) { function getObjectModelIndexFromModel(model, gameId = getGame()) {
let objects = getGameConfig().objects[gameId]; let objects = getGameConfig().objects[gameId];
for (let i in objects) { for (let i in objects) {
if (toLowerCase(objects[i][1]).indexOf(toLowerCase(model)) != -1) { if (toLowerCase(objects[i][0]).indexOf(toLowerCase(model)) != -1) {
return i; return i;
} }
} }
@@ -3230,4 +3230,20 @@ function isServerGoingToChangeMapsSoon(hour, minute) {
return false; return false;
} }
// ===========================================================================
function getRandomBoolWithProbability(percentChance) {
return (Math.random() < percentChance / 100);
}
// ===========================================================================
function getWeatherData(weatherIndex, gameId = getGame()) {
if (typeof getGameConfig().weather[gameId][weatherIndex] == "undefined") {
return false;
}
return getGameConfig().weather[gameId][weatherIndex];
}
// =========================================================================== // ===========================================================================