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

@@ -2017,7 +2017,7 @@ function createBusinessEntrancePickup(businessId) {
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;
if (isGameFeatureSupported("pickup")) {
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})`);
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"));
if (entranceBlip != null) {
if (businessData.entranceDimension != -1) {
@@ -2864,7 +2864,7 @@ function getBusinessIdFromDatabaseId(databaseId) {
// Updates all pickup data for a business by 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));
return false;
}

View File

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

View File

@@ -115,7 +115,7 @@ class ClientData {
// Misc
this.changingCharacterName = false;
this.currentPickup = false;
this.currentPickup = null;
this.usingSkinSelect = false;
this.keyBinds = [];
this.incomingDamageMultiplier = 1;
@@ -228,7 +228,7 @@ function initClient(client) {
sendPlayerCurrencyString(client);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
updatePlayerSnowState(client);
updatePlayerSnowState(client, getServerConfig().groundSnow);
//logToConsole(LOG_DEBUG, `[AGRP.Account] Showing connect camera to ${getPlayerDisplayForConsole(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("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("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"),
],
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("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("clearchat", clearChatCommand, "", getStaffFlagValue("None"), true, true, "Clears the chat"),
],
startup: [],
subAccount: [
@@ -719,6 +722,9 @@ function addAllCommandHandlers() {
// ===========================================================================
/**
* @return {CommandData} command
*/
function getCommand(command) {
let commandGroups = getCommands()
for (let i in commandGroups) {
@@ -735,6 +741,9 @@ function getCommand(command) {
// ===========================================================================
/**
* @return {CommandData} command
*/
function getCommandData(command) {
return getCommand(command);
}
@@ -1029,10 +1038,10 @@ function cacheAllCommandsAliases() {
// ===========================================================================
function getCommandAliasesNames(command) {
function getCommandAliasesNames(commandData) {
let commandAliases = [];
for (let i in command.aliases) {
commandAliases.push(command.aliases[i].name);
for (let i in commandData.aliases) {
commandAliases.push(commandData.aliases[i].name);
}
return commandAliases;

View File

@@ -387,7 +387,7 @@ function applyConfigToServer(tempServerConfig) {
if (isWeatherSupported()) {
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
game.forceWeather(tempServerConfig.weather);
game.forceWeather(getWeatherData(tempServerConfig.weather).weatherId);
}
updateServerRules();
@@ -583,19 +583,19 @@ function setWeatherCommand(command, params, client) {
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!`);
return false;
}
game.forceWeather(toInteger(weatherId));
getServerConfig().weather = weatherId;
game.forceWeather(getWeatherData(weatherIndex).weatherId);
getServerConfig().weather = weatherIndex;
getServerConfig().needsSaved = true;
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getGame()][toInteger(weatherId)]);
announceAdminAction("ServerWeatherSet", getPlayerName(client), getWeatherData(weatherIndex).name);
updateServerRules();
return true;
}

View File

@@ -8,9 +8,9 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let scriptVersion = "1.2";
let scriptVersion = "1.3";
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 playerResourceStarted = new Array(server.maxClients).fill(false);

View File

@@ -205,12 +205,6 @@ function onPedExitingVehicle(event, ped, vehicle) {
let client = getClientFromPlayerElement(ped);
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) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} entered sphere ${sphere.id}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
//if (ped.isType(ELEMENT_PLAYER)) {
// let client = getClientFromPlayerElement(ped);
// Handled client-side since server spheres aren't showing on GTAC atm (bug)
//if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
// playerArrivedAtJobRouteLocation(client);
// }
//}
}
// Handled client-side since server spheres aren't showing on GTAC atm (bug)
//if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
// playerArrivedAtJobRouteLocation(client);
// }
//}
//}
}
// ===========================================================================
@@ -286,6 +280,7 @@ function onPedPickupPickedUp(event, ped, pickup) {
// ===========================================================================
/*
function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
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);
}
}
*/
// ===========================================================================
@@ -396,12 +392,12 @@ function onPlayerDeath(client, killer, weapon, pedPiece) {
function onPedSpawn(ped) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} spawned!`);
if (ped.type == ELEMENT_PLAYER) {
if (getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
//setTimeout(onPlayerSpawn, 250, ped);
//onPlayerSpawn();
}
}
//if (ped.type == ELEMENT_PLAYER) {
// if (getGame() != AGRP_GAME_MAFIA_ONE) {
// //setTimeout(onPlayerSpawn, 250, getClientFromPlayerElement(ped));
// //onPlayerSpawn(getClientFromPlayerElement(ped));
// }
//}
}
// ===========================================================================
@@ -458,7 +454,7 @@ async function onPlayerSpawn(client) {
// 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`);
restorePlayerCamera(client);
}
@@ -509,10 +505,10 @@ async function onPlayerSpawn(client) {
setPlayer2DRendering(client, true, true, true, true, true, true);
}
if (isGameFeatureSupported("snow")) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
updatePlayerSnowState(client);
}
//if (isGameFeatureSupported("snow")) {
// logToConsole(LOG_DEBUG, `[AGRP.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
// updatePlayerSnowState(client, true);
//}
if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
@@ -589,11 +585,13 @@ async function onPlayerSpawn(client) {
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)`);
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
sendAllJobsToPlayer(client);
if (getGame() != AGRP_GAME_GTA_IV) {
sendAllJobsToPlayer(client);
}
requestPlayerPedNetworkId(client);
}
@@ -629,7 +627,9 @@ async function onPlayerSpawn(client) {
if (areServerElementsSupported()) {
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 {
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
@@ -676,11 +676,21 @@ function onPlayerCommand(event, client, command, params) {
function onPedExitedVehicle(event, ped, vehicle, 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)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
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);
if (!getVehicleData(vehicle)) {
@@ -714,10 +724,6 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
}
if (!getVehicleData(vehicle)) {
return false;
}

View File

@@ -348,22 +348,23 @@ function showCommandHelpMessage(client, commandName) {
commandName = commandName.slice(1);
}
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
let commandData = getCommandData(commandName);
let aliases = getCommandAliasesNames(commandData);
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) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.map(alias => `/${alias.command}`).join(", ")}`);
} else {
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"))) {
// 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;
}
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
let entrancePickup = null;
if (isGameFeatureSupported("pickup")) {
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
@@ -1781,7 +1781,7 @@ function getHouseFromParams(params) {
// ===========================================================================
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);
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}`);
if (tempKey == true) {
keyBindData.databaseId = -1;
}
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")) {
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 j in getLocales()[i].countries) {
if (toLowerCase(getLocales()[i].countries[j]) == toLowerCase(isoCode)) {

View File

@@ -232,7 +232,8 @@ function messagePlayersInRace(raceId, message) {
// ===========================================================================
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;
}
let position = getPlayerPosition(client);
let dimension = getPlayerDimension(client);
/*
// The player's currentPickup wasn't always being set. This prevented entering/exiting a property.
// Needs further testing and tweaks.
if (!getPlayerData(client).currentPickup) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id");
if (getPlayerData(client).currentPickup != null) {
if (getDistance(getPlayerData(client).currentPickup.position, getPlayerPosition(client)) <= 2) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id");
switch (ownerType) {
case AGRP_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
switch (ownerType) {
case AGRP_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
case AGRP_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case AGRP_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case AGRP_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case AGRP_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case AGRP_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
case AGRP_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
default:
return false;
default:
return false;
}
} else {
getPlayerData(client).currentPickup = null;
}
}
*/
/*
// Check businesses first
if (closestProperty == null) {
let businessIndex = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
@@ -284,6 +294,48 @@ function enterExitPropertyCommand(command, params, client) {
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) {
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"}`);
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;
if (isEntrance) {

View File

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

View File

@@ -222,10 +222,10 @@ function syncPlayerProperties(client) {
// ===========================================================================
function updatePlayerSnowState(client) {
function updatePlayerSnowState(client, forceGroundSnow = false) {
if (isSnowSupported(getGame())) {
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);
}
// ==========================================================================
function sendClientVariablesToClient(client) {
sendNetworkEventToPlayer("agrp.cvar", client, JSON.stringify(clientVariables));
}
// ==========================================================================

View File

@@ -245,7 +245,22 @@ function playerPromptAnswerYes(client) {
}
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;
}

View File

@@ -517,22 +517,9 @@ function selectCharacter(client, characterId = -1) {
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
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);
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) {
//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]})`);

View File

@@ -134,11 +134,18 @@ function thirtyMinuteTimerFunction() {
checkPayDays();
}
checkInactiveVehicleRespawns();
if (isGameFeatureSupported("snow")) {
checkSnowChance();
setSnowWithChance();
}
checkInactiveVehicleRespawns();
if (isGameFeatureSupported("weather")) {
setRandomWeather();
}
updateServerRules();
saveServerDataToDatabase();
}
@@ -330,7 +337,7 @@ function checkInactiveVehicleRespawns() {
if (getVehicleData(vehicles[i]).lastActiveTime != false) {
if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false;
//getVehicleData(vehicles[i]).lastActiveTime = false;
}
}
} else {
@@ -342,13 +349,31 @@ function checkInactiveVehicleRespawns() {
// ===========================================================================
function checkSnowChance() {
function setSnowWithChance() {
let date = new Date();
let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonths()]);
let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonth()]);
getServerConfig().groundSnow = 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 (getServerConfig() != false) {
if (typeof getGameConfig().weatherNames[getGame()] != "undefined") {
let tempText = getGameConfig().weatherNames[getGame()][getServerConfig().weather];
if (getWeatherData(getServerConfig().weather) != false) {
let tempText = getWeatherData(getServerConfig().weather).name;
timeWeatherRule.push(tempText);
}
}
@@ -124,14 +124,16 @@ function updateServerRules() {
function getWeatherFromParams(params) {
if (isNaN(params)) {
for (let i in getGameConfig().weatherNames[getGame()]) {
if (toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
for (let i in getGameConfig().weather[getGame()]) {
if (toLowerCase(getGameConfig().weather[getGame()][i].name).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if (typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
return toInteger(params);
for (let i in getGameConfig().weather[getGame()]) {
if (typeof getGameConfig().weather[getGame()][i].weatherId != "undefined") {
return toInteger(i);
}
}
}
@@ -439,11 +441,13 @@ function isClientInitialized(client) {
// ===========================================================================
function getPedForNetworkEvent(ped) {
if (getGame() == AGRP_GAME_GTA_IV) {
return ped;
} else {
return ped.id;
}
//if (getGame() == AGRP_GAME_GTA_IV) {
// return ped;
//} else {
// return ped.id;
//}
return ped.id;
}
// ===========================================================================
@@ -638,6 +642,10 @@ function processPlayerEnteringExitingProperty(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));
}

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
* @property {Array.<Number>} trunkItemCache
@@ -165,6 +157,14 @@ class VehicleData {
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]);
getServerData().vehicles[i].vehicle = vehicle;
setEntityData(vehicle, "agrp.dataSlot", i, false);
setAllVehicleIndexes();
}
setAllVehicleIndexes();
}
// ===========================================================================
@@ -338,15 +338,11 @@ function spawnAllVehicles() {
* @return {VehicleData} The vehicles's data (class instance)
*/
function getVehicleData(vehicle) {
if (getGame() != AGRP_GAME_GTA_IV) {
if (isVehicleObject(vehicle)) {
let dataIndex = getEntityData(vehicle, "agrp.dataSlot");
if (typeof getServerData().vehicles[dataIndex] != "undefined") {
return getServerData().vehicles[dataIndex];
}
if (isVehicleObject(vehicle)) {
let dataIndex = getEntityData(vehicle, "agrp.dataSlot");
if (typeof getServerData().vehicles[dataIndex] != "undefined") {
return getServerData().vehicles[dataIndex];
}
} else {
return getServerData().vehicles.find((v) => v.ivNetworkId == vehicle);
}
return false;
@@ -428,11 +424,11 @@ function getNearbyVehiclesCommand(command, params, client) {
}
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);
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) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
@@ -609,8 +605,8 @@ function vehicleAdminColourCommand(command, params, client) {
let colour1 = toInteger(getParam(params, " ", 1)) || 0;
let colour2 = toInteger(getParam(params, " ", 2)) || 0;
takePlayerCash(client, getGlobalConfig().resprayVehicleCost);
updatePlayerCash(client);
//takePlayerCash(client, getGlobalConfig().resprayVehicleCost);
//updatePlayerCash(client);
vehicle.colour1 = colour1;
vehicle.colour2 = colour2;
getVehicleData(vehicle).colour1 = colour1;
@@ -618,7 +614,7 @@ function vehicleAdminColourCommand(command, params, client) {
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`);
takePlayerCash(client, getGlobalConfig().repairVehicleCost);
//takePlayerCash(client, getGlobalConfig().repairVehicleCost);
repairVehicle(vehicle);
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;
}
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!)`);
return false;
}
//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!)`);
// return false;
//}
let livery = toInteger(params) || 3;
@@ -675,7 +671,7 @@ function vehicleAdminLiveryCommand(command, params, client) {
setEntityData(vehicle, "agrp.livery", livery, true);
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;
}
if (doesPlayerOwnVehicle(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "AlreadyOwnVehicle"));
return false;
}
if (getPlayerCurrentSubAccount(client).cash < getVehicleData(vehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
return false;
@@ -845,7 +846,7 @@ function doesPlayerHaveVehicleKeys(client, vehicle) {
// ===========================================================================
function doesClientOwnVehicle(client, vehicle) {
function canPlayerManageVehicle(client, vehicle) {
let vehicleData = getVehicleData(vehicle);
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;
}
@@ -1079,9 +1114,10 @@ function setVehicleRentPriceCommand(command, params, client) {
return false;
}
if (!doesClientOwnVehicle(client, vehicle)) {
if (!canPlayerManageVehicle(client, vehicle)) {
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
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;
}
if (!doesClientOwnVehicle(client, vehicle)) {
if (!canPlayerManageVehicle(client, vehicle)) {
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageVehicles"))) {
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);
}
return vehicle;
}