Merge branch 'nightly' into ragemp

This commit is contained in:
Vortrex
2022-04-16 22:39:48 -05:00
172 changed files with 25499 additions and 10148 deletions

View File

@@ -8,30 +8,30 @@
// ===========================================================================
function getPlayerAccentText(client) {
return getPlayerCurrentSubAccount(client).accent;
return getPlayerCurrentSubAccount(client).accent;
}
// ===========================================================================
function setPlayerAccentText(client, text) {
getPlayerCurrentSubAccount(client).accent = text;
getPlayerCurrentSubAccount(client).accent = text;
}
// ===========================================================================
function doesPlayerHaveAccent(client) {
return (getPlayerCurrentSubAccount(client).accent != "");
return (getPlayerCurrentSubAccount(client).accent != "");
}
// ===========================================================================
function getPlayerAccentInlineOutput(client) {
let outputText = "";
if(doesPlayerHaveAccent(client)) {
outputText = `[${getPlayerAccentText(client)}] `;
}
let outputText = "";
if(doesPlayerHaveAccent(client)) {
outputText = `[${getPlayerAccentText(client)}] `;
}
return outputText;
return outputText;
}
// ===========================================================================

View File

@@ -94,13 +94,13 @@ function toggleAutoSelectLastCharacterCommand(command, params, client) {
function toggleAccountGUICommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("NoGUI");
if(!doesPlayerHaveGUIEnabled(client)) {
if(doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}`));
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}`));
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
}
@@ -271,6 +271,26 @@ function setAccountChatScrollLinesCommand(command, params, client) {
// ===========================================================================
function setAccountChatAutoHideDelayCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(isNaN(params)) {
messagePlayerError(client, `The delay time must be a number!`);
return false;
}
let delay = Math.ceil(toInteger(params));
getPlayerData(client).accountData.chatAutoHideDelay = delay;
sendPlayerChatAutoHideDelay(client, delay);
messagePlayerSuccess(client, `Your chatbox will now automatically hide after ${toInteger(delay)} seconds!`);
}
// ===========================================================================
function setAccountEmailCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -569,6 +589,7 @@ function loginSuccess(client) {
if(doesServerHaveTesterOnlyEnabled()) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
setTimeout(function() {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
client.disconnect();
}, 3500);
@@ -580,13 +601,13 @@ function loginSuccess(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
}
}
}
if(getPlayerData(client).subAccounts.length == 0) {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"));
showPlayerPromptGUI(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
@@ -600,8 +621,8 @@ function loginSuccess(client) {
getPlayerData(client).accountData.ipAddress = client.ip;
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow"));
messageDiscordChatChannel(`👋 ${getPlayerName(client)} has joined the server`);
}
// ===========================================================================
@@ -636,6 +657,7 @@ function saveAccountToDatabase(accountData) {
["acct_svr_staff_flags", accountData.flags.admin],
["acct_svr_mod_flags", accountData.flags.moderation],
["acct_svr_chat_scroll_lines", accountData.chatScrollLines],
["acct_svr_chat_auto_hide_delay", accountData.chatAutoHideDelay],
];
let queryString1 = createDatabaseUpdateQuery("acct_main", data, `acct_id=${accountData.databaseId}`);
@@ -915,13 +937,13 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
} else {
messagePlayerError(client, "Password doesn't meet requirements!");
}
return false
return false;
}
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
if(!isValidEmailAddress(emailAddress)) {
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedInvalidEmail"));
return false
return false;
}
}
@@ -947,7 +969,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} was sent a registration email verification code`);
}
}
if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
setTimeout(function() {
@@ -962,7 +984,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
}
} else {
messagePlayerAlert(client, getLocaleString(client, "RegistrationCreateCharReminder"));
@@ -979,6 +1001,10 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
// ===========================================================================
function checkAccountResetPasswordRequest(client, inputText) {
if(!checkForSMTPModule() || !getEmailConfig().enabled) {
return false;
}
if(getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_NONE) {
if(toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
@@ -1063,7 +1089,7 @@ function isValidEmailAddress(emailAddress) {
// ===========================================================================
function saveAllClientsToDatabase() {
function savePlayersToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Saving all clients to database ...");
getClients().forEach(function(client) {
savePlayerToDatabase(client);
@@ -1078,7 +1104,7 @@ function savePlayerToDatabase(client) {
return false;
}
if(!getPlayerData(client).loggedIn) {
if(!isPlayerLoggedIn(client)) {
return false;
}
@@ -1088,7 +1114,7 @@ function savePlayerToDatabase(client) {
if(getPlayerData(client).currentSubAccount != -1) {
//let subAccountData = getPlayerCurrentSubAccount(client);
if(client.player != null) {
if(getPlayerPed(client) != null) {
if(getPlayerData(client).returnToPosition != null) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
@@ -1146,6 +1172,7 @@ function initClient(client) {
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} else {
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
@@ -1153,6 +1180,12 @@ function initClient(client) {
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen"));
//if(checkForGeoIPModule()) {
// let iso = module.geoip.getCountryISO(client.ip);
// let localeId = getLocaleFromCountryISO(iso);
//}
//showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
}
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}

View File

@@ -20,17 +20,17 @@ function playPlayerAnimationCommand(command, params, client) {
return false;
}
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
if(!animationSlot) {
messagePlayerError(client, getLocaleString(client, "AnimationNotFound"));
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
messagePlayerInfo(client, getLocaleString(client, "AnimationHelpTip"), `{ALTCOLOUR}/animlist{MAINCOLOUR}`);
return false;
}
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, getLocaleString(client, "AnimationInvalidDistance"));
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
return false;
}
@@ -39,7 +39,7 @@ let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
}
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, `You aren't able to do that`);
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false;
}
@@ -51,17 +51,17 @@ let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
function stopPlayerAnimationCommand(command, params, client) {
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
messagePlayerError(client, `You aren't able to do that`);
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
return false;
}
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
makePedStopAnimation(getPlayerPed(client));
getPlayerData(client).currentAnimation = -1;
getPlayerData(client).currentAnimationPositionOffset = false;
getPlayerData(client).currentAnimationPositionReturnTo = false;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationForced = false;
setPlayerMouseCameraState(client, false);
@@ -70,7 +70,7 @@ function stopPlayerAnimationCommand(command, params, client) {
// ===========================================================================
function showAnimationListCommand(command, params, client) {
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x[0]; });
let animList = getGameConfig().animations[getServerGame()].map(function(x) { return x.name; });
let chunkedList = splitArrayIntoChunks(animList, 10);
@@ -88,7 +88,7 @@ function showAnimationListCommand(command, params, client) {
* @return {Array} The animation's data (array)
*/
function getAnimationData(animationSlot, gameId = getServerGame()) {
return getGameConfig().animations[gameId][animationSlot];
return getGameConfig().animations[gameId][animationSlot];
}
// ===========================================================================
@@ -100,14 +100,14 @@ function isPlayerInForcedAnimation(client) {
// ===========================================================================
function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
makePedPlayAnimation(getPlayerData(client).ped, animationSlot, offsetPosition);
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
setEntityData(getPlayerPed(client), "vrr.anim", animationSlot, true);
//if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) {
// if(getGame() < VRR_GAME_GTA_SA) {
// setPlayerMouseCameraState(client, true);
@@ -118,35 +118,36 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
// ===========================================================================
function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
setPlayerControlState(client, false);
forcePedAnimation(getPlayerData(client).ped, animationSlot, offsetPosition);
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
}
// ===========================================================================
function makePlayerStopAnimation(client) {
//setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
makePedStopAnimation(getPlayerPed(client));
getPlayerData(client).currentAnimation = -1;
getPlayerData(client).currentAnimationPositionOffset = false;
getPlayerData(client).currentAnimationPositionReturnTo = false;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationStart = 0;
getPlayerData(client).animationForced = false;
}
// ===========================================================================
function getAnimationFromParams(params) {
let animations = getGameConfig().animations[getServerGame()];
if(isNaN(params)) {
for(let i in getGameConfig().animations[getServerGame()]) {
if(toLowerCase(getGameConfig().animations[getServerGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
for(let i in animations) {
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
return i;
}
}

View File

@@ -8,14 +8,14 @@
// ===========================================================================
function initAntiCheatScript() {
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Anticheat script initialized!");
}
// ===========================================================================
function clearPlayerStateToEnterExitProperty(client) {
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
if(getPlayerData(client).pedState == VRR_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;

View File

@@ -10,8 +10,8 @@
// ===========================================================================
function initBanScript() {
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
}
// ===========================================================================
@@ -22,24 +22,24 @@ function accountBanCommand(command, params, client) {
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been account banned.`);
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
}
@@ -52,27 +52,27 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
return false;
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been character banned.`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client);
disconnectPlayer(client);
}
// ===========================================================================
@@ -81,28 +81,28 @@ function ipBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let reason = splitParams.slice(1).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been IP banned.`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
targetClient.disconnect();
server.banIP(targetClient.ip);
targetClient.disconnect();
}
// ===========================================================================
@@ -111,190 +111,189 @@ function subNetBanCommand(command, params, client, fromDiscord) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
}
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let octetAmount = Number(getParam(params, " ", 2));
let reason = splitParams.slice(2).join(" ");
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let octetAmount = Number(getParam(params, " ", 2));
let reason = splitParams.slice(2).join(" ");
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player is not connected!")
return false;
}
// Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false;
}
}
messageAdminAction(`{ALTCOLOUR}${getPlayerData(targetClient).currentSubAccountData.name} {MAINCOLOUR}has been subnet banned`);
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`);
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip);
server.banIP(targetClient.ip);
}
// ===========================================================================
function banAccount(accountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banSubAccount(subAccountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banIPAddress(ipAddress, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${VRR_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanAccount(accountId, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanSubAccount(subAccountId, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanIPAddress(ipAddress, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${VRR_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
}
return false;
return false;
}
// ===========================================================================
function isAccountBanned(accountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_ACCOUNT) {
if(bans[i].detail == accountId) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_ACCOUNT) {
if(bans[i].detail == accountId) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================
function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) {
if(bans[i].detail == subAccountId) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) {
if(bans[i].detail == subAccountId) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================
function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_IPADDRESS) {
if(bans[i].detail == ipAddress) {
return true;
}
}
}
let bans = getServerData().bans;
for(let i in bans) {
if(bans[i].type == VRR_BANTYPE_IPADDRESS) {
if(bans[i].detail == ipAddress) {
return true;
}
}
}
return false;
return false;
}
// ===========================================================================

View File

@@ -21,7 +21,6 @@ let serverBitFlags = {
npcTriggerTypeFlags: {},
npcTriggerConditionTypesFlags: {},
npcTriggerResponseTypeFlags: {},
serverSettings: {}
};
// ===========================================================================
@@ -41,6 +40,8 @@ let serverBitFlagKeys = {
"ManageWorld",
"ManageAntiCheat",
"Developer",
"ManageNPCs",
"ManageRaces",
],
moderationFlagKeys: [
"None",
@@ -119,6 +120,8 @@ let serverBitFlagKeys = {
"NoRandomTips",
"NoActionTips",
],
// Not going to be used. Use trigger, condition, and response stuff in trigger.js
npcTriggerTypeKeys: [
"None",
"FarProximity", // Comes within a far distance of NPC
@@ -219,26 +222,6 @@ let serverBitFlagKeys = {
"ShowItemsAfterPurchase",
"BuyCommandAfterEnterBusiness",
],
serverSettingsKeys: [
"None",
"GUI",
"ServerLogo",
"FallingSnow",
"GroundSnow",
"Anticheat",
"CheckGameScripts",
"GameScriptBlackList",
"GameScriptWhiteList",
"JobBlips",
"JobPickups",
"BusinessBlips",
"BusinessPickups",
"HouseBlips",
"HousePickups",
"DiscordBot",
"RealTime",
"Testing",
],
};
// ===========================================================================
@@ -255,7 +238,6 @@ function initBitFlagScript() {
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
serverBitFlags.serverSettings = createBitFlagTable(serverBitFlagKeys.serverSettingsKeys);
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
return true;
}
@@ -311,15 +293,15 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
}
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if(staffFlags == getStaffFlagValue("All")) {
return true;
}
if(staffFlags == getStaffFlagValue("All")) {
return true;
}
if(hasBitFlag(staffFlags, requiredFlags)) {
return true;
}
if(hasBitFlag(staffFlags, requiredFlags)) {
return true;
}
return false;
return false;
}
// ===========================================================================
@@ -341,22 +323,22 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankFlags(getPlayerCurrentSubAccount(client).clanRank);
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
if(clanFlags == getClanFlagValue("All")) {
return true;
}
if(clanFlags == getClanFlagValue("All")) {
return true;
}
if(hasBitFlag(clanFlags, requiredFlags)) {
return true;
}
if(hasBitFlag(clanFlags, requiredFlags)) {
return true;
}
return false;
return false;
}
// ===========================================================================
function getStaffFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.staffFlags[flagName] == "undefined") {
@@ -369,8 +351,8 @@ function getStaffFlagValue(flagName) {
// ===========================================================================
function getClanFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
@@ -383,8 +365,8 @@ function getClanFlagValue(flagName) {
// ===========================================================================
function getAccountSettingsFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
@@ -397,8 +379,8 @@ function getAccountSettingsFlagValue(flagName) {
// ===========================================================================
function getModerationFlagValue(flagName) {
if(flagName == "All") {
return -1;
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
@@ -410,20 +392,6 @@ function getModerationFlagValue(flagName) {
// ===========================================================================
function getServerSettingsFlagValue(flagName) {
if(flagName == "All") {
return -1;
}
if(typeof serverBitFlags.serverSettings[flagName] == "undefined") {
return false;
}
return serverBitFlags.serverSettings[flagName];
}
// ===========================================================================
function givePlayerStaffFlag(client, flagName) {
if(!getStaffFlagValue(flagName)) {
return false;

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: bakery.js
// DESC: Provides bakery business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: bar.js
// DESC: Provides bar/pub business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,67 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: casino.js
// DESC: Provides casino business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================
let deckCards = [
DeckCardData("deckCardSpadeAce", VRR_DECKCARD_SUIT_SPADE, 1),
DeckCardData("deckCardSpade2", VRR_DECKCARD_SUIT_SPADE, 2),
DeckCardData("deckCardSpade3", VRR_DECKCARD_SUIT_SPADE, 3),
DeckCardData("deckCardSpade4", VRR_DECKCARD_SUIT_SPADE, 4),
DeckCardData("deckCardSpade5", VRR_DECKCARD_SUIT_SPADE, 5),
DeckCardData("deckCardSpade6", VRR_DECKCARD_SUIT_SPADE, 6),
DeckCardData("deckCardSpade7", VRR_DECKCARD_SUIT_SPADE, 7),
DeckCardData("deckCardSpade8", VRR_DECKCARD_SUIT_SPADE, 8),
DeckCardData("deckCardSpade9", VRR_DECKCARD_SUIT_SPADE, 9),
DeckCardData("deckCardSpade10", VRR_DECKCARD_SUIT_SPADE, 10),
DeckCardData("deckCardSpadeJack", VRR_DECKCARD_SUIT_SPADE, 11),
DeckCardData("deckCardSpadeQueen", VRR_DECKCARD_SUIT_SPADE, 12),
DeckCardData("deckCardSpadeKing", VRR_DECKCARD_SUIT_SPADE, 13),
DeckCardData("deckCardClubAce", VRR_DECKCARD_SUIT_CLUB, 1),
DeckCardData("deckCardClub2", VRR_DECKCARD_SUIT_CLUB, 2),
DeckCardData("deckCardClub3", VRR_DECKCARD_SUIT_CLUB, 3),
DeckCardData("deckCardClub4", VRR_DECKCARD_SUIT_CLUB, 4),
DeckCardData("deckCardClub5", VRR_DECKCARD_SUIT_CLUB, 5),
DeckCardData("deckCardClub6", VRR_DECKCARD_SUIT_CLUB, 6),
DeckCardData("deckCardClub7", VRR_DECKCARD_SUIT_CLUB, 7),
DeckCardData("deckCardClub8", VRR_DECKCARD_SUIT_CLUB, 8),
DeckCardData("deckCardClub9", VRR_DECKCARD_SUIT_CLUB, 9),
DeckCardData("deckCardClub10", VRR_DECKCARD_SUIT_CLUB, 10),
DeckCardData("deckCardClubJack", VRR_DECKCARD_SUIT_CLUB, 11),
DeckCardData("deckCardClubQueen", VRR_DECKCARD_SUIT_CLUB, 12),
DeckCardData("deckCardClubKing", VRR_DECKCARD_SUIT_CLUB, 13),
DeckCardData("deckCardHeartAce", VRR_DECKCARD_SUIT_HEART, 1),
DeckCardData("deckCardHeart2", VRR_DECKCARD_SUIT_HEART, 2),
DeckCardData("deckCardHeart3", VRR_DECKCARD_SUIT_HEART, 3),
DeckCardData("deckCardHeart4", VRR_DECKCARD_SUIT_HEART, 4),
DeckCardData("deckCardHeart5", VRR_DECKCARD_SUIT_HEART, 5),
DeckCardData("deckCardHeart6", VRR_DECKCARD_SUIT_HEART, 6),
DeckCardData("deckCardHeart7", VRR_DECKCARD_SUIT_HEART, 7),
DeckCardData("deckCardHeart8", VRR_DECKCARD_SUIT_HEART, 8),
DeckCardData("deckCardHeart9", VRR_DECKCARD_SUIT_HEART, 9),
DeckCardData("deckCardHeart10", VRR_DECKCARD_SUIT_HEART, 10),
DeckCardData("deckCardHeartJack", VRR_DECKCARD_SUIT_HEART, 11),
DeckCardData("deckCardHeartQueen", VRR_DECKCARD_SUIT_HEART, 12),
DeckCardData("deckCardHeartKing", VRR_DECKCARD_SUIT_HEART, 13),
DeckCardData("deckCardDiamondAce", VRR_DECKCARD_SUIT_DIAMOND, 1),
DeckCardData("deckCardDiamond2", VRR_DECKCARD_SUIT_DIAMOND, 2),
DeckCardData("deckCardDiamond3", VRR_DECKCARD_SUIT_DIAMOND, 3),
DeckCardData("deckCardDiamond4", VRR_DECKCARD_SUIT_DIAMOND, 4),
DeckCardData("deckCardDiamond5", VRR_DECKCARD_SUIT_DIAMOND, 5),
DeckCardData("deckCardDiamond6", VRR_DECKCARD_SUIT_DIAMOND, 6),
DeckCardData("deckCardDiamond7", VRR_DECKCARD_SUIT_DIAMOND, 7),
DeckCardData("deckCardDiamond8", VRR_DECKCARD_SUIT_DIAMOND, 8),
DeckCardData("deckCardDiamond9", VRR_DECKCARD_SUIT_DIAMOND, 9),
DeckCardData( "deckCardDiamond10", VRR_DECKCARD_SUIT_DIAMOND, 10),
DeckCardData("deckCardDiamondJack", VRR_DECKCARD_SUIT_DIAMOND, 11),
DeckCardData("deckCardDiamondQueen", VRR_DECKCARD_SUIT_DIAMOND, 12),
DeckCardData("deckCardDiamondKing", VRR_DECKCARD_SUIT_DIAMOND, 13),
];
let deckCardBacks = [
]

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: club.js
// DESC: Provides club/nightclub business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,8 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -1,9 +0,0 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: weapon.js
// DESC: Provides weapon (ammunations & illegal gunshops) business usage
// TYPE: Business (JavaScript)
// ===========================================================================

View File

@@ -39,12 +39,13 @@ function processPlayerChat(client, messageText) {
messageText = messageText.substring(0, 128);
messagePlayerNormal(null, `💬 ${getCharacterFullName(client)}: ${messageText}`);
messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
} else {
messagePlayerNormal(null, `🛡️ (ADMIN) - ${messageText}`);
}
/*
let clients = getClients();
/*
let clients = getClients();
for(let i in clients) {
let translatedText;
translatedText = await translateMessage(messageText, getPlayerData(client).locale, getPlayerData(clients[i]).locale);
@@ -52,9 +53,9 @@ function processPlayerChat(client, messageText) {
let original = (getPlayerData(client).locale == getPlayerData(clients[i]).locale) ? `` : ` {ALTCOLOUR}(${messageText})`;
messagePlayerNormal(clients[i], `💬 ${getCharacterFullName(client)}: [#FFFFFF]${translatedText}${original}`, clients[i], getColourByName("mediumGrey"));
}
*/
//messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
*/
//messageDiscordChatChannel(`💬 ${getCharacterFullName(client)}: ${messageText}`);
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initClanScript() {
logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
if(!getServerConfig().devServer) {
getServerData().clans = loadClansFromDatabase();
}
setAllClanDataIndexes();
logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!");
return true;
@@ -114,7 +117,7 @@ function createClanRank(clanId, rankId, rankName) {
let rankIndex = getClanData(clanId).ranks.push(tempClanRankData);
setAllClanDataIndexes();
saveAllClanRanksToDatabase(clanId);
saveClanRanksToDatabase(clanId);
return rankIndex;
}
@@ -927,12 +930,20 @@ function doesClanIdExist(clanId) {
// ===========================================================================
function reloadAllClans() {
if(getServerConfig().devServer) {
return false;
}
getServerData().clans = loadClansFromDatabase();
}
// ===========================================================================
function saveAllClanRanksToDatabase(clanId) {
function saveClanRanksToDatabase(clanId) {
if(getServerConfig().devServer) {
return false;
}
let ranks = getServerData().clans[clanId].ranks;
for(let i in ranks) {
saveClanRankToDatabase(clanId, i);
@@ -948,9 +959,13 @@ function saveClanToDatabase(clanId) {
return false;
}
if(!tempClanData.needsSaved) {
return false;
}
if(tempClanData.databaseId == -1) {
return false;
}
if(!tempClanData.needsSaved) {
return false;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -982,7 +997,7 @@ function saveClanToDatabase(clanId) {
disconnectFromDatabase(dbConnection);
}
saveAllClanRanksToDatabase(clanId);
saveClanRanksToDatabase(clanId);
return true;
}
@@ -994,41 +1009,41 @@ function saveClanToDatabase(clanId) {
function saveClanRankToDatabase(clanId, rankId) {
let tempClanRankData = getClanRankData(clanId, rankId);
if(!tempClanRankData.needsSaved) {
return false;
}
if(!tempClanRankData.needsSaved) {
return false;
}
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeTag = escapeDatabaseString(dbConnection, tempClanRankData.customTag);
//let safeTitle = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeName = escapeDatabaseString(dbConnection, tempClanRankData.name);
let safeTag = escapeDatabaseString(dbConnection, tempClanRankData.customTag);
//let safeTitle = escapeDatabaseString(dbConnection, tempClanRankData.name);
let data = [
["clan_rank_name", safeName],
["clan_rank_clan", tempClanRankData.clan],
["clan_rank_custom_tag", safeTag],
//["clan_rank_title", safeTitle],
["clan_rank_flags", tempClanRankData.flags],
["clan_rank_level", tempClanRankData.level],
["clan_rank_enabled", boolToInt(tempClanRankData.enabled)],
];
let data = [
["clan_rank_name", safeName],
["clan_rank_clan", tempClanRankData.clan],
["clan_rank_custom_tag", safeTag],
//["clan_rank_title", safeTitle],
["clan_rank_flags", tempClanRankData.flags],
["clan_rank_level", tempClanRankData.level],
["clan_rank_enabled", boolToInt(tempClanRankData.enabled)],
];
let dbQuery = null;
if(tempClanRankData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("clan_rank", data);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).databaseId = getDatabaseInsertId(dbConnection);
getClanRankData(clanId, rankId).needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("clan_rank", data, `clan_rank_id=${tempClanRankData.databaseId} LIMIT 1`);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).needsSaved = false;
}
let dbQuery = null;
if(tempClanRankData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("clan_rank", data);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).databaseId = getDatabaseInsertId(dbConnection);
getClanRankData(clanId, rankId).needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("clan_rank", data, `clan_rank_id=${tempClanRankData.databaseId} LIMIT 1`);
dbQuery = queryDatabase(dbConnection, queryString);
getClanRankData(clanId, rankId).needsSaved = false;
}
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
}
return false;
@@ -1071,7 +1086,11 @@ function setClanRankTitle(clanId, rankId, title) {
// ===========================================================================
function saveAllClansToDatabase() {
function saveClansToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().clans) {
saveClanToDatabase(i);
}
@@ -1134,6 +1153,11 @@ function getClanRankIdFromDatabaseId(clanId, databaseId) {
// ===========================================================================
/**
* @param {number} clanId - The data index of the clan
* @param {number} clanRankId - The data index of the clan rank
* @return {ClanRankData} The clan rank's data (class instance)
*/
function getClanRankData(clanId, rankId) {
return getServerData().clans[clanId].ranks[rankId];
}
@@ -1213,6 +1237,10 @@ let rankId = getClanRankFromParams(clanId, getParam(params, " ", 1));
}
*/
/**
* @param {String} params - The params to search for
* @return {Number} The data index of a matching clan
*/
function getClanFromParams(params) {
if(isNaN(params)) {
for(let i in getServerData().clans) {
@@ -1231,6 +1259,11 @@ function getClanFromParams(params) {
// ===========================================================================
/**
* @param {Number} clanId - The clan ID to search ranks for
* @param {String} params - The params to search for
* @return {Number} The data index of a matching clan
*/
function getClanRankFromParams(clanId, params) {
if(isNaN(params)) {
for(let i in getClanData(clanId).ranks) {

View File

@@ -19,7 +19,7 @@ function initClassScript() {
/**
* @class Representing data for server configuration
*/
class ServerData {
class ServerConfigData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.needsSaved = false;
@@ -58,7 +58,7 @@ class ServerData {
this.showLogo = true;
this.inflationMultiplier = 1;
this.testerOnly = false;
this.settings = 0;
this.devServer = false;
this.antiCheat = {
enabled: false,
@@ -87,9 +87,6 @@ class ServerData {
this.realTimeZone = 0;
this.discordConfig = {
eventChannelWebHookURL: "",
chatChannelWebHookURL: "",
adminChannelWebHookURL: "",
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
@@ -104,7 +101,6 @@ class ServerData {
bank: dbAssoc["svr_newchar_bank"],
skin: dbAssoc["svr_newchar_skin"],
},
this.settings = toInteger(dbAssoc["svr_settings"]);
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
this.connectCameraLookAt = toVector3(dbAssoc["svr_connectcam_lookat_x"], dbAssoc["svr_connectcam_lookat_y"], dbAssoc["svr_connectcam_lookat_z"]);
@@ -113,6 +109,21 @@ class ServerData {
this.minute = toInteger(dbAssoc["svr_start_time_min"]);
this.minuteDuration = toInteger(dbAssoc["svr_time_min_duration"]);
this.weather = toInteger(dbAssoc["svr_start_weather"]);
//this.fallingSnow = intToBool(toInteger(dbAssoc["svr_start_snow_falling"]));
//this.groundSnow = intToBool(toInteger(dbAssoc["svr_start_snow_ground"]));
//this.useGUI = intToBool(toInteger(dbAssoc["svr_gui_enabled"]));
//this.showLogo = intToBool(toInteger(dbAssoc["svr_logo_enabled"]));
//this.testerOnly = intToBool(toInteger(dbAssoc["svr_tester_only"]));
/*
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups_enabled"]));
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups_enabled"]));
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups_enabled"]));
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips_enabled"]));
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips_enabled"]));
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips_enabled"]));
*/
this.guiColourPrimary = [toInteger(dbAssoc["svr_gui_col1_r"]), toInteger(dbAssoc["svr_gui_col1_g"]), toInteger(dbAssoc["svr_gui_col1_b"])];
this.guiColourSecondary = [toInteger(dbAssoc["svr_gui_col2_r"]), toInteger(dbAssoc["svr_gui_col2_g"]), toInteger(dbAssoc["svr_gui_col2_b"])];
this.guiTextColourPrimary = [toInteger(dbAssoc["svr_gui_textcol1_r"]), toInteger(dbAssoc["svr_gui_textcol1_g"]), toInteger(dbAssoc["svr_gui_textcol1_b"])];
@@ -121,15 +132,14 @@ class ServerData {
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
this.introMusicURL = dbAssoc["svr_intro_music"];
this.realTimeZone = dbAssoc["svr_time_realtime_timezone"];
this.discordConfig = {
eventChannelWebHookURL: dbAssoc["svr_discord_event_webhook"],
chatChannelWebHookURL: dbAssoc["svr_discord_chat_webhook"],
adminChannelWebHookURL: dbAssoc["svr_discord_admin_webhook"],
//this.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
//this.realTimeZone = dbAssoc["svr_real_time_timezone"];
this.discord = {
sendEvents: true,
sendChat: true,
sendAdminEvents: true,
sendAdmin: true,
};
}
}
@@ -239,6 +249,10 @@ class ClientData {
this.locale = 0;
this.enteringVehicle = null;
this.customDisconnectReason = "";
this.interiorCutscene = "";
}
};
@@ -271,6 +285,7 @@ class AccountData {
this.twoFactorAuthVerificationCode = "";
this.chatScrollLines = 1;
this.chatAutoHideDelay = 0;
this.streamingRadioVolume = 20;
this.locale = 0;
@@ -300,6 +315,7 @@ class AccountData {
this.emailVerificationCode = dbAssoc["acct_code_verifyemail"];
this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"];
this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]);
this.chatAutoHideDelay = toInteger(dbAssoc["acct_svr_chat_auto_hide_delay"]);
this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]);
this.locale = toInteger(dbAssoc["acct_locale"]);
}
@@ -524,6 +540,7 @@ class BusinessData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -533,6 +550,7 @@ class BusinessData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.entranceFee = 0;
this.till = 0;
@@ -541,6 +559,8 @@ class BusinessData {
this.labelHelpType = VRR_PROPLABEL_INFO_NONE;
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
@@ -557,6 +577,7 @@ class BusinessData {
this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["biz_entrance_cutscene"]);
this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
@@ -564,12 +585,14 @@ class BusinessData {
this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.exitCutscene = toString(dbAssoc["biz_exit_cutscene"]);
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
this.labelHelpType = toInteger(dbAssoc["biz_label_help_type"]);
this.streamingRadioStation = toInteger(dbAssoc["biz_radiostation"]);
}
};
};
@@ -658,6 +681,7 @@ class HouseData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceCutscene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -667,9 +691,12 @@ class HouseData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitCutscene = "";
this.streamingRadioStation = -1;
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(dbAssoc["house_description"]);
@@ -688,6 +715,7 @@ class HouseData {
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.entranceCutscene = toString(dbAssoc["house_entrance_cutscene"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
@@ -695,6 +723,7 @@ class HouseData {
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
this.exitCutscene = toString(dbAssoc["house_exit_cutscene"]);
}
}
};
@@ -934,6 +963,8 @@ class VehicleData {
this.lastActiveTime = false;
this.triggers = [];
if(dbAssoc) {
// General Info
this.databaseId = toInteger(dbAssoc["veh_id"]);
@@ -1003,7 +1034,7 @@ class VehicleData {
};
/**
* @class Representing a command's data. Loaded and saved in the database
* @class Representing a command's data.
*/
class CommandData {
enable() {
@@ -1018,7 +1049,7 @@ class CommandData {
this.enabled = !this.enabled;
}
constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) {
constructor(command, handlerFunction, syntaxString = "", requiredStaffFlags = 0, requireLogin = true, allowOnDiscord = false, helpDescription = "") {
this.command = command;
this.handlerFunction = handlerFunction;
this.syntaxString = syntaxString;
@@ -1302,49 +1333,6 @@ class KeyBindData {
}
};
class BlackListedGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.enabled = false
this.serverId = 0;
this.scriptName = "";
this.index = -1;
this.needsSaved = false;
if(dbAssoc) {
this.databaseId = dbAssoc["ac_script_bl_id"];
this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]);
this.serverId = dbAssoc["ac_script_bl_server"];
this.scriptName = dbAssoc["ac_script_bl_name"];
}
}
};
class WhiteListedGameScriptData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.enabled = false
this.serverId = 0;
this.scriptName = "";
this.index = -1;
this.needsSaved = false;
if(dbAssoc) {
this.databaseId = dbAssoc["ac_script_wl_id"];
this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]);
this.serverId = dbAssoc["ac_script_wl_server"];
this.scriptName = dbAssoc["ac_script_wl_name"];
}
}
};
class InteriorTemplateData {
constructor(exitPosition, exitInterior) {
this.exitPosition = exitPosition;
this.exitInterior = exitInterior;
}
};
class RadioStationData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1486,6 +1474,7 @@ class ItemTypeData {
}
}
};
class NPCData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1495,8 +1484,10 @@ class NPCData {
this.middleName = "Q";
this.skin = 0;
this.cash = 0;
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.position = toVector3(0.0, 0.0, 0.0);
this.rotation = toVector3(0.0, 0.0, 0.0);
this.scale = toVector3(1.0, 1.0, 1.0);
this.heading = 0.0;
this.clan = 0;
this.isWorking = false;
this.jobUniform = this.skin;
@@ -1505,13 +1496,16 @@ class NPCData {
this.weapons = [];
this.interior = 0;
this.dimension = 0;
this.pedScale = toVector3(1.0, 1.0, 1.0);
this.walkStyle = 0;
this.fightStyle = 0;
this.health = 100;
this.armour = 100;
this.currentAction = VRR_NPCACTION_NONE;
this.triggers = [];
this.typeFlags = 0;
this.heedThreats = false;
this.threats = 0;
this.invincible = false;
this.bodyParts = {
hair: [0,0],
@@ -1533,6 +1527,8 @@ class NPCData {
rightFoot: [0,0],
};
this.triggers = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["npc_id"]);
this.serverId = toInteger(dbAssoc["npc_server"]);
@@ -1541,21 +1537,24 @@ class NPCData {
this.middleName = dbAssoc["npc_name_middle"] || "";
this.skin = toInteger(dbAssoc["npc_skin"]);
this.cash = toInteger(dbAssoc["npc_cash"]);
this.spawnPosition = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.spawnHeading = toFloat(dbAssoc["npc_angle"]);
this.position = toVector3(toFloat(dbAssoc["npc_pos_x"]), toFloat(dbAssoc["npc_pos_y"]), toFloat(dbAssoc["npc_pos_z"]));
this.rotation = toVector3(toFloat(dbAssoc["npc_rot_x"]), toFloat(dbAssoc["npc_rot_y"]), toFloat(dbAssoc["npc_rot_z"]));
this.scale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.heading = toFloat(dbAssoc["npc_rot_z"]);
this.lastLogin = toInteger(dbAssoc["npc_when_lastlogin"]);
this.clan = toInteger(dbAssoc["npc_clan"]);
this.clanFlags = toInteger(dbAssoc["npc_clan_flags"]);
this.clanRank = toInteger(dbAssoc["npc_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["npc_clan_title"]);
this.rank = toInteger(dbAssoc["npc_rank"]);
this.title = toInteger(dbAssoc["npc_title"]);
this.job = toInteger(dbAssoc["npc_job"]);
this.interior = toInteger(dbAssoc["npc_int"]);
this.dimension = toInteger(dbAssoc["npc_vw"]);
this.pedScale = toVector3(toFloat(dbAssoc["npc_scale_x"]), toFloat(dbAssoc["npc_scale_y"]), toFloat(dbAssoc["npc_scale_z"]));
this.walkStyle = toInteger(dbAssoc["npc_walkstyle"]);
this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]);
this.health = toInteger(dbAssoc["npc_health"]);
this.armour = toInteger(dbAssoc["npc_armour"]);
this.typeFlags = toInteger(dbAssoc["npc_type_flags"]);
this.heedThreats = intToBool(dbAssoc["npc_headthreats"]);
this.threats = toInteger(dbAssoc["npc_threats"]);
this.invincible = intToBool(dbAssoc["npc_invincible"]);
this.bodyParts = {
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
@@ -1656,28 +1655,6 @@ class BanData {
}
}
class DeckCardData {
constructor(imageName, value) {
this.imageName = imageName,
this.value = value;
}
}
class DeckCardGameData {
constructor() {
this.gameType = VRR_DECKCARD_GAME_NONE;
this.playedCards = [];
this.remainingCards = [];
}
}
class DeckCardHandData {
constructor() {
this.cards = [];
this.total = 0;
}
}
class JobRouteData {
constructor(dbAssoc = false) {
this.databaseId = 0;
@@ -1708,7 +1685,7 @@ class JobRouteData {
this.pay = toInteger(dbAssoc["job_route_pay"]);
this.startMessage = toString(dbAssoc["job_route_start_msg"]);
this.finishMessage = toString(dbAssoc["job_route_finish_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationArriveMessage = toString(dbAssoc["job_route_loc_arrive_msg"]);
this.locationNextMessage = toString(dbAssoc["job_route_loc_next_msg"]);
this.vehicleColour1 = toInteger(dbAssoc["job_route_veh_colour1"]);
this.vehicleColour2 = toInteger(dbAssoc["job_route_veh_colour2"]);
@@ -1724,7 +1701,7 @@ class JobRouteLocationData {
this.routeId = 0;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
this.jobIndex = -1;
this.routeIndex = -1;
this.needsSaved = false;
this.position = toVector3(0.0, 0.0, 0.0);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,8 @@ let gameConfig = false;
// ===========================================================================
let globalConfig = {
keyBind: [],
economy: {},
accountPasswordHash: "SHA512",
npcFarProximity: 100,
npcMediumProximity: 40,
@@ -31,7 +33,6 @@ let globalConfig = {
stopWorkingDistance: 10,
spawnCarDistance: 5,
payAndSprayDistance: 5,
keyBind: [],
exitPropertyDistance: 3.0,
enterPropertyDistance: 3.0,
businessDimensionStart: 5000,
@@ -67,10 +68,19 @@ let globalConfig = {
],
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
chatSectionHeaderLength: 96,
economy: {},
locales: [],
accents: [],
useServerSideVehiclePurchaseCheck: false,
useServerSideVehiclePurchaseCheck: true,
businessPickupStreamInDistance: 100,
businessPickupStreamOutDistance: 120,
housePickupStreamInDistance: 100,
housePickupStreamOutDistance: 120,
jobPickupStreamInDistance: 100,
jobPickupStreamOutDistance: 120,
businessBlipStreamInDistance: 200,
businessBlipStreamOutDistance: 220,
houseBlipStreamInDistance: 200,
houseBlipStreamOutDistance: 220,
jobBlipStreamInDistance: 200,
jobBlipStreamOutDistance: 220,
};
// ===========================================================================
@@ -84,20 +94,20 @@ function initConfigScript() {
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("gui")));
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("vrr_fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("vrr_groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("vrr_gui")));
getServerConfig().showLogo = false;
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("testeronly")));
getServerConfig().testerOnly = intToBool(toInteger(server.getCVar("vrr_testeronly")));
getServerConfig().discordEnabled = false;
getServerConfig().createJobPickups = intToBool(toInteger(server.getCVar("jobpickups")));
getServerConfig().createBusinessPickups = intToBool(toInteger(server.getCVar("businesspickups")));
getServerConfig().createHousePickups = intToBool(toInteger(server.getCVar("housepickups")));
getServerConfig().createJobBlips = intToBool(toInteger(server.getCVar("jobblips")));
getServerConfig().createBusinessBlips = intToBool(toInteger(server.getCVar("businessblips")));
getServerConfig().createHouseBlips = intToBool(toInteger(server.getCVar("houseblips")));
getServerConfig().useRealTime = intToBool(toInteger(server.getCVar("realtime")));
getServerConfig().antiCheat.enabled = intToBool(toInteger(server.getCVar("anticheat")));
getServerConfig().createJobPickups = intToBool(toInteger(server.getCVar("vrr_jobpickups")));
getServerConfig().createBusinessPickups = intToBool(toInteger(server.getCVar("vrr_businesspickups")));
getServerConfig().createHousePickups = intToBool(toInteger(server.getCVar("vrr_housepickups")));
getServerConfig().createJobBlips = intToBool(toInteger(server.getCVar("vrr_jobblips")));
getServerConfig().createBusinessBlips = intToBool(toInteger(server.getCVar("vrr_businessblips")));
getServerConfig().createHouseBlips = intToBool(toInteger(server.getCVar("vrr_houseblips")));
getServerConfig().useRealTime = intToBool(toInteger(server.getCVar("vrr_realtime")));
getServerConfig().antiCheat.enabled = intToBool(toInteger(server.getCVar("vrr_anticheat")));
applyConfigToServer(serverConfig);
logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!");
@@ -112,6 +122,7 @@ function loadGlobalConfig() {
getGlobalConfig().economy = loadEconomyConfig();
getGlobalConfig().locale = loadLocaleConfig();
getGlobalConfig().accents = loadAccentConfig();
getGlobalConfig().discord = loadDiscordConfig();
}
// ===========================================================================
@@ -124,7 +135,7 @@ function loadServerConfigFromGameAndPort(gameId, port, mpMod) {
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerData(dbAssoc);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
@@ -144,7 +155,7 @@ function loadServerConfigFromId(tempServerId) {
if(dbQuery) {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerData(dbAssoc);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
@@ -178,7 +189,7 @@ function saveServerConfigToDatabase() {
let dbConnection = connectToDatabase();
if(dbConnection) {
let data = [
["svr_settings", toInteger(getServerConfig().settings)],
//["svr_settings", toInteger(getServerConfig().settings)],
["svr_start_time_hour", getServerConfig().hour],
["svr_start_time_min", getServerConfig().minute],
["svr_start_weather", getServerConfig().weather],
@@ -233,7 +244,7 @@ function saveServerConfigToDatabase() {
/**
*
* @return {ServerData} - Server configuration data
* @return {ServerConfigData} - Server configuration data
*
*/
function getServerConfig() {
@@ -283,24 +294,24 @@ function setTimeCommand(command, params, client) {
if(hour > 23 || hour < 0) {
messagePlayerError(client, "The hour must be between 0 and 23!");
return false;
}
}
if(minute > 59 || minute < 0) {
messagePlayerError(client, "The minute must be between 0 and 59!");
return false;
}
}
getServerConfig().hour = hour;
getServerConfig().minute = minute;
game.time.hour = getServerConfig().hour;
game.time.minute = getServerConfig().minute;
game.time.hour = getServerConfig().hour;
game.time.minute = getServerConfig().minute;
//checkServerGameTime();
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the time to ${makeReadableTime(hour, minute)}`);
announceAdminAction("ServerTimeSet", getPlayerName(client), makeReadableTime(hour, minute));
return true;
}
@@ -322,13 +333,13 @@ function setMinuteDurationCommand(command, params, client) {
return false;
}
let minuteDuration = toInteger(params);
let minuteDuration = toInteger(params);
getServerConfig().minuteDuration = minuteDuration;
setTimeMinuteDuration(null, minuteDuration);
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the minute duration to ${minuteDuration}ms`);
announceAdminAction("ServerMinuteDurationSet", getPlayerName(client), makeReadableTime(hour, minute));
return true;
}
@@ -354,15 +365,15 @@ function setWeatherCommand(command, params, client) {
if(!weatherId) {
messagePlayerError(client, `That weather ID or name is invalid!`);
return false;
}
}
game.forceWeather(toInteger(weatherId));
game.forceWeather(toInteger(weatherId));
getServerConfig().weather = weatherId;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} set the weather to {ALTCOLOUR}${getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]}`);
updateServerRules();
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]);
updateServerRules();
return true;
}
@@ -384,7 +395,7 @@ function setSnowingCommand(command, params, client) {
}
let splitParams = params.split(" ");
let falling = toInteger(getParam(params, " ", 1));
let falling = toInteger(getParam(params, " ", 1));
let ground = toInteger(getParam(params, " ", 2));
getServerConfig().fallingSnow = intToBool(falling);
@@ -394,8 +405,8 @@ function setSnowingCommand(command, params, client) {
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned falling snow ${getBoolRedGreenInlineColour(falling)}${getOnOffFromBool(falling)} {MAINCOLOUR}and ground snow ${getBoolRedGreenInlineColour(ground)}${getOnOffFromBool(ground)}`);
updateServerRules();
announceAdminAction("ServerSnowSet", getPlayerName(client), `${getBoolRedGreenInlineColour(falling)}${getOnOffFromBool(falling)}`, `${getBoolRedGreenInlineColour(ground)}${getOnOffFromBool(ground)}`);
updateServerRules();
return true;
}
@@ -417,7 +428,7 @@ function setServerGUIColoursCommand(command, params, client) {
}
let splitParams = params.split(" ");
let colourRed = toInteger(getParam(params, " ", 1)) || 255;
let colourRed = toInteger(getParam(params, " ", 1)) || 255;
let colourGreen = toInteger(getParam(params, " ", 2)) || 255;
let colourBlue = toInteger(getParam(params, " ", 3)) || 255;
@@ -430,8 +441,8 @@ function setServerGUIColoursCommand(command, params, client) {
getServerConfig().needsSaved = true;
//messageAdminAction(`${getPlayerName(client)} ${getInlineChatColourByName("orange")}set the server ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} ${getInlineChatColourByName("orange")}and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
//updateServerRules();
//announceAdminAction(`${getPlayerName(client)} ${getInlineChatColourByName("orange")}set the server ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} ${getInlineChatColourByName("orange")}and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
//updateServerRules();
return true;
}
@@ -452,8 +463,8 @@ function toggleServerLogoCommand(command, params, client) {
updatePlayerShowLogoState(null, getServerConfig().useLogo);
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned the server logo image ${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR}${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
return true;
}
@@ -472,7 +483,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobBlips = !getServerConfig().createJobBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))} {MAINCOLOUR}all job blips`);
announceAdminAction("ServerJobBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobBlips))}{MAINCOLOUR}`);
resetAllJobBlips();
return true;
}
@@ -492,7 +503,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createJobPickups = !getServerConfig().createJobPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveJobPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))} {MAINCOLOUR}all job pickups`);
announceAdminAction("ServerJobPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createJobPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createJobPickups))}{MAINCOLOUR}`);
resetAllJobPickups();
return true;
}
@@ -509,10 +520,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessBlipsCommand(command, params, client) {
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))} {MAINCOLOUR}all business blips`);
announceAdminAction("ServerBusinessBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessBlips))}{MAINCOLOUR}`);
resetAllBusinessBlips();
return true;
}
@@ -529,10 +540,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerBusinessPickupsCommand(command, params, client) {
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveBusinessPickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))} {MAINCOLOUR}all business pickups`);
announceAdminAction("ServerBusinessPickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createBusinessPickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createBusinessPickups))}{MAINCOLOUR}`);
resetAllBusinessPickups();
return true;
}
@@ -549,10 +560,10 @@ function toggleServerLogoCommand(command, params, client) {
*
*/
function toggleServerHouseBlipsCommand(command, params, client) {
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHouseBlipsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))} {MAINCOLOUR}all house blips`);
announceAdminAction("ServerHouseBlipsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHouseBlips)}${toUpperCase(getOnOffFromBool(getServerConfig().createHouseBlips))}{MAINCOLOUR}`);
resetAllHouseBlips();
return true;
}
@@ -572,7 +583,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned ${getBoolRedGreenInlineColour(doesServerHaveHousePickupsEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))} {MAINCOLOUR}all house pickups`);
announceAdminAction("ServerHousePickupsSet", `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().createHousePickups)}${toUpperCase(getOnOffFromBool(getServerConfig().createHousePickups))}{MAINCOLOUR}`);
resetAllHousePickups();
return true;
}
@@ -593,8 +604,8 @@ function toggleServerGUICommand(command, params, client) {
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned GUI ${toLowerCase(getOnOffFromBool(doesServerHaveGUIEnabled()))} for this server`);
updateServerRules();
announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned GUI ${toLowerCase(getOnOffFromBool(getServerConfig().useGUI))} for this server`);
updateServerRules();
return true;
}
@@ -611,12 +622,12 @@ function toggleServerGUICommand(command, params, client) {
*/
function toggleServerUseRealWorldTimeCommand(command, params, client) {
getServerConfig().useRealTime = !getServerConfig().useRealTime;
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
updateServerRules();
return true;
}
@@ -637,12 +648,12 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
return false;
}
getServerConfig().realTimeZone = toInteger(params);
getServerConfig().realTimeZone = toInteger(params);
getServerConfig().needsSaved = true;
messageAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
//announceAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
updateServerGameTime();
updateServerRules();
updateServerRules();
return true;
}
@@ -662,7 +673,7 @@ function reloadServerConfigurationCommand(command, params, client) {
applyConfigToServer(serverConfig);
updateServerRules();
messagePlayerSuccess(client, `You reloaded the server configuration!`);
messagePlayerSuccess(client, `You reloaded the server configuration!`);
return true;
}
@@ -679,7 +690,7 @@ function reloadServerConfigurationCommand(command, params, client) {
*/
function reloadEmailConfigurationCommand(command, params, client) {
emailConfig = loadEmailConfiguration();
messagePlayerSuccess(client, `You reloaded the email configuration!`);
messagePlayerSuccess(client, `You reloaded the email configuration!`);
return true;
}
@@ -746,6 +757,15 @@ function loadAccentConfig() {
// ===========================================================================
function loadDiscordConfig() {
let discordConfig = JSON.parse(loadTextFile(`config/discord.json`));
if(discordConfig != null) {
return discordConfig;
}
}
// ===========================================================================
function doesServerHaveGUIEnabled() {
return getServerConfig().useGUI;
}
@@ -782,7 +802,7 @@ function doesServerHaveJobPickupsEnabled() {
// ===========================================================================
function doesServerHaveBusinesBlipsEnabled() {
function doesServerHaveBusinessBlipsEnabled() {
return getServerConfig().createBusinessBlips;
}

View File

@@ -11,6 +11,7 @@
const VRR_PROMPT_NONE = 0;
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
const VRR_PROMPT_BIZORDER = 2;
const VRR_PROMPT_GIVEVEHTOCLAN = 3;
// Job Types
const VRR_JOB_NONE = 0;
@@ -346,4 +347,9 @@ const VRR_GPS_TYPE_BUSINESS = 1; // Business
const VRR_GPS_TYPE_POLICE = 2; // Police Station
const VRR_GPS_TYPE_HOSPITAL = 3; // Hospital
const VRR_GPS_TYPE_JOB = 4; // Job
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
const VRR_GPS_TYPE_GAMELOC = 5; // Game Location
// Discord Webhook Types
const VRR_DISCORD_WEBHOOK_NONE = 0;
const VRR_DISCORD_WEBHOOK_LOG = 1;
const VRR_DISCORD_WEBHOOK_ADMIN = 2;

View File

@@ -9,7 +9,7 @@
let scriptVersion = "1.0";
let serverStartTime = 0;
let logLevel = LOG_INFO;
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE|LOG_WARN|LOG_ERROR;
// ===========================================================================
@@ -31,6 +31,10 @@ let serverData = {
localeStrings: {},
cachedTranslations: [],
cachedTranslationFrom: [],
triggers: [],
npcs: [],
locales: [],
accents: [],
};
// ===========================================================================

View File

@@ -20,4 +20,3 @@ function initDatabaseScript() {
}
// ===========================================================================

View File

@@ -152,7 +152,7 @@ function addLogLevelCommand(command, params, client) {
sendPlayerLogLevel(null, logLevel);
messageAdminAction(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -222,7 +222,7 @@ function removeLogLevelCommand(command, params, client) {
sendPlayerLogLevel(null, logLevel);
messageAdminAction(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -380,15 +380,72 @@ function setPlayerTesterStatusCommand(command, params, client) {
let enabled = hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
messageAdminAction(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`)
messageAdmins(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`)
return true;
}
// ===========================================================================
function saveAllServerDataCommand(command, params, client) {
function testPromptGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerPromptGUI(targetClient, "Testing the two button prompt GUI", "Testing", "Yes", "No")
return true;
}
// ===========================================================================
function testInfoGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerInfoGUI(targetClient, "Testing the info dialog GUI", "Testing", "Ok");
return true;
}
// ===========================================================================
function testErrorGUICommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(params);
if(!targetClient) {
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
return false;
}
showPlayerErrorGUI(targetClient, "Testing the error dialog GUI", "Testing", "Ok");
return true;
}
// ===========================================================================
function saveServerDataCommand(command, params, client) {
messageAdmins(`{clanOrange}Vortrex has forced a manual save of all data. Initiating ...`);
saveAllServerDataToDatabase();
saveServerDataToDatabase();
messageAdmins(`{clanOrange}All server data saved to database successfully!`);
return true;
}
@@ -572,9 +629,9 @@ function streamAudioNameToAllPlayersCommand(command, params, client) {
// ===========================================================================
function fixAllServerBlipsCommand(command, params, client) {
deleteAllBusinessBlips();
deleteAllJobBlips();
deleteAllHouseBlips();
deleteAllBusinessBlips();
deleteAllJobBlips();
deleteAllHouseBlips();
let blips = getElementsByType(ELEMENT_BLIP);
blips.forEach((blip) => {

View File

@@ -16,31 +16,31 @@ function initDiscordScript() {
/*
addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
let commandData = getCommand(command);
let commandData = getCommand(command);
if(!commandData) {
messagePlayerError(discordUser, "That command does not exist!");
return false;
}
if(!commandData) {
messagePlayerError(discordUser, "That command does not exist!");
return false;
}
if(isCommandAllowedOnDiscord(command)) {
messagePlayerError(discordUser, "That command can not be used on Discord!");
return false;
}
if(isCommandAllowedOnDiscord(command)) {
messagePlayerError(discordUser, "That command can not be used on Discord!");
return false;
}
if(doesClientHavePermission(discordUser, getCommandRequiredPermissions(command))) {
messagePlayerError(discordUser, "You do not have permission to use that command!");
return false;
}
if(doesClientHavePermission(discordUser, getCommandRequiredPermissions(command))) {
messagePlayerError(discordUser, "You do not have permission to use that command!");
return false;
}
commandData.handlerFunction(command, params, discordUser);
commandData.handlerFunction(command, params, discordUser);
});
*/
// ===========================================================================
function messageDiscordUser(discordUser, messageText) {
let socketData = JSON.stringify({
let socketData = JSON.stringify({
type: "chat.message.text",
payload: {
author: discordUser.name,
@@ -53,88 +53,82 @@ function messageDiscordUser(discordUser, messageText) {
// ===========================================================================
function sendDiscordSocketData(socketData) {
if(!getDiscordSocket()) {
return false;
}
if(!getDiscordSocket()) {
return false;
}
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
}
// ===========================================================================
function isClientFromDiscord(client) {
if(client == null) {
return false;
}
if(client == null) {
return false;
}
if(client instanceof Client) {
return false;
} else {
return true;
}
if(client instanceof Client) {
return false;
} else {
return true;
}
}
// ===========================================================================
function getDiscordSocket() {
return false;
return false;
}
// ===========================================================================
function getDiscordUserData(discordUserId) {
return loadAccountFromDiscordUserId(discordUserId);
return loadAccountFromDiscordUserId(discordUserId);
}
// ===========================================================================
function messageDiscordChatChannel(message) {
if(!getServerConfig().discordConfig.sendChat) {
return false;
}
function messageDiscordChatChannel(messageString) {
if(getServerConfig().devServer) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Chat",
"content": message,
};
if(!getServerConfig().discord.sendChat) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.chatChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
function messageDiscordAdminChannel(message) {
if(!getServerConfig().discordConfig.sendAdminEvents) {
return false;
}
function messageDiscordEventChannel(messageString) {
if(getServerConfig().devServer == true) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Admin Event",
"content": message,
};
if(!getServerConfig().discord.sendEvents) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.adminChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
function messageDiscordEventChannel(message) {
if(!getServerConfig().discordConfig.sendEvents) {
return false;
}
function messageDiscordAdminChannel(messageString) {
if(getServerConfig().devServer == true) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Event",
"content": message,
};
if(!getServerConfig().discord.sendAdmin) {
return false;
}
triggerWebHook(getServerConfig().discordConfig.eventChannelWebHookURL, JSON.stringify(payloadData));
messageString = removeColoursInMessage(messageString);
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN);
}
// ===========================================================================

View File

@@ -30,12 +30,17 @@ function playerPayDay(client) {
let wealth = calculateWealth(client);
let grossIncome = getPlayerData(client).payDayAmount;
// Passive income
// Passive income
grossIncome = grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay;
// Payday bonus
// Payday bonus
grossIncome = grossIncome*getGlobalConfig().economy.grossIncomeMultiplier;
// Double bonus
if(isDoubleBonusActive()) {
grossIncome = grossIncome*2;
}
let incomeTaxAmount = calculateIncomeTax(wealth);
let netIncome = grossIncome-incomeTaxAmount;
@@ -49,11 +54,11 @@ function playerPayDay(client) {
let canPayNow = totalCash+netIncome;
if(incomeTaxAmount <= canPayNow) {
takePlayerCash(client, canPayNow);
messagePlayerInfo(client, `You covered the remaining taxes with {ALTCOLOUR}$${canPayNow} {MAINCOLOUR}in cash.`);
messagePlayerAlert(client, `{orange}You lost money since your taxes are more than your paycheck!`);
messagePlayerAlert(client, `{orange}If you don't have enough cash to cover taxes on next paycheck, you will lose stuff!`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${canPayNow}{MAINCOLOUR}`)}`);
messagePlayerAlert(client, `{orange}${getLocaleString(client, "LostMoneyFromTaxes")}`);
messagePlayerAlert(client, `{orange}${getLocaleString(client, "NextPaycheckRepossessionWarning")}`);
} else {
messagePlayerInfo(client, `{orange}You don't have enough cash to pay your taxes!`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "NotEnoughCashForTax")}`);
takePlayerCash(client, canPayNow);
let vehicleCount = getAllVehiclesOwnedByPlayer(client).length;
@@ -65,7 +70,7 @@ function playerPayDay(client) {
let newVehicleCount = getAllVehiclesOwnedByPlayer(client).length;
let newHouseCount = getAllHousesOwnedByPlayer(client).length;
let newBusinessCount = getAllBusinessesOwnedByPlayer(client).length;
messagePlayerInfo(client, `{orange}You lost ${newVehicleCount-vehicleCount} vehicles, ${newHouseCount-houseCount} houses, and ${newBusinessCount-businessCount} businesses to cover the remaining tax.`);
messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount-vehicleCount, newHouseCount-houseCount, newBusinessCount-businessCount)}`);
}
}
@@ -120,14 +125,14 @@ function setPayDayBonusMultiplier(command, params, client) {
let newMultiplier = params;
if(isNaN(newMultiplier)) {
messagePlayerError(client, getLocaleString(client, "AmountNotNumber"));
return false;
}
if(isNaN(newMultiplier)) {
messagePlayerError(client, getLocaleString(client, "AmountNotNumber"));
return false;
}
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
messageAdminAction(`${client.name} set payday bonus to ${newMultiplier*100}%`);
announceAdminAction(`PaydayBonusSet`, `{adminRed}${client.name}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
}
// ===========================================================================
@@ -157,6 +162,8 @@ function attemptRepossession(client, totalToPay) {
return true;
}
// ===========================================================================
function repossessFirstAsset(client) {
let vehicles = getAllVehiclesOwnedByPlayer(client);
if(vehicles.length > 0) {
@@ -193,4 +200,16 @@ function getAllBusinessesOwnedByPlayer(client) {
function getAllHousesOwnedByPlayer(client) {
return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
}
}
// ===========================================================================
function isDoubleBonusActive() {
if(isWeekend()) {
return true;
}
return false;
}
// ===========================================================================

View File

@@ -8,47 +8,47 @@
// ===========================================================================
function initEmailScript() {
if(!checkForSMTPModule()) {
return false;
}
if(!checkForSMTPModule()) {
return false;
}
logToConsole(LOG_INFO, "[VRR.Email]: Initializing email script ...");
emailConfig = loadEmailConfiguration();
emailConfig = loadEmailConfiguration();
logToConsole(LOG_INFO, "[VRR.Email]: Email script initialized successfully!");
}
// ===========================================================================
function sendEmail(toEmail, toName, subject, body) {
if(!checkForSMTPModule()) {
return false;
}
if(!checkForSMTPModule()) {
return false;
}
module.smtp.send(
getEmailConfig().smtp.host,
getEmailConfig().smtp.port,
intToBool(getEmailConfig().smtp.useTLS),
getEmailConfig().smtp.username,
getEmailConfig().smtp.password,
toEmail,
toName,
subject,
body,
getEmailConfig().smtp.from,
getEmailConfig().smtp.fromName);
module.smtp.send(
getEmailConfig().smtp.host,
getEmailConfig().smtp.port,
intToBool(getEmailConfig().smtp.useTLS),
getEmailConfig().smtp.username,
getEmailConfig().smtp.password,
toEmail,
toName,
subject,
body,
getEmailConfig().smtp.from,
getEmailConfig().smtp.fromName);
}
// ===========================================================================
function loadEmailConfiguration() {
let emailConfigFile = loadTextFile("config/email.json");
let emailConfigFile = loadTextFile("config/email.json");
return JSON.parse(emailConfigFile);
}
// ===========================================================================
function getEmailConfig() {
return emailConfig;
return emailConfig;
}
// ===========================================================================

View File

@@ -8,59 +8,60 @@
// ===========================================================================
function initEventScript() {
logToConsole(LOG_INFO, "[VRR.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_INFO, "[VRR.Event]: Event script initialized!");
logToConsole(LOG_INFO, "[VRR.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_INFO, "[VRR.Event]: Event script initialized!");
}
// ===========================================================================
function addAllEventHandlers() {
addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onResourceStart", onResourceStart);
addEventHandler("onResourceStop", onResourceStop);
addEventHandler("onServerStop", onResourceStop);
addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onProcess", onProcess);
addEventHandler("onEntityProcess", onEntityProcess);
addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined);
addEventHandler("onPlayerChat", onPlayerChat);
addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPlayerConnect", onPlayerConnect);
addEventHandler("onPlayerJoin", onPlayerJoin);
addEventHandler("onPlayerJoined", onPlayerJoined);
addEventHandler("onPlayerChat", onPlayerChat);
addEventHandler("onPlayerQuit", onPlayerQuit);
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
addEventHandler("onPedEnteringVehicle", onPedEnteringVehicle);
addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
addEventHandler("OnPlayerCommand", onPlayerCommand);
//addEventHandler("OnPlayerCommand", onPlayerCommand);
}
// ===========================================================================
function onPlayerConnect(event, ipAddress, port) {
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
// return false;
//}
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
// return false;
//}
}
// ===========================================================================
function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`);
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`);
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
messageDiscordEventChannel(`👋 ${client.name} is connecting to the server ...`);
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
}
// ===========================================================================
@@ -72,16 +73,16 @@ function onPlayerJoined(event, client) {
// ===========================================================================
function onElementStreamIn(event, element, client) {
//if(getPlayerDimension(client) != getElementDimension(element)) {
// event.preventDefault();
//}
//if(getPlayerDimension(client) != getElementDimension(element)) {
// event.preventDefault();
//}
if(getPlayerData(getClientFromIndex(element.owner)) != false ) {
if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
event.preventDefault();
destroyGameElement(element);
}
}
if(getPlayerData(getClientFromIndex(element.owner)) != false ) {
if(hasBitFlag(getPlayerData(getClientFromIndex(element.owner)).accountData.flags.moderation, getModerationFlagValue("DontSyncClientElements"))) {
event.preventDefault();
destroyGameElement(element);
}
}
}
// ===========================================================================
@@ -93,39 +94,44 @@ function onElementStreamOut(event, element, client) {
// ===========================================================================
function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
if(isPlayerLoggedIn(client)) {
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
}
if(isPlayerLoggedIn(client)) {
let reasonText = disconnectReasons[quitReasonId];
if(getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
}
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
messageDiscordEventChannel(`👋 ${client.name} has left the server (${reasonText})`);
messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has left the server.`);
savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
} else {
messageDiscordEventChannel(`👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
}
clearTemporaryVehicles();
clearTemporaryPeds();
clearTemporaryVehicles();
clearTemporaryPeds();
}
// ===========================================================================
async function onPlayerChat(event, client, messageText) {
event.preventDefault();
processPlayerChat(client, messageText);
processPlayerChat(client, messageText);
event.preventDefault();
}
// ===========================================================================
function onProcess(event, deltaTime) {
updateServerGameTime();
//checkPlayerSpawning();
//checkPlayerPedState();
//checkVehicleBurning();
updateServerGameTime();
//checkPlayerSpawning();
//checkPlayerPedState();
//checkVehicleBurning();
processVehiclePurchasing();
processVehiclePurchasing();
}
// ===========================================================================
@@ -136,89 +142,89 @@ function onEntityProcess(event, entity) {
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGVEHICLE;
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(getVehicleData(vehicle).locked) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
}
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
if(getVehicleData(vehicle).locked) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "lock")) {
messagePlayerTip(client, `🔒 This ${getVehicleName(vehicle)} is locked. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "lock").key))} {MAINCOLOUR}to unlock it.`);
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked. Use /lock to unlock it`);
}
} else {
messagePlayerNormal(client, `🔒 This ${getVehicleName(vehicle)} is locked and you don't have the keys to unlock it`);
}
getPlayerData(client).enteringVehicle = null;
makePlayerStopAnimation(client);
return false;
}
getPlayerData(client).enteringVehicle = null;
makePlayerStopAnimation(client);
return false;
}
getPlayerData(client).enteringVehicle = vehicle;
}
getPlayerData(client).enteringVehicle = vehicle;
}
}
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle) {
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
}
if(ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGVEHICLE;
}
if(!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
if(!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
}
// ===========================================================================
function onResourceStart(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} started!`);
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} started!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}started!`);
}
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}started!`);
}
}
// ===========================================================================
function onResourceStop(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} stopped!`);
logToConsole(LOG_WARN, `[VRR.Event] ${resource.name} stopped!`);
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}stopped!`);
}
if(resource != thisResource) {
messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name} {MAINCOLOUR}stopped!`);
}
if(resource == thisResource) {
saveAllServerDataToDatabase();
clearArray(getServerData().vehicles);
clearArray(getServerData().clients);
clearArray(getServerData().businesses);
clearArray(getServerData().houses);
clearArray(getServerData().factions);
clearArray(getServerData().jobs);
clearArray(getServerData().clans);
clearArray(getServerData().items);
clearArray(getServerData().itemTypes);
clearArray(getServerData().groundItemCache);
clearArray(getServerData().groundPlantCache);
kickAllClients();
}
if(resource == thisResource) {
saveServerDataToDatabase();
clearArray(getServerData().vehicles);
clearArray(getServerData().clients);
clearArray(getServerData().businesses);
clearArray(getServerData().houses);
clearArray(getServerData().factions);
clearArray(getServerData().jobs);
clearArray(getServerData().clans);
clearArray(getServerData().items);
clearArray(getServerData().itemTypes);
clearArray(getServerData().groundItemCache);
clearArray(getServerData().groundPlantCache);
kickAllClients();
}
collectAllGarbage();
collectAllGarbage();
}
// ===========================================================================
@@ -236,183 +242,202 @@ function onPlayerExitedSphere(client, sphere) {
// ===========================================================================
async function onPlayerEnteredVehicle(client, clientVehicle, seat) {
if(client == null) {
return false;
}
if(client == null) {
return false;
}
let vehicle = null;
let vehicle = null;
if(getGame() == VRR_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
} else {
if(client.player == null) {
return false;
}
if(getGame() == VRR_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
} else {
if(getPlayerPed(client) == null) {
return false;
}
await waitUntil(() => client != null && client.player != null && client.player.vehicle != null);
await waitUntil(() => client != null && getPlayerPed(client) != null && getPlayerVehicle(client) != null);
vehicle = client.player.vehicle;
}
vehicle = getPlayerVehicle(client);
}
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getPlayerVehicleSeat(client) == VRR_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if(getVehicleData(vehicle).rentPrice > 0) {
if(getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
}
} else {
let ownerName = "Nobody";
let ownerType = "None";
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch(getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
if(getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if(getVehicleData(vehicle).rentPrice > 0) {
if(getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, `You are renting this ${getVehicleName(vehicle)} for {ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)} per minute. {MAINCOLOUR}Use {ALTCOLOUR}/stoprent {MAINCOLOUR}if you want to stop renting it.`);
}
} else {
let ownerName = "Nobody";
let ownerType = "None";
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch(getVehicleData(vehicle).ownerType) {
case VRR_VEHOWNER_CLAN:
ownerName = getClanData(getClanIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "clan";
break;
case VRR_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "job";
break;
case VRR_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = "job";
break;
case VRR_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = "player";
break;
case VRR_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = "player";
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = "business";
break;
case VRR_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
ownerType = "business";
break;
default:
break;
}
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
}
default:
break;
}
messagePlayerAlert(client, `This ${getVehicleName(vehicle)} belongs to {ALTCOLOUR}${ownerName} (${ownerType})`);
}
if(!getVehicleData(vehicle).engine) {
if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
if(!getVehicleData(vehicle).engine) {
if(getVehicleData(vehicle).buyPrice == 0 && getVehicleData(vehicle).rentPrice == 0) {
if(doesPlayerHaveVehicleKeys(client, vehicle)) {
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "engine")) {
messagePlayerTip(client, `This ${getVehicleName(vehicle)}'s engine is off. Press {ALTCOLOUR}${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "engine").key))} {MAINCOLOUR}to start it.`);
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off. Use /engine to start it`);
}
} else {
messagePlayerAlert(client, `This ${getVehicleName(vehicle)}'s engine is off and you don't have the keys to start it`);
}
}
resetVehiclePosition(vehicle);
}
}
}
resetVehiclePosition(vehicle);
}
let currentSubAccount = getPlayerCurrentSubAccount(client);
let currentSubAccount = getPlayerCurrentSubAccount(client);
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if(isPlayerWorking(client)) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
stopReturnToJobVehicleCountdown(client);
}
}
}
}
if(getVehicleData(vehicle).streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
playRadioStreamForPlayer(client, radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
if(getVehicleData(vehicle).streamingRadioStation != -1) {
if(getPlayerData(client).streamingRadioStation != getVehicleData(vehicle).streamingRadioStation) {
playRadioStreamForPlayer(client, getServerData().radioStations[getVehicleData(vehicle).streamingRadioStation].url, true, getPlayerStreamingRadioVolume(client));
}
}
}
// ===========================================================================
function onPlayerExitedVehicle(client, vehicle) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
stopRadioStreamForPlayer(client);
stopRadioStreamForPlayer(client);
if(!getVehicleData(vehicle)) {
return false;
}
if(!getVehicleData(vehicle)) {
return false;
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
if(isPlayerWorking(client)) {
if(isPlayerOnJobRoute(client)) {
if(vehicle == getPlayerJobRouteVehicle(client)) {
startReturnToJobVehicleCountdown(client);
}
}
}
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("vrr.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
// ===========================================================================
function onPlayerDeath(client, position) {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = VRR_PEDSTATE_DEAD;
updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false);
setPlayerControlState(client, false);
setTimeout(function() {
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
if(isFadeCameraSupported()) {
fadeCamera(client, false, 1.0);
}
setTimeout(function() {
if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
if(isPlayerWorking(client)) {
stopWorking(client);
}
if(getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading);
} else {
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
} else {
let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer();
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
if(isPlayerWorking(client)) {
stopWorking(client);
}
if(getGame() == VRR_GAME_MAFIA_ONE) {
spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading);
} else {
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
}
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updatePlayerSpawnedState(client, true);
makePlayerStopAnimation(client);
setPlayerControlState(client, true);
}
}, 2000);
}, 1000);
@@ -421,179 +446,191 @@ function onPlayerDeath(client, position) {
// ===========================================================================
function onPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) {
//setTimeout(onPlayerSpawn, 250, ped);
onPlayerSpawn();
}
if(ped.type == ELEMENT_PLAYER) {
//setTimeout(onPlayerSpawn, 250, ped);
onPlayerSpawn();
}
}
// ===========================================================================
function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(client.player == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(getPlayerPed(client) == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!getPlayerData(client).loggedIn) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect();
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if(getServerGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(client.player, "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(client.player, "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
}
if(getServerGame() == VRR_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped body parts and props`);
setEntityData(getPlayerPed(client), "vrr.bodyParts", getPlayerCurrentSubAccount(client).bodyParts, true);
setEntityData(getPlayerPed(client), "vrr.bodyProps", getPlayerCurrentSubAccount(client).bodyProps, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(client.player, "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(getPlayerPed(client), "vrr.scale", getPlayerCurrentSubAccount(client).pedScale, true);
if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
if(isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
return false;
}
if(isCustomCameraSupported()) {
restorePlayerCamera(client);
}
if(isCustomCameraSupported()) {
restorePlayerCamera(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
if(areServerElementsSupported()) {
getPlayerData(client).ped = client.player;
}
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
if(areServerElementsSupported()) {
getPlayerData(client).ped = getPlayerPed(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: {businessBlue}${getCharacterFullName(client)}`, getColourByName("white"));
messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: {businessBlue}${getCharacterFullName(client)}`, getColourByName("white"));
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
logToConsole(LOG_DEBUG, `[VRR.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
//if(getPlayerCurrentSubAccount(client).interior != 0 || getPlayerCurrentSubAccount(client).dimension != 0) {
// updateAllInteriorVehiclesForPlayer(client, getPlayerCurrentSubAccount(client).interior, getPlayerCurrentSubAccount(client).dimension);
//}
//if(getPlayerCurrentSubAccount(client).interior != 0 || getPlayerCurrentSubAccount(client).dimension != 0) {
// updateAllInteriorVehiclesForPlayer(client, getPlayerCurrentSubAccount(client).interior, getPlayerCurrentSubAccount(client).dimension);
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
if(isSnowSupported()) {
updatePlayerSnowState(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
if(isSnowSupported()) {
updatePlayerSnowState(client);
}
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(client.player, "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
if(areServerElementsSupported() && getServerGame() == VRR_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walk and fightstyle for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "vrr.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
}
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
if(getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)) {
updatePlayerShowLogoState(client, true);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
}
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
}
//if(isGTAIV()) {
// setEntityData(client.player, "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(client.player, "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(client.player, "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(client.player, "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(client.player, "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(client.player, "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(client.player, "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(client.player, "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(client.player, "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(client.player, "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(client.player, "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(client.player, "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(client.player, "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//}
sendPlayerLocaleStrings(client);
if(isGTAIV()) {
//sendPlayerPedPartsAndProps(client);
}
//if(isGTAIV()) {
// setEntityData(getPlayerPed(client), "vrr.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(getPlayerPed(client), "vrr.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
if(isGTAIV()) {
//sendPlayerPedPartsAndProps(client);
}
if(areServerElementsSupported()) {
syncPlayerProperties(client);
//setTimeout(function() {
// syncPlayerProperties(client);
//}, 1000);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
if(areServerElementsSupported()) {
syncPlayerProperties(client);
//setTimeout(function() {
// syncPlayerProperties(client);
//}, 1000);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
//sendAllHousesToPlayer(client);
//sendAllJobLocationsToPlayer(client);
//sendAllVehiclesToPlayer(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
updateAllPlayerNameTags();
requestPlayerPedNetworkId(client);
}
if(!areServerElementsSupported()) {
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
sendAllJobsToPlayer(client);
//sendAllVehiclesToPlayer(client);
getPlayerData(client).payDayTickStart = sdl.ticks;
requestPlayerPedNetworkId(client);
}
getPlayerData(client).payDayTickStart = sdl.ticks;
messageDiscordEventChannel(`🧍 ${client.name} spawned as ${getCharacterFullName(client)}`);
}
// ===========================================================================
function onPlayerCommand(event, client, command, params) {
if(!doesCommandExist(command)) {
processPlayerCommand(command, params, client);
}
}
// ===========================================================================

View File

@@ -54,7 +54,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
return true;
}
@@ -64,7 +64,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
return true;
}
@@ -80,11 +80,11 @@ function doesPlayerHaveGateKeys(client, vehicle) {
// ===========================================================================
function getGateData(gateId) {
if(typeof getServerData().gates[gateId] != "undefined") {
return getServerData().gates[gateId];
}
if(typeof getServerData().gates[gateId] != "undefined") {
return getServerData().gates[gateId];
}
return false;
return false;
}
// ===========================================================================

View File

@@ -15,121 +15,148 @@ function initGUIScript() {
// ===========================================================================
function playerPromptAnswerNo(client) {
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
break;
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
default:
break;
}
default:
break;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
getPlayerData(client).promptType = VRR_PROMPT_NONE;
}
// ===========================================================================
function playerPromptAnswerYes(client) {
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
showPlayerNewCharacterGUI(client);
break;
switch(getPlayerData(client).promptType) {
case VRR_PROMPT_CREATEFIRSTCHAR:
showPlayerNewCharacterGUI(client);
break;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
case VRR_PROMPT_BIZORDER:
if(getPlayerData(client).businessOrderAmount > 0) {
if(getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost/getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, VRR_ITEM_OWNER_BIZFLOOR, getBusinessData(getPlayerData(client).businessOrderBusiness).databaseId, getPlayerData(client).businessOrderAmount);
cacheBusinessItems(getPlayerData(client).businessOrderBusiness);
getBusinessData(getPlayerData(client).businessOrderBusiness).till -= getPlayerData(client).businessOrderCost;
updateBusinessPickupLabelData(getPlayerData(client).businessOrderBusiness);
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
}
} else {
showPlayerErrorGUI(client, `You aren't ordering anything for a business!`, `Business Order Canceled`);
}
break;
}
} else {
showPlayerErrorGUI(client, ``, `Business Order Canceled`);
}
break;
default:
break;
}
case VRR_PROMPT_GIVEVEHTOCLAN:
if(!isPlayerInAnyVehicle(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
return false;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
if(!getVehicleData(getPlayerVehicle(client))) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
if(getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
getVehicleData(getPlayerVehicle(client)).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan"));
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
break;
default:
break;
}
getPlayerData(client).promptType = VRR_PROMPT_NONE;
}
// ===========================================================================
function canPlayerUseGUI(client) {
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
}
// ===========================================================================
function playerPromptAnswerYesCommand(command, params, client) {
playerPromptAnswerYes(client);
playerPromptAnswerYes(client);
}
// ===========================================================================
function playerPromptAnswerNoCommand(command, params, client) {
playerPromptAnswerNo(client);
playerPromptAnswerNo(client);
}
// ===========================================================================
function playerToggledGUI(client) {
toggleAccountGUICommand("gui", "", client);
toggleAccountGUICommand("gui", "", client);
}
// ===========================================================================
function showPlayerChangePasswordGUI(client) {
sendNetworkEventToPlayer("vrr.changePassword", client);
sendNetworkEventToPlayer("vrr.changePassword", client);
}
// ===========================================================================
function showPlayerTwoFactorAuthenticationGUI(client) {
sendNetworkEventToPlayer("vrr.2fa", client);
sendNetworkEventToPlayer("vrr.2fa", client);
}
// ===========================================================================

View File

@@ -15,144 +15,144 @@ function initHelpScript() {
// ===========================================================================
let randomTips = [
`{MAINCOLOUR}Look for yellow dots on your map for job locations.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/help keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Use /notips if you don't want to see tips and extra information`,
`{MAINCOLOUR}You can edit your keybinds using {ALTCOLOUR}/bindkey and /unbindkey`,
`{MAINCOLOUR}Press to see your inventory, and use number keys to select an item`,
`{MAINCOLOUR}Use /buy at a business to purchase items.`,
`{MAINCOLOUR}Found a bug? Report it with {ALTCOLOUR}/bug`,
`{MAINCOLOUR}Have an idea or suggestion for the server? Let the devs know using {ALTCOLOUR}/idea`,
`{MAINCOLOUR}Want to buy a business? Use /bizbuy at one for sale`,
`{MAINCOLOUR}Want to buy a house? Use /housebuy at one for sale`,
`{MAINCOLOUR}Want to buy a vehicle? Visit a dealership and enter one for info on how to buy it!`,
`{MAINCOLOUR}Switch to any of your characters with {ALTCOLOUR}/switchchar`,
`{MAINCOLOUR}Use {ALTCOLOUR}/iplogin {MAINCOLOUR}to automatically login when connecting with the same IP`,
`{MAINCOLOUR}Use {ALTCOLOUR}/houselights or /bizlights {MAINCOLOUR}to turn on/off the lights in your house or business`,
`{MAINCOLOUR}Use {ALTCOLOUR}/radiostation {MAINCOLOUR}to play an internet radio station in your car, house, or business`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Tax is based on your total wealth. This includes money, vehicles, businesses and more.`,
//`{MAINCOLOUR}Don't go broke because of a hospital bill! Get insured today by visiting an insurance agency!`,
//`{MAINCOLOUR}Don't go broke because your car was destroyed. Visit an insurance agency today!`,
//`{MAINCOLOUR}You can find most locations by using {ALTCOLOUR}/gps`,
//`{MAINCOLOUR}Want to advertise your business? Visit the news station and place an /ad today!`,
//`{MAINCOLOUR}You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
//`{MAINCOLOUR}Hold [#0066FF]E {MAINCOLOUR}to hail a nearby taxi if you need a ride.`,
//`{MAINCOLOUR}Press [#0066FF]G {MAINCOLOUR}to enter a vehicle as passenger.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/help loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/help clans {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Legal weapons can be purchased at any ammunation.`,
`{MAINCOLOUR}Look for yellow dots on your map for job locations.`,
`{MAINCOLOUR}You can set custom key binds. Use {ALTCOLOUR}/help keys {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Use /notips if you don't want to see tips and extra information`,
`{MAINCOLOUR}You can edit your keybinds using {ALTCOLOUR}/bindkey and /unbindkey`,
`{MAINCOLOUR}Press to see your inventory, and use number keys to select an item`,
`{MAINCOLOUR}Use /buy at a business to purchase items.`,
`{MAINCOLOUR}Found a bug? Report it with {ALTCOLOUR}/bug`,
`{MAINCOLOUR}Have an idea or suggestion for the server? Let the devs know using {ALTCOLOUR}/idea`,
`{MAINCOLOUR}Want to buy a business? Use /bizbuy at one for sale`,
`{MAINCOLOUR}Want to buy a house? Use /housebuy at one for sale`,
`{MAINCOLOUR}Want to buy a vehicle? Visit a dealership and enter one for info on how to buy it!`,
`{MAINCOLOUR}Switch to any of your characters with {ALTCOLOUR}/switchchar`,
`{MAINCOLOUR}Use {ALTCOLOUR}/iplogin {MAINCOLOUR}to automatically login when connecting with the same IP`,
`{MAINCOLOUR}Use {ALTCOLOUR}/houselights or /bizlights {MAINCOLOUR}to turn on/off the lights in your house or business`,
`{MAINCOLOUR}Use {ALTCOLOUR}/radiostation {MAINCOLOUR}to play an internet radio station in your car, house, or business`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Lower your car windows with /windows {ALTCOLOUR} to play the vehicle's internet radio station {ALTCOLOUR}(/radiostation) {MAINCOLOUR}to nearby players`,
//`{MAINCOLOUR}Tax is based on your total wealth. This includes money, vehicles, businesses and more.`,
//`{MAINCOLOUR}Don't go broke because of a hospital bill! Get insured today by visiting an insurance agency!`,
//`{MAINCOLOUR}Don't go broke because your car was destroyed. Visit an insurance agency today!`,
//`{MAINCOLOUR}You can find most locations by using {ALTCOLOUR}/gps`,
//`{MAINCOLOUR}Want to advertise your business? Visit the news station and place an /ad today!`,
//`{MAINCOLOUR}You can change your quick item display. Choices are GTAV-style pie menu or Minecraft-style hotbar`,
//`{MAINCOLOUR}Hold [#0066FF]E {MAINCOLOUR}to hail a nearby taxi if you need a ride.`,
//`{MAINCOLOUR}Press [#0066FF]G {MAINCOLOUR}to enter a vehicle as passenger.`,
//`{MAINCOLOUR}Banks can provide loans. Use {ALTCOLOUR}/help loans {MAINCOLOUR} for more details.`,
`{MAINCOLOUR}Want to make a clan? Use {ALTCOLOUR}/help clans {MAINCOLOUR} for details.`,
`{MAINCOLOUR}Legal weapons can be purchased at any ammunation.`,
];
// ===========================================================================
function helpCommand(command, params, client) {
if(areParamsEmpty(params)) {
showMainHelpMessage(client);
return false;
}
showMainHelpMessage(client);
return false;
}
let splitParams = params.split(" ");
let splitParams = params.split(" ");
switch(toLowerCase(getParam(params, " ", 1))) {
case "account":
showAccountHelpMessage(client);
break;
switch(toLowerCase(getParam(params, " ", 1))) {
case "account":
showAccountHelpMessage(client);
break;
case "vehicle":
case "veh":
case "vehs":
case "vehicles":
case "car":
case "cars":
showVehicleHelpMessage(client);
break;
case "vehicle":
case "veh":
case "vehs":
case "vehicles":
case "car":
case "cars":
showVehicleHelpMessage(client);
break;
case "dealership":
showVehicleDealershipHelpMessage(client);
break;
case "dealership":
showVehicleDealershipHelpMessage(client);
break;
case "business":
showBusinessHelpMessage(client);
break;
case "business":
showBusinessHelpMessage(client);
break;
case "job":
showJobHelpMessage(client);
break;
case "job":
showJobHelpMessage(client);
break;
case "chat":
showChatHelpMessage(client);
break;
case "chat":
showChatHelpMessage(client);
break;
case "rules":
showRulesHelpMessage(client);
break;
case "rules":
showRulesHelpMessage(client);
break;
case "website":
showWebsiteHelpMessage(client);
break;
case "website":
showWebsiteHelpMessage(client);
break;
case "discord":
showDiscordHelpMessage(client);
break;
case "discord":
showDiscordHelpMessage(client);
break;
case "anim":
case "anims":
case "animation":
case "animations":
showAnimationHelpMessage(client);
break;
case "anim":
case "anims":
case "animation":
case "animations":
showAnimationHelpMessage(client);
break;
case "skin":
case "skins":
case "clothes":
showClothesHelpMessage(client);
break;
case "skin":
case "skins":
case "clothes":
showClothesHelpMessage(client);
break;
case "key":
case "keys":
case "keybinds":
case "keybind":
case "bindkey":
case "bindkeys":
showBindKeysHelpMessage(client);
break;
case "key":
case "keys":
case "keybinds":
case "keybind":
case "bindkey":
case "bindkeys":
showBindKeysHelpMessage(client);
break;
case "command":
case "cmd":
showCommandHelpMessage(client, getParam(params, " ", 2));
break;
case "command":
case "cmd":
showCommandHelpMessage(client, getParam(params, " ", 2));
break;
case "clan":
case "clans":
case "group":
case "groups":
case "faction":
case "factions":
case "family":
case "families":
showClanHelpMessage(client);
break;
case "clan":
case "clans":
case "group":
case "groups":
case "faction":
case "factions":
case "family":
case "families":
showClanHelpMessage(client);
break;
case "radio":
case "radiostations":
case "music":
showRadioHelpMessage(client);
break;
case "radio":
case "radiostations":
case "music":
showRadioHelpMessage(client);
break;
case "economy":
case "wealth":
case "tax":
case "taxes":
case "payday":
showWealthAndTaxHelpMessage(client);
break;
case "economy":
case "wealth":
case "tax":
case "taxes":
case "payday":
showWealthAndTaxHelpMessage(client);
break;
default:
showMainHelpMessage(client);
break;
}
default:
showMainHelpMessage(client);
break;
}
}
// == Account Help =============================
@@ -184,188 +184,188 @@ function helpCommand(command, params, client) {
// ===========================================================================
function showMainHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHelpMainList")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /help <category> for commands and info. Example: {ALTCOLOUR}/help vehicle`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Help Categories: [#A9A9A9]account, command, vehicle, job, chat, rules, website, animation`);
messagePlayerNormal(client, `{clanOrange}• [#A9A9A9]skin, mechanic, dealership, discord, colour, keybind`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderHelpMainList")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use /help <category> for commands and info. Example: {ALTCOLOUR}/help vehicle`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Help Categories: [#A9A9A9]account, command, vehicle, job, chat, rules, website, animation`);
messagePlayerNormal(client, `{clanOrange}• [#A9A9A9]skin, mechanic, dealership, discord, colour, keybind`);
}
// ===========================================================================
function showAccountHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Do not share your password with anybody else.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/changepass{MAINCOLOUR} to change your password.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some settings you can use: {ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAccountHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 1, `{ALTCOLOUR}/changepass{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 2, `{ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert{MAINCOLOUR}`));
}
// ===========================================================================
function showVehicleHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit dealerships to buy new vehicles (Use {ALTCOLOUR}/help dealership {MAINCOLOUR}for more info.)`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some commands: {ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your personal vehicles will save wherever you or somebody else leaves them!`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit a mechanic garage to repair, colour, and tune up your car! {ALTCOLOUR}/help mechanic {MAINCOLOUR} for info`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Don't forget to register and insure your vehicle! Use {ALTCOLOUR}/gps {MAINCOLOUR}to find a DMV for this.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0, `{ALTCOLOUR}/help dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 1, `{ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 3, `{ALTCOLOUR}/help mechanic{MAINCOLOUR}`));
}
// ===========================================================================
function showVehicleDealershipHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleDealershipHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit a vehicle dealer to buy new vehicles. Use {ALTCOLOUR}/gps {MAINCOLOUR}to find one.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}At the dealer, simply enter a car you want to buy, and the price will be shown to you`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}If you want to buy the vehicle and have enough money, use {ALTCOLOUR}/buyveh {MAINCOLOUR}and you will be given keys`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}A new car for sale will appear when you drive away from the dealer.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleDealershipHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 0, `{ALTCOLOUR}/gps{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1, `{ALTCOLOUR}/buyveh{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 2));
}
// ===========================================================================
function showJobHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Visit job locations get a job and earn money. Look for yellow spots on the map`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}At a job location, use {ALTCOLOUR}/takejob {MAINCOLOUR}to get the job. Use {ALTCOLOUR}/quitjob {MAINCOLOUR}to quit your job`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/startwork {MAINCOLOUR}to begin working. You can also get a job {ALTCOLOUR}/uniform and {ALTCOLOUR}/equipment`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Most job vehicles are locked. Use {ALTCOLOUR}/lock {MAINCOLOUR}near one to enter it.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}When entering a job vehicle, information on how to do the job will be shown to you.`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderJobHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 1, `{ALTCOLOUR}/takejob{MAINCOLOUR}`, `{ALTCOLOUR}/quitjob{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 2, `{ALTCOLOUR}/lock{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "JobHelp", 3));
}
// ===========================================================================
function showChatHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderChatHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}There are two main types of chat: out-of-character (OOC) and in-character (IC)`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Mixing these two types is not proper roleplay. See {ALTCOLOUR}/rules {MAINCOLOUR}for info.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some chat commands: {ALTCOLOUR}/dm /whisper /talk /shout /me.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Some have shorter names available ({ALTCOLOUR}/t {MAINCOLOUR}for talk, {ALTCOLOUR}/s {MAINCOLOUR}for shout, etc)`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderChatHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 1, `{ALTCOLOUR}/rules{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 2, `{ALTCOLOUR}/dm /whisper /talk /shout /me{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ChatHelp", 3, `{ALTCOLOUR}/t{MAINCOLOUR}`, `{ALTCOLOUR}/s{MAINCOLOUR}`));
}
// ===========================================================================
function showRulesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 3));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/help language {MAINCOLOUR}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 3));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 4), `{ALTCOLOUR}/help language {MAINCOLOUR}`);
}
// ===========================================================================
function showWebsiteHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWebsiteInfo")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${server.getRule("Website")}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWebsiteInfo")));
messagePlayerHelpContent(client, `{MAINCOLOUR}${server.getRule("Website")}`);
}
// ===========================================================================
function showDiscordHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDiscordInfo")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${server.getRule("Website")}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderDiscordInfo")));
messagePlayerHelpContent(client, `{MAINCOLOUR}${server.getRule("Discord")}`);
}
// ===========================================================================
function showAnimationHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 1, `{ALTCOLOUR}/an {MAINCOLOUR}`, `{ALTCOLOUR}/anim {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 2, `{ALTCOLOUR}/animlist {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 1, `{ALTCOLOUR}/an {MAINCOLOUR}`, `{ALTCOLOUR}/anim {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AnimationHelp", 2, `{ALTCOLOUR}/animlist {MAINCOLOUR}`));
}
// ===========================================================================
function showClothesHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSkinHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/help items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 2));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderSkinHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 0, `{ALTCOLOUR}/buy {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 1, `{ALTCOLOUR}/help items {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "SkinHelp", 2));
}
// ===========================================================================
function showBindKeysHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBindableKeysHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 0, `{ALTCOLOUR}/keybinds {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 1, `{ALTCOLOUR}/bindkey {MAINCOLOUR}`, `{ALTCOLOUR}/unbindkey {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 2, `{ALTCOLOUR}K {MAINCOLOUR}`, `{ALTCOLOUR}L {MAINCOLOUR}`, `{ALTCOLOUR}J {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 3, `{ALTCOLOUR}I {MAINCOLOUR}`, `{ALTCOLOUR}1-9 {MAINCOLOUR}`, `{ALTCOLOUR}0 {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 4, `{ALTCOLOUR}U {MAINCOLOUR}`, `{ALTCOLOUR}O {MAINCOLOUR}`, `{ALTCOLOUR}P {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBindableKeysHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 0, `{ALTCOLOUR}/keybinds {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 1, `{ALTCOLOUR}/bindkey {MAINCOLOUR}`, `{ALTCOLOUR}/unbindkey {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 2, `{ALTCOLOUR}K{MAINCOLOUR}`, `{ALTCOLOUR}L{MAINCOLOUR}`, `{ALTCOLOUR}J{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 3, `{ALTCOLOUR}I{MAINCOLOUR}`, `{ALTCOLOUR}1-9{MAINCOLOUR}`, `{ALTCOLOUR}0{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "KeyBindHelp", 4, `{ALTCOLOUR}U{MAINCOLOUR}`, `{ALTCOLOUR}O{MAINCOLOUR}`, `{ALTCOLOUR}P{MAINCOLOUR}`));
}
// ===========================================================================
function showBusinessHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 2, `{ALTCOLOUR}/bizorder, /bizlock, /bizlights, /radiostation, /bizitemprice, /bizbuyprice, /bizfee, /biztill, /bizwithdraw, /bizdeposit`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 3));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 2, `{ALTCOLOUR}/bizorder, /bizlock, /bizlights, /radiostation, /bizitemprice, /bizbuyprice, /bizfee, /biztill, /bizwithdraw, /bizdeposit`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "BusinessHelp", 3));
}
// ===========================================================================
function showClanHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderClanHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 2, `{ALTCOLOUR}/clan, /clanmotd, /clanname, /clanowner, /clanhouse, /clanbiz, /claninvite, /clanuninvite, /clansetrank`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 3, `{ALTCOLOUR}/clanranks, /clanflags, /clanaddrank, /clandelrank, /clanaddrankflag, /clandelrankflag, /clanaddmemberflag, /clandelmemberflag`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderClanHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 2, `{ALTCOLOUR}/clan, /clanmotd, /clanname, /clanowner, /clanhouse, /clanbiz, /claninvite, /clanuninvite, /clansetrank`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "ClanHelp", 3, `{ALTCOLOUR}/clanranks, /clanflags, /clanaddrank, /clandelrank, /clanaddrankflag, /clandelrankflag, /clanaddmemberflag, /clandelmemberflag`));
}
// ===========================================================================
function showRadioHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderRadioHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 0, `{ALTCOLOUR}/radiostation {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 1, `{ALTCOLOUR}/radiostations {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 2, `{ALTCOLOUR}/radiovolume {MAINCOLOUR}`));
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderRadioHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 0, `{ALTCOLOUR}/radiostation {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 1, `{ALTCOLOUR}/radiostations {MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RadioHelp", 2, `{ALTCOLOUR}/radiovolume {MAINCOLOUR}`));
}
// ===========================================================================
function showWealthAndTaxHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your taxes on payday are ${100*getGlobalConfig().economy.incomeTaxRate}% of your calculated wealth.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Your calculated wealth is a total sum based on how many vehicles, houses, and businesses you have.`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Each vehicle is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}, {MAINCOLOUR}each house is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}, {MAINCOLOUR}and each business is {ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Use {ALTCOLOUR}/wealth {MAINCOLOUR}to see your current wealth, and {ALTCOLOUR}/tax {MAINCOLOUR}to see how much you'll pay in tax each payday`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 0, `{ALTCOLOUR}${100*getGlobalConfig().economy.incomeTaxRate}%{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 2, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerHouse}{MAINCOLOUR}`, `{ALTCOLOUR}${getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness}{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 3, `{ALTCOLOUR}/wealth{MAINCOLOUR}`, `{ALTCOLOUR}/tax{MAINCOLOUR}`));
}
// ===========================================================================
function showCommandHelpMessage(client, commandName) {
if(!commandName) {
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
return false;
}
if(!commandName) {
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
return false;
}
commandName = toLowerCase(commandName);
commandName = commandName.trim();
commandName = toLowerCase(commandName);
commandName = commandName.trim();
if(commandName.slice(0, 1) == "/") {
commandName = commandName.slice(1);
}
if(commandName.slice(0, 1) == "/") {
commandName = commandName.slice(1);
}
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.description}`);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`);
if(aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
} else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
}
if(aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.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(command.allowOnDiscord)}`);
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//}
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//}
}
// ===========================================================================
@@ -380,7 +380,7 @@ function showCommandHelpMessage(client, commandName) {
*
*/
function helpGetCarCommand(command, params, client) {
messagePlayerAlert(client, `You can buy a car by visiting a vehicle dealership. Use {ALTCOLOUR}/help vehicle {MAINCOLOUR}for more info.`);
messagePlayerAlert(client, getLocaleString(client, "CarCommandHelp", `{ALTCOLOUR}/help vehicle{MAINCOLOUR}`));
}
// ===========================================================================
@@ -395,7 +395,8 @@ function helpGetCarCommand(command, params, client) {
*
*/
function helpGetSkinCommand(command, params, client) {
messagePlayerAlert(client, `You can change your skin by visiting a clothes store. Use {ALTCOLOUR}/help skin {MAINCOLOUR}for more info.`);
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/help skin{MAINCOLOUR}`));
messagePlayerAlert(client, ``);
}
// ===========================================================================

View File

@@ -9,7 +9,9 @@
function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
getServerData().houses = loadHousesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().houses = loadHousesFromDatabase();
}
if(getServerConfig().createHousePickups) {
createAllHousePickups();
@@ -219,7 +221,7 @@ function setHouseOwnerCommand(command, params, client) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, "You don't own this house!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
@@ -259,7 +261,7 @@ function setHouseClanCommand(command, params, client) {
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if(getHouseData(houseId).ownerType == VRR_HOUSEOWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, "You don't own this house!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
@@ -305,7 +307,7 @@ function setHouseClanCommand(command, params, client) {
}
if(doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
messagePlayerError(client, "You can't set clan house ranks!");
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
@@ -496,7 +498,7 @@ function moveHouseEntranceCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -532,7 +534,7 @@ function moveHouseExitCommand(command, params, client) {
let houseId = getPlayerHouse(client);
if(!getHouseData(houseId)) {
messagePlayer(client, "You need to be near or inside a house!");
messagePlayer(client, getLocaleString(client, "InvalidHouse"));
return false;
}
@@ -718,7 +720,11 @@ function getPlayerHouse(client) {
// ===========================================================================
function saveAllHousesToDatabase() {
function saveHousesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
logToConsole(LOG_INFO, `[VRR.House]: Saving all server houses to database ...`);
for(let i in getServerData().houses) {
if(getServerData().houses[i].needsSaved) {
@@ -737,6 +743,8 @@ function saveHouseToDatabase(houseId) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
let safeExitCutscene = escapeDatabaseString(dbConnection, tempHouseData.exitCutscene);
let safeEntranceCutscene = escapeDatabaseString(dbConnection, tempHouseData.entranceCutscene);
let data = [
["house_server", getServerId()],
@@ -753,6 +761,7 @@ function saveHouseToDatabase(houseId) {
["house_entrance_vw", tempHouseData.entranceDimension],
["house_entrance_pickup", tempHouseData.entrancePickupModel],
["house_entrance_blip", tempHouseData.entranceBlipModel],
["house_entrance_cutscene", safeEntranceCutscene],
["house_exit_pos_x", tempHouseData.exitPosition.x],
["house_exit_pos_y", tempHouseData.exitPosition.y],
["house_exit_pos_z", tempHouseData.exitPosition.z],
@@ -761,10 +770,12 @@ function saveHouseToDatabase(houseId) {
["house_exit_vw", tempHouseData.exitDimension],
["house_exit_pickup", tempHouseData.exitPickupModel],
["house_exit_blip", tempHouseData.exitBlipModel],
["house_exit_cutscene", safeExitCutscene],
["house_buy_price", tempHouseData.buyPrice],
["house_rent_price", tempHouseData.rentPrice],
["house_has_interior", boolToInt(tempHouseData.hasInterior)],
["house_interior_lights", boolToInt(tempHouseData.interiorLights)],
];
let dbQuery = null;
@@ -874,10 +885,18 @@ function createHouseEntrancePickup(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementOnAllDimensions(getHouseData(houseId).entrancePickup, false);
setElementDimension(getHouseData(houseId).entrancePickup, getHouseData(houseId).entranceDimension);
addToWorld(getHouseData(houseId).entrancePickup);
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getServerGame()].house);
if(entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
setElementStreamInDistance(entrancePickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(entrancePickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(entrancePickup, false);
addToWorld(entrancePickup);
getHouseData(houseId).entrancePickup = entrancePickup;
updateHousePickupLabelData(houseId);
}
}
updateHousePickupLabelData(houseId);
}
@@ -898,14 +917,19 @@ function createHouseEntranceBlip(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).entranceBlip, false);
//getHouseData(houseId).entranceBlip.streamInDistance = 300;
//getHouseData(houseId).entranceBlip.streamOutDistance = 350;
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(getHouseData(houseId).entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).entranceBlip);
let entranceBlip = createGameBlip(getHouseData(houseId).entrancePosition, blipModelId, 1, getColourByName("houseGreen"));
if(entranceBlip != null) {
setElementDimension(entranceBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(entranceBlip, false);
setElementStreamInDistance(entranceBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(entranceBlip, false);
setEntityData(entranceBlip, "vrr.owner.type", VRR_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "vrr.owner.id", houseId, false);
addToWorld(entranceBlip);
getHouseData(houseId).entranceBlip = entranceBlip;
}
}
}
}
@@ -926,10 +950,18 @@ function createHouseExitPickup(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
setElementDimension(getHouseData(houseId).exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(getHouseData(houseId).exitPickup, false);
addToWorld(getHouseData(houseId).exitPickup);
let exitPickup = createGamePickup(pickupModelId, getHouseData(houseId).exitPosition, getGameConfig().pickupTypes[getServerGame()].house);
if(exitPickup != null) {
setElementDimension(exitPickup, getHouseData(houseId).exitDimension);
setElementOnAllDimensions(exitPickup, false);
setElementStreamInDistance(exitPickup, getGlobalConfig().housePickupStreamInDistance);
setElementStreamOutDistance(exitPickup, getGlobalConfig().housePickupStreamOutDistance);
setElementTransient(exitPickup, false);
addToWorld(exitPickup);
getHouseData(houseId).exitPickup = exitPickup;
updateHousePickupLabelData(houseId);
}
}
updateHousePickupLabelData(houseId);
}
@@ -952,12 +984,19 @@ function createHouseExitBlip(houseId) {
}
if(areServerElementsSupported()) {
getHouseData(houseId).exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
setElementDimension(getHouseData(houseId).exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(getHouseData(houseId).exitBlip, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(getHouseData(houseId).exitBlip, "vrr.owner.id", houseId, false);
addToWorld(getHouseData(houseId).exitBlip);
let exitBlip = createGameBlip(blipModelId, getHouseData(houseId).exitPosition, 1, getColourByName("houseGreen"));
if(exitBlip != null) {
setElementDimension(exitBlip, getHouseData(houseId).entranceDimension);
setElementOnAllDimensions(exitBlip, false);
setElementStreamInDistance(exitBlip, getGlobalConfig().houseBlipStreamInDistance);
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
setElementTransient(exitBlip, false);
setEntityData(exitBlip, "vrr.owner.type", VRR_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "vrr.owner.id", houseId, false);
addToWorld(exitBlip);
getHouseData(houseId).exitBlip = exitBlip;
}
}
}
}
@@ -989,6 +1028,15 @@ function getHouseOwnerTypeText(ownerType) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function getHouseInfoCommand(command, params, client) {
let houseId = getPlayerHouse(client);
@@ -1030,6 +1078,15 @@ function getHouseInfoCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setHouseBuyPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1058,6 +1115,15 @@ function setHouseBuyPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setHouseRentPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1086,6 +1152,15 @@ function setHouseRentPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function buyHouseCommand(command, params, client) {
let houseId = getPlayerHouse(client);
@@ -1195,6 +1270,15 @@ function deleteHouseExitBlip(houseId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function reloadAllHousesCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
@@ -1215,7 +1299,7 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups();
createAllHouseBlips();
messageAdminAction(`All houses have been reloaded by an admin!`);
announceAdminAction(`HousesReloaded`);
}
// ===========================================================================
@@ -1431,30 +1515,30 @@ function updateHousePickupLabelData(houseId) {
return false;
}
let houseData = getHouseData(houseId);
let houseData = getHouseData(houseId);
if(houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
//setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if(houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true);
} else {
if(houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true);
}
}
}
if(houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "vrr.owner.type", VRR_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "vrr.label.type", VRR_LABEL_HOUSE, true);
//setEntityData(houseData.entrancePickup, "vrr.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "vrr.label.locked", houseData.locked, true);
if(houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYHOUSE, true);
} else {
if(houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "vrr.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_RENTHOUSE, true);
}
}
}
if(houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
if(houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "vrr.owner.type", VRR_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "vrr.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "vrr.label.type", VRR_LABEL_EXIT, true);
}
}
// ===========================================================================

View File

@@ -10,7 +10,9 @@
function initItemScript() {
logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ...");
getServerData().itemTypes = loadItemTypesFromDatabase();
getServerData().items = loadItemsFromDatabase();
if(!getServerConfig().devServer) {
getServerData().items = loadItemsFromDatabase();
}
setItemTypeDataIndexes();
setItemDataIndexes();
@@ -132,6 +134,15 @@ function deleteGroundItemObject(itemId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createGroundItemCommand(command, params, client) {
let splitParams = params.split(" ");
let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
@@ -154,13 +165,22 @@ function createGroundItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createItemCommand(command, params, client) {
let splitParams = params.split(" ");
let itemType = getItemTypeFromParams(splitParams.slice(0, -1).join(" "));
let value = splitParams.slice(-1) || 1;
if(!getItemTypeData(itemType)) {
messagePlayerError(client, getLocaleString("InvalidItemType"));
messagePlayerError(client, getLocaleString(client, "InvalidItemType"));
return false;
}
@@ -176,6 +196,15 @@ function createItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function useItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -230,6 +259,15 @@ function useItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteGroundItemCommand(command, params, client) {
let itemId = getClosestItemOnGround(getPlayerPosition(client));
@@ -252,6 +290,15 @@ function deleteGroundItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function pickupItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -303,6 +350,15 @@ function pickupItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function dropItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -364,6 +420,15 @@ function dropItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function putItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -411,6 +476,15 @@ function putItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function takeItemCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -458,6 +532,15 @@ function takeItemCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function createItemTypeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -470,6 +553,15 @@ function createItemTypeCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeDropModelCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -490,6 +582,15 @@ function setItemTypeDropModelCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeOrderPriceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -510,6 +611,15 @@ function setItemTypeOrderPriceCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeRiskMultiplierCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -530,6 +640,15 @@ function setItemTypeRiskMultiplierCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleItemTypeEnabledCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -549,6 +668,15 @@ function toggleItemTypeEnabledCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeUseTypeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -569,6 +697,15 @@ function setItemTypeUseTypeCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setItemTypeUseValueCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -663,7 +800,7 @@ function playerUseItem(client, hotBarSlot) {
break;
case VRR_ITEM_USETYPE_ROPE:
closestPlayer = getClosestPlayer(getPlayerPosition(client), client.player);
closestPlayer = getClosestPlayer(getPlayerPosition(client), getPlayerPed(client));
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to tie up!");
@@ -1063,16 +1200,16 @@ function playerSwitchItem(client, newHotBarSlot) {
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
} else {
let ammoItemSlot = getPlayerFirstAmmoItemForWeapon(client, getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId);
if(ammoItemSlot != false) {
getItemData(newHotBarItem).value = getItemData(getPlayerData(client).hotBarItems[ammoItemSlot]).value;
givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true);
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
deleteItem(getPlayerData(client).hotBarItems[ammoItemSlot]);
} else {
messagePlayerError(client, getLocaleString(client, "ItemUnequippableNoAmmo", getItemName(newHotBarItem), newHotBarSlot));
}
let ammoItemSlot = getPlayerFirstAmmoItemForWeapon(client, getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId);
if(ammoItemSlot != false) {
getItemData(newHotBarItem).value = getItemData(getPlayerData(client).hotBarItems[ammoItemSlot]).value;
givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useId), toInteger(getItemData(newHotBarItem).value), true, true);
setPlayerWeaponDamageEnabled(client, true);
setPlayerWeaponDamageEvent(client, VRR_WEAPON_DAMAGE_EVENT_NORMAL);
deleteItem(getPlayerData(client).hotBarItems[ammoItemSlot]);
} else {
messagePlayerError(client, getLocaleString(client, "ItemUnequippableNoAmmo", getItemName(newHotBarItem), newHotBarSlot));
}
}
} else if(getItemTypeData(getItemData(newHotBarItem).itemTypeIndex).useType == VRR_ITEM_USETYPE_TAZER) {
if(getItemData(newHotBarItem).value > 0) {
@@ -1105,6 +1242,15 @@ function playerSwitchItem(client, newHotBarSlot) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function playerSwitchHotBarSlotCommand(command, params, client) {
clearPlayerItemActionState(client);
@@ -1394,12 +1540,30 @@ function getBestItemToTake(client, slot) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listPlayerInventoryCommand(command, params, client) {
showPlayerInventoryToPlayer(client, client);
}
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listBusinessStorageInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
@@ -1418,6 +1582,15 @@ function listBusinessStorageInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listBusinessFloorInventoryCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
@@ -1436,6 +1609,15 @@ function listBusinessFloorInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listHouseInventoryCommand(command, params, client) {
let houseId = (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
@@ -1454,6 +1636,15 @@ function listHouseInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function listItemInventoryCommand(command, params, client) {
let itemId = getClosestItemOnGround(getPlayerPosition(client));
@@ -1472,6 +1663,10 @@ function listItemInventoryCommand(command, params, client) {
// ===========================================================================
/**
* @param {number} itemId - The data index of the item
* @return {ItemData} The item's data (class instance)
*/
function getItemData(itemId) {
if(typeof getServerData().items[itemId] != "undefined") {
return getServerData().items[itemId];
@@ -1481,37 +1676,54 @@ function getItemData(itemId) {
// ===========================================================================
/**
* @param {number} itemTypeId - The data index of the item type
* @return {ItemTypeData} The item type's data (class instance)
*/
function getItemTypeData(itemTypeId) {
return getServerData().itemTypes[itemTypeId];
}
// ===========================================================================
function saveAllItemsToDatabase() {
function saveItemsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().items) {
if(getServerData().items[i].needsSaved) {
if(getServerData().items[i].databaseId != -1) {
saveItemToDatabase(getServerData().items[i]);
}
}
saveItemToDatabase(i);
}
}
// ===========================================================================
function saveAllItemTypesToDatabase() {
function saveItemTypesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().itemTypes) {
if(getServerData().itemTypes[i].needsSaved) {
if(getServerData().itemTypes[i].databaseId != -1) {
saveItemTypeToDatabase(getServerData().itemTypes[i]);
}
}
saveItemTypeToDatabase(i);
}
}
// ===========================================================================
function saveItemToDatabase(itemData) {
function saveItemToDatabase(itemId) {
let itemData = getItemData(itemId);
if(itemData == false) {
return false;
}
if(itemData.databaseId == -1) {
return false;
}
if(!itemData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item '${itemData.index}' to database ...`);
let dbConnection = connectToDatabase();
@@ -1553,15 +1765,36 @@ function saveItemToDatabase(itemData) {
// ===========================================================================
function saveItemTypeToDatabase(itemTypeData) {
function saveItemTypeToDatabase(itemTypeId) {
let itemTypeData = getItemTypeData(itemTypeId);
if(itemTypeData == false) {
return false;
}
if(itemTypeData.databaseId == -1) {
return false;
}
if(!itemTypeData.needsSaved) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Item]: Saving item type '${itemTypeData.name}' to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeItemTypeName = escapeDatabaseString(dbConnection, itemTypeData.name);
let safeAnimationUse = escapeDatabaseString(dbConnection, itemTypeData.useAnimationName);
let safeAnimationDrop = escapeDatabaseString(dbConnection, itemTypeData.dropAnimationName);
let safeAnimationPickup = escapeDatabaseString(dbConnection, itemTypeData.pickupAnimationName);
let safeAnimationGive = escapeDatabaseString(dbConnection, itemTypeData.giveAnimationName);
let safeAnimationTake = escapeDatabaseString(dbConnection, itemTypeData.takeAnimationName);
let safeAnimationSwitch = escapeDatabaseString(dbConnection, itemTypeData.switchAnimationName);
let data = [
["item_type_id", itemTypeData.databaseId],
["item_type_server", itemTypeData.serverId],
["item_type_name", itemTypeData.name],
["item_type_name", safeItemTypeName],
["item_type_enabled", itemTypeData.enabled],
["item_type_use_type", itemTypeData.useType],
["item_type_drop_type", itemTypeData.dropType],
@@ -1592,6 +1825,12 @@ function saveItemTypeToDatabase(itemTypeData) {
["item_type_delay_take", itemTypeData.takeDelay],
["item_type_delay_give", itemTypeData.giveDelay],
["item_type_delay_drop", itemTypeData.dropDelay],
["item_type_anim_use", safeAnimationUse],
["item_type_anim_drop", safeAnimationDrop],
["item_type_anim_pickup", safeAnimationPickup],
["item_type_anim_give", safeAnimationGive],
["item_type_anim_take", safeAnimationTake],
["item_type_anim_switch", safeAnimationSwitch],
];
let dbQuery = null;
@@ -1698,7 +1937,7 @@ function playerItemActionDelayComplete(client) {
break;
}
clearPlayerItemActionState(client);
clearPlayerItemActionState(client);
}
// ===========================================================================
@@ -1757,6 +1996,15 @@ function getPlayerFirstItemSlotByUseType(client, useType) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function toggleItemEnabledCommand(command, params, client) {
if(!getPlayerActiveItem(client)) {
messagePlayerError(client, `You aren't holding anything!`);
@@ -1774,6 +2022,15 @@ function toggleItemEnabledCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteItemInPlayerInventoryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -1815,6 +2072,15 @@ function deleteItemInPlayerInventoryCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function deleteAllItemsInPlayerInventoryCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -2084,19 +2350,19 @@ function getItemTypeFromParams(params) {
// ===========================================================================
function getPlayerFirstAmmoItemForWeapon(client, weaponId) {
for(let i in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[i] != -1) {
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) {
return i;
}
}
}
}
}
for(let i in getPlayerData(client).hotBarItems) {
if(getPlayerData(client).hotBarItems[i] != -1) {
if(getItemData(getPlayerData(client).hotBarItems[i]) != false) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == VRR_ITEM_USETYPE_AMMO_CLIP) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useId == weaponId) {
return i;
}
}
}
}
}
return false;
return false;
}
// ===========================================================================

View File

@@ -10,27 +10,27 @@
// ===========================================================================
function isPlayerHandCuffed(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
}
// ===========================================================================
function handCuffPlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function unHandCuffPlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================
function isPlayerSurrendered(client) {
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
}
// ===========================================================================

View File

@@ -8,48 +8,48 @@
// ===========================================================================
function getItemWithPhoneNumber(phoneNumber) {
for(let i in getServerData().items) {
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
if(getItemData(i).value == phoneNumber) {
return i;
}
}
}
return -1;
for(let i in getServerData().items) {
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
if(getItemData(i).value == phoneNumber) {
return i;
}
}
}
return -1;
}
// ===========================================================================
function isPhoneItemEnabled(itemIndex) {
return getItemData(itemIndex).enabled;
return getItemData(itemIndex).enabled;
}
// ===========================================================================
function ringPhoneForNearbyPlayers(itemIndex) {
/*
if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) {
case VRR_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break;
/*
if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) {
case VRR_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
case VRR_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
}
}
*/
case VRR_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
}
}
*/
}
// ===========================================================================
function phoneTransmit(radioFrequency, messageText, transmittingPlayer) {
phoneOutgoingToNearbyPlayers(transmittingPlayer, messageText);
phoneOutgoingToNearbyPlayers(transmittingPlayer, messageText);
}
// ===========================================================================

View File

@@ -10,21 +10,21 @@
// ===========================================================================
function isPlayerTied(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
}
// ===========================================================================
function ropeTiePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function ropeUnTiePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
}
// ===========================================================================

View File

@@ -10,34 +10,34 @@
// ===========================================================================
function isPlayerTazed(client) {
return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
}
// ===========================================================================
function tazePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
setPlayerControlState(client, false);
getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
setPlayerControlState(client, false);
let animationId = getAnimationFromParams("tazed");
if(animationId != false) {
forcePlayerPlayAnimation(client, animationId);
}
let animationId = getAnimationFromParams("tazed");
if(animationId != false) {
forcePlayerPlayAnimation(client, animationId);
}
setTimeout(function() {
unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration);
setTimeout(function() {
unTazePlayer(client);
doActionToNearbyPlayers(client, `The tazer effect wears off`);
}, getGlobalConfig().tazerEffectDuration);
}
// ===========================================================================
function unTazePlayer(client) {
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
makePedStopAnimation(getPlayerData(client).ped);
}

View File

@@ -16,15 +16,15 @@ function getPlayerActiveWalkieTalkieFrequency(client) {
return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value;
}
}
}
}
return false;
return false;
}
// ===========================================================================
function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
//let clients = getServerData().items;
//for(let i in clients) {

View File

@@ -617,9 +617,9 @@ function stopWorking(client) {
let jobVehicle = getPlayerData(client).lastJobVehicle;
if(jobVehicle) {
if(client.player.vehicle) {
if(getPlayerVehicle(client) == jobVehicle) {
removePlayerFromVehicle(client);
//client.player.removeFromVehicle();
//getPlayerPed(client).removeFromVehicle();
}
respawnVehicle(jobVehicle);
@@ -631,7 +631,7 @@ function stopWorking(client) {
deleteJobItems(client);
restorePlayerJobLockerItems(client);
respawnJobVehicle(client);
sendPlayerStopJobRoute(client);
sendPlayerStopJobRoute(client);
let jobId = getPlayerJob(client);
switch(getJobType(jobId)) {
@@ -665,9 +665,9 @@ function stopWorking(client) {
case VRR_JOB_DRUG:
break;
case VRR_JOB_GENERIC:
messagePlayerInfo(client, "Your vehicle has been respawned at your job location");
break;
case VRR_JOB_GENERIC:
messagePlayerInfo(client, "Your vehicle has been respawned at your job location");
break;
default:
break;
@@ -753,13 +753,13 @@ function jobUniformCommand(command, params, client) {
return false;
}
if(uniformId == 0) {
setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
meActionToNearbyPlayers(client, `takes off their uniform`);
} else {
setPlayerSkin(client, jobData.uniforms[uniformId-1].skin);
meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId-1].name)} ${jobData.uniforms[uniformId-1].name} uniform`);
}
if(uniformId == 0) {
setPlayerSkin(client, getPlayerCurrentSubAccount(client).skin);
meActionToNearbyPlayers(client, `takes off their uniform`);
} else {
setPlayerSkin(client, jobData.uniforms[uniformId-1].skin);
meActionToNearbyPlayers(client, `puts on ${getProperDeterminerForName(jobData.uniforms[uniformId-1].name)} ${jobData.uniforms[uniformId-1].name} uniform`);
}
}
// ===========================================================================
@@ -942,7 +942,7 @@ function reloadAllJobsCommand(command, params, client) {
}
}
messageAdminAction(`All server jobs have been reloaded by an admin!`);
announceAdminAction("AllJobsReloaded");
}
// ===========================================================================
@@ -966,8 +966,8 @@ function createJob(name) {
tempJobData.pickupModel = getGameConfig().pickupModels[getGame()].job;
getServerData().jobs.push(tempJobData);
saveJobToDatabase(tempJobData);
setAllJobDataIndexes();
saveJobToDatabase(tempJobData);
setAllJobDataIndexes();
}
// ===========================================================================
@@ -1213,17 +1213,17 @@ function setJobRouteAllLocationDelaysCommand(command, params, client) {
let jobId = getPlayerJob(client);
let jobRoute = getPlayerJobRoute(client);
let delay = getParam(params, " ", 1);
let delay = getParam(params, " ", 1);
if(isNaN(delay)) {
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
if(isNaN(delay)) {
messagePlayerError(client, getLocaleString(client, "TimeNotNumber"))
return false;
}
for(let i in getJobData(jobId).routes[jobRoute].locations) {
getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay;
getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true;
}
getJobData(jobId).routes[jobRoute].locations[i].stopDelay = delay;
getJobData(jobId).routes[jobRoute].locations[i].needsSaved = true;
}
messageAdmins(`${getPlayerName(client)} {MAINCOLOUR}${getEnabledDisabledFromBool(getJobData(jobId).enabled)}{MAINCOLOUR} set route {ALTCOLOUR}${oldName}{MAINCOLOUR} location's stop delays to {ALTCOLOUR}${delay/1000}{MAINCOLOUR} seconds for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`);
}
@@ -1569,40 +1569,40 @@ function forceAllPlayersToStopWorking() {
// ===========================================================================
function jobStartRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
return false;
}
if(!isPlayerWorking(client)) {
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You aren't working yet! Use /startwork first.");
return false;
}
return false;
}
if(getJobData(getPlayerJob(client)).routes.length == 0) {
if(getJobData(getPlayerJob(client)).routes.length == 0) {
messagePlayerError(client, "Your job doesn't have any routes for this location!");
return false;
return false;
}
if(!isPlayerInJobVehicle(client)) {
messagePlayerError(client, "You need to be in a vehicle that belongs to your job!");
return false;
return false;
}
if(isPlayerOnJobRoute(client)) {
if(isPlayerOnJobRoute(client)) {
messagePlayerError(client, "You're already on a job route! Finish the route or use /stoproute");
return false;
return false;
}
let forceRoute = -1;
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
if(!areParamsEmpty(params)) {
let tempRoute = getJobRouteFromParams(params, getPlayerJob(client));
if(tempRoute != false) {
forceRoute = tempRoute;
}
}
}
let forceRoute = -1;
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
if(!areParamsEmpty(params)) {
let tempRoute = getJobRouteFromParams(params, getPlayerJob(client));
if(tempRoute != false) {
forceRoute = tempRoute;
}
}
}
startJobRoute(client, forceRoute);
return true;
@@ -1611,24 +1611,24 @@ function jobStartRouteCommand(command, params, client) {
// ===========================================================================
function jobStopRouteCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
return false;
}
if(!isPlayerWorking(client)) {
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You aren't working yet! Use /startwork first.");
return false;
}
return false;
}
//if(!doesPlayerHaveJobType(client, VRR_JOB_BUS) && !doesPlayerHaveJobType(client, VRR_JOB_GARBAGE)) {
//if(!doesPlayerHaveJobType(client, VRR_JOB_BUS) && !doesPlayerHaveJobType(client, VRR_JOB_GARBAGE)) {
// messagePlayerError(client, "Your job doesn't use a route!");
// return false;
// return false;
//}
if(!isPlayerOnJobRoute(client)) {
messagePlayerError(client, "You aren't on a job route!");
return false;
return false;
}
stopJobRoute(client, false, false);
@@ -1660,21 +1660,21 @@ function isPlayerWorking(client) {
// ===========================================================================
function startJobRoute(client, forceRoute = -1) {
let jobId = getPlayerJob(client);
let jobRoute = 0;
let jobId = getPlayerJob(client);
let jobRoute = 0;
if(forceRoute == -1) {
jobRoute = getRandomJobRouteForLocation(getClosestJobLocationForJob(getPlayerPosition(client), jobId));
} else {
jobRoute = forceRoute;
}
if(forceRoute == -1) {
jobRoute = getRandomJobRouteForLocation(getClosestJobLocationForJob(getPlayerPosition(client), jobId));
} else {
jobRoute = forceRoute;
}
if(jobRoute == -1) {
messagePlayerError(client, `There are no routes for this location.`);
return false;
}
if(jobRoute == -1) {
messagePlayerError(client, `There are no routes for this location.`);
return false;
}
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} is starting job route ${jobRoute} for job ${jobId}`);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} is starting job route ${jobRoute} for job ${jobId}`);
getPlayerData(client).jobRoute = jobRoute;
getPlayerData(client).jobRouteLocation = 0;
@@ -1684,26 +1684,26 @@ function startJobRoute(client, forceRoute = -1) {
getPlayerVehicle(client).colour2 = getJobRouteData(jobId, jobRoute).vehicleColour2;
messagePlayerNormal(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, jobRoute).startMessage, jobId, jobRoute));
if(getJobRouteData(jobId, jobRoute).locations.length > 0) {
if(getJobRouteData(jobId, jobRoute).locations.length > 0) {
showCurrentJobLocation(client);
} else {
messagePlayerError(client, `There are no locations for this route.`);
}
messagePlayerError(client, `There are no locations for this route.`);
}
}
// ===========================================================================
function stopJobRoute(client, successful = false, alertPlayer = true) {
let jobId = getPlayerJob(client);
let jobId = getPlayerJob(client);
if(alertPlayer) {
messagePlayerAlert(client, replaceJobRouteStringsInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).finishMessage), jobId, getPlayerJobRoute(client));
}
if(successful == true) {
finishSuccessfulJobRoute(client);
return false;
}
if(successful == true) {
finishSuccessfulJobRoute(client);
return false;
}
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
@@ -1797,26 +1797,26 @@ function deleteJobLocation(jobLocationData) {
quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${jobLocationData.databaseId}`);
}
deleteJobLocationBlip(tempJob, tempLocation);
deleteJobLocationPickup(tempJob, tempLocation);
deleteJobLocationBlip(tempJob, tempLocation);
deleteJobLocationPickup(tempJob, tempLocation);
getJobData(getJobIdFromDatabaseId(tempJob)).locations.splice(tempLocation, 1);
setAllJobDataIndexes();
setAllJobDataIndexes();
}
// ===========================================================================
function freezePlayerJobVehicleForRouteLocation(client) {
getVehicleData(getPlayerVehicle(client)).engine = false;
getVehicleData(getPlayerVehicle(client)).engine = false;
setVehicleEngine(getPlayerVehicle(client), getVehicleData(getPlayerVehicle(client)).engine);
//setPlayerControlState(client, false);
//setPlayerControlState(client, false);
}
// ===========================================================================
function unFreezePlayerJobVehicleForRouteLocation(client) {
getVehicleData(getPlayerVehicle(client)).engine = true;
getVehicleData(getPlayerVehicle(client)).engine = true;
setVehicleEngine(getPlayerVehicle(client), getVehicleData(getPlayerVehicle(client)).engine);
//setPlayerControlState(client, true);
//setPlayerControlState(client, true);
}
// ===========================================================================
@@ -2236,7 +2236,7 @@ function saveJobUniformToDatabase(jobUniformData) {
// ===========================================================================
function saveAllJobsToDatabase() {
function saveJobsToDatabase() {
for(let i in getServerData().jobs) {
saveJobToDatabase(getServerData().jobs[i]);
@@ -2291,24 +2291,33 @@ function createJobLocationPickup(jobId, locationId) {
return false;
}
if(getJobData(jobId).pickupModel != -1) {
let tempJobData = getJobData(jobId);
if(tempJobData.pickupModel != -1) {
let pickupModelId = getGameConfig().pickupModels[getServerGame()].Job;
if(getJobData(jobId).pickupModel != 0) {
pickupModelId = getJobData(jobId).pickupModel;
if(tempJobData.pickupModel != 0) {
pickupModelId = tempJobData.pickupModel;
}
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${getServerData().jobs[jobId].name} job`);
logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating pickup for location ${locationId} of the ${tempJobData.name} job`);
getJobData(jobId).locations[locationId].pickup = createGamePickup(pickupModelId, getJobData(jobId).locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
setElementDimension(getJobData(jobId).locations[locationId].pickup, getJobData(jobId).locations[locationId].dimension);
setElementOnAllDimensions(getJobData(jobId).locations[locationId].pickup, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.owner.type", VRR_PICKUP_JOB, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.owner.id", locationId, false);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.type", VRR_LABEL_JOB, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.name", getJobData(jobId).name, true);
setEntityData(getServerData().jobs[jobId].locations[locationId].pickup, "vrr.label.jobType", getJobData(jobId).databaseId, true);
addToWorld(getJobData(jobId).locations[locationId].pickup);
if(areServerElementsSupported()) {
let pickup = createGamePickup(pickupModelId, tempJobData.locations[locationId].position, getGameConfig().pickupTypes[getServerGame()].job);
if(pickup != false) {
tempJobData.locations[locationId].pickup = pickup;
setElementDimension(pickup, tempJobData.locations[locationId].dimension);
setElementOnAllDimensions(pickup, false);
setEntityData(pickup, "vrr.owner.type", VRR_PICKUP_JOB, false);
setEntityData(pickup, "vrr.owner.id", locationId, false);
setEntityData(pickup, "vrr.label.type", VRR_LABEL_JOB, true);
setEntityData(pickup, "vrr.label.name", tempJobData.name, true);
setEntityData(pickup, "vrr.label.jobType", tempJobData.databaseId, true);
addToWorld(pickup);
}
} else {
// sendJobToPlayer(null, jobId, tempJobData.name, tempJobData.locations[locationId].position, pickupModel);
}
}
}
@@ -2319,6 +2328,8 @@ function createJobLocationBlip(jobId, locationId) {
return false;
}
let tempJobData = getJobData(jobId);
if(getJobData(jobId).blipModel != -1) {
let blipModelId = getGameConfig().blipSprites[getServerGame()].Job;
@@ -2326,12 +2337,17 @@ function createJobLocationBlip(jobId, locationId) {
blipModelId = getJobData(jobId).blipModel;
}
getJobData(jobId).locations[locationId].blip = createGameBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job"));
//setElementStreamInDistance(getServerData().jobs[i].locations[j].blip, 30);
//setElementStreamOutDistance(getServerData().jobs[i].locations[j].blip, 40);
setElementOnAllDimensions(getJobData(jobId).locations[locationId].blip, false);
setElementDimension(getJobData(jobId).locations[locationId].blip, getJobData(jobId).locations[locationId].dimension);
addToWorld(getJobData(jobId).locations[locationId].blip);
if(areServerElementsSupported()) {
let blip = createGameBlip(tempJobData.locations[locationId].position, blipModelId, getColourByType("job"));
if(blip != false) {
tempJobData.locations[locationId].blip = blip;
}
setElementOnAllDimensions(blip, false);
setElementDimension(blip, tempJobData.locations[locationId].dimension);
addToWorld(blip);
} else {
sendJobToPlayer(null, jobId, tempJobData.name, tempJobData.locations[locationId].position, blipModelId);
}
}
}
@@ -2408,31 +2424,31 @@ function isPlayerOnJobBlackList(client, jobId) {
// ===========================================================================
function playerArrivedAtJobRouteLocation(client) {
let jobId = getPlayerJob(client);
let jobId = getPlayerJob(client);
if(!isPlayerOnJobRoute(client)) {
return false;
}
if(isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) {
finishSuccessfulJobRoute(client);
return false;
}
if(isLastLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client))) {
finishSuccessfulJobRoute(client);
return false;
}
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
if(getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay > 0) {
freezePlayerJobVehicleForRouteLocation(client);
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
setTimeout(function() {
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
unFreezePlayerJobVehicleForRouteLocation(client);
}, getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay);
} else {
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
}
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationArriveMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
if(getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay > 0) {
freezePlayerJobVehicleForRouteLocation(client);
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
setTimeout(function() {
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
unFreezePlayerJobVehicleForRouteLocation(client);
}, getJobRouteLocationData(jobId, getPlayerJobRoute(client),getPlayerJobRouteLocation(client)).stopDelay);
} else {
getPlayerData(client).jobRouteLocation = getNextLocationOnJobRoute(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client));
showCurrentJobLocation(client);
showGameMessage(client, replaceJobRouteStringsInMessage(removeColoursInMessage(getJobRouteData(jobId, getPlayerJobRoute(client)).locationNextMessage), jobId, getPlayerJobRoute(client)), getJobData(jobId).colour, 3500);
}
}
// ===========================================================================
@@ -2579,14 +2595,14 @@ function createJobRoute(routeName, closestJobLocation) {
tempJobRouteData.vehicleColour1 = 1;
tempJobRouteData.vehicleColour2 = 1;
tempJobRouteData.pay = 500;
tempJobRouteData.jobIndex = closestJobLocation.jobIndex;
tempJobRouteData.jobIndex = closestJobLocation.jobIndex;
tempJobRouteData.startMessage = `You are now on route {ALTCOLOUR}{JOBROUTENAME}{MAINCOLOUR} for the {jobYellow}{JOBNAME}{MAINCOLOUR} job!`;
tempJobRouteData.finishMessage = `You have finished the {ALTCOLOUR}{JOBROUTENAME}{MAINCOLOUR} route and {ALTCOLOUR}{JOBROUTEPAY}{MAINCOLOUR} has been added to your next paycheck!`;
tempJobRouteData.locationArriveMessage = `You arrived at a stop.`;
tempJobRouteData.locationNextMessage = `Drive to the next stop.`;
getJobData(closestJobLocation.jobIndex).routes.push(tempJobRouteData);
saveJobRouteToDatabase(tempJobRouteData);
saveJobRouteToDatabase(tempJobRouteData);
setAllJobDataIndexes();
}
@@ -2599,10 +2615,10 @@ function createJobRouteLocation(routeLocationName, position, jobRouteData) {
tempJobRouteLocationData.enabled = true;
tempJobRouteLocationData.needsSaved = true;
tempJobRouteLocationData.position = position;
tempJobRouteLocationData.routeIndex = jobRouteData.index;
tempJobRouteLocationData.routeIndex = jobRouteData.index;
getJobData(jobRouteData.jobIndex).routes[jobRouteData.index].locations.push(tempJobRouteLocationData);
saveJobRouteLocationToDatabase(tempJobRouteLocationData);
saveJobRouteLocationToDatabase(tempJobRouteLocationData);
setAllJobDataIndexes();
}
@@ -2622,7 +2638,7 @@ function deleteJobRouteLocationCommand(command, params, client) {
getJobData(getJobIdFromDatabaseId(tempJob)).routes[tempJobRoute].locations.splice(tempIndex, 1);
setAllJobDataIndexes();
collectAllGarbage();
collectAllGarbage();
}
// ===========================================================================
@@ -2631,9 +2647,9 @@ function deleteJobRouteCommand(command, params, client) {
let jobId = getPlayerJob(client);
let jobRoute = getPlayerData(client).jobRoute;
if(!areParamsEmpty(client)) {
jobRoute = getJobRouteFromParams(params, jobId);
}
if(!areParamsEmpty(client)) {
jobRoute = getJobRouteFromParams(params, jobId);
}
let jobRouteData = getServerData().jobs[jobId].routes[jobRoute];
@@ -2651,10 +2667,10 @@ function deleteJobRouteCommand(command, params, client) {
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR} deleted route {ALTCOLOUR}${jobRouteData.name} (DB ID ${jobRouteData.databaseId}) {MAINCOLOUR}for the {jobYellow}${getJobData(jobId).name}{MAINCOLOUR} job`);
if(jobRouteData.databaseId > 0) {
quickDatabaseQuery(`DELETE FROM job_route WHERE job_route_id = ${jobRouteData.databaseId}`);
quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_route = ${jobRouteData.databaseId}`);
}
if(jobRouteData.databaseId > 0) {
quickDatabaseQuery(`DELETE FROM job_route WHERE job_route_id = ${jobRouteData.databaseId}`);
quickDatabaseQuery(`DELETE FROM job_route_loc WHERE job_route_loc_route = ${jobRouteData.databaseId}`);
}
clearArray(getServerData().jobs[jobId].routes[jobRoute].locations);
getServerData().jobs[jobId].routes.splice(jobRoute, 1);
@@ -2728,7 +2744,7 @@ function getJobPointsInRange(position, distance) {
// ===========================================================================
function respawnJobVehicle(client) {
respawnVehicle(getPlayerJobVehicle(client));
respawnVehicle(getPlayerJobVehicle(client));
}
// ===========================================================================
@@ -2740,12 +2756,12 @@ function getPlayerJobVehicle(client) {
// ===========================================================================
function getRandomJobRouteForLocation(closestJobLocation) {
if(closestJobLocation.routeCache.length > 0) {
let randomRoute = getRandom(0, closestJobLocation.routeCache.length-1);
let routeId = closestJobLocation.routeCache[randomRoute];
return getJobRouteData(closestJobLocation.jobIndex, routeId).index;
}
return -1;
if(closestJobLocation.routeCache.length > 0) {
let randomRoute = getRandom(0, closestJobLocation.routeCache.length-1);
let routeId = closestJobLocation.routeCache[randomRoute];
return getJobRouteData(closestJobLocation.jobIndex, routeId).index;
}
return -1;
}
// ===========================================================================
@@ -2785,58 +2801,58 @@ function getClosestJobLocationForJob(position, jobId) {
// ===========================================================================
function getPlayerJobRoute(client) {
return getPlayerData(client).jobRoute;
return getPlayerData(client).jobRoute;
}
// ===========================================================================
function getPlayerJobRouteLocation(client) {
return getPlayerData(client).jobRouteLocation;
return getPlayerData(client).jobRouteLocation;
}
// ===========================================================================
function showCurrentJobLocation(client) {
let jobId = getPlayerJob(client);
sendJobRouteLocationToPlayer(client, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(jobId).colour);
let jobId = getPlayerJob(client);
sendJobRouteLocationToPlayer(client, getJobRouteLocationData(jobId, getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).position, getJobData(jobId).colour);
}
// ===========================================================================
function finishSuccessfulJobRoute(client) {
let jobId = getPlayerJob(client);
let jobRouteData = getJobRouteData(jobId, getPlayerJobRoute(client));
let payout = toInteger(applyServerInflationMultiplier(jobRouteData.pay));
getPlayerData(client).payDayAmount = getPlayerData(client).payDayAmount + payout;
let jobId = getPlayerJob(client);
let jobRouteData = getJobRouteData(jobId, getPlayerJobRoute(client));
let payout = toInteger(applyServerInflationMultiplier(jobRouteData.pay));
getPlayerData(client).payDayAmount = getPlayerData(client).payDayAmount + payout;
messagePlayerSuccess(client, replaceJobRouteStringsInMessage(jobRouteData.finishMessage, jobId, jobRouteData.index));
messagePlayerSuccess(client, replaceJobRouteStringsInMessage(jobRouteData.finishMessage, jobId, jobRouteData.index));
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
respawnVehicle(getPlayerData(client).jobRouteVehicle);
stopReturnToJobVehicleCountdown(client);
sendPlayerStopJobRoute(client);
respawnVehicle(getPlayerData(client).jobRouteVehicle);
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = -1;
getPlayerData(client).jobRouteLocation = -1;
getPlayerData(client).jobRouteVehicle = false;
getPlayerData(client).jobRoute = -1;
getPlayerData(client).jobRouteLocation = -1;
}
// ===========================================================================
function getNextLocationOnJobRoute(jobId, routeId, currentLocationId) {
if(!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) {
return currentLocationId+1;
} else {
return getJobRouteData(jobId, routeId).locations.length-1;
}
if(!isLastLocationOnJobRoute(jobId, routeId, currentLocationId)) {
return currentLocationId+1;
} else {
return getJobRouteData(jobId, routeId).locations.length-1;
}
}
// ===========================================================================
function isLastLocationOnJobRoute(jobId, routeId, currentLocationId) {
if(currentLocationId == getJobRouteData(jobId, routeId).locations.length-1) {
return true;
}
return false;
if(currentLocationId == getJobRouteData(jobId, routeId).locations.length-1) {
return true;
}
return false;
}
// ===========================================================================
@@ -2860,21 +2876,21 @@ function getJobRouteFromParams(params, jobId) {
// ===========================================================================
function replaceJobRouteStringsInMessage(messageText, jobId, jobRouteId) {
let tempJobRouteData = getJobRouteData(jobId, jobRouteId);
let tempJobRouteData = getJobRouteData(jobId, jobRouteId);
let tempFind = `{JOBROUTENAME}`;
let tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, tempJobRouteData.name);
tempFind = `{JOBROUTEPAY}`;
tempFind = `{JOBROUTEPAY}`;
tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, `$${tempJobRouteData.pay}`);
tempFind = `{JOBNAME}`;
tempFind = `{JOBNAME}`;
tempRegex = new RegExp(tempFind, 'g');
messageText = messageText.replace(tempRegex, getJobData(tempJobRouteData.jobIndex).name);
return messageText;
return messageText;
}
// ===========================================================================

View File

@@ -8,157 +8,157 @@
// ===========================================================================
function policeTazerCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeCuffCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeArrestCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeSearchCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeDragCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================
function policeDetainCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!canPlayerUsePoliceJob(client)) {
messagePlayerError(client, "You are not allowed to use the police job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
messagePlayerError(client, "You don't have a police job.");
return false;
}
return true;
return true;
}
// ===========================================================================

View File

@@ -8,25 +8,25 @@
// ===========================================================================
function taxiSetFareCommand(command, params, client) {
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseJobs(client)) {
messagePlayerError(client, "You are not allowed to use jobs.");
return false;
}
if(!canPlayerUseTaxiJob(client)) {
messagePlayerError(client, "You are not allowed to use the taxi job.");
return false;
}
if(!canPlayerUseTaxiJob(client)) {
messagePlayerError(client, "You are not allowed to use the taxi job.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!isPlayerWorking(client)) {
messagePlayerError(client, "You are not working! Use /startwork first.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_TAXI)) {
messagePlayerError(client, "You don't have a taxi job.");
return false;
}
if(!doesPlayerHaveJobType(client, VRR_JOB_TAXI)) {
messagePlayerError(client, "You don't have a taxi job.");
return false;
}
return true;
}

View File

@@ -1,16 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
"module": "commonjs",
"target": "es6",
"moduleResolution": "classic"
},
"include": [
"*.js",
"job/*.js",
"business/*.js",
"item/*.js",
"npc/*.js",
"native/*.js",
"../shared/*.js"
"*.js",
"job/*.js",
"business/*.js",
"item/*.js",
"npc/*.js",
"native/*.js",
"../shared/*.js"
]
}

View File

@@ -10,190 +10,187 @@
function initKeyBindScript() {
logToConsole(LOG_INFO, "[VRR.KeyBind]: Initializing key bind script ...");
getGlobalConfig().keyBind = loadKeyBindConfiguration();
getGlobalConfig().keyBind = loadKeyBindConfiguration();
logToConsole(LOG_INFO, "[VRR.KeyBind]: Key bind script initialized!");
}
// ===========================================================================
function addKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
let tempCommand = getParam(params, " ", 2);
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
let keys = getKeysInComboName(getParam(params, " ", 1));
let tempCommand = getParam(params, " ", 2);
let tempParams = (splitParams.length > 2) ? splitParams.slice(2).join(" ") : "";
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(keys.indexOf(false) != -1) {
messagePlayerError(client, "One of the key names you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces. Must be lowercase.");
messagePlayerTip(client, "No actual symbols, use a name for those if needed like ampersand, hashtag, tilde, etc");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
messagePlayerInfo(client, `For combos, use a plus sign between the keys. No spaces! Example: {ALTCOLOUR}rightctrl+num3{MAINCOLOUR}`);
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
if(areParamsEmpty(tempCommand)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(areParamsEmpty(tempCommand)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(keys.join(" + "))} {MAINCOLOUR}keys to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
}
// ===========================================================================
function removeKeyBindCommand(command, params, client) {
let splitParams = params.split(" ");
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(!keyId) {
messagePlayerError(client, "The key ID or name you input is invalid!");
messagePlayerTip(client, "Use simple key names, letters, or numbers. Don't add spaces.");
messagePlayerInfo(client, `Examples: {ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl`);
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
if(!keyId) {
messagePlayerError(client, "That key name/id is invalid!");
return false;
}
removePlayerKeyBind(client, keyId);
messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
removePlayerKeyBind(client, keyId);
messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
}
// ===========================================================================
function addPlayerKeyBind(client, keys, command, params, tempKey = false) {
let keyBindData = new KeyBindData(false, keys, `${command} ${params}`);
if(tempKey == true) {
keyBindData.databaseId = -1;
}
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) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
keyBindData.needsSaved = true;
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
getPlayerData(client).keyBinds.push(keyBindData);
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
}
// ===========================================================================
function removePlayerKeyBind(client, keyId) {
if(isPlayerLoggedIn(client)) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
}
if(isPlayerLoggedIn(client)) {
quickDatabaseQuery(`DELETE FROM acct_hotkey WHERE acct_hotkey_acct = ${getPlayerData(client).accountData.databaseId} AND acct_hotkey_key = ${keyId}`);
}
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == keyId) {
getPlayerData(client).keyBinds.splice(i, 1);
}
}
sendRemoveAccountKeyBindToClient(client, keyId);
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == keyId) {
getPlayerData(client).keyBinds.splice(i, 1);
}
}
sendRemoveAccountKeyBindToClient(client, keyId);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
} else {
sendPlayerEnterPropertyKey(client, false);
}
}
// ===========================================================================
function doesPlayerHaveKeyBindForCommand(client, command) {
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return true;
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return true;
}
}
return false;
}
// ===========================================================================
function getPlayerKeyBindForCommand(client, command) {
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
}
// ===========================================================================
function doesPlayerHaveKeyBindForKey(client, key) {
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return true;
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return true;
}
}
return false;
}
// ===========================================================================
function doesPlayerHaveKeyBindsDisabled(client) {
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoKeyBinds"));
return hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoKeyBinds"));
}
// ===========================================================================
function getPlayerKeyBindForKey(client, key) {
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
for(let i in getPlayerData(client).keyBinds) {
if(getPlayerData(client).keyBinds[i].key == key) {
return getPlayerData(client).keyBinds[i];
}
}
return false;
}
// ===========================================================================
function playerUsedKeyBind(client, key) {
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) {
let splitCommandString = keyBindData.commandString.split(" ");
let tempCommand = splitCommandString[0];
let tempParams = "";
if(splitCommandString.length > 1) {
tempParams = splitCommandString.slice(1).join(" ");
}
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, client);
//triggerEvent("OnPlayerCommand", null, tempCommand, tempParams, client);
}
}
logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
let keyBindData = getPlayerKeyBindForKey(client, key);
if(keyBindData.enabled) {
let splitCommandString = keyBindData.commandString.split(" ");
let tempCommand = splitCommandString[0];
let tempParams = "";
if(splitCommandString.length > 1) {
tempParams = splitCommandString.slice(1).join(" ");
}
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, client);
//triggerEvent("OnPlayerCommand", null, tempCommand, tempParams, client);
}
}
}
// ===========================================================================
function sendAccountKeyBindsToClient(client) {
sendClearKeyBindsToClient(client);
for(let i in getPlayerData(client).keyBinds) {
sendAddAccountKeyBindToClient(client, getPlayerData(client).keyBinds[i].key, getPlayerData(client).keyBinds[i].keyState);
}
sendClearKeyBindsToClient(client);
for(let i in getPlayerData(client).keyBinds) {
sendAddAccountKeyBindToClient(client, getPlayerData(client).keyBinds[i].key, getPlayerData(client).keyBinds[i].keyState);
}
}
// ===========================================================================
@@ -217,4 +214,29 @@ function showKeyBindListCommand(command, params, client) {
}
}
// ===========================================================================
function getKeyNamesInComboName(comboName) {
if(comboName.indexOf("+") != -1) {
return comboName.split("+");
} else {
return [comboName];
}
}
// ===========================================================================
function getKeysInComboName(comboName) {
let keyNames = getKeyNamesInComboName(comboName);
let keys = [];
for(let i in keyNames) {
if(getKeyIdFromParams(keyNames[i])) {
keys.push(getKeyIdFromParams(keyNames[i]));
} else {
keys.push(false);
}
}
return keys
}
// ===========================================================================

View File

@@ -12,16 +12,16 @@ let translateURL = "http://api.mymemory.translated.net/get?de={3}&q={0}&langpair
// ===========================================================================
function initLocaleScript() {
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
getServerData().localeStrings = loadAllLocaleStrings();
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
getServerData().localeStrings = loadAllLocaleStrings();
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguageId);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguageId);
logToConsole(LOG_INFO, "[VRR.Locale]: Locale script initialized!");
}
@@ -29,68 +29,83 @@ function initLocaleScript() {
// ===========================================================================
function getLocaleString(client, stringName, ...args) {
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
return tempString;
}
// ===========================================================================
function getLanguageLocaleString(localeId, stringName, ...args) {
let tempString = getRawLocaleString(stringName, localeId);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
}
// ===========================================================================
function getGroupedLocaleString(client, stringName, index, ...args) {
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
return tempString;
}
// ===========================================================================
function getRawLocaleString(stringName, localeName) {
return getLocaleStrings()[localeName][stringName];
function getRawLocaleString(stringName, localeId) {
return getLocaleStrings()[localeId][stringName];
}
// ===========================================================================
function getRawGroupedLocaleString(stringName, localeName, index) {
return getLocaleStrings()[localeName][stringName][index];
function getRawGroupedLocaleString(stringName, localeId, index) {
return getLocaleStrings()[localeId][stringName][index];
}
// ===========================================================================
function getPlayerLocaleName(client) {
let localeId = getPlayerData(client).locale;
return getLocales()[localeId][0];
let localeId = getPlayerData(client).locale;
return getLocales()[localeId].englishName;
}
// ===========================================================================
function loadAllLocaleStrings() {
let tempLocaleStrings = {};
let tempLocaleStrings = {};
let locales = getGlobalConfig().locale.locales;
for(let i in locales) {
let localeData = locales[i];
let localeFile = JSON.parse(loadTextFile(`locale/${localeData[1]}.json`));
tempLocaleStrings[i] = localeFile;
}
let locales = getGlobalConfig().locale.locales;
for(let i in locales) {
let localeData = locales[i];
let localeFile = JSON.parse(loadTextFile(`locale/${localeData.stringsFile}`));
tempLocaleStrings[i] = localeFile;
}
return tempLocaleStrings;
return tempLocaleStrings;
}
// ===========================================================================
function getLocaleStrings() {
return getServerData().localeStrings;
return getServerData().localeStrings;
}
// ===========================================================================
@@ -99,11 +114,11 @@ function getLocaleFromParams(params) {
let locales = getLocales();
if(isNaN(params)) {
for(let i in locales) {
if(toLowerCase(locales[i][2]).indexOf(toLowerCase(params)) != -1) {
if(toLowerCase(locales[i].isoCode).indexOf(toLowerCase(params)) != -1) {
return i;
}
if(toLowerCase(locales[i][0]).indexOf(toLowerCase(params)) != -1) {
if(toLowerCase(locales[i].englishName).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
@@ -115,7 +130,7 @@ function getLocaleFromParams(params) {
// ===========================================================================
function getLocales() {
return getGlobalConfig().locale.locales;
return getGlobalConfig().locale.locales;
}
// ===========================================================================
@@ -138,41 +153,42 @@ function setLocaleCommand(command, params, client) {
return false;
}
let localeId = getLocaleFromParams(params);
let localeId = getLocaleFromParams(params);
if(!getLocaleData(localeId)) {
messagePlayerInfo(client, getLocaleString(client, "InvalidLocale"));
return false;
}
if(!getLocaleData(localeId)) {
messagePlayerInfo(client, getLocaleString(client, "InvalidLocale"));
return false;
}
getPlayerData(client).accountData.locale = localeId;
getPlayerData(client).locale = localeId;
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1"), getLocaleString(client, "LocaleNativeName"));
getPlayerData(client).accountData.locale = localeId;
getPlayerData(client).locale = localeId;
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName")));
sendPlayerLocaleStrings(client);
}
// ===========================================================================
function getLocaleData(localeId) {
if(typeof getLocales()[localeId] != "undefined") {
return getLocales()[localeId];
}
if(typeof getLocales()[localeId] != "undefined") {
return getLocales()[localeId];
}
return false;
return false;
}
// ===========================================================================
function reloadLocaleConfigurationCommand(command, params, client) {
getGlobalConfig().locale = loadLocaleConfig();
getServerData().localeStrings = loadAllLocaleStrings();
getServerData().localeStrings = loadAllLocaleStrings();
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
// Translation Cache
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom = new Array(getGlobalConfig().locale.locales.length);
getServerData().cachedTranslationFrom.fill([]);
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
messageAdmins(`${client.name}{MAINCOLOUR} has reloaded the locale settings and texts`);
}
@@ -181,18 +197,19 @@ function reloadLocaleConfigurationCommand(command, params, client) {
async function translateMessage(messageText, translateFrom = getGlobalConfig().locale.defaultLanguageId, translateTo = getGlobalConfig().locale.defaultLanguageId) {
return new Promise(resolve => {
if(translateFrom == translateTo) {
resolve(messageText);
}
if(translateFrom == translateTo) {
resolve(messageText);
}
for(let i in cachedTranslations[translateFrom][translateTo]) {
if(cachedTranslations[translateFrom][translateTo][i][0] == messageText) {
logToConsole(LOG_DEBUG, `[Translate]: Using existing translation for ${getGlobalConfig().locale.locales[translateFrom][0]} to ${getGlobalConfig().locale.locales[translateTo][0]} - (${messageText}), (${cachedTranslations[translateFrom][translateTo][i][1]})`);
logToConsole(LOG_DEBUG, `[Translate]: Using existing translation for ${getGlobalConfig().locale.locales[translateFrom].englishName} to ${getGlobalConfig().locale.locales[translateTo].englishName} - (${messageText}), (${cachedTranslations[translateFrom][translateTo][i][1]})`);
resolve(cachedTranslations[translateFrom][translateTo][i][1]);
return true;
}
}
let thisTranslationURL = translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom][2]), toUpperCase(getGlobalConfig().locale.locales[translateTo][2]), getGlobalConfig().locale.apiEmail);
let thisTranslationURL = translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
httpGet(
thisTranslationURL,
"",

View File

@@ -14,11 +14,14 @@ function initMessagingScript() {
// ===========================================================================
function messageAdminAction(messageText) {
messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`);
}
function announceAdminAction(localeString, ...args) {
let clients = getClients();
for(let i in clients) {
let messageText = getLocaleString.apply(null, [clients[i], localeString, args]);
messagePlayerNormal(clients[i], `⚠️ ${messageText}`, getColourByName("orange"));
}
messageDiscordEventChannel(getLanguageLocaleString.apply(null, [0, localeString, args]));
}
// ===========================================================================
@@ -33,196 +36,195 @@ function messageAdminAction(messageText) {
*
*/
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
//if(isConsole(client) || client == null) {
// logToConsole(LOG_INFO, `${removeColoursInMessage(messageText)}`);
//}
//if(isConsole(client) || client == null) {
// logToConsole(LOG_INFO, `${removeColoursInMessage(messageText)}`);
//}
messageText = replaceColoursInMessage(messageText);
//messageText = replaceColoursInMessage(messageText);
if(client == null) {
message(messageText, colour);
} else {
messageClient(messageText, client, colour);
}
//if(client == null) {
// message(messageText, colour);
//} else {
// messageClient(messageText, client, colour);
//}
//sendChatBoxMessageToPlayer(client, messageText, colour);
return true;
sendChatBoxMessageToPlayer(client, messageText, colour);
return true;
}
// ===========================================================================
function messageAdmins(messageText, colour = getColourByName("softRed")) {
//let plainMessage = removeColoursInMessage(messageText);
//console.warn(`🛡️ ${plainMessage}`);
//
//console.warn(`🛡️ ${plainMessage}`);
let clients = getClients();
for(let i in clients) {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, colour);
}
}
let clients = getClients();
for(let i in clients) {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, colour);
}
}
//if(getServerConfig().discordConfig.sendAdminEvents) {
// messageDiscordAdminChannel(plainMessage);
//}
let plainMessage = removeColoursInMessage(messageText);
messageDiscordAdminChannel(plainMessage);
}
// ===========================================================================
function messagePlayerError(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `${messageText}`);
}
}
// ===========================================================================
function messagePlayerSyntax(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `⌨️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `⌨️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⌨️ USAGE: {MAINCOLOUR} ${messageText}`, getColourByType("syntaxMessage"));
} else {
messageDiscordUser(client, `⌨️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⌨️ USAGE: {MAINCOLOUR} ${messageText}`, getColourByType("syntaxMessage"));
} else {
messageDiscordUser(client, `⌨️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerAlert(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `⚠️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `⚠️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⚠️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `⚠️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `⚠️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `⚠️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerSuccess(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, `✔️ ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, `✔️ ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `✔️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `✔️ ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `✔️ ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `✔️ ${messageText}`);
}
}
// ===========================================================================
function messagePlayerInfo(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
}
// ===========================================================================
function messagePlayerTip(client, messageText) {
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(isConsole(client)) {
logToConsole(LOG_INFO, ` ${messageText}`);
return true;
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, ` ${messageText}`, getColourByName("white"));
} else {
messageDiscordUser(client, `:information_source: ${messageText}`);
}
}
// ===========================================================================
function messagePlayerTalk(client, talkingClient, messageText) {
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`, getColourByType("talkMessage"));
}
// ===========================================================================
function messagePlayerWhisper(client, whisperingClient, messageText) {
messagePlayerNormal(client, `🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
messagePlayerNormal(client, `🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`, getColourByType("whisperMessage"));
}
// ===========================================================================
function messagePlayerMegaPhone(client, shoutingClient, messageText) {
messagePlayerNormal(client, `📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`, getColourByType("yellow"));
messagePlayerNormal(client, `📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`, getColourByType("yellow"));
}
// ===========================================================================
function messagePlayerShout(client, shoutingClient, messageText) {
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
messagePlayerNormal(client, `🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`, getColourByType("shoutMessage"));
}
// ===========================================================================
function messagePlayerDoAction(client, doingActionClient, messageText) {
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText} * (${getClientSubAccountName(doingActionClient)})`, getColourByType("doActionMessage"));
}
if(!isClientFromDiscord(client)) {
messagePlayerNormal(client, `${messageText} * (${getClientSubAccountName(doingActionClient)})`, getColourByType("doActionMessage"));
}
}
// ===========================================================================
function messagePlayerMeAction(client, doingActionClient, messageText) {
messagePlayerNormal(client, `${getClientSubAccountName(doingActionClient)} ${messageText}`, getColourByType("meActionMessage"));
messagePlayerNormal(client, `${getClientSubAccountName(doingActionClient)} ${messageText}`, getColourByType("meActionMessage"));
}
// ===========================================================================
function messagePlayerClanChat(client, clanChattingClient, messageText) {
messagePlayerNormal(client, `👥 ${getInlineChatColourByName("clanOrange")}${(getPlayerClanRankName(clanChattingClient) != false) ? getPlayerClanRankName(clanChattingClient) : "No Rank"} ${getCharacterFullName(clanChattingClient)} {MAINCOLOUR}says (clan): {ALTCOLOUR}${messageText}`, getColourByType("clanChatMessage"));
messagePlayerNormal(client, `👥 ${getInlineChatColourByName("clanOrange")}${(getPlayerClanRankName(clanChattingClient) != false) ? getPlayerClanRankName(clanChattingClient) : "No Rank"} ${getCharacterFullName(clanChattingClient)} {MAINCOLOUR}says (clan): {ALTCOLOUR}${messageText}`, getColourByType("clanChatMessage"));
}
// ===========================================================================
function messagePlayerAdminChat(client, adminChattingClient, messageText) {
messagePlayerNormal(client, `🛡️ [ADMIN CHAT] {ALTCOLOUR}${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: {MAINCOLOUR}${messageText}`, getColourByType("orange"));
messagePlayerNormal(client, `🛡️ [ADMIN CHAT] {ALTCOLOUR}${getPlayerData(adminChattingClient).accountData.staffTitle} [#CCCCCC]${getPlayerData(adminChattingClient).accountData.name}: {MAINCOLOUR}${messageText}`, getColourByType("orange"));
}
// ===========================================================================
function messagePlayerNewbieTip(client, message) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
// ===========================================================================
function messagePlayerTimedRandomTip(client, message) {
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
messagePlayerNormal(client, `💡 ${message}`);
}
}
}
// ===========================================================================
@@ -245,7 +247,7 @@ function clearChatBox(client) {
// ===========================================================================
function messagePlayerHelpContent(client, messageString) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${messageString}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}${messageString}`);
}
// ===========================================================================

View File

@@ -35,19 +35,23 @@ function toggleMouseCursorCommand(command, params, client) {
// ===========================================================================
function toggleMouseCameraCommand(command, params, client) {
sendPlayerMouseCameraToggle(client);
if(getGame() != VRR_GAME_GTA_VC) {
sendPlayerMouseCameraToggle(client);
}
return true;
}
// ===========================================================================
function setNewCharacterSpawnPositionCommand(command, params, client) {
let position = client.player.position;
let position = getPlayerPosition(client);
let heading = getPlayerHeading(client);
getServerConfig().newCharacter.spawnPosition = position;
getServerConfig().newCharacter.spawnHeading = client.player.heading;
getServerConfig().newCharacter.spawnHeading = heading;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character spawn position has been set to ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`)
messagePlayerNormal(client, `The new character spawn position has been set to ${position.x.toFixed(2)}, ${position.y.toFixed(2)}, ${position.z.toFixed(2)}`)
return true;
}
@@ -64,7 +68,7 @@ let amount = toInteger(getParam(params, " ", 1)) || 1000;
getServerConfig().newCharacter.cash = amount;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character money has been set to $${amount}`);
messagePlayerNormal(client, `The new character money has been set to $${amount}`);
return true;
}
@@ -81,7 +85,7 @@ function setNewCharacterSkinCommand(command, params, client) {
getServerConfig().newCharacter.skin = skinId;
getServerConfig().needsSaved = true;
messagePlayerNormal(client, `The new character skin has been set to ${getSkinNameFromModel(skinId)} (Index ${skinId})`);
messagePlayerNormal(client, `The new character skin has been set to ${getSkinNameFromModel(skinId)} (Index ${skinId})`);
return true;
}
@@ -95,7 +99,7 @@ function submitIdeaCommand(command, params, client) {
submitIdea(client, params);
messagePlayerNormal(client, `Your suggestion/idea has been sent to the developers!`);
messagePlayerNormal(client, `Your suggestion/idea has been sent to the developers!`);
return true;
}
@@ -109,7 +113,7 @@ function submitBugReportCommand(command, params, client) {
submitBugReport(client, params);
messagePlayerNormal(client, `Your bug report has been sent to the developers!`);
messagePlayerNormal(client, `Your bug report has been sent to the developers!`);
return true;
}
@@ -127,47 +131,47 @@ function enterExitPropertyCommand(command, params, client) {
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
switch(ownerType) {
case VRR_PICKUP_BUSINESS_ENTRANCE:
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_BUSINESS_EXIT:
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[ownerId];
break;
case VRR_PICKUP_HOUSE_ENTRANCE:
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().houses[ownerId];
break;
case VRR_PICKUP_HOUSE_EXIT:
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().houses[ownerId];
break;
default:
return false;
}
}
} else {
for(let i in getServerData().businesses) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let businessId = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = true;
closestProperty = getServerData().businesses[businessId];
closestProperty = getServerData().businesses[businessId];
} else {
let businessId = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = true;
isEntrance = false;
closestProperty = getServerData().businesses[businessId];
closestProperty = getServerData().businesses[businessId];
}
}
@@ -176,12 +180,12 @@ function enterExitPropertyCommand(command, params, client) {
let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = true;
closestProperty = getServerData().businesses[houseId];
closestProperty = getServerData().businesses[houseId];
} else {
let houseId = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
isBusiness = false;
isEntrance = false;
closestProperty = getServerData().businesses[houseId];
closestProperty = getServerData().businesses[houseId];
}
}
}
@@ -213,6 +217,7 @@ function enterExitPropertyCommand(command, params, client) {
}
setTimeout(function() {
setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
setPlayerPosition(client, closestProperty.exitPosition);
setPlayerHeading(client, closestProperty.exitRotation);
setPlayerDimension(client, closestProperty.exitDimension);
@@ -223,6 +228,7 @@ function enterExitPropertyCommand(command, params, client) {
}
updateInteriorLightsForPlayer(client, closestProperty.interiorLights);
}, 1000);
//setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
//updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension);
}, 1100);
if(closestProperty.streamingRadioStation != -1) {
@@ -249,6 +255,7 @@ function enterExitPropertyCommand(command, params, client) {
disableCityAmbienceForPlayer(client, true);
setTimeout(function() {
setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene);
setPlayerPosition(client, closestProperty.entrancePosition);
setPlayerHeading(client, closestProperty.entranceRotation);
setPlayerDimension(client, closestProperty.entranceDimension);
@@ -257,11 +264,14 @@ function enterExitPropertyCommand(command, params, client) {
if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0);
}
updateInteriorLightsForPlayer(client, true);
}, 1000);
}, 1100);
//setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene);
stopRadioStreamForPlayer(client);
getPlayerData(client).streamingRadioStation = -1;
//logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
return true;
}
@@ -301,7 +311,6 @@ function getPlayerInfoCommand(command, params, client) {
`{MAINCOLOUR}Skin: {ALTCOLOUR}${getSkinNameFromModel(getPlayerCurrentSubAccount(targetClient).skin)}[${getPlayerCurrentSubAccount(targetClient).skin}]`,
`{MAINCOLOUR}Clan: {ALTCOLOUR}${clan}`,
`{MAINCOLOUR}Job: {ALTCOLOUR}${job}`,
]
let chunkedList = splitArrayIntoChunks(stats, 6);
@@ -313,7 +322,7 @@ function getPlayerInfoCommand(command, params, client) {
// ===========================================================================
function playerChangeAFKState(client, afkState) {
getPlayerData(client).afk = afkState;
getPlayerData(client).afk = afkState;
updateAllPlayerNameTags();
}
@@ -324,7 +333,7 @@ function checkPlayerSpawning() {
for(let i in clients) {
if(!isConsole(clients[i])) {
if(getPlayerData(clients[i])) {
if(getPlayerData(clients[i]).loggedIn) {
if(isPlayerLoggedIn(clients[i])) {
if(!getPlayerData(clients[i]).ped) {
if(clients[i].player != null) {
//getPlayerData(clients[i]).ped = clients[i].player;
@@ -475,15 +484,15 @@ function gpsCommand(command, params, client) {
default: {
let itemTypeId = getItemTypeFromParams(params);
if(getItemTypeData(itemTypeId) != false) {
locationType = VRR_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
locationType = VRR_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
useType = getItemTypeData(itemTypeId).useType;
} else {
let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
}
}
let gameLocationId = getGameLocationFromParams(params);
if(gameLocationId != false) {
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
}
}
}
}
@@ -504,87 +513,98 @@ function gpsCommand(command, params, client) {
return false;
}
hideAllBlipsForPlayerGPS(client);
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
}
if(locationType == VRR_GPS_TYPE_GAMELOC) {
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
return true;
}
if(locationType == VRR_GPS_TYPE_GAMELOC) {
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
return true;
}
}
// ===========================================================================
function stuckPlayerCommand(command, params, client) {
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
messagePlayerError(client, "CantUseCommandYet");
return false;
}
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
messagePlayerError(client, "CantUseCommandYet");
return false;
}
let dimension = getPlayerDimension(client);
let interior = getPlayerInterior(client);
let dimension = getPlayerDimension(client);
let interior = getPlayerInterior(client);
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client);
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
messagePlayerAlert(client, "You canceled the skin change.");
restorePlayerCamera(client);
setPlayerPosition(client, getPlayerData(client).returnToPosition);
setPlayerHeading(client, getPlayerData(client).returnToHeading);
setPlayerInterior(client, getPlayerData(client).returnToInterior);
setPlayerDimension(client, getPlayerData(client).returnToDimension);
setPlayerPosition(client, getPlayerData(client).returnToPosition);
setPlayerHeading(client, getPlayerData(client).returnToHeading);
setPlayerInterior(client, getPlayerData(client).returnToInterior);
setPlayerDimension(client, getPlayerData(client).returnToDimension);
getPlayerData(client).returnToPosition = null;
getPlayerData(client).returnToHeading = null;
getPlayerData(client).returnToInterior = null;
getPlayerData(client).returnToDimension = null;
getPlayerData(client).returnToPosition = null;
getPlayerData(client).returnToHeading = null;
getPlayerData(client).returnToInterior = null;
getPlayerData(client).returnToDimension = null;
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_NONE;
}
}
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_NONE;
}
}
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_ADMINGET) {
// messagePlayerError(client, `You were teleported by an admin and can't use the stuck command`);
// return false;
//}
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_ADMINGET) {
// messagePlayerError(client, `You were teleported by an admin and can't use the stuck command`);
// return false;
//}
if(dimension > 0) {
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].exitDimension == dimension) {
setPlayerPosition(client, businesses[i].entrancePosition);
setPlayerDimension(client, businesses[i].entranceDimension);
setPlayerInterior(client, businesses[i].entranceInterior);
if(dimension > 0) {
let businesses = getServerData().businesses;
for(let i in businesses) {
if(businesses[i].exitDimension == dimension) {
setPlayerPosition(client, businesses[i].entrancePosition);
setPlayerDimension(client, businesses[i].entranceDimension);
setPlayerInterior(client, businesses[i].entranceInterior);
return true;
}
}
return true;
}
}
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].exitDimension == dimension) {
setPlayerPosition(client, houses[i].entrancePosition);
setPlayerDimension(client, houses[i].entranceDimension);
setPlayerInterior(client, houses[i].entranceInterior);
let houses = getServerData().houses;
for(let i in houses) {
if(houses[i].exitDimension == dimension) {
setPlayerPosition(client, houses[i].entrancePosition);
setPlayerDimension(client, houses[i].entranceDimension);
setPlayerInterior(client, houses[i].entranceInterior);
return true;
}
}
} else {
setPlayerDimension(client, 1);
setPlayerDimension(client, getGameConfig().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameConfig().mainWorldInterior[getGame()]);
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), 2.0));
}
return true;
}
}
} else {
setPlayerDimension(client, 1);
setPlayerDimension(client, getGameConfig().mainWorldDimension[getGame()]);
setPlayerInterior(client, getGameConfig().mainWorldInterior[getGame()]);
setPlayerPosition(client, getPosAbovePos(getPlayerPosition(client), 2.0));
}
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
setPlayerInterior(client, 0);
setPlayerDimension(client, 0);
}
// ===========================================================================
function playerPedSpeakCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
makePlayerPedSpeak(client, params);
}
// ===========================================================================

View File

@@ -7,93 +7,106 @@
// TYPE: Server (JavaScript)
// ===========================================================================
let builtInCommands = [
"refresh",
"restart",
"stop",
"start",
"reconnect",
"setname",
"connect",
"disconnect",
"say",
"dumpdoc",
];
// ===========================================================================
function getPlayerPosition(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
} else {
if(client.player != null) {
return client.player.position;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncPosition;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).position;
}
}
}
// ===========================================================================
function setPlayerPosition(client, position) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
sendPlayerSetPosition(client, position);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s position to ${position.x}, ${position.y}, ${position.z}`);
sendPlayerSetPosition(client, position);
}
// ===========================================================================
function getPlayerHeading(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncHeading;
} else {
if(client.player != null) {
return client.player.heading;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncHeading;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).heading;
}
}
}
// ===========================================================================
function setPlayerHeading(client, heading) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s heading to ${heading}`);
sendPlayerSetHeading(client, heading);
}
// ===========================================================================
function getPlayerVehicle(client) {
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicle;
} else {
if(client.player.vehicle) {
return client.player.vehicle;
}
}
return false;
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicle;
} else {
if(getPlayerPed(client).vehicle) {
return getPlayerPed(client).vehicle;
}
}
return false;
}
// ===========================================================================
function getPlayerDimension(client) {
if(!areServerElementsSupported()) {
return getPlayerData(client).syncDimension;
} else {
if(client.player != null) {
return client.player.dimension;
}
}
if(!areServerElementsSupported()) {
return getPlayerData(client).syncDimension;
} else {
if(getPlayerPed(client) != null) {
return getPlayerPed(client).dimension;
}
}
}
// ===========================================================================
function getPlayerInterior(client) {
return getPlayerCurrentSubAccount(client).interior || 0;
return getPlayerCurrentSubAccount(client).interior || 0;
}
// ===========================================================================
function setPlayerDimension(client, dimension) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
if(client.player != null) {
client.player.dimension = dimension;
}
}
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
if(!areServerElementsSupported()) {
getPlayerData(client).syncDimension = dimension;
} else {
if(getPlayerPed(client) != null) {
getPlayerPed(client).dimension = dimension;
}
}
}
// ===========================================================================
function setPlayerInterior(client, interior) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
sendPlayerSetInterior(client, interior);
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).interior = interior;
}
@@ -102,139 +115,171 @@ function setPlayerInterior(client, interior) {
// ===========================================================================
function isPlayerInAnyVehicle(client) {
if(!areServerElementsSupported()) {
return (getPlayerData().syncVehicle != null);
} else {
return (client.player.vehicle != null);
}
if(!areServerElementsSupported()) {
return (getPlayerData().syncVehicle != null);
} else {
return (getPlayerPed(client).vehicle != null);
}
}
// ===========================================================================
function getPlayerVehicleSeat(client) {
if(!isPlayerInAnyVehicle(client)) {
return false;
}
if(!isPlayerInAnyVehicle(client)) {
return false;
}
if(!areServerElementsSupported()) {
return getPlayerData().syncVehicleSeat;
} else {
for(let i = 0 ; i <= 8 ; i++) {
if(getPlayerVehicle(client).getOccupant(i) == client.player) {
if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) {
return i;
}
}
}
return false;
return false;
}
// ===========================================================================
function isPlayerSpawned(client) {
return getPlayerData(client).spawned;
return getPlayerData(client).spawned;
}
// ===========================================================================
function getVehiclePosition(vehicle) {
return vehicle.position;
return vehicle.position;
}
// ===========================================================================
function getVehicleHeading(vehicle) {
return vehicle.heading;
return vehicle.heading;
}
// ===========================================================================
function setVehicleHeading(vehicle, heading) {
return vehicle.heading = heading;
if(getGame() == VRR_GAME_GTA_IV) {
return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
}
return vehicle.heading = heading;
}
// ===========================================================================
function getElementTransient(element) {
if(typeof element.transient != "undefined") {
return element.transient;
}
return false;
}
// ===========================================================================
function setElementTransient(element, state) {
if(typeof element.transient != "undefined") {
element.transient = state;
return true;
}
return false;
}
// ===========================================================================
function getVehicleSyncer(vehicle) {
return getElementSyncer(vehicle);
return getElementSyncer(vehicle);
}
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
return vehicle;
if(getGame() == VRR_GAME_GTA_IV) {
if(getVehicleData(vehicle).ivNetworkId != -1) {
return getVehicleData(vehicle).ivNetworkId;
}
return -1;
}
return vehicle.id;
}
// ===========================================================================
function deleteGameElement(element) {
try {
if(element != null) {
destroyElement(element);
return true;
}
} catch(error) {
return false;
}
try {
if(element != null) {
destroyElement(element);
return true;
}
} catch(error) {
return false;
}
}
// ===========================================================================
function isPlayerInFrontVehicleSeat(client) {
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
return (getPlayerVehicleSeat(client) == 0 || getPlayerVehicleSeat(client) == 1);
}
// ===========================================================================
function removePlayerFromVehicle(client) {
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
sendPlayerRemoveFromVehicle(client);
return true;
logToConsole(LOG_DEBUG, `Removing ${getPlayerDisplayForConsole(client)} from their vehicle`);
sendPlayerRemoveFromVehicle(client);
return true;
}
// ===========================================================================
function setPlayerSkin(client, skinIndex) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameConfig().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameConfig().skins[getGame()][skinIndex][1]})`);
if(getGame() == VRR_GAME_GTA_IV) {
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
} else {
client.player.modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
}
}
// ===========================================================================
function getPlayerSkin(client) {
return getSkinIndexFromModel(client.player.modelIndex);
return getSkinIndexFromModel(client.player.modelIndex);
}
// ===========================================================================
function setPlayerHealth(client, health) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
sendPlayerSetHealth(client, health);
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${health}`);
sendPlayerSetHealth(client, health);
getServerData(client).health = health;
}
// ===========================================================================
function getPlayerHealth(client) {
return getServerData(client).health;
return getServerData(client).health;
}
// ===========================================================================
function setPlayerArmour(client, armour) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
sendPlayerSetArmour(client, armour);
//client.player.armour = armour;
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${armour}`);
sendPlayerSetArmour(client, armour);
//client.player.armour = armour;
}
// ===========================================================================
function getPlayerArmour(client) {
return client.player.armour;
if(areServerElementsSupported(client)) {
return getPlayerPed(client).armour;
} else {
return getPlayerData(client).syncArmour;
}
}
// ===========================================================================
@@ -244,9 +289,9 @@ function setPlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = toInteger(amount);
updatePlayerCash(client);
@@ -259,9 +304,9 @@ function givePlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash + toInteger(amount);
updatePlayerCash(client);
@@ -274,9 +319,9 @@ function takePlayerCash(client, amount) {
return false;
}
if(isNaN(amount)) {
return false;
}
if(isNaN(amount)) {
return false;
}
getPlayerCurrentSubAccount(client).cash = getPlayerCurrentSubAccount(client).cash - toInteger(amount);
updatePlayerCash(client);
@@ -285,173 +330,185 @@ function takePlayerCash(client, amount) {
// ===========================================================================
function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
return false;
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect();
return false;
}
// ===========================================================================
function getElementSyncer(element) {
return getClients()[element.syncer];
return getClients()[element.syncer];
}
// ===========================================================================
function getPlayerWeaponAmmo(client) {
return client.player.weaponAmmunition;
return getPlayerPed(client).weaponAmmunition;
}
// ===========================================================================
function setPlayerVelocity(client, velocity) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
if(typeof client.player.velocity != "undefined") {
client.player.velocity = velocity;
}
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
if(typeof getPlayerPed(client).velocity != "undefined") {
getPlayerPed(client).velocity = velocity;
}
}
// ===========================================================================
function getPlayerVelocity(client, velocity) {
if(typeof client.player.velocity != "undefined") {
return client.player.velocity;
}
return toVector3(0.0, 0.0, 0.0);
function getPlayerVelocity(client) {
if(typeof getPlayerPed(client).velocity != "undefined") {
return getPlayerPed(client).velocity;
}
return toVector3(0.0, 0.0, 0.0);
}
// ===========================================================================
function getElementDimension(element) {
if(typeof element.dimension != "undefined") {
return element.dimension;
}
return 0;
if(typeof element.dimension != "undefined") {
return element.dimension;
}
return 0;
}
// ===========================================================================
function setElementDimension(element, dimension) {
if(typeof element.dimension != "undefined") {
element.dimension = dimension;
return true;
}
return false;
if(typeof element.dimension != "undefined") {
element.dimension = dimension;
return true;
}
return false;
}
// ===========================================================================
function setElementRotation(element, rotation) {
return element.setRotation(rotation);
if(typeof element.setRotation != "undefined") {
element.setRotation(rotation);
} else {
return element.rotation = rotation;
}
}
// ===========================================================================
function givePlayerHealth(client, amount) {
if(getPlayerHealth(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`);
setPlayerHealth(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`);
setPlayerHealth(client, getPlayerHealth(client)+amount);
}
if(getPlayerHealth(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to 100`);
setPlayerHealth(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s health to ${getPlayerHealth(client)+amount}`);
setPlayerHealth(client, getPlayerHealth(client)+amount);
}
}
// ===========================================================================
function givePlayerArmour(client, amount) {
if(getPlayerArmour(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`);
setPlayerArmour(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`);
setPlayerArmour(client, getPlayerArmour(client)+amount);
}
if(getPlayerArmour(client)+amount > 100) {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to 100`);
setPlayerArmour(client, 100);
} else {
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client)+amount}`);
setPlayerArmour(client, getPlayerArmour(client)+amount);
}
}
// ===========================================================================
function getServerGame() {
return getGame();
return getGame();
}
// ===========================================================================
function consolePrint(text) {
console.log(text);
console.log(text);
}
// ===========================================================================
function getPlayerName(client) {
return client.name;
return client.name;
}
// ===========================================================================
function getServerName() {
return server.name;
return server.name;
}
// ===========================================================================
function createGamePickup(modelIndex, position, type) {
if(!isGameFeatureSupported("pickups")) {
return false;
}
return game.createPickup(modelIndex, position, type);
if(!isGameFeatureSupported("pickups")) {
return false;
}
return game.createPickup(modelIndex, position, type);
}
// ===========================================================================
function createGameBlip(position, type = 0, colour = toColour(255, 255, 255, 255)) {
if(!isGameFeatureSupported("blips")) {
return false;
}
return game.createBlip(type, position, 1, colour);
if(!isGameFeatureSupported("blips")) {
return false;
}
return game.createBlip(type, position, 1, colour);
}
// ===========================================================================
function createGameObject(modelIndex, position) {
if(!isGameFeatureSupported("objects")) {
return false;
}
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
if(!isGameFeatureSupported("objects")) {
return false;
}
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
}
// ===========================================================================
function setElementOnAllDimensions(element, state) {
if(!isNull(element) && element != false) {
element.onAllDimensions = state;
}
if(!isNull(element) && element != false) {
if(typeof element.netFlags != "undefined") {
if(typeof element.netFlags.onAllDimensions != "undefined") {
element.netFlags.onAllDimensions = state;
}
} else {
if(typeof element.onAllDimensions != "undefined") {
element.onAllDimensions = state;
}
}
}
}
// ===========================================================================
function destroyGameElement(element) {
if(!isNull(element) && element != false) {
destroyElement(element);
}
if(!isNull(element) && element != false) {
destroyElement(element);
}
}
// ===========================================================================
function isMeleeWeapon(weaponId, gameId = getServerGame()) {
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
return (getGameConfig().meleeWeapons[gameId].indexOf(weaponId) != -1);
}
// ===========================================================================
function getPlayerLastVehicle(client) {
return getPlayerData(client).lastVehicle;
return getPlayerData(client).lastVehicle;
}
// ===========================================================================
function isVehicleObject(vehicle) {
return (vehicle.type == ELEMENT_VEHICLE);
return (vehicle.type == ELEMENT_VEHICLE);
}
// ===========================================================================
@@ -470,7 +527,7 @@ function setVehicleLights(vehicle, lights) {
function setVehicleEngine(vehicle, engine) {
vehicle.engine = engine;
setEntityData(vehicle, "vrr.engine", engine, true);
setEntityData(vehicle, "vrr.engine", engine, true);
}
// ===========================================================================
@@ -500,7 +557,7 @@ function getVehicleEngine(vehicle) {
// ===========================================================================
function getVehicleLocked(vehicle) {
return vehicle.locked;
return vehicle.lockedStatus;
}
// ===========================================================================
@@ -515,13 +572,13 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1
vehicle.colour1 = colour1;
vehicle.colour2 = colour2;
if(colour3 != -1) {
vehicle.colour3 = colour3;
}
if(colour3 != -1) {
vehicle.colour3 = colour3;
}
if(colour4 != -1) {
vehicle.colour4 = colour4;
}
if(colour4 != -1) {
vehicle.colour4 = colour4;
}
}
// ===========================================================================
@@ -534,8 +591,24 @@ function createGameVehicle(modelIndex, position, heading, toClient = null) {
// ===========================================================================
function createGameCivilian(modelIndex, position, heading, toClient = null) {
if(areServerElementsSupported()) {
let civilian = game.createCivilian(getGameConfig().skins[getGame()][modelIndex][0], 0);
if(!isNull(civilian)) {
civilian.position = position;
civilian.heading = heading;
addToWorld(civilian);
return civilian;
}
}
return false;
}
// ===========================================================================
function getIsland(position) {
if(getServerGame() == VRR_GAME_GTA_III) {
if(getServerGame() == VRR_GAME_GTA_III) {
if(position.x > 616) {
return VRR_ISLAND_PORTLAND;
} else if(position.x < -283) {
@@ -552,11 +625,11 @@ function getIsland(position) {
// ===========================================================================
function isValidVehicleModel(model) {
if(getVehicleModelIndexFromModel(model) != false) {
return true;
}
if(getVehicleModelIndexFromModel(model) != false) {
return true;
}
return false;
return false;
}
// ===========================================================================
@@ -580,8 +653,8 @@ function setPlayerFightStyle(client, fightStyleId) {
return false;
}
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
setEntityData(getPlayerElement(client), "vrr.fightStyle", [getGameConfig().fightStyles[getServerGame()][fightStyleId][1][0], getGameConfig().fightStyles[getServerGame()][fightStyleId][1][1]]);
forcePlayerToSyncElementProperties(null, getPlayerElement(client));
}
// ===========================================================================
@@ -640,32 +713,36 @@ function isTaxiVehicle(vehicle) {
// ===========================================================================
function getVehicleName(vehicle) {
let model = getElementModel(vehicle);
let model = getElementModel(vehicle);
return getVehicleNameFromModel(model) || "Unknown";
}
// ===========================================================================
function getElementModel(element) {
if(typeof element.modelIndex != "undefined") {
return element.modelIndex;
}
if(typeof element.modelIndex != "undefined") {
return element.modelIndex;
}
if(typeof element.model != "undefined") {
return element.model;
}
if(typeof element.model != "undefined") {
return element.model;
}
}
// ===========================================================================
function givePlayerWeaponAmmo(client, ammo) {
givePlayerWeapon(client, getPlayerWeapon(client), getPlayerWeaponAmmo(client) + ammo);
givePlayerWeapon(client, getPlayerWeapon(client), getPlayerWeaponAmmo(client) + ammo);
}
// ===========================================================================
function getPlayerWeapon(client) {
return client.player.weapon;
if(areServerElementsSupported(client)) {
return getPlayerPed(client).weapon;;
} else {
return getPlayerData(client).syncWeapon;
}
}
// ===========================================================================
@@ -905,7 +982,7 @@ function sendNetworkEventToPlayer(eventName, client, ...args) {
// ===========================================================================
function addNetworkEventHandler(eventName, handlerFunction) {
addNetworkHandler(eventName, handlerFunction);
addNetworkHandler(eventName, handlerFunction);
}
// ===========================================================================
@@ -1018,8 +1095,75 @@ function setVehicleHealth(vehicle, health) {
// ===========================================================================
function givePlayerWeapon(client, weaponId, ammo, active = true) {
logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
sendNetworkEventToPlayer("vrr.giveWeapon", client, weaponId, ammo, active);
logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
sendNetworkEventToPlayer("vrr.giveWeapon", client, weaponId, ammo, active);
}
// ===========================================================================
function setPlayerWantedLevel(client, wantedLevel) {
sendNetworkEventToPlayer("vrr.wantedLevel", client, wantedLevel);
return true;
}
// ===========================================================================
function setElementStreamInDistance(element, distance) {
if(!isNull(element) && element != false) {
if(typeof element == "Entity") {
if(typeof element.streamInDistance != "undefined") {
element.streamInDistance = distance;
}
}
}
}
// ===========================================================================
function setElementStreamOutDistance(element, distance) {
if(!isNull(element) && element != false) {
if(typeof element == "Entity") {
if(typeof element.streamOutDistance != "undefined") {
element.streamOutDistance = distance;
}
}
}
}
// ===========================================================================
function getPlayerPed(client) {
if(getGame() == VRR_GAME_GTA_IV) {
return getPlayerData(client).ped;
} else {
return client.player;
}
}
// ===========================================================================
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
if(entity != null) {
return entity.setData(dataName, dataValue, syncToClients);
}
}
// ===========================================================================
function removeEntityData(entity, dataName) {
if(entity != null) {
return entity.removeData(dataName);
}
return null;
}
// ===========================================================================
function doesEntityDataExist(entity, dataName) {
if(entity != null) {
return (entity.getData(dataName) != null);
}
return null;
}
// ===========================================================================

View File

@@ -8,23 +8,25 @@
// ===========================================================================
function initNPCScript() {
getServerData().npcs = loadNPCsFromDatabase();
setAllNPCDataIndexes();
if(!getServerConfig().devServer) {
getServerData().npcs = loadNPCsFromDatabase();
}
spawnAllNPCs();
setNPCDataIndexes();
spawnNPCs();
}
// ===========================================================================
/**
* @param {Ped} ped - The data index of the NPC
* @param {Number} npcId - The data index of the NPC
* @return {NPCData} The NPC's data (class instancee)
*/
function getNPCData(ped) {
if(ped.getData("vrr.dataIndex")) {
return ped.getData("vrr.dataIndex");
function getNPCData(npcId) {
if(typeof getServerData().npcs[npcId] != "undefined") {
return getServerData().npcs[npcId];
}
return false;
return false;
}
// ===========================================================================
@@ -38,20 +40,14 @@ function createNPCCommand(client, command, params) {
let skinId = getSkinModelIndexFromParams(params);
if(!skinId) {
messagePlayerError(client, `Invalid skin`);
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
return false;
}
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
let tempNPCData = new NPCData(false);
tempNPCData.position = position;
tempNPCData.heading = getPlayerHeading(client);
tempNPCData.skin = skinId;
let npcIndex = getServerData().npcs.push(tempNPCData);
spawnNPC(npcIndex-1);
let npcId = createNPC(skinId, position, getPlayerHeading(client));
messageAdmins(`${client.name}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
}
// ===========================================================================
@@ -155,7 +151,11 @@ function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
// ===========================================================================
function saveAllNPCsToDatabase() {
function saveNPCsToDatabase() {
if(getServerConfig().devServer) {
return false;
}
for(let i in getServerData().npcs) {
saveNPCToDatabase(i);
}
@@ -163,108 +163,93 @@ function saveAllNPCsToDatabase() {
// ===========================================================================
function saveNPCToDatabase(npc) {
if(getNPCData(vehicleDataId) == null) {
// Invalid vehicle data
function saveNPCToDatabase(npcDataId) {
if(getNPCData(npcDataId) == null) {
// Invalid NPC data
return false;
}
let tempVehicleData = getServerData().vehicles[vehicleDataId];
let tempNPCData = getNPCData(npcDataId);
if(tempVehicleData.databaseId == -1) {
// Temp vehicle, no need to save
if(tempNPCData.databaseId == -1) {
// Temp NPC, no need to save
return false;
}
if(!tempVehicleData.needsSaved) {
// Vehicle hasn't changed. No need to save.
if(!tempNPCData.needsSaved) {
// NPC hasn't changed. No need to save.
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Saving vehicle ${tempVehicleData.databaseId} to database ...`);
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
let dbConnection = connectToDatabase();
if(dbConnection) {
if(tempVehicleData.vehicle != false) {
if(!tempVehicleData.spawnLocked) {
if(tempNPCData.ped != false) {
if(!tempNPCData.spawnLocked) {
if(areServerElementsSupported()) {
tempVehicleData.spawnPosition = tempVehicleData.vehicle.position;
tempVehicleData.spawnRotation = tempVehicleData.vehicle.heading;
tempNPCData.spawnPosition = tempNPCData.vehicle.position;
tempNPCData.spawnRotation = tempNPCData.vehicle.heading;
} else {
tempVehicleData.spawnPosition = tempVehicleData.syncPosition;
tempVehicleData.spawnRotation = tempVehicleData.syncHeading;
tempNPCData.spawnPosition = tempNPCData.syncPosition;
tempNPCData.spawnRotation = tempNPCData.syncHeading;
}
}
}
let safeAnimationName = escapeDatabaseString(tempNPCData.animationName);
let safeFirstName = escapeDatabaseString(tempNPCData.firstName);
let safeLastName = escapeDatabaseString(tempNPCData.lastName);
let safeMiddleName = escapeDatabaseString(tempNPCData.middleName);
let data = [
["veh_server", getServerId()],
["veh_model", toInteger(tempVehicleData.model)],
["veh_owner_type", toInteger(tempVehicleData.ownerType)],
["veh_owner_id", toInteger(tempVehicleData.ownerId)],
["veh_locked", boolToInt(tempVehicleData.locked)],
["veh_spawn_lock", boolToInt(tempVehicleData.spawnLocked)],
["veh_buy_price", toInteger(tempVehicleData.buyPrice)],
["veh_rent_price", toInteger(tempVehicleData.rentPrice)],
["veh_pos_x", toFloat(tempVehicleData.spawnPosition.x)],
["veh_pos_y", toFloat(tempVehicleData.spawnPosition.y)],
["veh_pos_z", toFloat(tempVehicleData.spawnPosition.z)],
["veh_rot_z", toFloat(tempVehicleData.spawnRotation)],
["veh_col1", toInteger(tempVehicleData.colour1)],
["veh_col2", toInteger(tempVehicleData.colour2)],
["veh_col3", toInteger(tempVehicleData.colour3)],
["veh_col4", toInteger(tempVehicleData.colour4)],
["veh_col1_isrgb", boolToInt(tempVehicleData.colour1IsRGBA)],
["veh_col2_isrgb", boolToInt(tempVehicleData.colour2IsRGBA)],
["veh_col3_isrgb", boolToInt(tempVehicleData.colour3IsRGBA)],
["veh_col4_isrgb", boolToInt(tempVehicleData.colour4IsRGBA)],
["veh_extra1", tempVehicleData.extras[0]],
["veh_extra2", tempVehicleData.extras[1]],
["veh_extra3", tempVehicleData.extras[2]],
["veh_extra4", tempVehicleData.extras[3]],
["veh_extra5", tempVehicleData.extras[4]],
["veh_extra6", tempVehicleData.extras[5]],
["veh_extra7", tempVehicleData.extras[6]],
["veh_extra8", tempVehicleData.extras[7]],
["veh_extra9", tempVehicleData.extras[8]],
["veh_extra10", tempVehicleData.extras[9]],
["veh_extra11", tempVehicleData.extras[10]],
["veh_extra12", tempVehicleData.extras[11]],
["veh_extra13", tempVehicleData.extras[12]],
["veh_engine", intToBool(tempVehicleData.engine)],
["veh_lights", intToBool(tempVehicleData.lights)],
["veh_health", toInteger(tempVehicleData.health)],
["veh_damage_engine", toInteger(tempVehicleData.engineDamage)],
["veh_damage_visual", toInteger(tempVehicleData.visualDamage)],
["veh_dirt_level", toInteger(tempVehicleData.dirtLevel)],
["veh_int", toInteger(tempVehicleData.interior)],
["veh_vw", toInteger(tempVehicleData.dimension)],
["veh_livery", toInteger(tempVehicleData.livery)],
["npc_server", getServerId()],
["npc_skin", toInteger(tempNPCData.model)],
["npc_name_first", safeFirstName],
["npc_name_middle", safeMiddleName],
["npc_name_last", safeLastName],
["npc_owner_type", toInteger(tempNPCData.ownerType)],
["npc_owner_id", toInteger(tempNPCData.ownerId)],
["npc_pos_x", toFloat(tempNPCData.position.x)],
["npc_pos_y", toFloat(tempNPCData.position.y)],
["npc_pos_z", toFloat(tempNPCData.position.z)],
["npc_rot_z", toFloat(tempNPCData.heading)],
["npc_scale_x", toFloat(tempNPCData.scale.x)],
["npc_scale_y", toFloat(tempNPCData.scale.y)],
["npc_scale_z", toFloat(tempNPCData.scale.z)],
["npc_animation", safeAnimationName],
["npc_health", toInteger(tempNPCData.health)],
["npc_armour", toInteger(tempNPCData.armour)],
["npc_invincible", boolToInt(tempNPCData.invincible)],
["npc_heedthreats", boolToInt(tempNPCData.heedThreats)],
["npc_threats", toInteger(tempNPCData.threats)],
["npc_stay", boolToInt(tempNPCData.stay)],
["npc_type_flags", toInteger(tempNPCData.typeFlags)],
];
let dbQuery = null;
if(tempVehicleData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("veh_main", data);
if(tempNPCData.databaseId == 0) {
let queryString = createDatabaseInsertQuery("npc_main", data);
dbQuery = queryDatabase(dbConnection, queryString);
getServerData().vehicles[vehicleDataId].databaseId = getDatabaseInsertId(dbConnection);
getServerData().vehicles[vehicleDataId].needsSaved = false;
tempNPCData.databaseId = getDatabaseInsertId(dbConnection);
tempNPCData.needsSaved = false;
} else {
let queryString = createDatabaseUpdateQuery("veh_main", data, `veh_id=${tempVehicleData.databaseId}`);
let queryString = createDatabaseUpdateQuery("npc_main", data, `npc_id=${tempNPCData.databaseId}`);
dbQuery = queryDatabase(dbConnection, queryString);
getServerData().vehicles[vehicleDataId].needsSaved = false;
tempNPCData.needsSaved = false;
}
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_VERBOSE, `[VRR.Vehicle]: Saved vehicle ${vehicleDataId} to database!`);
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saved NPC ${npcDataId} to database!`);
return false;
}
// ===========================================================================
function setAllNPCDataIndexes() {
function setNPCDataIndexes() {
for(let i in getServerData().npcs) {
getServerData().npcs[i].index = i;
@@ -291,16 +276,120 @@ function spawnNPC(npcIndex) {
let civilian = createGameCivilian(getNPCData(npcIndex).model, getNPCData(npcIndex).spawnPosition, getNPCData(npcIndex).spawnRotation);
if(civilian) {
civilian.setData("vrr.dataIndex", npcIndex);
if(getNPCData(npcIndex).animationName != "") {
civilian.setData("vrr.animation", getNPCData(npcIndex).animationName);
}
getNPCData(npcIndex).ped = civilian;
}
}
// ===========================================================================
function spawnAllNPCs() {
function spawnNPCs() {
for(let i in getServerData().npcs) {
spawnNPC(npcIndex);
}
}
// ===========================================================================
function deleteNPCCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, command);
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
if(!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
return false;
}
let npcName = getNPCData(closestNPC).name;
deleteNPC(closestNPC);
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
}
// ===========================================================================
function deleteNPC(npcId) {
quickDatabaseQuery(`DELETE FROM npc_main WHERE npc_id=${getNPCData(npcId).databaseId}`);
if(getNPCData(npcId)) {
if(getNPCData(npcId).ped != false) {
deleteEntity(getNPCData(npcId).ped);
}
getServerData().npcs.splice(npcId, 1);
}
setNPCDataIndexes();
}
// ===========================================================================
function setNPCAnimationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, command);
return false;
}
let closestNPC = getClosestNPC(getPlayerPosition(client));
let animationId = getAnimationFromParams(getParam(params, " ", 1));
let animationPositionOffset = 1;
if(!getNPCData(closestNPC)) {
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
return false;
}
if(!getAnimationData(animationId)) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
return false;
}
if(areThereEnoughParams(params, 2, " ")) {
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
return false;
}
animationPositionOffset = getParam(params, " ", 2);
}
getNPCData(closestNPC).animationName = animation;
makePedPlayAnimation(getNPCData(closestNPC).ped, animationId, animationPositionOffset);
}
// ===========================================================================
function getClosestNPC(position) {
let npcs = getServerData().npcs;
let closest = 0;
for(let i in npcs) {
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[i].ped.position, position)) {
closest = i;
}
}
return closest;
}
// ===========================================================================
function createNPC(skinIndex, position, heading) {
let tempNPCData = new NPCData(false);
tempNPCData.position = position;
tempNPCData.heading = heading;
tempNPCData.skin = skinIndex;
tempNPCData.animationName = "";
let npcIndex = getServerData().npcs.push(tempNPCData);
spawnNPC(npcIndex-1);
setNPCDataIndexes();
return npcIndex-1;
}
// ===========================================================================

View File

@@ -8,21 +8,21 @@
// ===========================================================================
function attemptToSignalToNearbyTaxi(client) {
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerLoggedIn(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
if(!isPlayerSpawned(client)) {
return false;
}
let nearbyTaxis = getElementsByType(ELEMENT_VEHICLE).filter((v) > getPlayerPosition(client).distance(v.position) <= 15 && isTaxiVehicle(v));
let nearbyTaxis = getElementsByType(ELEMENT_VEHICLE).filter((v) > getPlayerPosition(client).distance(v.position) <= 15 && isTaxiVehicle(v));
let closestTaxi = nearbyTaxis.reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
if(!closestTaxi.getOccupant(0).isType(ELEMENT_PLAYER)) {
setVehicleCruiseSpeed(closestTaxi, 0.0);
setVehicleLockedState(closestTaxi, false);
}
let closestTaxi = nearbyTaxis.reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
if(!closestTaxi.getOccupant(0).isType(ELEMENT_PLAYER)) {
setVehicleCruiseSpeed(closestTaxi, 0.0);
setVehicleLocked(closestTaxi, false);
}
}
// ===========================================================================

31
scripts/server/race.js Normal file
View File

@@ -0,0 +1,31 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: race.js
// DESC: Provides racing usage and functions
// TYPE: Server (JavaScript)
// ===========================================================================
function initRaceScript() {
if(!getServerConfig().devServer) {
getServerData().races = loadRacesFromDatabase();
}
setRaceDataIndexes();
}
// ===========================================================================
/**
* @param {Number} raceId - The data index of the race
* @return {RaceData} The race's data (class instance)
*/
function getRaceData(raceId) {
if(typeof getServerData().races[raceId] != "undefined") {
return getServerData().races[raceId];
}
return false;
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initRadioScript() {
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
getServerData().radioStations = loadRadioStationsFromDatabase();
if(!getServerConfig().devServer) {
getServerData().radioStations = loadRadioStationsFromDatabase();
}
setRadioStationIndexes();
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
return true;
@@ -41,6 +44,15 @@ function loadRadioStationsFromDatabase() {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function playStreamingRadioCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -145,6 +157,15 @@ function playStreamingRadioCommand(command, params, client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function setStreamingRadioVolumeCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
@@ -185,6 +206,15 @@ function getPlayerStreamingRadioVolume(client) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function showRadioStationListCommand(command, params, client) {
let stationList = getServerData().radioStations.map(function(x) { return `{ALTCOLOUR}${toInteger(x.index)+1}: {MAINCOLOUR}${x.name}`; });
@@ -213,13 +243,22 @@ function getRadioStationData(radioStationId) {
// ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function reloadAllRadioStationsCommand(command, params, client) {
stopRadioStreamForPlayer(null);
clearArray(getServerData().radioStations);
getServerData().radioStations = loadRadioStationsFromDatabase();
setRadioStationIndexes();
messageAdminAction(`All radio stations have been reloaded by an admin!`);
announceAdminAction(`AllRadioStationsReloaded`);
}
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -185,7 +185,7 @@ function saveSubAccountToDatabase(subAccountData) {
freeDatabaseQuery(dbQuery);
disconnectFromDatabase(dbConnection);
}
}
}
// ===========================================================================
@@ -275,7 +275,7 @@ function checkNewCharacter(client, firstName, lastName) {
lastName = lastName.trim();
if(doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) {
logToConsole(LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
logToConsole(LOG_INFO|LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
showPlayerNewCharacterFailedGUI(client, "Invalid characters in name!");
return false;
}
@@ -371,16 +371,20 @@ function selectCharacter(client, characterId = -1) {
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING;
if(getGame() < VRR_GAME_GTA_IV) {
if(getGame() <= VRR_GAME_GTA_SA) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
} else if(getGame() == VRR_GAME_GTA_IV) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
//clearPlayerWeapons(client);
//setPlayerSkin(client, skin);
//setPlayerPosition(client, spawnPosition);
//setPlayerHeading(client, spawnHeading);
//setPlayerInterior(client, spawnInterior);
//setPlayerDimension(client, spawnDimension);
} else if(getGame() >= VRR_GAME_MAFIA_ONE) {
//restorePlayerCamera(client);
} else if(getGame() == VRR_GAME_MAFIA_ONE) {
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]);
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`);
spawnPlayer(client, getGameConfig().skins[getGame()][skin][0], spawnPosition, spawnHeading);
}
@@ -546,45 +550,6 @@ function setFightStyleCommand(command, params, client) {
// ===========================================================================
function forceFightStyleCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
let fightStyleId = getFightStyleFromParams(getParam(params, " ", 2));
//if(!targetClient) {
// messagePlayerError(client, `Player not found!`);
// return false;
//}
//if(!getPlayerData(targetClient)) {
// messagePlayerError(client, `Player not found!`);
// return false;
//}
//if(!isPlayerSpawned(targetClient)) {
// messagePlayerError(client, `That player isn't spawned`);
// return false;
//}
if(!fightStyleId) {
messagePlayerError(client, `That fight style doesn't exist!`);
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getServerGame()].map(fs => fs[0]).join(", ")}`);
return false;
}
getPlayerCurrentSubAccount(client).fightStyle = fightStyleId;
setPlayerFightStyle(client, fightStyleId);
messagePlayerSuccess(client, `You set ${getCharacterFullName(targetClient)}'s fight style to ${getGameConfig().fightStyles[getServerGame()][fightStyleId][0]}`)
return true;
}
// ===========================================================================
function createDefaultSubAccountServerData(databaseId, thisServerSkin) {
for(let i = 1 ; i <= 5 ; i++) {
if(i == getServerId()) {

View File

@@ -11,7 +11,7 @@ let serverTimers = {};
// ===========================================================================
function saveAllServerDataToDatabase() {
function saveServerDataToDatabase() {
if(getServerConfig().pauseSavingToDatabase) {
return false;
}
@@ -19,55 +19,49 @@ function saveAllServerDataToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ...");
try {
saveAllClientsToDatabase();
saveClientsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clients to database: ${error}`);
}
try {
saveAllClansToDatabase();
saveClansToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`);
}
try {
saveAllHousesToDatabase();
saveHousesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`);
}
try {
saveAllBusinessesToDatabase();
saveBusinessesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`);
}
try {
saveServerConfigToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`);
}
try {
saveAllVehiclesToDatabase();
saveVehiclesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`);
}
try {
saveAllItemTypesToDatabase();
saveItemTypesToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`);
}
try {
saveAllItemsToDatabase();
saveItemsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save items to database: ${error}`);
}
try {
saveAllJobsToDatabase();
saveJobsToDatabase();
} catch(error) {
logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`);
}
@@ -112,7 +106,7 @@ function oneMinuteTimerFunction() {
function tenMinuteTimerFunction() {
showRandomTipToAllPlayers();
saveAllServerDataToDatabase();
saveServerDataToDatabase();
checkInactiveVehicleRespawns();
}
@@ -251,18 +245,18 @@ function showRandomTipToAllPlayers() {
function checkInactiveVehicleRespawns() {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(getVehicleData(vehicles[i] != false)) {
if(isVehicleUnoccupied(vehicles[i])) {
if(getVehicleData(vehicles[i]).lastActiveTime != false) {
if(getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false;
}
}
} else {
getVehicleData(vehicles[i]).lastActiveTime = getCurrentUnixTimestamp();
}
}
if(getVehicleData(vehicles[i] != false)) {
if(isVehicleUnoccupied(vehicles[i])) {
if(getVehicleData(vehicles[i]).lastActiveTime != false) {
if(getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
respawnVehicle(vehicles[i]);
getVehicleData(vehicles[i]).lastActiveTime = false;
}
}
} else {
getVehicleData(vehicles[i]).lastActiveTime = getCurrentUnixTimestamp();
}
}
}
}

View File

@@ -8,44 +8,44 @@
// ===========================================================================
const triggerTypes = [
"onBusinessOwnerChange",
"onBusinessNameChange",
"onBusinessLockChange",
"onBusinessPlayerEnter",
"onBusinessPlayerExit",
"onBusinessBotEnter",
"onBusinessBotExit",
"onBusinessDamage",
"onBusinessRobbed",
"onBusinessPlayerPurchase",
"onBusinessBotPurchase",
"onHouseOwnerChange",
"onHouseNameChange",
"onHouseLockChange",
"onHousePlayerEnter",
"onHousePlayerExit",
"onHouseBotEnter",
"onHouseBotExit",
"onHouseDamage",
"onHouseRobbed",
"onVehicleOwnerChange",
"onVehiclePlayerEnter",
"onVehiclePlayerExit",
"onVehicleBotEnter",
"onVehicleBotExit",
"onVehicleCollision",
"onVehicleDamaged",
"onVehicleShot",
"onVehicleTrunkChange",
"onVehicleItemTaken",
"onVehicleItemStored",
"onVehicleEngineChange",
"onVehicleLightsChange",
"onVehicleSirenChange",
"onVehicleLockChange",
"onVehicleRepaired",
"onVehicleColourChange",
"onVehicleExtraChange",
"onBusinessOwnerChange",
"onBusinessNameChange",
"onBusinessLockChange",
"onBusinessPlayerEnter",
"onBusinessPlayerExit",
"onBusinessBotEnter",
"onBusinessBotExit",
"onBusinessDamage",
"onBusinessRobbed",
"onBusinessPlayerPurchase",
"onBusinessBotPurchase",
"onHouseOwnerChange",
"onHouseNameChange",
"onHouseLockChange",
"onHousePlayerEnter",
"onHousePlayerExit",
"onHouseBotEnter",
"onHouseBotExit",
"onHouseDamage",
"onHouseRobbed",
"onVehicleOwnerChange",
"onVehiclePlayerEnter",
"onVehiclePlayerExit",
"onVehicleBotEnter",
"onVehicleBotExit",
"onVehicleCollision",
"onVehicleDamaged",
"onVehicleShot",
"onVehicleTrunkChange",
"onVehicleItemTaken",
"onVehicleItemStored",
"onVehicleEngineChange",
"onVehicleLightsChange",
"onVehicleSirenChange",
"onVehicleLockChange",
"onVehicleRepaired",
"onVehicleColourChange",
"onVehicleExtraChange",
];
// ===========================================================================

View File

@@ -10,8 +10,8 @@
// ===========================================================================
function startTutorial(client) {
getPlayerData(client).tutorialItem = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialVehicle = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialItem = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
getPlayerData(client).tutorialVehicle = createGroundItem(tutorialItem[0], tutorialItem[1], tutorialItem[3]);
}
// ===========================================================================

View File

@@ -82,7 +82,7 @@ function initAllClients() {
function updateServerRules() {
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Updating all server rules ...`);
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Time support: ${isTimeSupported()}`);
if(isTimeSupported()) {
if(getServerConfig() != false) {
@@ -363,7 +363,7 @@ function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWid
let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion);
let safeScreenWidth = escapeDatabaseString(dbConnection, toString(screenWidth));
let safeScreenHeight = escapeDatabaseString(dbConnection, toString(screenHeight));
quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${getPlayerData(client).sessionId}`);
quickDatabaseQuery(`UPDATE conn_main SET conn_client_version='${safeClientVersion}', conn_screen_width='${safeScreenWidth}', conn_screen_height='${safeScreenHeight}' WHERE conn_id = ${getPlayerData(client).sessionId}`);
}
}
@@ -395,19 +395,22 @@ function getClientFromSyncerId(syncerId) {
// ===========================================================================
async function triggerWebHook(webHookURL, payloadData) {
return new Promise(resolve => {
//console.warn(webHookURL);
httpGet(
webHookURL,
`data=${payloadData}`,
function(data) {
//console.warn(JSON.parse(data));
},
function(data) {
}
);
});
function triggerWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) {
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
tempURL = tempURL.replace("{0}", encodeURI(messageString));
tempURL = tempURL.replace("{1}", serverId);
tempURL = tempURL.replace("{2}", type);
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);
httpGet(
tempURL,
"",
function(data) {
},
function(data) {
}
);
}
// ===========================================================================
@@ -445,9 +448,9 @@ function clearTemporaryPeds() {
// ===========================================================================
function kickAllClients() {
getClients().forEach((client) => {
client.disconnect();
})
getClients().forEach((client) => {
client.disconnect();
})
}
// ===========================================================================
@@ -464,4 +467,30 @@ function isClientInitialized(client) {
return (typeof getServerData().clients[client.index] != "undefined");
}
// ===========================================================================
// ===========================================================================
function getPedForNetworkEvent(ped) {
if(getGame() == VRR_GAME_GTA_IV) {
return ped;
} else {
return ped.id;
}
}
// ===========================================================================
// Get how many times a player connected in the last month by name
function getPlayerConnectionsInLastMonthByName(name) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, name);
let result = quickDatabaseQuery(`SELECT COUNT(*) AS count FROM conn_main WHERE conn_when_connect >= NOW() - INTERVAL 1 MONTH AND conn_name = '${safeName}'`);
if(result) {
return result[0].count;
}
}
return 0;
}
// ===========================================================================

View File

@@ -9,7 +9,10 @@
function initVehicleScript() {
logToConsole(LOG_INFO, "[VRR.Vehicle]: Initializing vehicle script ...");
getServerData().vehicles = loadVehiclesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().vehicles = loadVehiclesFromDatabase();
}
spawnAllVehicles();
setAllVehicleIndexes();
logToConsole(LOG_INFO, "[VRR.Vehicle]: Vehicle script initialized successfully!");
@@ -42,7 +45,11 @@ function loadVehiclesFromDatabase() {
// ===========================================================================
function saveAllVehiclesToDatabase() {
function saveVehiclesToDatabase() {
if(getServerConfig().devServer) {
return false;
}
logToConsole(LOG_INFO, "[VRR.Vehicle]: Saving all server vehicles to database ...");
let vehicles = getServerData().vehicles;
for(let i in vehicles) {
@@ -560,7 +567,7 @@ function buyVehicleCommand(command, params, client) {
getPlayerData(client).buyingVehicle = vehicle;
getVehicleData(vehicle).engine = true;
vehicle.engine = true;
setEntityData(vehicle, "vrr.engine", getVehicleData(vehicle).engine, true);
setEntityData(vehicle, "vrr.engine", getVehicleData(vehicle).engine, true);
getVehicleData(vehicle).needsSaved = true;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_TESTDRIVE, vehicle.id, getVehiclePosition(vehicle));
@@ -790,17 +797,25 @@ function setVehicleClanCommand(command, params, client) {
}
let vehicle = getPlayerVehicle(client);
let clanId = getClanFromParams(params);
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "That clan is invalid or doesn't exist!");
return false;
}
getVehicleData(vehicle).ownerType = VRR_VEHOWNER_CLAN;
getVehicleData(vehicle).ownerId = getClanData(clanId).databaseId;
if(getVehicleData(vehicle).ownerType != VRR_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
if(getVehicleData(vehicle).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
showPlayerPromptGUI(client, getLocaleString(client, "SetVehicleClanConfirmMessage"), getLocaleString(client, "SetVehicleClanConfirm"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = VRR_PROMPT_GIVEVEHTOCLAN;
getVehicleData(vehicle).needsSaved = true;
}
@@ -1073,7 +1088,7 @@ function reloadAllVehiclesCommand(command, params, client) {
getServerData().vehicles = loadVehiclesFromDatabase();
spawnAllVehicles();
messageAdminAction(`All server vehicles have been reloaded by an admin!`);
announceAdminAction(`AllVehiclesReloaded`);
getVehicleData(vehicle).needsSaved = true;
}
@@ -1081,14 +1096,14 @@ function reloadAllVehiclesCommand(command, params, client) {
// ===========================================================================
function respawnVehicleCommand(command, params, client) {
if(isPlayerInAnyVehicle(client)) {
removeAllOccupantsFromVehicle(getPlayerVehicle(client));
respawnVehicle(getPlayerVehicle(client));
}
if(isPlayerInAnyVehicle(client)) {
removeAllOccupantsFromVehicle(getPlayerVehicle(client));
respawnVehicle(getPlayerVehicle(client));
}
setAllVehicleIndexes();
messagePlayerSuccess(client, `Your vehicle has been respawned`);
messagePlayerSuccess(client, getLocaleString(client, `YourVehicleRespawned`));
}
@@ -1106,7 +1121,7 @@ function respawnAllVehiclesCommand(command, params, client) {
setAllVehicleIndexes();
messageAdminAction(`All vehicles have been respawned by an admin!`);
announceAdminAction(`AllVehiclesRespawned`);
}
// ===========================================================================
@@ -1125,7 +1140,7 @@ function respawnEmptyVehiclesCommand(command, params, client) {
}
}
messageAdminAction(`All empty vehicles have been respawned by an admin!`);
announceAdminAction(`EmptyVehiclesRespawned`);
}
// ===========================================================================
@@ -1135,9 +1150,9 @@ function respawnJobVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_JOB) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All job vehicles have been respawned by an admin!`);
announceAdminAction(`JobVehiclesRespawned`);
}
// ===========================================================================
@@ -1147,9 +1162,9 @@ function respawnClanVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_CLAN) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All clan vehicles have been respawned by an admin!`);
announceAdminAction(`ClanVehiclesRespawned`);
}
// ===========================================================================
@@ -1159,9 +1174,9 @@ function respawnPlayerVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PLAYER) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All player-owned vehicles have been respawned by an admin!`);
announceAdminAction(`PlayerVehiclesRespawned`);
}
// ===========================================================================
@@ -1171,9 +1186,9 @@ function respawnPublicVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_PUBLIC) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All public vehicles have been respawned by an admin!`);
announceAdminAction(`PublicVehiclesRespawned`);
}
// ===========================================================================
@@ -1183,9 +1198,9 @@ function respawnBusinessVehiclesCommand(command, params, client) {
if(getServerData().vehicles[i].ownerType == VRR_VEHOWNER_BIZ) {
respawnVehicle(getServerData().vehicles[i].vehicle);
}
}
}
messageAdminAction(`All business-owned vehicles have been respawned by an admin!`);
announceAdminAction(`BusinessVehiclesRespawned`);
}
// ===========================================================================
@@ -1417,76 +1432,83 @@ function createPermanentVehicle(modelIndex, position, heading, interior = 0, dim
// ===========================================================================
function processVehiclePurchasing() {
if(!getGlobalConfig().useServerSideVehiclePurchaseCheck) {
return false;
}
if(!getGlobalConfig().useServerSideVehiclePurchaseCheck) {
return false;
}
getClients().forEach((client) => {
if(!isPlayerLoggedIn(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerSpawned(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client).buyingVehicle) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerInAnyVehicle(client)) {
if(getPlayerData(client).buyingVehicle != false) {
messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
}
return false;
}
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
createNewDealershipVehicle(getVehicleData(getPlayerData(client).buyingVehicle).model, getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(client).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice, getVehicleData(getPlayerData(client).buyingVehicle).ownerId);
takePlayerCash(client, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice);
updatePlayerCash(client);
getVehicleData(getPlayerData(client).buyingVehicle).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getVehicleData(getPlayerData(client).buyingVehicle).ownerType = VRR_VEHOWNER_PLAYER;
getVehicleData(getPlayerData(client).buyingVehicle).buyPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).rentPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
getPlayerData(client).buyingVehicle = false;
messagePlayerSuccess(client, getLocaleString(client, "VehiclePurchaseComplete"));
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return true;
}
});
let clients = getClients();
for(let i in clients) {
checkVehicleBuying(clients[i]);
}
return false;
}
// ===========================================================================
function checkVehicleBuying(client) {
if(!isPlayerLoggedIn(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerSpawned(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client)) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!getPlayerData(client).buyingVehicle) {
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
if(!isPlayerInAnyVehicle(client)) {
if(getPlayerData(client).buyingVehicle != false) {
messagePlayerError(client, getLocaleString(client, "DealershipPurchaseExitedVehicle"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
}
return false;
}
if(getDistance(getVehiclePosition(getPlayerData(client).buyingVehicle), getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
if(getPlayerCurrentSubAccount(client).cash < getVehicleData(getPlayerData(client).buyingVehicle).buyPrice) {
messagePlayerError(client, getLocaleString(client, "VehiclePurchaseNotEnoughMoney"));
respawnVehicle(getPlayerData(client).buyingVehicle);
getPlayerData(client).buyingVehicle = false;
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return false;
}
createNewDealershipVehicle(getVehicleData(getPlayerData(client).buyingVehicle).model, getVehicleData(getPlayerData(client).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(client).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice, getVehicleData(getPlayerData(client).buyingVehicle).ownerId);
takePlayerCash(client, getVehicleData(getPlayerData(client).buyingVehicle).buyPrice);
updatePlayerCash(client);
getVehicleData(getPlayerData(client).buyingVehicle).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getVehicleData(getPlayerData(client).buyingVehicle).ownerType = VRR_VEHOWNER_PLAYER;
getVehicleData(getPlayerData(client).buyingVehicle).buyPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).rentPrice = 0;
getVehicleData(getPlayerData(client).buyingVehicle).spawnLocked = false;
getPlayerData(client).buyingVehicle = false;
messagePlayerSuccess(client, getLocaleString(client, "VehiclePurchaseComplete"));
setPlayerBuyingVehicleState(client, VRR_VEHBUYSTATE_NONE, null, null);
return true;
}
}
// ===========================================================================
function processVehicleBurning() {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for(let i in vehicles) {
if(vehicles[i].health <= 250) {
return false;
}
if(vehicles[i].health <= 250) {
return false;
}
}
}
@@ -1524,19 +1546,19 @@ function setAllVehicleIndexes() {
// ===========================================================================
function doesVehicleHaveMegaphone(vehicle) {
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) {
return true;
}
if(getVehicleData(vehicle).ownerType == VRR_VEHOWNER_JOB) {
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_POLICE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_FIRE) {
return true;
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) {
return true;
}
}
if(getJobType(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)) == VRR_JOB_MEDICAL) {
return true;
}
}
return false;
}
@@ -1581,11 +1603,11 @@ function getVehicleTrunkPosition(vehicle) {
// ===========================================================================
function removeAllOccupantsFromVehicle(vehicle) {
for(let i = 0 ; i <= 16 ; i++) {
if(vehicle.getOccupant(i) != null) {
removePlayerFromVehicle(vehicle.getOccupant(i));
}
}
for(let i = 0 ; i <= 16 ; i++) {
if(vehicle.getOccupant(i) != null) {
removePlayerFromVehicle(vehicle.getOccupant(i));
}
}
}
// ===========================================================================