Merge branch 'nightly' into ragemp
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: accent.js
|
||||
// DESC: Provides accent functions and usage
|
||||
@@ -27,7 +28,7 @@ function doesPlayerHaveAccent(client) {
|
||||
|
||||
function getPlayerAccentInlineOutput(client) {
|
||||
let outputText = "";
|
||||
if(doesPlayerHaveAccent(client)) {
|
||||
if (doesPlayerHaveAccent(client)) {
|
||||
outputText = `[${getPlayerAccentText(client)}] `;
|
||||
}
|
||||
|
||||
@@ -37,14 +38,14 @@ function getPlayerAccentInlineOutput(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let accentId = getAccentFromParams(params);
|
||||
|
||||
if(!accentId) {
|
||||
if (!accentId) {
|
||||
messagePlayerError(client, getLocaleString(client, "AccentNotFound"));
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +65,7 @@ function listAccentsCommand(command, params, client) {
|
||||
let chunkedList = splitArrayIntoChunks(accentList, 8);
|
||||
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "AccentsListHeader")));
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
@@ -72,14 +73,14 @@ function listAccentsCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAccentFromParams(params) {
|
||||
if(isNaN(params)) {
|
||||
for(let i in getGlobalConfig().accents) {
|
||||
if(toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in getGlobalConfig().accents) {
|
||||
if (toLowerCase(getGlobalConfig().accents[i]).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGlobalConfig().accents[params] != "undefined") {
|
||||
if (typeof getGlobalConfig().accents[params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
@@ -97,14 +98,14 @@ function reloadAccentConfigurationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function addAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let newAccentName = params;
|
||||
|
||||
if(getAccentFromParams(newAccentName) != false) {
|
||||
if (getAccentFromParams(newAccentName) != false) {
|
||||
messagePlayerError(client, `That accent already exists!`)
|
||||
return false;
|
||||
}
|
||||
@@ -117,14 +118,14 @@ function addAccentCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function removeAccentCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let newAccentName = params;
|
||||
|
||||
if(!getAccentFromParams(newAccentName)) {
|
||||
if (!getAccentFromParams(newAccentName)) {
|
||||
messagePlayerError(client, `That accent doesn't exist!`)
|
||||
return false;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: animation.js
|
||||
// DESC: Provides animation functions and usage
|
||||
@@ -8,14 +9,14 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initAnimationScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Animation]: Initializing animation script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Animation]: Animation script initialized!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Animation]: Initializing animation script ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Animation]: Animation script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playPlayerAnimationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -23,34 +24,36 @@ function playPlayerAnimationCommand(command, params, client) {
|
||||
let animationSlot = getAnimationFromParams(getParam(params, " ", 1));
|
||||
let animationPositionOffset = 1;
|
||||
|
||||
if(!animationSlot) {
|
||||
if (!animationSlot) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
|
||||
messagePlayerInfo(client, getLocaleString(client, "AnimationCommandTip", `{ALTCOLOUR}/animlist{MAINCOLOUR}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getAnimationData(animationSlot)[3] == VRR_ANIMTYPE_SURRENDER) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_HANDSUP;
|
||||
if (getAnimationData(animationSlot)[3] == AGRP_ANIMTYPE_SURRENDER) {
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_HANDSUP;
|
||||
}
|
||||
|
||||
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
messagePlayerTip(client, getLocaleString(client, "AnimationStopCommandTip", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
|
||||
if (hasPlayerSeenActionTip(client, "AnimationStop")) {
|
||||
messagePlayerTip(client, getGroupedLocaleString(client, "ActionTips", "AnimationStop", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
|
||||
}
|
||||
makePlayerPlayAnimation(client, animationSlot, animationPositionOffset);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function stopPlayerAnimationCommand(command, params, client) {
|
||||
if(isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
@@ -65,34 +68,26 @@ function stopPlayerAnimationCommand(command, params, client) {
|
||||
getPlayerData(client).animationForced = false;
|
||||
|
||||
//setPlayerMouseCameraState(client, false);
|
||||
|
||||
markPlayerActionTipSeen(client, "AnimationStop");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function showAnimationListCommand(command, params, client) {
|
||||
let animList = getGameConfig().animations[getGame()].map(function(x) { return x.name; });
|
||||
let animList = getGameConfig().animations[getGame()].map(function (x) { return x.name; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(animList, 10);
|
||||
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderAnimationsList")));
|
||||
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerNormal(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} animationSlot - The slot index of the animation
|
||||
* @return {Array} The animation's data (array)
|
||||
*/
|
||||
function getAnimationData(animationSlot, gameId = getGame()) {
|
||||
return getGameConfig().animations[gameId][animationSlot];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInForcedAnimation(client) {
|
||||
return getPlayerData(client).animationForced;
|
||||
}
|
||||
@@ -107,9 +102,9 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
|
||||
getPlayerData(client).animationForced = false;
|
||||
|
||||
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) {
|
||||
//setEntityData(getPlayerPed(client), "agrp.anim", animationSlot, true);
|
||||
//if(getAnimationData(animationSlot)[9] != AGRP_ANIMMOVE_NONE) {
|
||||
// if(getGame() < AGRP_GAME_GTA_SA) {
|
||||
// setPlayerMouseCameraState(client, true);
|
||||
// }
|
||||
//}
|
||||
@@ -125,7 +120,7 @@ function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
|
||||
getPlayerData(client).animationForced = true;
|
||||
|
||||
setPlayerControlState(client, false);
|
||||
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
|
||||
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -141,23 +136,4 @@ function makePlayerStopAnimation(client) {
|
||||
getPlayerData(client).animationForced = false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAnimationFromParams(params) {
|
||||
let animations = getGameConfig().animations[getGame()];
|
||||
if(isNaN(params)) {
|
||||
for(let i in animations) {
|
||||
if(toLowerCase(animations[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGameConfig().animations[getGame()][params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: anticheat.js
|
||||
// DESC: Provides anticheat functions and usage
|
||||
@@ -8,17 +9,17 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initAntiCheatScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Initializing anticheat script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.AntiCheat]: Anticheat script initialized!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.AntiCheat]: Initializing anticheat script ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.AntiCheat]: Anticheat script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearPlayerStateToEnterExitProperty(client) {
|
||||
if(getPlayerData(client).pedState != VRR_PEDSTATE_READY) {
|
||||
if(getPlayerData(client).pedState == VRR_PEDSTATE_ENTERINGVEHICLE) {
|
||||
if (getPlayerData(client).pedState != AGRP_PEDSTATE_READY) {
|
||||
if (getPlayerData(client).pedState == AGRP_PEDSTATE_ENTERINGVEHICLE) {
|
||||
sendPlayerClearPedState(client);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ function clearPlayerStateToEnterExitProperty(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerExemptFromAntiCheat(client) {
|
||||
if(hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
|
||||
if (hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("ExemptFromAntiCheat"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ function isPlayerExemptFromAntiCheat(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canPlayerUsePoliceJob(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.policeBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ function canPlayerUsePoliceJob(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseFireJob(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.fireBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ function canClientUseFireJob(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseAmmunations(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.AmmuBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ function canClientUseAmmunations(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function canClientUseGuns(client) {
|
||||
if(getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) {
|
||||
if (getPlayerData(client).accountData.flags.moderation & getServerBitFlags().moderationFlags.GunBanned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,52 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bans.js
|
||||
// DESC: Provides ban functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Ban Types
|
||||
const AGRP_BANTYPE_NONE = 0;
|
||||
const AGRP_BANTYPE_ACCOUNT = 1;
|
||||
const AGRP_BANTYPE_SUBACCOUNT = 2;
|
||||
const AGRP_BANTYPE_IPADDRESS = 3;
|
||||
const AGRP_BANTYPE_SUBNET = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class BanData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.type = AGRP_BANTYPE_NONE;
|
||||
this.detail = "";
|
||||
this.ipAddress = "";
|
||||
this.name = "";
|
||||
this.reason = "";
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["ban_id"]);
|
||||
this.type = dbAssoc["ban_type"];
|
||||
this.detail = toInteger(dbAssoc["ban_detail"]);
|
||||
this.ipAddress = toInteger(dbAssoc["ban_ip"]);
|
||||
this.reason = toInteger(dbAssoc["ban_reason"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initBanScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Ban]: Initializing ban script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Ban]: Ban script initialized!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Ban]: Initializing ban script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Ban]: Ban script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function accountBanCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -24,28 +55,30 @@ function accountBanCommand(command, params, client) {
|
||||
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
|
||||
let reason = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
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")) {
|
||||
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}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
|
||||
logToConsole(LOG_WARN, `[AGRP.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
|
||||
|
||||
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
|
||||
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
|
||||
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
|
||||
disconnectPlayer(client);
|
||||
|
||||
getPlayerData(targetClient).customDisconnectReason = "Banned";
|
||||
disconnectPlayer(targetClient);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function subAccountBanCommand(command, params, client, fromDiscord) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -54,29 +87,30 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
|
||||
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
|
||||
let reason = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
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")) {
|
||||
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, `[AGRP.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
|
||||
|
||||
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
|
||||
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
|
||||
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
|
||||
|
||||
disconnectPlayer(client);
|
||||
getPlayerData(targetClient).customDisconnectReason = "Banned";
|
||||
disconnectPlayer(targetClient);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function ipBanCommand(command, params, client, fromDiscord) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -85,13 +119,13 @@ function ipBanCommand(command, params, client, fromDiscord) {
|
||||
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
|
||||
let reason = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
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")) {
|
||||
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -99,6 +133,7 @@ function ipBanCommand(command, params, client, fromDiscord) {
|
||||
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
|
||||
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
|
||||
|
||||
getPlayerData(targetClient).customDisconnectReason = "Banned";
|
||||
serverBanIP(getPlayerIP(targetClient));
|
||||
disconnectPlayer(targetClient);
|
||||
}
|
||||
@@ -106,7 +141,7 @@ function ipBanCommand(command, params, client, fromDiscord) {
|
||||
// ===========================================================================
|
||||
|
||||
function subNetBanCommand(command, params, client, fromDiscord) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -116,13 +151,13 @@ function subNetBanCommand(command, params, client, fromDiscord) {
|
||||
let octetAmount = Number(getParam(params, " ", 2));
|
||||
let reason = splitParams.slice(2).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
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")) {
|
||||
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -130,6 +165,7 @@ function subNetBanCommand(command, params, client, fromDiscord) {
|
||||
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
|
||||
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
|
||||
|
||||
getPlayerData(client).customDisconnectReason = "Banned";
|
||||
serverBanIP(getPlayerIP(targetClient));
|
||||
}
|
||||
|
||||
@@ -137,9 +173,9 @@ function subNetBanCommand(command, params, client, fromDiscord) {
|
||||
|
||||
function banAccount(accountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
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}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -152,9 +188,9 @@ function banAccount(accountId, adminAccountId, reason) {
|
||||
|
||||
function banSubAccount(subAccountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
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}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -167,9 +203,9 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
|
||||
|
||||
function banIPAddress(ipAddress, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
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}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -182,9 +218,9 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
|
||||
|
||||
function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
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}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -197,8 +233,8 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
|
||||
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}`);
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -211,8 +247,8 @@ function unbanAccount(accountId, adminAccountId) {
|
||||
|
||||
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}`);
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -225,8 +261,8 @@ function unbanSubAccount(subAccountId, adminAccountId) {
|
||||
|
||||
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})`);
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -239,8 +275,8 @@ function unbanIPAddress(ipAddress, adminAccountId) {
|
||||
|
||||
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})`);
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -252,8 +288,8 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isAccountBanned(accountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
if(bans.length > 0) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -263,8 +299,8 @@ function isAccountBanned(accountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isSubAccountBanned(subAccountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
if(bans.length > 0) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -274,8 +310,8 @@ function isSubAccountBanned(subAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isIpAddressBanned(ipAddress) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
if(bans.length > 0) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
80
scripts/server/bank.js
Normal file
80
scripts/server/bank.js
Normal file
@@ -0,0 +1,80 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bank.js
|
||||
// DESC: Provides banking functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// House Owner Types
|
||||
const AGRP_BANK_ACCT_OWNER_NONE = 0; // Not owned
|
||||
const AGRP_BANK_ACCT_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const AGRP_BANK_ACCT_OWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_BANK_ACCT_OWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_BANK_ACCT_OWNER_FACTION = 4; // Owned by a faction
|
||||
const AGRP_BANK_ACCT_OWNER_BIZ = 4; // Owned by a faction
|
||||
const AGRP_BANK_ACCT_OWNER_PUBLIC = 5; // Is a public bank account. Technically not owned. This probably won't be used.
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerAtBank(client) {
|
||||
if (isPositionAtATM(getPlayerPosition(client))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if (getBusinessData(client) != false) {
|
||||
if (getBusinessData(businessId).type == AGRP_BIZ_TYPE_BANK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPositionAtATM(position) {
|
||||
let atmId = getClosestATM(position);
|
||||
|
||||
let atmData = getServerData().atmLocationCache[atmId];
|
||||
|
||||
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestATM(position) {
|
||||
let atmLocations = getServerData().atmLocationCache;
|
||||
let closest = 0;
|
||||
|
||||
for (let i in atmLocations) {
|
||||
if (getDistance(position, atmLocations[i]) < getDistance(position, atmLocations[closest])) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPositionAtATM(position) {
|
||||
let atmId = getClosestATM(position);
|
||||
|
||||
let atmData = getServerData().atmLocationCache[atmId];
|
||||
|
||||
if (getDistance(position, atmData[2]) <= getGlobalConfig().atmDistance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bitflags.js
|
||||
// DESC: Provides bitwise operations, functions and usage
|
||||
@@ -15,7 +16,7 @@ let serverBitFlags = {
|
||||
accountSettingsFlags: {},
|
||||
subAccountSettingsFlags: {},
|
||||
accountFlags: {},
|
||||
seenHelpTipsFlags: {},
|
||||
seenActionTipsFlags: {},
|
||||
npcTriggerTypeFlags: {},
|
||||
npcTriggerConditionTypesFlags: {},
|
||||
npcTriggerResponseTypeFlags: {},
|
||||
@@ -64,6 +65,7 @@ let serverBitFlagKeys = {
|
||||
"DontSyncClientElements",
|
||||
"IsTester"
|
||||
],
|
||||
/*
|
||||
factionFlagKeys: [
|
||||
"None",
|
||||
"Police",
|
||||
@@ -72,6 +74,7 @@ let serverBitFlagKeys = {
|
||||
"Government",
|
||||
"Generic",
|
||||
],
|
||||
*/
|
||||
clanTypeFlagKeys: [
|
||||
"None",
|
||||
"Illegal",
|
||||
@@ -101,6 +104,24 @@ let serverBitFlagKeys = {
|
||||
"ManageRanks",
|
||||
"Owner",
|
||||
],
|
||||
clanDiscordWebhookFlagKeys: [
|
||||
"None",
|
||||
"ClanName",
|
||||
"ClanMOTD",
|
||||
"ClanTag",
|
||||
"ClanRankEdit",
|
||||
"ClanRankSet",
|
||||
"ClanVehicleEdit",
|
||||
"ClanHouseEdit",
|
||||
"ClanBusinessEdit",
|
||||
"ClanNPCEdit",
|
||||
"ClanMemberInvite",
|
||||
"ClanMemberRemove",
|
||||
"ClanMemberSuspend",
|
||||
"ClanRankFlagSet",
|
||||
"ClanTurfWar",
|
||||
"ClanPointWar",
|
||||
],
|
||||
accountSettingsFlagKeys: [
|
||||
"None",
|
||||
"UseWhiteList",
|
||||
@@ -117,6 +138,12 @@ let serverBitFlagKeys = {
|
||||
"NoKeyBinds",
|
||||
"NoRandomTips",
|
||||
"NoActionTips",
|
||||
"ChatBoxTimestamps",
|
||||
"ProfanityFilter",
|
||||
"ChatAutoHide",
|
||||
"NoPlayerContent",
|
||||
"ChatEmoji",
|
||||
//"NoBlood",
|
||||
],
|
||||
|
||||
// Not going to be used. Use trigger, condition, and response stuff in trigger.js
|
||||
@@ -213,55 +240,87 @@ let serverBitFlagKeys = {
|
||||
"EnterProperty",
|
||||
"SearchArea",
|
||||
],
|
||||
seenHelpTipsKeys: [
|
||||
seenActionTipsKeys: [
|
||||
"None",
|
||||
"VehicleEngineOffWhenEntering",
|
||||
"VehicleLockedAfterEntryAttempt",
|
||||
"ShowItemsAfterPurchase",
|
||||
"BuyCommandAfterEnterBusiness",
|
||||
"UseItemKeyAfterEquipping",
|
||||
"UseItemKeyAfterEquippingWalkieTalkie",
|
||||
"RadioCommandAfterEnablingWalkieTalkie",
|
||||
"ReplyToDirectMessage",
|
||||
"UseItemKeyAmmoAfterEquippingWeapon",
|
||||
"AnimationStop",
|
||||
"JobEquipmentInventory",
|
||||
"ViewInventory",
|
||||
"VehicleRepairItemUsage",
|
||||
"VehicleColourItemUsage",
|
||||
"VehiclePartItemUsage",
|
||||
"AmmoClipItemUsage",
|
||||
"GenericItemUsage",
|
||||
"EnterJobVehicleForRoute",
|
||||
"JobLocations",
|
||||
"JobRouteStart",
|
||||
],
|
||||
jobRankKeys: [
|
||||
"None",
|
||||
"PublicAccess",
|
||||
"WhiteList",
|
||||
"BlackList",
|
||||
"SetRank",
|
||||
"SetPay",
|
||||
"ManageUniforms",
|
||||
"ManageEquipment",
|
||||
"ManageVehicles",
|
||||
"ManageBusinesses",
|
||||
"Leader",
|
||||
],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initBitFlagScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.BitFlag]: Initializing bit flag script ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.BitFlag]: Initializing bit flag script ...");
|
||||
serverBitFlags.staffFlags = createBitFlagTable(serverBitFlagKeys.staffFlagKeys);
|
||||
serverBitFlags.moderationFlags = createBitFlagTable(serverBitFlagKeys.moderationFlagKeys);
|
||||
serverBitFlags.accountSettingsFlags = createBitFlagTable(serverBitFlagKeys.accountSettingsFlagKeys);
|
||||
//serverBitFlags.subAccountSettingsFlags = createBitFlagTable(getServerData().subAccountSettingsFlagKeys);
|
||||
serverBitFlags.clanFlags = createBitFlagTable(serverBitFlagKeys.clanFlagKeys);
|
||||
serverBitFlags.clanTypeFlagKeys = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys);
|
||||
serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
|
||||
serverBitFlags.clanTypeFlags = createBitFlagTable(serverBitFlagKeys.clanTypeFlagKeys);
|
||||
serverBitFlags.clanDiscordWebhookFlags = createBitFlagTable(serverBitFlagKeys.clanDiscordWebhookFlagKeys);
|
||||
//serverBitFlags.factionFlags = createBitFlagTable(serverBitFlagKeys.factionFlagKeys);
|
||||
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
|
||||
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
|
||||
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
|
||||
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
|
||||
serverBitFlags.seenActionTips = createBitFlagTable(serverBitFlagKeys.seenActionTipsKeys);
|
||||
serverBitFlags.jobRankFlags = createBitFlagTable(serverBitFlagKeys.jobRankKeys);
|
||||
logToConsole(LOG_INFO, "[AGRP.BitFlag]: Bit flag script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveStaffPermission(client, requiredFlags) {
|
||||
if(isConsole(client)) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(requiredFlags == getStaffFlagValue("None")) {
|
||||
if (requiredFlags == getStaffFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let staffFlags = 0;
|
||||
if(getPlayerData(client)) {
|
||||
if (getPlayerData(client)) {
|
||||
staffFlags = getPlayerData(client).accountData.flags.admin;
|
||||
}
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if(staffFlags == getStaffFlagValue("All")) {
|
||||
if (staffFlags == getStaffFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(hasBitFlag(staffFlags, requiredFlags)) {
|
||||
if (hasBitFlag(staffFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -271,27 +330,57 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveClanPermission(client, requiredFlags) {
|
||||
if(isConsole(client)) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(requiredFlags == getClanFlagValue("None")) {
|
||||
if (requiredFlags == getClanFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let clanFlags = 0;
|
||||
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankFlags(getPlayerCurrentSubAccount(client).clanRank);
|
||||
clanFlags = getPlayerCurrentSubAccount(client).clanFlags | getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).flags;
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if(clanFlags == getClanFlagValue("All")) {
|
||||
if (clanFlags == getClanFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(hasBitFlag(clanFlags, requiredFlags)) {
|
||||
if (hasBitFlag(clanFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveJobPermission(client, requiredFlags) {
|
||||
if (isConsole(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (requiredFlags == getClanFlagValue("None")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let jobFlags = 0;
|
||||
jobFlags = getPlayerCurrentSubAccount(client).jobFlags | getJobRankData(getPlayerJob(client), getPlayerJobRank(client)).flags;
|
||||
|
||||
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
|
||||
if (jobFlags == getJobFlagValue("All")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasBitFlag(jobFlags, requiredFlags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -301,11 +390,11 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
|
||||
// ===========================================================================
|
||||
|
||||
function getStaffFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.staffFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.staffFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -315,11 +404,11 @@ function getStaffFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClanFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
|
||||
if (typeof getServerBitFlags().clanFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,11 +418,11 @@ function getClanFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAccountSettingsFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.accountSettingsFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,11 +432,11 @@ function getAccountSettingsFlagValue(flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function getModerationFlagValue(flagName) {
|
||||
if(flagName == "All") {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
|
||||
if (typeof serverBitFlags.moderationFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -356,8 +445,36 @@ function getModerationFlagValue(flagName) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClanDiscordWebhookValue(flagName) {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (typeof serverBitFlags.clanDiscordWebhookFlags[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return serverBitFlags.clanDiscordWebhookFlags[flagName];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getSeenActionTipsValue(flagName) {
|
||||
if (flagName == "All") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (typeof serverBitFlags.seenActionTips[flagName] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return serverBitFlags.seenActionTips[flagName];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerStaffFlag(client, flagName) {
|
||||
if(!getStaffFlagValue(flagName)) {
|
||||
if (!getStaffFlagValue(flagName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -369,7 +486,7 @@ function givePlayerStaffFlag(client, flagName) {
|
||||
|
||||
function takePlayerStaffFlag(client, flagName) {
|
||||
let flagValue = getStaffFlagValue(flagName);
|
||||
if(!flagValue) {
|
||||
if (!flagValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -380,7 +497,7 @@ function takePlayerStaffFlag(client, flagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function takePlayerStaffFlag(client, flagName) {
|
||||
if(!getStaffFlagValue(flagName)) {
|
||||
if (!getStaffFlagValue(flagName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
177
scripts/server/casino.js
Normal file
177
scripts/server/casino.js
Normal file
@@ -0,0 +1,177 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: casino.js
|
||||
// DESC: Provides casino games functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
const AGRP_CASINO_GAME_NONE = 0;
|
||||
const AGRP_CASINO_GAME_BLACKJACK = 1;
|
||||
const AGRP_CASINO_GAME_POKER = 2;
|
||||
const AGRP_CASINO_GAME_BACCARAT = 3;
|
||||
const AGRP_CASINO_GAME_ROULETTE = 4;
|
||||
const AGRP_CASINO_GAME_CRAPS = 5;
|
||||
const AGRP_CASINO_GAME_HOLDEM = 6;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
const AGRP_CASINO_DECK_SUIT_NONE = 1;
|
||||
const AGRP_CASINO_DECK_SUIT_CLUBS = 1;
|
||||
const AGRP_CASINO_DECK_SUIT_DIAMONDS = 2;
|
||||
const AGRP_CASINO_DECK_SUIT_HEARTS = 3;
|
||||
const AGRP_CASINO_DECK_SUIT_SPADES = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class DeckCard {
|
||||
constructor(suit, value, imageName) {
|
||||
this.suit = suit;
|
||||
this.value = value;
|
||||
this.imageName = imageName;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let cardDeck = [
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 1, "deckCardClubAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 2, "deckCardClubTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 3, "deckCardClubThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 4, "deckCardClubFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 5, "deckCardClubFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 6, "deckCardClubSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 7, "deckCardClubSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 8, "deckCardClubEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 9, "deckCardClubNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 10, "deckCardClubTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 11, "deckCardClubJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 12, "deckCardClubQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_CLUBS, 13, "deckCardClubKing"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 1, "deckCardDiamondAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 2, "deckCardDiamondTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 3, "deckCardDiamondThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 4, "deckCardDiamondFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 5, "deckCardDiamondFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 6, "deckCardDiamondSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 7, "deckCardDiamondSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 8, "deckCardDiamondEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 9, "deckCardDiamondNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 10, "deckCardDiamondTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 11, "deckCardDiamondJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 12, "deckCardDiamondQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_DIAMONDS, 13, "deckCardDiamondKing"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 1, "deckCardHeartAce"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 2, "deckCardHeartTwo"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 3, "deckCardHeartThree"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 4, "deckCardHeartFour"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 5, "deckCardHeartFive"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 6, "deckCardHeartSix"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 7, "deckCardHeartSeven"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 8, "deckCardHeartEight"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 9, "deckCardHeartNine"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 10, "deckCardHeartTen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 11, "deckCardHeartJack"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 12, "deckCardHeartQueen"),
|
||||
new DeckCard(AGRP_CASINO_DECK_SUIT_HEARTS, 13, "deckCardHeartKing"),
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createBlackJackDeck() {
|
||||
let deck = [];
|
||||
for (let i in cardDeck) {
|
||||
deck.push(cardDeck[i]);
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function shuffleBlackJackDeck(deck) {
|
||||
// For 1000 turns, switch the values of two random cards
|
||||
// This may need to be lowered for a more optimized shuffling algorithm (reduces server load)
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var location1 = Math.floor((Math.random() * deck.length));
|
||||
var location2 = Math.floor((Math.random() * deck.length));
|
||||
var tmp = deck[location1];
|
||||
|
||||
deck[location1] = deck[location2];
|
||||
deck[location2] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackHitCommand(command, params, client) {
|
||||
if (!isPlayerPlayingBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayersTurnInBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let hand = getPlayerData(client).casinoCardHand;
|
||||
|
||||
hand.push(deck.pop());
|
||||
|
||||
let tempHandValue = 0;
|
||||
|
||||
for (let i in hand) {
|
||||
if (hand[i].value == 1) {
|
||||
|
||||
if ((tempHandValue + 11) > 21) {
|
||||
tempHandValue += 1;
|
||||
} else {
|
||||
tempHandValue += 11;
|
||||
}
|
||||
} else {
|
||||
tempHandValue += hand[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
if (handValue > 21) {
|
||||
playerBustBlackJack(client);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackStandCommand(command, params, client) {
|
||||
if (!isPlayerPlayingBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayersTurnInBlackJack(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function blackJackHit(hand, deck) {
|
||||
|
||||
|
||||
return handValue;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function dealPlayerBlackJackHand(deck, players) {
|
||||
// Alternate handing cards to each player, 2 cards each
|
||||
for (var i = 0; i < 2; i++) {
|
||||
for (var x = 0; x < players.length; x++) {
|
||||
var card = deck.pop();
|
||||
getPlayerData(players[i]).casinoCardHand.push(card);
|
||||
updateCasinoCardHand(players[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: chat.js
|
||||
// DESC: Provides chat functions and usage
|
||||
@@ -8,31 +9,31 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initChatScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Chat]: Initializing chat script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Chat]: Chat script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Chat]: Initializing chat script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Chat]: Chat script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processPlayerChat(client, messageText) {
|
||||
if(!isConsole(client)) {
|
||||
if(!getPlayerData(client)) {
|
||||
if (!isConsole(client)) {
|
||||
if (!getPlayerData(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerSpawned(client)) {
|
||||
if (!isPlayerSpawned(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeLoggedInAndSpawnedToChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ function processPlayerChat(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function meActionCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -73,12 +74,12 @@ function meActionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function doActionCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -90,12 +91,12 @@ function doActionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function shoutCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -107,17 +108,17 @@ function shoutCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function megaphoneChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUseMegaphone(client)) {
|
||||
if (!canPlayerUseMegaphone(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantUseMegaphone"));
|
||||
return false;
|
||||
}
|
||||
@@ -129,12 +130,12 @@ function megaphoneChatCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function talkCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -146,12 +147,12 @@ function talkCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function whisperCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -163,12 +164,12 @@ function whisperCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function adminChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -179,12 +180,12 @@ function adminChatCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function clanChatCommand(command, params, client) {
|
||||
if(isPlayerMuted(client)) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -194,24 +195,82 @@ function clanChatCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function privateMessageCommand(command, params, client) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let splitParams = params.split(" ");
|
||||
let targetClient = getPlayerFromParams(splitParams[0]);
|
||||
let messageText = splitParams.slice(1).join(" ");
|
||||
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getPlayerData(targetClient).privateMessageReplyTo = client;
|
||||
messagePlayerPrivateMessage(targetClient, client, messageText);
|
||||
|
||||
if (hasPlayerSeenActionTip(targetClient, "ReplyToDirectMessage")) {
|
||||
messagePlayerTip(targetClient, getGroupedLocaleString(targetClient, "ActionTips", "ReplyToDirectMessage", "{ALTCOLOUR}/reply{MAINCOLOUR}"));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function replyToLastPrivateMessageCommand(command, params, client) {
|
||||
if (isPlayerMuted(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MutedCantChat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPlayerData(client).privateMessageReplyTo == null) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoPrivateMessageToReply"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getPlayerData(targetClient).privateMessageReplyTo = client;
|
||||
messagePlayerPrivateMessage(targetClient, client, messageText);
|
||||
|
||||
markPlayerActionTipSeen(client, "ReplyToDirectMessage");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function talkToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerTalk(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(talkingClient)}${getClientSubAccountName(talkingClient)} says: ${messageText}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function phoneOutgoingToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().talkDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to phone): {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -222,9 +281,9 @@ function phoneOutgoingToNearbyPlayers(client, messageText) {
|
||||
|
||||
function phoneIncomingToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().phoneSpeakerDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(from phone): {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -235,91 +294,115 @@ function phoneIncomingToNearbyPlayers(client, messageText) {
|
||||
|
||||
function whisperToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().whisperDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerWhisper(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🤫 ${getPlayerAccentInlineOutput(whisperingClient)}${getClientSubAccountName(whisperingClient)} whispers: ${messageText}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function shoutToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().shoutDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerShout(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`🗣️ ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} shouts: ${messageText}!`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function megaPhoneToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().megaphoneDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerMegaPhone(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendLocalChat) {
|
||||
messageDiscordChatChannel(`📢 ${getPlayerAccentInlineOutput(shoutingClient)}${getClientSubAccountName(shoutingClient)} (megaphone): ${messageText}!`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doActionToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().doActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerDoAction(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendAction) {
|
||||
messageDiscordChatChannel(`🙋 *${messageText} (${getCharacterFullName(client)})*`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function meActionToNearbyPlayers(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || (getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= getGlobalConfig().meActionDistance && getPlayerDimension(client) == getPlayerDimension(clients[i]))) {
|
||||
messagePlayerMeAction(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getGlobalConfig().discord.sendAction) {
|
||||
messageDiscordChatChannel(`🙋 *${getCharacterFullName(client)} ${messageText}*`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clanChat(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if(hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) {
|
||||
for (let i in clients) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
if (hasBitFlag(getPlayerData(clients[i]).accountData.flags.moderation, getModerationFlagValue("CanHearEverything")) || arePlayersInSameClan(client, clients[i])) {
|
||||
messagePlayerClanChat(clients[i], client, messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (getGlobalConfig().discord.sendClan) {
|
||||
// messageDiscordClanWebhook(getPlayerClan(client), getClanDiscordWebhookFlagValue("ClanChat"), fullString);
|
||||
//}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function canPlayerUseMegaphone(client) {
|
||||
if(getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_MEGAPHONE) != -1) {
|
||||
if(isPlayerActiveItemEnabled(client)) {
|
||||
if (getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_MEGAPHONE) != -1) {
|
||||
if (isPlayerActiveItemEnabled(client)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(getPlayerVehicle(client)) {
|
||||
if(doesVehicleHaveMegaphone(getPlayerVehicle(client))) {
|
||||
if (getPlayerVehicle(client)) {
|
||||
if (doesVehicleHaveMegaphone(getPlayerVehicle(client))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,51 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: command.js
|
||||
// DESC: Provides command data, functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a command's data. Loaded and saved in the database
|
||||
*/
|
||||
class CommandData {
|
||||
enable() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
toggleEnabled() {
|
||||
this.enabled = !this.enabled;
|
||||
}
|
||||
|
||||
constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) {
|
||||
this.command = command;
|
||||
this.handlerFunction = handlerFunction;
|
||||
this.syntaxString = syntaxString;
|
||||
this.requiredStaffFlags = requiredStaffFlags;
|
||||
this.enabled = true;
|
||||
this.requireLogin = requireLogin;
|
||||
this.allowOnDiscord = allowOnDiscord;
|
||||
this.helpDescription = helpDescription;
|
||||
this.aliases = [];
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let serverCommands = [];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initCommandScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Command]: Initializing commands script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Command]: Initialized commands script!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -34,8 +70,18 @@ function loadCommands() {
|
||||
new CommandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off random tips"),
|
||||
new CommandData("loginalert", toggleAccountLoginAttemptNotificationsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off email notifications for attempts to login to your account"),
|
||||
new CommandData("scrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatscrolllines", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatscroll", setAccountChatScrollLinesCommand, "<number of lines>", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"),
|
||||
new CommandData("chatautohide", setAccountChatAutoHideDelayCommand, "<time in seconds>", getStaffFlagValue("None"), true, false, "Sets how long to wait to hide the chatbox after last use (in seconds)"),
|
||||
|
||||
new CommandData("chattimestamp", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattimestamps", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattime", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattimes", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chattimestamps", toggleChatBoxTimeStampsCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off timestamps in the chatbox"),
|
||||
new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"),
|
||||
new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
|
||||
new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
|
||||
//new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"),
|
||||
],
|
||||
ammunation: [],
|
||||
animation: [
|
||||
@@ -92,14 +138,15 @@ function loadCommands() {
|
||||
new CommandData("bizpickup", setBusinessPickupCommand, "<type name/model id>", getStaffFlagValue("ManageBusinesses"), true, true, "Sets the business pickup display"),
|
||||
new CommandData("bizinfo", getBusinessInfoCommand, "[business id]", getStaffFlagValue("None"), true, true, "Shows business information"),
|
||||
new CommandData("bizflooritems", getBusinessFloorItemsCommand, "[business id]", getStaffFlagValue("None"), true, true, "Shows all business floor items (for sale) to a player"),
|
||||
new CommandData("bizflooritems", getBusinessStorageItemsCommand, "[business id]", getStaffFlagValue("None"), true, true, "Shows all business storage items (i.e. back room) to a player"),
|
||||
new CommandData("bizstorageitems", getBusinessStorageItemsCommand, "[business id]", getStaffFlagValue("None"), true, true, "Shows all business storage items (i.e. back room) to a player"),
|
||||
new CommandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("ManageBusinesses"), true, true, "Moves the entrance (exterior point) of the business"),
|
||||
new CommandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("ManageBusinesses"), true, true, "Moves the exit (interior point) of the business"),
|
||||
new CommandData("bizinttype", setBusinessInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("ManageBusinesses"), true, true, "Changes the business interior"),
|
||||
new CommandData("bizdefaultitems", giveDefaultItemsToBusinessCommand, "<item template>", getStaffFlagValue("ManageItems"), true, true, "Gives the business the default items based on template name"),
|
||||
new CommandData("bizdelflooritems", deleteBusinessFloorItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items on the business floor (for-sale items)"),
|
||||
new CommandData("bizdelstorageitems", deleteBusinessStorageItemsCommand, "", getStaffFlagValue("ManageItems"), true, true, "Destroys all items in the business's storage"),
|
||||
new CommandData("bizdealership", setBusinessEntranceLabelToDealershipCommand, "", getStaffFlagValue("ManageBusinesses"), true, true, "Sets the business's door label to vehicle dealership"),
|
||||
new CommandData("bizdealership", setBusinessDealershipCommand, "", getStaffFlagValue("None"), true, true, "Sets the business's door label to vehicle dealership"),
|
||||
//new CommandData("bizpaintball", setBusinessPaintBallCommand, "", getStaffFlagValue("None"), true, true, "Sets the business to a paintball arena"),
|
||||
],
|
||||
chat: [
|
||||
new CommandData("me", meActionCommand, "<message>", getStaffFlagValue("None"), true, false, "Shows a custom action message in chat"),
|
||||
@@ -114,10 +161,11 @@ function loadCommands() {
|
||||
new CommandData("clanchat", clanChatCommand, "<message>", getStaffFlagValue("None"), true, false, "Sends an OOC chat message to members in your clan"),
|
||||
new CommandData("clan", clanChatCommand, "<message>", getStaffFlagValue("None"), true, false, "Sends an OOC chat message to members in your clan"),
|
||||
new CommandData("c", clanChatCommand, "<message>", getStaffFlagValue("None"), true, false, "Sends an OOC chat message to members in your clan"),
|
||||
new CommandData("adminchat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("a", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("achat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("m", megaphoneChatCommand, "<message>", getStaffFlagValue("None"), true, true, "Shouts a message over a megaphone (portable bullhorn/loudspeaker)"),
|
||||
new CommandData("pm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("dm", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("msg", privateMessageCommand, "<player name/id> <message>", getStaffFlagValue("None"), true, true, "Sends a private message to a player"),
|
||||
new CommandData("reply", replyToLastPrivateMessageCommand, "<message>", getStaffFlagValue("None"), true, true, "Replies to the last private message you received"),
|
||||
],
|
||||
clan: [
|
||||
new CommandData("clans", listClansCommand, "[search text]", getStaffFlagValue("None"), true, true, "List clans (search by partial name, if provided)"),
|
||||
@@ -215,6 +263,8 @@ function loadCommands() {
|
||||
email: [
|
||||
new CommandData("testemail", testEmailCommand, "<email address>", getStaffFlagValue("Developer"), true, true),
|
||||
],
|
||||
fishing: [],
|
||||
forensics: [],
|
||||
gate: [
|
||||
new CommandData("gate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
@@ -223,8 +273,8 @@ function loadCommands() {
|
||||
new CommandData("bizgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("businessgate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("door", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
//new CommandData("opengate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
//new CommandData("closegate", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("opendoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("closedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
new CommandData("garagedoor", triggerGateCommand, "", getStaffFlagValue("None"), true, true, "Opens/closes the nearest gate"),
|
||||
@@ -267,6 +317,7 @@ function loadCommands() {
|
||||
new CommandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("ManageHouses"), true, true, "Moves a house's exit (inside/interior location to exit the house)"),
|
||||
new CommandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("ManageHouses"), true, true, "Sets a house's interior to a pre-defined type"),
|
||||
],
|
||||
insurance: [],
|
||||
item: [
|
||||
new CommandData("i", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
|
||||
new CommandData("item", playerSwitchHotBarSlotCommand, "<slot id>", getStaffFlagValue("None"), true, false, "Switches to the item in the specified slot of your inventory."),
|
||||
@@ -299,9 +350,17 @@ function loadCommands() {
|
||||
new CommandData("additemtype", createItemTypeCommand, "<name>", getStaffFlagValue("ManageItems"), true, false, "Adds a new item type"),
|
||||
new CommandData("itemtypeusetype", setItemTypeUseTypeCommand, "<item type> <use type>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-type (what kind of action is performed when using it)"),
|
||||
new CommandData("itemtypeuseval", setItemTypeUseValueCommand, "<item type> <use value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's use-value (how much gets subtracted when using it)"),
|
||||
new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"),
|
||||
new CommandData("itemtypeorderprice", setItemTypeOrderPriceCommand, "<item type> <order price>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's order price (base price when ordering for a business"),
|
||||
new CommandData("itemtyperiskmult", setItemTypeRiskMultiplierCommand, "<item type> <risk multiplier>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's risk multiplayer (higher value for more dangerous or rare illegal items)"),
|
||||
new CommandData("itemtypeenabled", toggleItemTypeEnabledCommand, "<item type>", getStaffFlagValue("ManageItems"), true, false, "Toggles an item type on or off (if off, any items with that type can't be interacted with)"),
|
||||
new CommandData("itemtypedroppos", setItemTypeDropPositionCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the offset position for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedroprot", setItemTypeDropRotationCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the rotation for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedropscale", setItemTypeDropScaleCommand, "<item type> [x] [y] [z]", getStaffFlagValue("ManageItems"), true, false, "Sets the scale for the object of an item type when dropped"),
|
||||
new CommandData("itemtypedropfrontdistance", setItemTypeDropFrontDistanceCommand, "<item type> <distance>", getStaffFlagValue("ManageItems"), true, false, "Sets how far in front of a player an item type will be dropped"),
|
||||
new CommandData("itemtypemaxval", setItemTypeMaxValueCommand, "<item type> <max value>", getStaffFlagValue("ManageItems"), true, false, "Sets the maximum value an item type can have"),
|
||||
new CommandData("itemtypeorderval", setItemTypeOrderValueCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the initial value of an item type when ordered by a business"),
|
||||
new CommandData("itemtypesize", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets the item type's size"),
|
||||
new CommandData("itemtypecapacity", setItemTypeSizeCommand, "<item type> <order value>", getStaffFlagValue("ManageItems"), true, false, "Sets an item type's capacity (how much it can hold)"),
|
||||
|
||||
new CommandData("delplritem", deleteItemInPlayerInventoryCommand, "<player name/id> <item slot>", getStaffFlagValue("ManageItems"), true, false, "Removes an item by slot from a player's personal inventory"),
|
||||
new CommandData("delplritems", deleteAllItemsInPlayerInventoryCommand, "<player name/id>", getStaffFlagValue("ManageItems"), true, false, "Removes all items from a player's personal inventory"),
|
||||
@@ -355,11 +414,14 @@ function loadCommands() {
|
||||
new CommandData("jobroutepay", setJobRoutePayCommand, "<amount>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutestartmsg", setJobRouteStartMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutefinishmsg", setJobRouteFinishMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocarrivemsg", setJobRouteLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocnextmsg", setJobRouteLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutearrivemsg", setJobRouteDefaultLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutenextmsg", setJobRouteDefaultLocationNextMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocarrivemsg", setJobRouteNextLocationArriveMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocnextmsg", setJobRouteNextLocationGotoMessageCommand, "<new message>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobrouteenabled", toggleJobRouteEnabledCommand, "", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutevehcolours", setJobRouteVehicleColoursCommand, "<colour 1> <colour 2>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutedelays", setJobRouteAllLocationDelaysCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobroutelocdelay", setJobRouteNextLocationDelayCommand, "<time in milliseconds>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobcolour", setJobColourCommand, "<job id/name> <red> <green> <blue>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobblip", setJobBlipCommand, "<job id/name> <blip id/name>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
new CommandData("jobpickup", setJobPickupCommand, "<job id/name> <pickup id/name>", getStaffFlagValue("ManageJobs"), true, false),
|
||||
@@ -397,6 +459,7 @@ function loadCommands() {
|
||||
new CommandData("idea", submitIdeaCommand, "<message>", getStaffFlagValue("None"), true, true, "Sends an suggestion/idea to the developers"),
|
||||
new CommandData("bug", submitBugReportCommand, "<message>", getStaffFlagValue("None"), true, true, "Submits a bug report"),
|
||||
new CommandData("enter", enterExitPropertyCommand, "", getStaffFlagValue("None"), true, true, "Enters or exists a house/business"),
|
||||
new CommandData("exit", enterExitPropertyCommand, "", getStaffFlagValue("None"), true, true, "Enters or exists a house/business"),
|
||||
new CommandData("cursor", toggleMouseCursorCommand, "", getStaffFlagValue("None"), true, false, "Toggles cursor visibility"),
|
||||
new CommandData("mousecam", toggleMouseCameraCommand, "", getStaffFlagValue("None"), true, false, "Toggles vehicle mouse camera for games that don't have it"),
|
||||
new CommandData("yes", playerPromptAnswerYesCommand, "", getStaffFlagValue("None"), true, false, "Answers a prompt with YES"),
|
||||
@@ -406,7 +469,13 @@ function loadCommands() {
|
||||
new CommandData("gps", gpsCommand, "[item or place name]", getStaffFlagValue("None"), true, false, "Shows you locations for special places or where to buy items"),
|
||||
new CommandData("speak", playerPedSpeakCommand, "<speech name>", getStaffFlagValue("None"), true, false, "Makes your ped say something in their game voice (IV only)"),
|
||||
new CommandData("lock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("locks", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("doorlock", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("lockdoor", lockCommand, "", getStaffFlagValue("None"), true, false, "Locks and unlocks your vehicle, house, or business"),
|
||||
new CommandData("lights", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
|
||||
new CommandData("light", lightsCommand, "", getStaffFlagValue("None"), true, false, "Turns on and off the lights for your vehicle, house, or business"),
|
||||
new CommandData("kill", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
|
||||
new CommandData("suicide", suicideCommand, "", getStaffFlagValue("None"), true, false, "Kills yourself"),
|
||||
],
|
||||
npc: [
|
||||
new CommandData("addnpc", createNPCCommand, "<skin id/name>", getStaffFlagValue("ManageNPCs"), true, false, "Creates an NPC with the specified skin"),
|
||||
@@ -418,6 +487,7 @@ function loadCommands() {
|
||||
//new CommandData("npcrespawnall", respawnAllNPCsCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns all NPCs"),
|
||||
//new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"),
|
||||
],
|
||||
paintball: [],
|
||||
race: [
|
||||
// Unfinished!
|
||||
//new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
|
||||
@@ -427,18 +497,25 @@ function loadCommands() {
|
||||
//new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
|
||||
//new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
|
||||
//new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
|
||||
//new CommandData("racestart", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
|
||||
//new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
|
||||
//new CommandData("racestop", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
|
||||
//new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
|
||||
//new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
|
||||
//new CommandData("racestopall", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"),
|
||||
//new CommandData("stopallraces", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops all active races"),
|
||||
],
|
||||
radio: [
|
||||
new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
|
||||
new CommandData("radiostations", showRadioStationListCommand, "", getStaffFlagValue("None"), true, false, "Shows a list of all available radio stations"),
|
||||
new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radiovolume", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radiovol", setStreamingRadioVolumeCommand, "<volume level 0-100>", getStaffFlagValue("None"), true, false, "Sets the radio streaming volume (for your game only)."),
|
||||
new CommandData("radioreloadall", reloadAllRadioStationsCommand, "", getStaffFlagValue("ManageServer"), true, false, "Reloads all radio stations from database (use after making changes)"),
|
||||
],
|
||||
security: [],
|
||||
staff: [
|
||||
new CommandData("adminchat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("a", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("achat", adminChatCommand, "<message>", getStaffFlagValue("BasicModeration"), true, true, "Sends an OOC chat message to other admins"),
|
||||
new CommandData("kick", kickClientCommand, "<player name/id> [reason]", getStaffFlagValue("BasicModeration"), true, true, "Kicks a player from the server"),
|
||||
new CommandData("mute", muteClientCommand, "<player name/id> [reason]", getStaffFlagValue("BasicModeration"), true, true, "Mutes a player, preventing them from using any chat."),
|
||||
new CommandData("freeze", freezeClientCommand, "<player name/id> [reason]", getStaffFlagValue("BasicModeration"), true, true, "Freeze a player, preventing them from moving."),
|
||||
@@ -468,18 +545,25 @@ function loadCommands() {
|
||||
new CommandData("int", playerInteriorCommand, "<player name/id> [interior id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's game interior."),
|
||||
new CommandData("vw", playerVirtualWorldCommand, "<player name/id> [virtual world id]", getStaffFlagValue("BasicModeration"), true, true, "Gets or sets a player's virtual world/dimension."),
|
||||
new CommandData("addplrstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("addplayerstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("addstaffflag", addPlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Gives a player a staff flag by name (this server only)."),
|
||||
new CommandData("delplrstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."),
|
||||
new CommandData("plrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
|
||||
new CommandData("clearstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("delstaffflag", removePlayerStaffFlagCommand, "<player name/id> <flag name>", getStaffFlagValue("ManageAdmins"), true, true, "Takes a player's staff flag by name (this server only)."),
|
||||
new CommandData("getplrstaffflags", getPlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all staff flags a player has (this server only)."),
|
||||
new CommandData("delplrstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("delstaffflags", removePlayerStaffFlagsCommand, "<player name/id>", getStaffFlagValue("ManageAdmins"), true, true, "Removes all staff flags for a player (this server only)."),
|
||||
new CommandData("allstaffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
|
||||
new CommandData("staffflags", getStaffFlagsCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Shows a list of all valid staff flag names."),
|
||||
new CommandData("plrstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("playerstafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("stafftitle", setPlayerStaffTitleCommand, "", getStaffFlagValue("ManageAdmins"), true, true, "Sets a player's staff title."),
|
||||
new CommandData("givemoney", givePlayerMoneyCommand, "<player name/id> <amount>", getStaffFlagValue("serverManager"), true, true),
|
||||
new CommandData("nonrpname", forceCharacterNameChangeCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to change their current character's name."),
|
||||
new CommandData("setname", setCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
|
||||
new CommandData("setskin", setPlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."),
|
||||
new CommandData("setaccent", setPlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."),
|
||||
//new CommandData("setfightstyle", setPlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
|
||||
new CommandData("setstars", setPlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
|
||||
new CommandData("setname", forceCharacterNameCommand, "<player name/id> <first name> <last name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's name directly."),
|
||||
new CommandData("setskin", forcePlayerSkinCommand, "<player name/id> <skin id/name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's skin."),
|
||||
new CommandData("setaccent", forcePlayerAccentCommand, "<player name/id> <accent name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's accent."),
|
||||
new CommandData("setfightstyle", forcePlayerFightStyleCommand, "<player name/id> <fight style name>", getStaffFlagValue("BasicModeration"), true, true, "Changes a character's fight style."),
|
||||
new CommandData("setstars", forcePlayerWantedLevelCommand, "<player name/id> <wanted level>", getStaffFlagValue("BasicModeration"), true, true, "Forces a player to have a wanted level"),
|
||||
new CommandData("plrinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
|
||||
new CommandData("playerinfo", getPlayerInfoCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows basic info about the specified player"),
|
||||
new CommandData("getplrhouses", getHousesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all houses owned by the player"),
|
||||
@@ -494,13 +578,20 @@ function loadCommands() {
|
||||
new CommandData("getplayervehicles", getVehiclesOwnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Shows a list of all vehicles owned by the player"),
|
||||
new CommandData("geoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
|
||||
new CommandData("ip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
|
||||
new CommandData("getgeoip", getPlayerGeoIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves GeoIP information on a player (country & city)"),
|
||||
new CommandData("getip", getPlayerIPInformationCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Retrieves IP information on a player"),
|
||||
new CommandData("plrsync", toggleSyncForElementsSpawnedByPlayerCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Sets whether elements spawned by a player are synced (traffic, peds, etc)"),
|
||||
new CommandData("health", setPlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("armour", setPlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("health", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("armour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("sethealth", forcePlayerHealthCommand, "<player name/id> <health", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's health"),
|
||||
new CommandData("setarmour", forcePlayerArmourCommand, "<player name/id> <armour>", getStaffFlagValue("BasicModeration"), true, true, "Sets a player's armour"),
|
||||
new CommandData("infiniterun", setPlayerInfiniteRunCommand, "<player name/id> <state>", getStaffFlagValue("BasicModeration"), true, true, "Toggles a player's infinite sprint"),
|
||||
new CommandData("atbiz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("atbusiness", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("athouse", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
|
||||
new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
|
||||
new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
|
||||
],
|
||||
startup: [],
|
||||
subAccount: [
|
||||
@@ -599,7 +690,6 @@ function loadCommands() {
|
||||
new CommandData("vehiclerepair", vehicleAdminRepairCommand, "", getStaffFlagValue("None"), true, true, "Repairs your vehicle"),
|
||||
new CommandData("repairveh", vehicleAdminRepairCommand, "", getStaffFlagValue("None"), true, true, "Repairs your vehicle"),
|
||||
new CommandData("repairvehicle", vehicleAdminRepairCommand, "", getStaffFlagValue("None"), true, true, "Repairs your vehicle"),
|
||||
|
||||
new CommandData("passenger", enterVehicleAsPassengerCommand, "", getStaffFlagValue("None"), true, true, "Enters a vehicle as passenger"),
|
||||
],
|
||||
};
|
||||
@@ -612,25 +702,28 @@ function loadCommands() {
|
||||
function addAllCommandHandlers() {
|
||||
let commandCount = 0;
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
|
||||
addCommandHandler(commands[i][j].command, processPlayerCommand);
|
||||
commandCount++;
|
||||
}
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`);
|
||||
removeCommandHandler("help");
|
||||
addCommandHandler("help", helpCommand);
|
||||
|
||||
logToConsole(LOG_INFO, `[AGRP.Command] ${commandCount} command handlers added!`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getCommand(command) {
|
||||
let commandGroups = getCommands()
|
||||
for(let i in commandGroups) {
|
||||
for (let i in commandGroups) {
|
||||
let commandGroup = commandGroups[i];
|
||||
for(let j in commandGroup) {
|
||||
if(toLowerCase(commandGroup[j].command) == toLowerCase(command)) {
|
||||
for (let j in commandGroup) {
|
||||
if (toLowerCase(commandGroup[j].command) == toLowerCase(command)) {
|
||||
return commandGroup[j];
|
||||
}
|
||||
}
|
||||
@@ -684,14 +777,14 @@ function isCommandAllowedOnDiscord(command) {
|
||||
// ===========================================================================
|
||||
|
||||
function disableCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
params = toLowerCase(params);
|
||||
|
||||
if(!getCommand(params)) {
|
||||
if (!getCommand(params)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
|
||||
return false;
|
||||
}
|
||||
@@ -704,14 +797,14 @@ function disableCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function enableCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
params = toLowerCase(params);
|
||||
|
||||
if(!getCommand(params)) {
|
||||
if (!getCommand(params)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
|
||||
return false;
|
||||
}
|
||||
@@ -724,19 +817,19 @@ function enableCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function disableAllCommandsByType(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
params = toLowerCase(params);
|
||||
|
||||
if(isNull(getServerData().commands[params])) {
|
||||
if (isNull(getServerData().commands[params])) {
|
||||
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(let i in getServerData().commands[params]) {
|
||||
for (let i in getServerData().commands[params]) {
|
||||
getServerData().commands[params][i].enabled = false;
|
||||
}
|
||||
|
||||
@@ -747,19 +840,19 @@ function disableAllCommandsByType(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function enableAllCommandsByType(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
params = toLowerCase(params);
|
||||
|
||||
if(isNull(getServerData().commands[params])) {
|
||||
if (isNull(getServerData().commands[params])) {
|
||||
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(let i in getServerData().commands[params]) {
|
||||
for (let i in getServerData().commands[params]) {
|
||||
getServerData().commands[params][i].enabled = true;
|
||||
}
|
||||
|
||||
@@ -776,22 +869,22 @@ function enableAllCommandsByType(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function processPlayerCommand(command, params, client) {
|
||||
if(builtInCommands.indexOf(toLowerCase(command)) != -1) {
|
||||
if (builtInCommands.indexOf(toLowerCase(command)) != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let commandData = getCommand(toLowerCase(command));
|
||||
|
||||
let paramsDisplay = params;
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
paramsDisplay = "";
|
||||
}
|
||||
|
||||
if(!doesCommandExist(toLowerCase(command))) {
|
||||
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
|
||||
if (!doesCommandExist(toLowerCase(command))) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
|
||||
|
||||
let possibleCommand = getCommandFromParams(command);
|
||||
if(possibleCommand != false && doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(possibleCommand.command)))) {
|
||||
if (possibleCommand != false && doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(possibleCommand.command)))) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidCommandPossibleMatchTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}${toLowerCase(possibleCommand.command)}{MAINCOLOUR}`));
|
||||
} else {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidCommandHelpTip", `{ALTCOLOUR}/${command}{MAINCOLOUR}`, `{ALTCOLOUR}/help{MAINCOLOUR}`));
|
||||
@@ -799,45 +892,45 @@ function processPlayerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!commandData.enabled) {
|
||||
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
|
||||
if (!commandData.enabled) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} is disabled!`);
|
||||
messagePlayerError(client, getLocaleString(client, "CommandDisabled", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(doesCommandRequireLogin(toLowerCase(command))) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
|
||||
if (doesCommandRequireLogin(toLowerCase(command))) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, getLocaleString(client, "CommandRequiresLogin", `{ALTCOLOUR}/${command}{MAINCOLOUR}`));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isClientFromDiscord(client)) {
|
||||
if(!isCommandAllowedOnDiscord(command)) {
|
||||
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`);
|
||||
if (isClientFromDiscord(client)) {
|
||||
if (!isCommandAllowedOnDiscord(command)) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} attempted to use command from discord, but failed (not available on discord): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, `The {ALTCOLOUR}/${command}{MAINCOLOUR} command isn't available on discord!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isConsole(client)) {
|
||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
|
||||
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
|
||||
if (!isConsole(client)) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, getLocaleString(client, "CommandNoPermissions", `{ALTCOLOUR}/${toLowerCase(command)}{MAINCOLOUR}`));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Command] ${getPlayerDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Command] ${getPlayerDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`);
|
||||
commandData.handlerFunction(toLowerCase(command), params, client);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
addCommandHandler("cmd", function(command, params, client) {
|
||||
if(!isConsole(client)) {
|
||||
addCommandHandler("cmd", function (command, params, client) {
|
||||
if (!isConsole(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -852,8 +945,8 @@ addCommandHandler("cmd", function(command, params, client) {
|
||||
|
||||
function listAllCommands() {
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
logToConsole(LOG_DEBUG, commands[i][j].command);
|
||||
}
|
||||
}
|
||||
@@ -864,8 +957,8 @@ function listAllCommands() {
|
||||
function getAllCommandsInSingleArray() {
|
||||
let tempCommands = [];
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
tempCommands.push(commands[i][j].command);
|
||||
}
|
||||
}
|
||||
@@ -878,8 +971,8 @@ function getAllCommandsInSingleArray() {
|
||||
function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
|
||||
let tempCommands = [];
|
||||
let commands = getCommands();
|
||||
for(let i in commands[groupName]) {
|
||||
if(getCommandRequiredPermissions(commands[groupName][i].command) == 0) {
|
||||
for (let i in commands[groupName]) {
|
||||
if (getCommandRequiredPermissions(commands[groupName][i].command) == 0) {
|
||||
tempCommands.push(commands[groupName][i].command);
|
||||
}
|
||||
}
|
||||
@@ -892,10 +985,10 @@ function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
|
||||
function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
|
||||
let tempCommands = [];
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
if(getCommandRequiredPermissions(commands[i][j].command) != 0) {
|
||||
if(hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) {
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
if (getCommandRequiredPermissions(commands[i][j].command) != 0) {
|
||||
if (hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) {
|
||||
tempCommands.push(commands[i][j].command);
|
||||
}
|
||||
}
|
||||
@@ -908,7 +1001,7 @@ function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesCommandExist(command) {
|
||||
if(getCommandData(command)) {
|
||||
if (getCommandData(command)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -919,11 +1012,11 @@ function doesCommandExist(command) {
|
||||
|
||||
function cacheAllCommandsAliases() {
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
for(let k in commands) {
|
||||
for(let m in commands[k]) {
|
||||
if(commands[i][j].handlerFunction == commands[k][m].handlerFunction) {
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
for (let k in commands) {
|
||||
for (let m in commands[k]) {
|
||||
if (commands[i][j].handlerFunction == commands[k][m].handlerFunction) {
|
||||
commands[i][j].aliases.push(commands[k][m]);
|
||||
commands[k][m].aliases.push(commands[i][j]);
|
||||
}
|
||||
@@ -937,7 +1030,7 @@ function cacheAllCommandsAliases() {
|
||||
|
||||
function getCommandAliasesNames(command) {
|
||||
let commandAliases = [];
|
||||
for(let i in command.aliases) {
|
||||
for (let i in command.aliases) {
|
||||
commandAliases.push(command.aliases[i].name);
|
||||
}
|
||||
|
||||
@@ -947,7 +1040,7 @@ function getCommandAliasesNames(command) {
|
||||
// ===========================================================================
|
||||
|
||||
function areParamsEmpty(params) {
|
||||
if(!params || params == "" || params.length == 0 || typeof params == "undefined") {
|
||||
if (!params || params == "" || params.length == 0 || typeof params == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -969,16 +1062,16 @@ function areThereEnoughParams(params, requiredAmount, delimiter = " ") {
|
||||
// ===========================================================================
|
||||
|
||||
function getParam(params, delimiter, index) {
|
||||
return params.split(delimiter)[index-1];
|
||||
return params.split(delimiter)[index - 1];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getCommandFromParams(params) {
|
||||
let commands = getCommands();
|
||||
for(let i in commands) {
|
||||
for(let j in commands[i]) {
|
||||
if(toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) {
|
||||
for (let i in commands) {
|
||||
for (let j in commands[i]) {
|
||||
if (toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) {
|
||||
return commands[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,154 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: config.js
|
||||
// DESC: Provides server configuration
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing data for server configuration
|
||||
*/
|
||||
class ServerConfigData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.needsSaved = false;
|
||||
|
||||
this.newCharacter = {
|
||||
spawnPosition: toVector3(0.0, 0.0, 0.0),
|
||||
spawnHeading: 0.0,
|
||||
spawnInterior: 0,
|
||||
spawnDimension: 0,
|
||||
money: 0,
|
||||
bank: 0,
|
||||
skin: 0,
|
||||
};
|
||||
|
||||
this.connectCameraPosition = toVector3(0.0, 0.0, 0.0);
|
||||
this.connectCameraLookAt = toVector3(0.0, 0.0, 0.0);
|
||||
|
||||
this.characterSelectCameraPosition = toVector3(0.0, 0.0, 0.0);
|
||||
this.characterSelectCameraLookAt = toVector3(0.0, 0.0, 0.0);
|
||||
this.characterSelectPedPosition = toVector3(0.0, 0.0, 0.0);
|
||||
this.characterSelectPedHeading = 0.0;
|
||||
this.characterSelectInterior = 0;
|
||||
this.characterSelectDimension = 0;
|
||||
|
||||
this.name = "";
|
||||
this.password = "";
|
||||
this.hour = 0;
|
||||
this.minute = 0
|
||||
this.minuteDuration = 1000;
|
||||
this.weather = 0
|
||||
this.fallingSnow = false;
|
||||
this.groundSnow = false;
|
||||
this.useGUI = true;
|
||||
this.guiColourPrimary = [200, 200, 200];
|
||||
this.guiColourSecondary = [200, 200, 200];
|
||||
this.guiTextColourPrimary = [0, 0, 0];
|
||||
this.guiTextColourSecondary = [0, 0, 0];
|
||||
this.showLogo = true;
|
||||
this.inflationMultiplier = 1;
|
||||
this.testerOnly = false;
|
||||
this.devServer = false;
|
||||
this.nameTagDistance = 50.0;
|
||||
|
||||
this.antiCheat = {
|
||||
enabled: false,
|
||||
//checkGameScripts: false,
|
||||
//gameScriptWhiteListEnabled: false,
|
||||
//gameScriptBlackListEnabled: false,
|
||||
//gameScriptWhiteList: [],
|
||||
//gameScriptBlackList: [],
|
||||
};
|
||||
|
||||
this.discordBotToken = "";
|
||||
this.discordEnabled = false;
|
||||
|
||||
this.createJobPickups = false;
|
||||
this.createBusinessPickups = false;
|
||||
this.createHousePickups = false;
|
||||
this.createJobBlips = false;
|
||||
this.createBusinessBlips = false;
|
||||
this.createHouseBlips = false;
|
||||
|
||||
this.introMusicURL = "";
|
||||
|
||||
this.pauseSavingToDatabase = false;
|
||||
|
||||
this.useRealTime = false;
|
||||
this.realTimeZone = 0;
|
||||
|
||||
this.discordConfig = {
|
||||
sendEvents: true,
|
||||
sendChat: true,
|
||||
sendAdmin: true,
|
||||
};
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = dbAssoc["svr_id"];
|
||||
this.newCharacter = {
|
||||
spawnPosition: toVector3(dbAssoc["svr_newchar_pos_x"], dbAssoc["svr_newchar_pos_y"], dbAssoc["svr_newchar_pos_z"]),
|
||||
spawnHeading: dbAssoc["svr_newchar_rot_z"],
|
||||
money: dbAssoc["svr_newchar_money"],
|
||||
bank: dbAssoc["svr_newchar_bank"],
|
||||
skin: dbAssoc["svr_newchar_skin"],
|
||||
};
|
||||
|
||||
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"]);
|
||||
|
||||
this.name = toInteger(dbAssoc["svr_name"]);
|
||||
this.password = toInteger(dbAssoc["svr_password"]);
|
||||
this.hour = toInteger(dbAssoc["svr_start_time_hour"]);
|
||||
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_snow_falling"]));
|
||||
this.groundSnow = intToBool(toInteger(dbAssoc["svr_snow_ground"]));
|
||||
this.useGUI = intToBool(toInteger(dbAssoc["svr_gui"]));
|
||||
this.showLogo = intToBool(toInteger(dbAssoc["svr_logo"]));
|
||||
this.createJobPickups = intToBool(toInteger(dbAssoc["svr_job_pickups"]));
|
||||
this.createBusinessPickups = intToBool(toInteger(dbAssoc["svr_biz_pickups"]));
|
||||
this.createHousePickups = intToBool(toInteger(dbAssoc["svr_house_pickups"]));
|
||||
this.createJobBlips = intToBool(toInteger(dbAssoc["svr_job_blips"]));
|
||||
this.createBusinessBlips = intToBool(toInteger(dbAssoc["svr_biz_blips"]));
|
||||
this.createHouseBlips = intToBool(toInteger(dbAssoc["svr_house_blips"]));
|
||||
this.createPlayerBlips = intToBool(toInteger(dbAssoc["svr_player_blips"]));
|
||||
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"])];
|
||||
//this.guiTextColourSecondary = [toInteger(dbAssoc["svr_gui_textcol2_r"]), toInteger(dbAssoc["svr_gui_textcol2_g"]), toInteger(dbAssoc["svr_gui_textcol2_b"])];
|
||||
this.inflationMultiplier = toFloat(dbAssoc["svr_inflation_multiplier"]);
|
||||
this.nameTagDistance = toFloat(dbAssoc["svr_nametag_distance"]);
|
||||
this.discordBotToken = intToBool(dbAssoc["svr_discord_bot_token"]);
|
||||
this.introMusicURL = dbAssoc["svr_intro_music"];
|
||||
|
||||
this.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
|
||||
this.realTimeZone = dbAssoc["svr_real_time_timezone"];
|
||||
|
||||
this.discord = {
|
||||
sendEvents: intToBool(dbAssoc["svr_discord_send_events"]),
|
||||
sendChat: intToBool(dbAssoc["svr_discord_send_chat"]),
|
||||
sendAdmin: intToBool(dbAssoc["svr_discord_send_admin"]),
|
||||
};
|
||||
|
||||
this.economy = {
|
||||
inflationMultiplier: toFloat(dbAssoc["svr_inflation_multiplier"]),
|
||||
incomeTaxRate: toFloat(dbAssoc["svr_income_tax_rate"]),
|
||||
passiveIncome: toFloat(dbAssoc["svr_passive_income"]),
|
||||
}
|
||||
|
||||
this.devServer = intToBool(toInteger(server.getCVar("agrp_devserver")));
|
||||
this.testerOnly = intToBool(toInteger(server.getCVar("agrp_testeronly")));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let serverConfig = false;
|
||||
let gameConfig = false;
|
||||
|
||||
@@ -52,22 +194,22 @@ let globalConfig = {
|
||||
subAccountNameAllowedCharacters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
||||
emailValidationRegex: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
|
||||
itemActionDelayExtraTimeout: 1000,
|
||||
geoIPCountryDatabaseFilePath: "geoip-country.mmdb",
|
||||
geoIPCityDatabaseFilePath: "geoip-city.mmdb",
|
||||
geoIPCountryDatabaseFilePath: "modules/geoip/geoip-country.mmdb",
|
||||
geoIPCityDatabaseFilePath: "modules/geoip/geoip-city.mmdb",
|
||||
randomTipInterval: 600000,
|
||||
weaponEquippableTypes: [
|
||||
VRR_ITEM_USETYPE_WEAPON,
|
||||
VRR_ITEM_USETYPE_TAZER,
|
||||
VRR_ITEM_USETYPE_EXTINGUISHER,
|
||||
VRR_ITEM_USETYPE_SPRAYPAINT,
|
||||
VRR_ITEM_USETYPE_PEPPERSPRAY,
|
||||
AGRP_ITEM_USE_TYPE_WEAPON,
|
||||
AGRP_ITEM_USE_TYPE_TAZER,
|
||||
AGRP_ITEM_USE_TYPE_EXTINGUISHER,
|
||||
AGRP_ITEM_USE_TYPE_SPRAYPAINT,
|
||||
AGRP_ITEM_USE_TYPE_PEPPERSPRAY,
|
||||
],
|
||||
onFootOnlyItems: [
|
||||
VRR_ITEM_USETYPE_VEHREPAIR,
|
||||
VRR_ITEM_USETYPE_VEHCOLOUR,
|
||||
VRR_ITEM_USETYPE_VEHUPGRADE_PART,
|
||||
VRR_ITEM_USETYPE_VEHLIVERY,
|
||||
VRR_ITEM_USETYPE_VEHTIRE,
|
||||
AGRP_ITEM_USE_TYPE_VEHREPAIR,
|
||||
AGRP_ITEM_USE_TYPE_VEHCOLOUR,
|
||||
AGRP_ITEM_USE_TYPE_VEHUPGRADE_PART,
|
||||
AGRP_ITEM_USE_TYPE_VEHLIVERY,
|
||||
AGRP_ITEM_USE_TYPE_VEHTIRE,
|
||||
],
|
||||
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
|
||||
chatSectionHeaderLength: 96,
|
||||
@@ -85,87 +227,119 @@ let globalConfig = {
|
||||
houseBlipStreamOutDistance: 120,
|
||||
jobBlipStreamInDistance: -1,
|
||||
jobBlipStreamOutDistance: -1,
|
||||
playerStreamInDistance: -1,
|
||||
playerStreamOutDistance: -1,
|
||||
playerBlipStreamInDistance: -1,
|
||||
playerBlipStreamOutDistance: -1,
|
||||
handcuffPlayerDistance: 3,
|
||||
firstAidKitPlayerDistance: 3,
|
||||
droppedItemPickupRange: 2,
|
||||
passwordRequiredCapitals: 0,
|
||||
passwordRequiredNumbers: 0,
|
||||
passwordRequiredSymbols: 0,
|
||||
minChatLines: 1,
|
||||
maxChatLines: 6,
|
||||
vehicleTrunkDistance: 2.0,
|
||||
fishingSpotDistance: 10.0,
|
||||
atmDistance: 1.5,
|
||||
loginTimeout: 60000,
|
||||
fishingCastMaxStrength: 100,
|
||||
fishingCastMinStrength: 30,
|
||||
jobRouteLocationSphereRadius: 3,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initConfigScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Config]: Initializing config script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Config]: Config script initialized!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Config]: Initializing config script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Config]: Config script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadGlobalConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading global configuration ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading global configuration ...");
|
||||
try {
|
||||
getGlobalConfig().database = loadDatabaseConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load global configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load global configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().economy = loadEconomyConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load economy configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load economy configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().locale = loadLocaleConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load locale configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load locale configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().accents = loadAccentConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load accent configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load accent configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().discord = loadDiscordConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load discord configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load discord configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().keyBind = loadKeyBindConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load keybind configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load keybind configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
try {
|
||||
getGlobalConfig().email = loadEmailConfig();
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Failed to load email configuration. Error: ${error}`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Failed to load email configuration. Error: ${error}`);
|
||||
thisResource.stop();
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loaded global configuration successfully!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loaded global configuration successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerConfigFromGameAndPort(gameId, port) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerConfigFromGame(gameId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -181,11 +355,11 @@ function loadServerConfigFromGameAndPort(gameId, port) {
|
||||
|
||||
function loadServerConfigFromId(tempServerId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_id = ${tempServerId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -200,16 +374,18 @@ function loadServerConfigFromId(tempServerId) {
|
||||
// ===========================================================================
|
||||
|
||||
function applyConfigToServer(tempServerConfig) {
|
||||
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config]: Server config applied successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Config]: Applying server config ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config]: Server config applied successfully!");
|
||||
|
||||
if(isTimeSupported()) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Config]: Setting time to to ${tempServerConfig.hour}:${tempServerConfig.minute} with minute duration of ${tempServerConfig.minuteDuration}`);
|
||||
setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration);
|
||||
}
|
||||
updateServerGameTime();
|
||||
|
||||
if(isWeatherSupported()) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Config]: Setting weather to ${tempServerConfig.weather}`);
|
||||
//if (isTimeSupported()) {
|
||||
// logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting time to to ${tempServerConfig.hour}:${tempServerConfig.minute} with minute duration of ${tempServerConfig.minuteDuration}`);
|
||||
// setGameTime(tempServerConfig.hour, tempServerConfig.minute, tempServerConfig.minuteDuration);
|
||||
//}
|
||||
|
||||
if (isWeatherSupported()) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
|
||||
game.forceWeather(tempServerConfig.weather);
|
||||
}
|
||||
|
||||
@@ -219,10 +395,10 @@ function applyConfigToServer(tempServerConfig) {
|
||||
// ===========================================================================
|
||||
|
||||
function saveServerConfigToDatabase() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Config]: Saving server ${getServerConfig().databaseId} configuration to database ...`);
|
||||
if(getServerConfig().needsSaved) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Config]: Saving server ${getServerConfig().databaseId} configuration to database ...`);
|
||||
if (getServerConfig().needsSaved) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let data = [
|
||||
//["svr_settings", toInteger(getServerConfig().settings)],
|
||||
["svr_start_time_hour", getServerConfig().hour],
|
||||
@@ -261,7 +437,7 @@ function saveServerConfigToDatabase() {
|
||||
["svr_inflation_multiplier", getServerConfig().inflationMultiplier],
|
||||
["svr_intro_music", getServerConfig().introMusicURL],
|
||||
["svr_gui", getServerConfig().useGUI],
|
||||
["svr_logo", getServerConfig().useLogo],
|
||||
["svr_logo", getServerConfig().showLogo],
|
||||
["svr_snow_falling", getServerConfig().fallingSnow],
|
||||
["svr_snow_ground", getServerConfig().groundSnow],
|
||||
["svr_biz_blips", getServerConfig().createBusinessBlips],
|
||||
@@ -283,7 +459,7 @@ function saveServerConfigToDatabase() {
|
||||
|
||||
}
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Config]: Server ${getServerConfig().databaseId} configuration saved to database!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Config]: Server ${getServerConfig().databaseId} configuration saved to database!`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -329,7 +505,7 @@ function getServerId() {
|
||||
*
|
||||
*/
|
||||
function setTimeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -337,12 +513,12 @@ function setTimeCommand(command, params, client) {
|
||||
let hour = toInteger(getParam(params, " ", 1));
|
||||
let minute = toInteger(getParam(params, " ", 2)) || 0;
|
||||
|
||||
if(hour > 23 || hour < 0) {
|
||||
if (hour > 23 || hour < 0) {
|
||||
messagePlayerError(client, "The hour must be between 0 and 23!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(minute > 59 || minute < 0) {
|
||||
if (minute > 59 || minute < 0) {
|
||||
messagePlayerError(client, "The minute must be between 0 and 59!");
|
||||
return false;
|
||||
}
|
||||
@@ -374,7 +550,7 @@ function setTimeCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setMinuteDurationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -401,14 +577,14 @@ function setMinuteDurationCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setWeatherCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let weatherId = getWeatherFromParams(getParam(params, " ", 1));
|
||||
|
||||
if(!weatherId) {
|
||||
if (!weatherId) {
|
||||
messagePlayerError(client, `That weather ID or name is invalid!`);
|
||||
return false;
|
||||
}
|
||||
@@ -435,7 +611,7 @@ function setWeatherCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setSnowingCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -468,7 +644,7 @@ function setSnowingCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setServerGUIColoursCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -481,7 +657,7 @@ function setServerGUIColoursCommand(command, params, client) {
|
||||
getServerConfig().guiColour = [colourRed, colourGreen, colourBlue];
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
for (let i in clients) {
|
||||
sendPlayerGUIColours(clients[i]);
|
||||
}
|
||||
|
||||
@@ -525,7 +701,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerJobBlipsCommand(command, params, client) {
|
||||
function toggleServerJobBlipsCommand(command, params, client) {
|
||||
getServerConfig().createJobBlips = !getServerConfig().createJobBlips;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -545,7 +721,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerJobPickupsCommand(command, params, client) {
|
||||
function toggleServerJobPickupsCommand(command, params, client) {
|
||||
getServerConfig().createJobPickups = !getServerConfig().createJobPickups;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -565,7 +741,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerBusinessBlipsCommand(command, params, client) {
|
||||
function toggleServerBusinessBlipsCommand(command, params, client) {
|
||||
getServerConfig().createBusinessBlips = !getServerConfig().createBusinessBlips;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -585,7 +761,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerBusinessPickupsCommand(command, params, client) {
|
||||
function toggleServerBusinessPickupsCommand(command, params, client) {
|
||||
getServerConfig().createBusinessPickups = !getServerConfig().createBusinessPickups;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -605,7 +781,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerHouseBlipsCommand(command, params, client) {
|
||||
function toggleServerHouseBlipsCommand(command, params, client) {
|
||||
getServerConfig().createHouseBlips = !getServerConfig().createHouseBlips;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -625,7 +801,7 @@ function toggleServerLogoCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function toggleServerHousePickupsCommand(command, params, client) {
|
||||
function toggleServerHousePickupsCommand(command, params, client) {
|
||||
getServerConfig().createHousePickups = !getServerConfig().createHousePickups;
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
@@ -650,7 +826,7 @@ function toggleServerGUICommand(command, params, client) {
|
||||
|
||||
getServerConfig().needsSaved = true;
|
||||
|
||||
announceAdminAction(`ServerGUISet`, `${getPlayerName(client)}{MAINCOLOUR}`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useGUI)}${toUpperCase(getOnOffFromBool(getServerConfig().useGUI))}{MAINCOLOUR}`);
|
||||
announceAdminAction(`ServerGUISet`, `${getPlayerName(client)}{MAINCOLOUR}`, `${getBoolRedGreenInlineColour(getServerConfig().useGUI)}${toUpperCase(getOnOffFromBool(getServerConfig().useGUI))}{MAINCOLOUR}`);
|
||||
updateServerRules();
|
||||
return true;
|
||||
}
|
||||
@@ -690,7 +866,7 @@ function toggleServerUseRealWorldTimeCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setServerRealWorldTimeZoneCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -756,8 +932,8 @@ function reloadEmailConfigurationCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function reloadDatabaseConfigurationCommand(command, params, client) {
|
||||
if(getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) {
|
||||
logToConsole(LOG_WARN, `[VRR.Database] Closing persistent database connection`);
|
||||
if (getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) {
|
||||
logToConsole(LOG_WARN, `[AGRP.Database] Closing persistent database connection`);
|
||||
persistentDatabaseConnection.close();
|
||||
persistentDatabaseConnection = null;
|
||||
}
|
||||
@@ -765,7 +941,7 @@ function reloadDatabaseConfigurationCommand(command, params, client) {
|
||||
getGlobalConfig().database = loadDatabaseConfig();
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reloaded the database config`);
|
||||
databaseEnabled = true;
|
||||
if(getDatabaseConfig().usePersistentConnection) {
|
||||
if (getDatabaseConfig().usePersistentConnection) {
|
||||
connectToDatabase();
|
||||
}
|
||||
return true;
|
||||
@@ -782,8 +958,8 @@ function reloadDatabaseConfigurationCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function setServerNameTagDistanceCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
function setServerNameTagDistanceCommand(command, params, client) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -805,9 +981,9 @@ function getServerIntroMusicURL() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadLocaleConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading locale configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading locale configuration");
|
||||
let localeConfig = JSON.parse(loadTextFile(`config/locale.json`));
|
||||
if(localeConfig != null) {
|
||||
if (localeConfig != null) {
|
||||
return localeConfig;
|
||||
}
|
||||
}
|
||||
@@ -815,9 +991,9 @@ function loadLocaleConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadEconomyConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading economy configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading economy configuration");
|
||||
let economyConfig = JSON.parse(loadTextFile(`config/economy.json`));
|
||||
if(economyConfig != null) {
|
||||
if (economyConfig != null) {
|
||||
return economyConfig;
|
||||
}
|
||||
}
|
||||
@@ -825,9 +1001,9 @@ function loadEconomyConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadAccentConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading accents configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading accents configuration");
|
||||
let accentConfig = JSON.parse(loadTextFile(`config/accents.json`));
|
||||
if(accentConfig != null) {
|
||||
if (accentConfig != null) {
|
||||
return accentConfig;
|
||||
}
|
||||
}
|
||||
@@ -835,9 +1011,9 @@ function loadAccentConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadDiscordConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading discord configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading discord configuration");
|
||||
let discordConfig = JSON.parse(loadTextFile(`config/discord.json`));
|
||||
if(discordConfig != null) {
|
||||
if (discordConfig != null) {
|
||||
return discordConfig;
|
||||
}
|
||||
return false;
|
||||
@@ -846,9 +1022,9 @@ function loadDiscordConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadDatabaseConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading database configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading database configuration");
|
||||
let databaseConfig = JSON.parse(loadTextFile("config/database.json"));
|
||||
if(databaseConfig != null) {
|
||||
if (databaseConfig != null) {
|
||||
return databaseConfig;
|
||||
}
|
||||
return false;
|
||||
@@ -857,9 +1033,9 @@ function loadDatabaseConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadKeyBindConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading keybind configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading keybind configuration");
|
||||
let keyBindConfig = JSON.parse(loadTextFile("config/keybind.json"));
|
||||
if(keyBindConfig != null) {
|
||||
if (keyBindConfig != null) {
|
||||
return keyBindConfig;
|
||||
}
|
||||
return false;
|
||||
@@ -868,9 +1044,9 @@ function loadKeyBindConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadEmailConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading email configuration");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading email configuration");
|
||||
let emailConfig = JSON.parse(loadTextFile("config/email.json"));
|
||||
if(emailConfig != null) {
|
||||
if (emailConfig != null) {
|
||||
return emailConfig;
|
||||
}
|
||||
return false;
|
||||
@@ -951,13 +1127,25 @@ function getDatabaseConfig() {
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerConfig() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration");
|
||||
try {
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading server configuration");
|
||||
|
||||
if (toInteger(server.getCVar("agrp_devserver")) == 1) {
|
||||
serverConfig = loadServerConfigFromGame(getGame());
|
||||
|
||||
if (serverConfig == false) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Could not load server configuration for game ${getGame()}`);
|
||||
server.shutdown();
|
||||
}
|
||||
} else {
|
||||
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`);
|
||||
thisResource.stop();
|
||||
|
||||
if (serverConfig == false) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort()}`);
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
//logToConsole(LOG_DEBUG | LOG_WARN, `Server ID: ${serverConfig.databaseId}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,371 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: const.js
|
||||
// DESC: Provides constants
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Prompts (used for client GUI prompt responses)
|
||||
const VRR_PROMPT_NONE = 0;
|
||||
const VRR_PROMPT_CREATEFIRSTCHAR = 1;
|
||||
const VRR_PROMPT_BIZORDER = 2;
|
||||
const VRR_PROMPT_VEHGIVETOCLAN = 3;
|
||||
const VRR_PROMPT_HOUSEGIVETOCLAN = 4;
|
||||
const VRR_PROMPT_BIZGIVETOCLAN = 5;
|
||||
const VRR_PROMPT_HOUSEBUY = 6;
|
||||
const VRR_PROMPT_BIZBUY = 7;
|
||||
|
||||
// Job Types
|
||||
const VRR_JOB_NONE = 0;
|
||||
const VRR_JOB_POLICE = 1;
|
||||
const VRR_JOB_MEDICAL = 2;
|
||||
const VRR_JOB_FIRE = 3;
|
||||
const VRR_JOB_BUS = 4;
|
||||
const VRR_JOB_TAXI = 5;
|
||||
const VRR_JOB_GARBAGE = 6;
|
||||
const VRR_JOB_WEAPON = 7;
|
||||
const VRR_JOB_DRUG = 8;
|
||||
const VRR_JOB_PIZZA = 9;
|
||||
const VRR_JOB_GENERIC = 10;
|
||||
|
||||
// Pickup Types
|
||||
const VRR_PICKUP_NONE = 0;
|
||||
const VRR_PICKUP_JOB = 1;
|
||||
const VRR_PICKUP_BUSINESS_ENTRANCE = 2;
|
||||
const VRR_PICKUP_BUSINESS_EXIT = 3;
|
||||
const VRR_PICKUP_HOUSE_ENTRANCE = 4;
|
||||
const VRR_PICKUP_HOUSE_EXIT = 5;
|
||||
const VRR_PICKUP_EXIT = 6;
|
||||
|
||||
// Vehicle Owner Types
|
||||
const VRR_VEHOWNER_NONE = 0; // Not owned
|
||||
const VRR_VEHOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const VRR_VEHOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_VEHOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_VEHOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const VRR_VEHOWNER_PUBLIC = 5; // Public vehicle. Anybody can drive it.
|
||||
const VRR_VEHOWNER_BIZ = 6; // Owned by a business (also includes dealerships since they're businesses)
|
||||
|
||||
// Business Owner Types
|
||||
const VRR_BIZOWNER_NONE = 0; // Not owned
|
||||
const VRR_BIZOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const VRR_BIZOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_BIZOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_BIZOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const VRR_BIZOWNER_PUBLIC = 5; // Public Business. Used for goverment/official places like police, fire, city hall, DMV, etc
|
||||
|
||||
// House Owner Types
|
||||
const VRR_HOUSEOWNER_NONE = 0; // Not owned
|
||||
const VRR_HOUSEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const VRR_HOUSEOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_HOUSEOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_HOUSEOWNER_FACTION = 4; // Owned by a faction
|
||||
const VRR_HOUSEOWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
|
||||
const VRR_HOUSEOWNER_BIZ = 6; // Owned by a business. Used for apartment buildings where rent goes to business.
|
||||
|
||||
// Gate Owner Types
|
||||
const VRR_GATEOWNER_NONE = 0; // Not owned
|
||||
const VRR_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const VRR_GATEOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_GATEOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_GATEOWNER_FACTION = 4; // Owned by a faction
|
||||
const VRR_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
|
||||
const VRR_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
|
||||
const VRR_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
|
||||
|
||||
// Business Location Types
|
||||
const VRR_BIZLOC_NONE = 0; // None
|
||||
const VRR_BIZLOC_GATE = 1; // Center of any moveable gate that belongs to the biz
|
||||
const VRR_BIZLOC_GARAGE = 2; // Location for attached garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
|
||||
const VRR_BIZLOC_FUEL = 3; // Fuel pump
|
||||
const VRR_BIZLOC_DRIVETHRU = 4; // Drivethrough
|
||||
const VRR_BIZLOC_VENDMACHINE = 5; // Vending machine
|
||||
|
||||
// House Location Types
|
||||
const VRR_HOUSELOC_NONE = 0; // None
|
||||
const VRR_HOUSELOC_GATE = 1; // Center of any moveable gate that belongs to the house
|
||||
const VRR_HOUSELOC_GARAGE = 2; // Location for garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
|
||||
|
||||
// Account Contact Types
|
||||
const VRR_CONTACT_NONE = 0;
|
||||
const VRR_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const VRR_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const VRR_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
|
||||
// Job Work Types (Currently Unused)
|
||||
const VRR_JOBWORKTYPE_NONE = 0;
|
||||
const VRR_JOBWORKTYPE_ROUTE = 1; // Jobs that use routes. Bus, trash collector, mail, etc
|
||||
const VRR_JOBWORKTYPE_SELL = 2; // Jobs that sell items to other players and NPCs. Drugs, guns, etc
|
||||
const VRR_JOBWORKTYPE_SERVICE = 3; // Services to other players and NPCs. Taxi ride, mechanic fix, etc
|
||||
|
||||
// Vehicle Seats
|
||||
const VRR_VEHSEAT_DRIVER = 0;
|
||||
const VRR_VEHSEAT_FRONTPASSENGER = 1;
|
||||
const VRR_VEHSEAT_REARLEFTPASSENGER = 2;
|
||||
const VRR_VEHSEAT_REARRIGHTPASSENGER = 3;
|
||||
|
||||
// Ban Types
|
||||
const VRR_BANTYPE_NONE = 0;
|
||||
const VRR_BANTYPE_ACCOUNT = 1;
|
||||
const VRR_BANTYPE_SUBACCOUNT = 2;
|
||||
const VRR_BANTYPE_IPADDRESS = 3;
|
||||
const VRR_BANTYPE_SUBNET = 4;
|
||||
|
||||
// Blip Owner Types
|
||||
const VRR_BLIP_NONE = 0;
|
||||
const VRR_BLIP_JOB = 1;
|
||||
const VRR_BLIP_BUSINESS_ENTRANCE = 2;
|
||||
const VRR_BLIP_BUSINESS_EXIT = 3;
|
||||
const VRR_BLIP_HOUSE_ENTRANCE = 4;
|
||||
const VRR_BLIP_HOUSE_EXIT = 5;
|
||||
const VRR_BLIP_EXIT = 6;
|
||||
|
||||
// Insurance Account Owner Types
|
||||
const VRR_INS_ACCT_OWNER_NONE = 0; // None
|
||||
const VRR_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
|
||||
const VRR_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
|
||||
const VRR_INS_ACCT_OWNER_CLAN = 3; // Clan owns insurance company
|
||||
|
||||
// Insurance Account Entity Types
|
||||
const VRR_INS_ACCT_ENTITY_NONE = 0; // None
|
||||
const VRR_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
|
||||
const VRR_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
|
||||
const VRR_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
|
||||
const VRR_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
|
||||
const VRR_INS_ACCT_ENTITY_HOUSE = 5; // House Insurance
|
||||
|
||||
// Insurance Account History Types
|
||||
const VRR_INS_ACCT_HISTORY_NONE = 0; // None
|
||||
const VRR_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
|
||||
const VRR_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
|
||||
const VRR_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
|
||||
const VRR_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
|
||||
const VRR_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
|
||||
const VRR_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
|
||||
const VRR_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
|
||||
const VRR_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
|
||||
const VRR_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
|
||||
|
||||
// Islands
|
||||
const VRR_ISLAND_NONE = 0; // None
|
||||
const VRR_ISLAND_PORTLAND = 0; // Portland Island
|
||||
const VRR_ISLAND_STAUNTON = 1; // Staunton Island
|
||||
const VRR_ISLAND_SHORESIDEVALE = 2; // Shoreside Vale
|
||||
const VRR_ISLAND_VICEWEST = 0; // Western Island of VC
|
||||
const VRR_ISLAND_VICEEAST = 1; // Eastern Island of VC
|
||||
const VRR_ISLAND_LOSSANTOS = 0; // Los Santos
|
||||
const VRR_ISLAND_LASVENTURAS = 1; // Las Venturas
|
||||
const VRR_ISLAND_SANFIERRO = 2; // San Fierro
|
||||
const VRR_ISLAND_REDCOUNTYNORTH = 4; // Red County North (spans all the way from Palamino/shore on the east east to border of Flint County on the west)
|
||||
const VRR_ISLAND_BONECOUNTYNORTH = 5; // Bone County North (usually called Tierra Robada)
|
||||
const VRR_ISLAND_BONECOUNTYSOUTH = 6; // Bone County South
|
||||
|
||||
// Item Owners
|
||||
const VRR_ITEM_OWNER_NONE = 0; // None
|
||||
const VRR_ITEM_OWNER_PLAYER = 1; // Item is in a player's inventory
|
||||
const VRR_ITEM_OWNER_VEHTRUNK = 2; // Item is in a vehicle's trunk
|
||||
const VRR_ITEM_OWNER_VEHDASH = 3; // Item is in a vehicle's glove compartment
|
||||
const VRR_ITEM_OWNER_BIZFLOOR = 4; // Item is in the public area of a business (on the floor = ready to buy)
|
||||
const VRR_ITEM_OWNER_BIZSTORAGE = 5; // Item is in a business's storage area (stock room)
|
||||
const VRR_ITEM_OWNER_HOUSE = 6; // Item is in a house
|
||||
const VRR_ITEM_OWNER_SAFE = 7; // Item is in a safe (safes can be anywhere)
|
||||
const VRR_ITEM_OWNER_ITEM = 8; // Item is in another item (trashbag, briefcase, wallet, suitcase, crate/box, barrel, etc)
|
||||
const VRR_ITEM_OWNER_GROUND = 9; // Item is on the ground
|
||||
const VRR_ITEM_OWNER_JOBLOCKER = 10; // Item is in player's job locker
|
||||
const VRR_ITEM_OWNER_LOCKER = 10; // Item is in player's locker
|
||||
|
||||
// Item Use Types
|
||||
const VRR_ITEM_USETYPE_NONE = 0; // Has no effect
|
||||
const VRR_ITEM_USETYPE_WEAPON = 1; // Equips weapon
|
||||
const VRR_ITEM_USETYPE_AMMO_CLIP = 2; // Magazine for weapon. If in inventory, R will load it into gun
|
||||
const VRR_ITEM_USETYPE_PHONE = 3; // Pulls out phone
|
||||
const VRR_ITEM_USETYPE_GPS = 4; // Not sure how I want this to work yet
|
||||
const VRR_ITEM_USETYPE_MAP = 5; // Shows minimap on HUD
|
||||
const VRR_ITEM_USETYPE_SKIN = 6; // Changes skin (uses skin changer)
|
||||
const VRR_ITEM_USETYPE_PEDPART = 7; // Changes ped part (clothing, skin, hair, etc) (UNUSED)
|
||||
const VRR_ITEM_USETYPE_PEDPROP = 8; // Changes ped prop (watches, glasses, hats, etc) (UNUSED)
|
||||
const VRR_ITEM_USETYPE_STORAGE = 9; // Shows stored items. Backpack, crate, briefcase, wallet, etc
|
||||
const VRR_ITEM_USETYPE_VEHKEY = 10; // Locks/unlocks a vehicle and allows starting engine without hotwire
|
||||
const VRR_ITEM_USETYPE_BIZKEY = 11; // Locks/unlocks a business
|
||||
const VRR_ITEM_USETYPE_HOUSEKEY = 12; // Locks/unlocks a house
|
||||
const VRR_ITEM_USETYPE_SEED = 13; // Plants a seed
|
||||
const VRR_ITEM_USETYPE_WEED = 14; // Light drug effect (short term relief of addiction symptoms?)
|
||||
const VRR_ITEM_USETYPE_COKE = 15; // Medium drug effect (medium term relief of addiction symptoms?)
|
||||
const VRR_ITEM_USETYPE_METH = 16; // Heavy drug effect (extended term relief of addiction symptoms?)
|
||||
const VRR_ITEM_USETYPE_CIGAR = 17; // Just for appearance. Makes people look cool I guess
|
||||
const VRR_ITEM_USETYPE_WATER = 18; // Replenishes small amount of health
|
||||
const VRR_ITEM_USETYPE_FOOD = 19; // Eat food. Replenishes a small amount of health
|
||||
const VRR_ITEM_USETYPE_BEER = 20; // Subtle drunk effect. Replenishes small amount of health.
|
||||
const VRR_ITEM_USETYPE_WINE = 21; // Moderate drunk effect. Replenishes moderate amount of health.
|
||||
const VRR_ITEM_USETYPE_LIQUOR = 22; // Heavy drunk effect. Replenishes large amount of health.
|
||||
const VRR_ITEM_USETYPE_COFFEE = 23; // Replenishes moderate amount of health.
|
||||
const VRR_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine. Not used at the moment
|
||||
const VRR_ITEM_USETYPE_HANDCUFF = 24; //
|
||||
const VRR_ITEM_USETYPE_ROPE = 25; //
|
||||
const VRR_ITEM_USETYPE_BLINDFOLD = 26; //
|
||||
const VRR_ITEM_USETYPE_TAZER = 27; //
|
||||
const VRR_ITEM_USETYPE_ARMOUR = 28; //
|
||||
const VRR_ITEM_USETYPE_HEALTH = 29; //
|
||||
const VRR_ITEM_USETYPE_AED = 30; //
|
||||
const VRR_ITEM_USETYPE_WALKIETALKIE = 31; //
|
||||
const VRR_ITEM_USETYPE_AREARADIO = 32; //
|
||||
const VRR_ITEM_USETYPE_PERSONALRADIO = 33; //
|
||||
const VRR_ITEM_USETYPE_BADGE = 34; //
|
||||
const VRR_ITEM_USETYPE_DRINK = 35; // Drinkable item. Action output shows "Player_Name drinks some (drink name)"
|
||||
const VRR_ITEM_USETYPE_EXTINGUISHER = 36; // Extinguisher item. Allows putting out fires
|
||||
const VRR_ITEM_USETYPE_SPRAYPAINT = 37; // Spraypaint item. Allows spraying custom clan tags on walls
|
||||
const VRR_ITEM_USETYPE_PEPPERSPRAY = 38; // Pepper spray item. Incapacitates nearby player
|
||||
const VRR_ITEM_USETYPE_FLASHLIGHT = 39; // Flashlight item. Unusable for now, but plan to cast a custom light beam
|
||||
const VRR_ITEM_USETYPE_AIRPLANETICKET = 40; // Airplane ticket. Allows a character to move to another server
|
||||
const VRR_ITEM_USETYPE_TRAINTICKET = 41; // Train ticket. Allows a character to move to another server
|
||||
const VRR_ITEM_USETYPE_VEHUPGRADE_PART = 42; // Vehicle update part item. Allows adding custom parts like spoilers, side skirts, roof scoops, etc
|
||||
const VRR_ITEM_USETYPE_VEHTIRE = 43; // Vehicle tire item. Allows changing the tire/rim types
|
||||
const VRR_ITEM_USETYPE_FUELCAN = 44; // Fuel can item. Allows refueling of a nearby vehicle anywhere
|
||||
const VRR_ITEM_USETYPE_VEHCOLOUR = 45; // Vehicle colour item. Changes primary and secondary vehicle colours
|
||||
const VRR_ITEM_USETYPE_VEHLIVERY = 46; // Vehicle livery/paintjob item. Applies decals and special paint jobs
|
||||
const VRR_ITEM_USETYPE_VEHREPAIR = 47; // Vehicle repair item. Much longer use time
|
||||
const VRR_ITEM_USETYPE_SMOKEDRUG = 48; // Smokable drug. Action output shows "Player_Name smokes some (drug)"
|
||||
const VRR_ITEM_USETYPE_SNORTDRUG = 49; // Snortable drug. Action output shows "Player_Name snorts some (drug)"
|
||||
const VRR_ITEM_USETYPE_PLANT = 50; // Plantable item. Pot plants, coke plants, etc
|
||||
const VRR_ITEM_USETYPE_MEGAPHONE = 51; // Megaphone item. Allows shouting over greater distances. Also called a bullhorn
|
||||
const VRR_ITEM_USETYPE_INJECTDRUG = 52; // Injectable drug. Action output shows "Player_Name injects some (drug)"
|
||||
const VRR_ITEM_USETYPE_ALCOHOL = 53; // Alcohol. Applies an intoxication/drunkness effect
|
||||
const VRR_ITEM_USETYPE_LOTTOTICKET = 54; // Lotto ticket. Allows a character to enter the lottery
|
||||
|
||||
// Item Drop Types
|
||||
const VRR_ITEM_DROPTYPE_NONE = 0; // Can't be dropped
|
||||
const VRR_ITEM_DROPTYPE_OBJECT = 1; // Drops as an object on the ground
|
||||
const VRR_ITEM_DROPTYPE_PICKUP = 2; // Drops as a pickup
|
||||
const VRR_ITEM_DROPTYPE_OBJECTLIGHT = 3; // Object that produces an area light effect (lamp, flashlight, etc)
|
||||
const VRR_ITEM_DROPTYPE_DESTROY = 4; // Will destroy the item on drop (keys mostly but for any tiny object)
|
||||
const VRR_ITEM_DROPTYPE_OBJECTSTACK = 5; // Stackable objects (crates and such). Will sit on top of closest other stackable
|
||||
|
||||
// Forensic Types
|
||||
const VRR_FORENSICS_NONE = 0;
|
||||
const VRR_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
|
||||
const VRR_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit when somebody is shot
|
||||
const VRR_FORENSICS_BODY = 3; // Body. A dead body lol
|
||||
const VRR_FORENSICS_HAIR = 4; // Hair. Automatically applied to
|
||||
const VRR_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
|
||||
const VRR_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank
|
||||
const VRR_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
|
||||
|
||||
// Account Authentication Methods
|
||||
const VRR_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const VRR_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const VRR_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const VRR_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const VRR_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const VRR_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
|
||||
|
||||
// Police Patrol Types
|
||||
const VRR_PATROLTYPE_NONE = 0; // None
|
||||
const VRR_PATROLTYPE_FOOT = 1; // Foot patrol. Officer takes a vehicle to get to their designated area and then walks a beat. More common in LC games
|
||||
const VRR_PATROLTYPE_VEHICLE = 2; // Vehicle patrol. More common in VC/LS/SF/LV cities.
|
||||
|
||||
// Job Route States
|
||||
const VRR_JOBROUTESTATE_NONE = 0; // None
|
||||
const VRR_JOBROUTESTATE_INPROGRESS = 1; // Route is in progress. Player is in between stops but not at the last one.
|
||||
const VRR_JOBROUTESTATE_LASTSTOP = 2; // Player is heading to the last stop on the route
|
||||
const VRR_JOBROUTESTATE_PAUSED = 3; // Route is paused for some reason. For police, this could be player accepted callout and once finished, patrol route will resume
|
||||
const VRR_JOBROUTESTATE_ATSTOP = 4; // For bus/trash stops that freeze player, this is the state when they're at one
|
||||
|
||||
// Item Occupied States
|
||||
const VRR_ITEM_ACTION_NONE = 0; // None
|
||||
const VRR_ITEM_ACTION_USE = 1; // Using item
|
||||
const VRR_ITEM_ACTION_PICKUP = 2; // Picking up item
|
||||
const VRR_ITEM_ACTION_DROP = 3; // Dropping item
|
||||
const VRR_ITEM_ACTION_SWITCH = 4; // Switching item
|
||||
const VRR_ITEM_ACTION_PUT = 5; // Putting item (into trunk, dash, crate, etc)
|
||||
const VRR_ITEM_ACTION_TAKE = 6; // Taking item (from trunk, dash, crate, etc)
|
||||
|
||||
// Ped States
|
||||
const VRR_PEDSTATE_NONE = 2; // None
|
||||
const VRR_PEDSTATE_READY = 1; // Ready
|
||||
const VRR_PEDSTATE_DRIVER = 2; // Driving a vehicle
|
||||
const VRR_PEDSTATE_PASSENGER = 3; // In a vehicle as passenger
|
||||
const VRR_PEDSTATE_DEAD = 4; // Dead
|
||||
const VRR_PEDSTATE_ENTERINGPROPERTY = 5; // Entering a property
|
||||
const VRR_PEDSTATE_EXITINGPROPERTY = 6; // Exiting a property
|
||||
const VRR_PEDSTATE_ENTERINGVEHICLE = 7; // Entering a vehicle
|
||||
const VRR_PEDSTATE_EXITINGVEHICLE = 8; // Exiting a vehicle
|
||||
const VRR_PEDSTATE_BINDED = 9; // Binded by rope or handcuffs
|
||||
const VRR_PEDSTATE_TAZED = 10; // Under incapacitating effect of tazer
|
||||
const VRR_PEDSTATE_INTRUNK = 11; // In vehicle trunk
|
||||
const VRR_PEDSTATE_INITEM = 12; // In item (crate, box, etc)
|
||||
const VRR_PEDSTATE_HANDSUP = 13; // Has hands up (surrendering)
|
||||
const VRR_PEDSTATE_SPAWNING = 14; // Spawning
|
||||
|
||||
// Two-Factor Authentication States
|
||||
const VRR_2FA_STATE_NONE = 0; // None
|
||||
const VRR_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const VRR_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const VRR_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
|
||||
// Reset Password States
|
||||
const VRR_RESETPASS_STATE_NONE = 0; // None
|
||||
const VRR_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const VRR_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
const VRR_RESETPASS_STATE_EMAILCONFIRM = 3; // Waiting on player to enter their email to confirm it's correct
|
||||
|
||||
// NPC Trigger Condition Match Types
|
||||
const VRR_NPC_COND_MATCH_NONE = 0; // None (invalid)
|
||||
const VRR_NPC_COND_MATCH_EQ = 1; // Must be equal to
|
||||
const VRR_NPC_COND_MATCH_GT = 2; // Must be greater than
|
||||
const VRR_NPC_COND_MATCH_LT = 3; // Must be less than
|
||||
const VRR_NPC_COND_MATCH_GTEQ = 4; // Must be greater than or equal to
|
||||
const VRR_NPC_COND_MATCH_LTEQ = 5; // Must be less than or equal to
|
||||
const VRR_NPC_COND_MATCH_CONTAINS = 6; // Must contain string (case insensitive)
|
||||
const VRR_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case sensitive)
|
||||
const VRR_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive)
|
||||
const VRR_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive)
|
||||
|
||||
// Business Types
|
||||
const VRR_BIZ_TYPE_NONE = 0; // None (invalid)
|
||||
const VRR_BIZ_TYPE_NORMAL = 1; // Normal business (sells items)
|
||||
const VRR_BIZ_TYPE_BANK = 2; // Bank
|
||||
const VRR_BIZ_TYPE_PUBLIC = 3; // Public business (Government, public service, etc)
|
||||
|
||||
// Return-To types (for when a player is teleported)
|
||||
const VRR_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid
|
||||
const VRR_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting
|
||||
const VRR_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select
|
||||
|
||||
// Card Game Types
|
||||
const VRR_DECKCARD_GAME_NONE = 0; // None (invalid)
|
||||
const VRR_DECKCARD_GAME_BLACKJACK = 1; // Blackjack
|
||||
const VRR_DECKCARD_GAME_TEXASHOLDEM = 2; // Texas Hold-em
|
||||
const VRR_DECKCARD_GAME_FIVECARDDRAW = 3; // Five Card Draw
|
||||
const VRR_DECKCARD_GAME_FIVECARDSTUD = 4; // Five Card Stud
|
||||
const VRR_DECKCARD_GAME_HIGHLOW = 5; // High-Low (Also known as War)
|
||||
|
||||
// Card Suits
|
||||
const VRR_DECKCARD_SUIT_NONE = 0; // None (invalid)
|
||||
const VRR_DECKCARD_SUIT_SPADE = 1; // Spades
|
||||
const VRR_DECKCARD_SUIT_CLUB = 2; // Clubs
|
||||
const VRR_DECKCARD_SUIT_HEART = 3; // Hearts
|
||||
const VRR_DECKCARD_SUIT_DIAMOND = 4; // Diamonds
|
||||
|
||||
// GPS State Types
|
||||
const VRR_GPS_TYPE_NONE = 0; // None (invalid)
|
||||
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
|
||||
|
||||
// Discord Webhook Types
|
||||
const VRR_DISCORD_WEBHOOK_NONE = 0;
|
||||
const VRR_DISCORD_WEBHOOK_LOG = 1;
|
||||
const VRR_DISCORD_WEBHOOK_ADMIN = 2;
|
||||
|
||||
// NPC Owner Types
|
||||
const VRR_NPCOWNER_NONE = 0; // Not owned
|
||||
const VRR_NPCOWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const VRR_NPCOWNER_JOB = 2; // Owned by a job
|
||||
const VRR_NPCOWNER_CLAN = 3; // Owned by a clan
|
||||
const VRR_NPCOWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const VRR_NPCOWNER_PUBLIC = 5; // Public NPC. Anybody can do stuff with it.
|
||||
const VRR_NPCOWNER_BIZ = 6; // Owned by a business
|
||||
@@ -1,20 +1,22 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: core.js
|
||||
// DESC: Provides core data structures, function, and operations
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let scriptVersion = "1.1";
|
||||
let scriptVersion = "1.2";
|
||||
let serverStartTime = 0;
|
||||
let logLevel = LOG_INFO|LOG_DEBUG|LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
|
||||
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
|
||||
|
||||
let playerResourceReady = new Array(server.maxClients).fill(false);
|
||||
let playerResourceStarted = new Array(server.maxClients).fill(false);
|
||||
let playerInitialized = new Array(server.maxClients).fill(false);
|
||||
let playerGUI = new Array(server.maxClients).fill(false);
|
||||
let defaultNoAccountId = 479;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -28,15 +30,19 @@ let playerGUI = new Array(server.maxClients).fill(false);
|
||||
* @property {Array.<ItemData>} items
|
||||
* @property {Array.<ItemTypeData>} itemTypes
|
||||
* @property {Array.<ClanData>} clans
|
||||
* @property {Array} localeStrings
|
||||
* @property {Array.<TriggerData>} triggers
|
||||
* @property {Array.<NPCData>} npcs
|
||||
* @property {Array.<RaceData>} races
|
||||
* @property {Array.<JobData>} jobs
|
||||
* @property {Array.<Gates>} gates
|
||||
* @property {Array.<GateData>} gates
|
||||
* @property {Array.<RadioStationData>} radioStations
|
||||
* @property {Array} locales
|
||||
* @property {Array} localeStrings
|
||||
* @property {Array} groundItemCache
|
||||
* @property {Array} groundPlantCache
|
||||
* @property {Array} purchasingVehicleCache
|
||||
* @property {Array} rentingVehicleCache
|
||||
* @property {Array} atmLocationCache
|
||||
*/
|
||||
let serverData = {
|
||||
vehicles: [],
|
||||
@@ -47,26 +53,26 @@ let serverData = {
|
||||
items: [],
|
||||
itemTypes: [],
|
||||
clans: [],
|
||||
localeStrings: {},
|
||||
cachedTranslations: [],
|
||||
cachedTranslationFrom: [],
|
||||
//triggers: [],
|
||||
triggers: [],
|
||||
npcs: [],
|
||||
races: [],
|
||||
jobs: [],
|
||||
gates: [],
|
||||
radioStations: [],
|
||||
localeStrings: {},
|
||||
groundItemCache: [],
|
||||
groundPlantCache: [],
|
||||
purchasingVehicleCache: [],
|
||||
rentingVehicleCache: [],
|
||||
atmLocationCache: [],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {ServerData}
|
||||
*
|
||||
* @return {ServerData} serverData
|
||||
*/
|
||||
function getServerData() {
|
||||
return serverData;
|
||||
|
||||
23
scripts/server/crime.js
Normal file
23
scripts/server/crime.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: crime.js
|
||||
// DESC: Provides crime data structures, functions, and operations
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a crime's data. Loaded and saved in the database
|
||||
*/
|
||||
class CrimeData {
|
||||
constructor(suspectId, crimeType, reporterId = 0) {
|
||||
this.crimeType = crimeType;
|
||||
this.suspectId = suspectId;
|
||||
this.reporterId = reporterId;
|
||||
this.whenCommitted = 0;
|
||||
this.whenReported = 0;
|
||||
this.databaseId = 0;
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: database.js
|
||||
// DESC: Provides database handling, functions and usage
|
||||
@@ -14,8 +15,8 @@ let persistentDatabaseConnection = null;
|
||||
// ===========================================================================
|
||||
|
||||
function initDatabaseScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Database]: Initializing database script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Database]: Database script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Database]: Initializing database script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Database]: Database script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -24,13 +25,13 @@ function createDatabaseInsertQuery(tableName, data) {
|
||||
let fields = [];
|
||||
let values = [];
|
||||
|
||||
for(let i in data) {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
for (let i in data) {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][0] != 'NaN') {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
fields.push(data[i][0]);
|
||||
|
||||
if(typeof data[i][1] == "string") {
|
||||
if(data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
if (typeof data[i][1] == "string") {
|
||||
if (data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
values.push("UNIX_TIMESTAMP()");
|
||||
} else {
|
||||
values.push(`'${data[i][1]}'`);
|
||||
@@ -51,11 +52,11 @@ function createDatabaseInsertQuery(tableName, data) {
|
||||
function createDatabaseUpdateQuery(tableName, data, whereClause) {
|
||||
let values = [];
|
||||
|
||||
for(let i in data) {
|
||||
if(data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
|
||||
if(data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
if(typeof data[i][1] == "string") {
|
||||
if(data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
for (let i in data) {
|
||||
if (data[i][0] != "undefined" && data[i][0] != NaN && data[i][0] != 'NaN') {
|
||||
if (data[i][1] != "undefined" && data[i][1] != NaN && data[i][1] != 'NaN') {
|
||||
if (typeof data[i][1] == "string") {
|
||||
if (data[i][1] == "{UNIXTIMESTAMP}") {
|
||||
values.push(`${data[i][0]}=UNIX_TIMESTAMP()`);
|
||||
} else {
|
||||
values.push(`${data[i][0]}='${data[i][1]}'`);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: developer.js
|
||||
// DESC: Provides developer operation, commands, functions and usage
|
||||
@@ -8,7 +9,7 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initDeveloperScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Developer]: Initializing developer script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Developer]: Initializing developer script ...");
|
||||
|
||||
// Use GTAC command handlers for these since they need to be available on console
|
||||
//addCommandHandler("sc", executeServerCodeCommand);
|
||||
@@ -17,7 +18,7 @@ function initDeveloperScript() {
|
||||
//addCommandHandler("allcmd", simulateCommandForAllPlayersCommand);
|
||||
//addCommandHandler("addloglvl", setServerLogLevelCommand);
|
||||
|
||||
logToConsole(LOG_INFO, "[VRR.Developer]: Developer script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Developer]: Developer script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,12 +121,12 @@ function pvd(params) {
|
||||
// ===========================================================================
|
||||
|
||||
function addLogLevelCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
switch (toLowerCase(params)) {
|
||||
case "debug":
|
||||
logLevel = logLevel | LOG_DEBUG;
|
||||
break;
|
||||
@@ -151,9 +152,7 @@ function addLogLevelCommand(command, params, client) {
|
||||
}
|
||||
|
||||
sendPlayerLogLevel(null, logLevel);
|
||||
|
||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -162,40 +161,39 @@ function addLogLevelCommand(command, params, client) {
|
||||
function getLogLevelCommand(command, params, client) {
|
||||
let logLevels = [];
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_DEBUG)) {
|
||||
if (hasBitFlag(logLevel, LOG_DEBUG)) {
|
||||
logLevels.push("debug");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_WARN)) {
|
||||
if (hasBitFlag(logLevel, LOG_WARN)) {
|
||||
logLevels.push("warn");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_ERROR)) {
|
||||
if (hasBitFlag(logLevel, LOG_ERROR)) {
|
||||
logLevels.push("error");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_INFO)) {
|
||||
if (hasBitFlag(logLevel, LOG_INFO)) {
|
||||
logLevels.push("info");
|
||||
}
|
||||
|
||||
if(hasBitFlag(logLevel, LOG_VERBOSE)) {
|
||||
if (hasBitFlag(logLevel, LOG_VERBOSE)) {
|
||||
logLevels.push("verbose");
|
||||
}
|
||||
|
||||
messagePlayerAlert(`{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`);
|
||||
|
||||
messagePlayerAlert(client, `{MAINCOLOUR}Current log levels: {ALTCOLOUR}${toLowerCase(logLevels.join(", "))}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function removeLogLevelCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
switch (toLowerCase(params)) {
|
||||
case "debug":
|
||||
logLevel = logLevel & ~LOG_DEBUG;
|
||||
break;
|
||||
@@ -221,28 +219,26 @@ function removeLogLevelCommand(command, params, client) {
|
||||
}
|
||||
|
||||
sendPlayerLogLevel(null, logLevel);
|
||||
|
||||
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function simulateCommandForPlayerCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
if (getCommand(command).requireLogin) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
messagePlayerError(client, "You must be logged in to use this command!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messagePlayerError(client, "You do not have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -252,12 +248,12 @@ function simulateCommandForPlayerCommand(command, params, client) {
|
||||
tempCommand.replace("/", "");
|
||||
let tempParams = splitParams.slice(2).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, "Invalid player name or ID");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getCommand(tempCommand)) {
|
||||
if (!getCommand(tempCommand)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
|
||||
return false;
|
||||
}
|
||||
@@ -270,19 +266,19 @@ function simulateCommandForPlayerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
if (getCommand(command).requireLogin) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
messagePlayerError(client, "You must be logged in to use this command!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messagePlayerError(client, "You do not have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
if (areParamsEmpty(params) || !areThereEnoughParams(params, 2)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -291,14 +287,14 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
tempCommand.replace("/", "");
|
||||
let tempParams = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!getCommand(tempCommand)) {
|
||||
if (!getCommand(tempCommand)) {
|
||||
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(!clients[i].console) {
|
||||
for (let i in clients) {
|
||||
if (!clients[i].console) {
|
||||
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, clients[i]);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +305,7 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeServerCodeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -317,7 +313,7 @@ function executeServerCodeCommand(command, params, client) {
|
||||
let returnValue = "Nothing";
|
||||
try {
|
||||
returnValue = eval("(" + params + ")");
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
messagePlayerError(client, "The code could not be executed!");
|
||||
return false;
|
||||
}
|
||||
@@ -332,7 +328,7 @@ function executeServerCodeCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeClientCodeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -341,12 +337,12 @@ function executeClientCodeCommand(command, params, client) {
|
||||
let targetClient = getPlayerFromParams(getParam(params, " ", 1));
|
||||
let targetCode = splitParams.slice(1).join(" ");
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(targetCode == "") {
|
||||
if (targetCode == "") {
|
||||
messagePlayerError(client, "You didn't enter any code!");
|
||||
return false;
|
||||
}
|
||||
@@ -361,19 +357,19 @@ function executeClientCodeCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setPlayerTesterStatusCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
|
||||
if (!hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
|
||||
getPlayerData(targetClient).accountData.flags.moderation = addBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
|
||||
} else {
|
||||
getPlayerData(targetClient).accountData.flags.moderation = removeBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
|
||||
@@ -388,14 +384,14 @@ function setPlayerTesterStatusCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testPromptGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -407,14 +403,14 @@ function testPromptGUICommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testInfoGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -426,14 +422,14 @@ function testInfoGUICommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function testErrorGUICommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
@@ -453,14 +449,8 @@ function saveServerDataCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function testEmailCommand(command, params, client) {
|
||||
try {
|
||||
messagePlayerAlert(client, `Sending test email to ${params}`);
|
||||
sendEmail(params, "Player", "Test email", "Just testing the SMTP module for the server!");
|
||||
} catch(error) {
|
||||
messagePlayerError(client, "The email could not be sent! Error: ${error}");
|
||||
return false;
|
||||
}
|
||||
async function testEmailCommand(command, params, client) {
|
||||
sendEmail(params, "Player", "Test email", "Just testing the email system for the server!");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -477,7 +467,7 @@ function restartGameModeCommand(command, params, client) {
|
||||
|
||||
function clientRunCodeFail(client, returnTo, error) {
|
||||
let returnClient = getClientFromIndex(returnTo);
|
||||
if(!returnClient) {
|
||||
if (!returnClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -488,7 +478,7 @@ function clientRunCodeFail(client, returnTo, error) {
|
||||
|
||||
function clientRunCodeSuccess(client, returnTo, returnVal) {
|
||||
let returnClient = getClientFromIndex(returnTo);
|
||||
if(!returnClient) {
|
||||
if (!returnClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -500,19 +490,25 @@ function clientRunCodeSuccess(client, returnTo, returnVal) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitIdea(client, ideaText) {
|
||||
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
let position = toVector3(0.0, 0.0, 0.0);
|
||||
let heading = 0.0;
|
||||
let session = 0;
|
||||
let databaseId = 0;
|
||||
|
||||
if(isConsole(client)) {
|
||||
databaseId = -1;
|
||||
if (client != null) {
|
||||
if (isConsole(client)) {
|
||||
databaseId = -1;
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
}
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
databaseId = defaultNoAccountId;
|
||||
}
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText);
|
||||
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
@@ -521,19 +517,25 @@ function submitIdea(client, ideaText) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitBugReport(client, bugText) {
|
||||
let position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
let heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
let position = toVector3(0.0, 0.0, 0.0);
|
||||
let heading = 0.0;
|
||||
let session = 0;
|
||||
let databaseId = 0;
|
||||
|
||||
if(isConsole(client)) {
|
||||
databaseId = -1;
|
||||
if (client != null) {
|
||||
if (isConsole(client)) {
|
||||
databaseId = -1;
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
position = (getPlayerVehicle(client)) ? getVehiclePosition(getPlayerVehicle(client)) : getPlayerPosition(client);
|
||||
heading = (getPlayerVehicle(client)) ? getVehicleHeading(getPlayerVehicle(client)) : getPlayerHeading(client);
|
||||
}
|
||||
} else {
|
||||
databaseId = getPlayerData(client).accountData.databaseId;
|
||||
databaseId = defaultNoAccountId;
|
||||
}
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeBugMessage = escapeDatabaseString(dbConnection, bugText);
|
||||
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, NOW(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
@@ -551,14 +553,14 @@ function migrateSubAccountsToPerServerData() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
if (dbQuery) {
|
||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
createDefaultSubAccountServerData(dbAssoc["sacct_id"]);
|
||||
|
||||
let dbQuery2 = queryDatabase(dbConnection, `UPDATE sacct_svr SET sacct_svr_skin = ${dbAssoc["sacct_skin"]}, sacct_svr_job = ${dbAssoc["sacct_job"]} WHERE sacct_svr_sacct=${dbAssoc["sacct_id"]} AND sacct_svr_server=${dbAssoc["sacct_server"]}`);
|
||||
if(dbQuery2) {
|
||||
if (dbQuery2) {
|
||||
freeDatabaseQuery(dbQuery2);
|
||||
}
|
||||
}
|
||||
@@ -573,10 +575,10 @@ function resetAllAccountsHotkeysToDefault() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
if (dbQuery) {
|
||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
createDefaultKeybindsForAccount(dbAssoc["acct_id"]);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -595,9 +597,9 @@ function togglePauseSavingToDatabaseCommand(command, params, client) {
|
||||
function createAccountDataForNewServer(serverId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_main`);
|
||||
if(dbQuery) {
|
||||
if (dbQuery) {
|
||||
let dbQueryString = `INSERT INTO acct_svr (acct_svr_acct, acct_svr_svr) VALUES (${accountDatabaseId}, ${serverId})`;
|
||||
quickDatabaseQuery(dbQueryString);
|
||||
}
|
||||
@@ -607,7 +609,7 @@ function createAccountDataForNewServer(serverId) {
|
||||
// ===========================================================================
|
||||
|
||||
function streamAudioURLToAllPlayersCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -621,7 +623,7 @@ function streamAudioURLToAllPlayersCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function streamAudioNameToAllPlayersCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -685,28 +687,28 @@ function showLocalePickerTestCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function executeDatabaseQueryCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, "That player was not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(targetCode == "") {
|
||||
if (targetCode == "") {
|
||||
messagePlayerError(client, "You didn't enter any code!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let success = quickDatabaseQuery(params);
|
||||
let results = quickDatabaseQueryWithResults(params);
|
||||
|
||||
if(!success) {
|
||||
if (results == false || results == null || results == undefined) {
|
||||
messagePlayerAlert(client, `Database query failed to execute: {ALTCOLOUR}${query}`);
|
||||
} else if(typeof success != "boolean") {
|
||||
messagePlayeSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
messagePlayerInfo(client, `Returns: ${success}`);
|
||||
} else if (typeof results == "boolean") {
|
||||
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
messagePlayerInfo(client, `Returns: ${getTrueFalseFromBool(results)}`);
|
||||
} else {
|
||||
messagePlayerSuccess(client, `Database query successful: {ALTCOLOUR}${query}`);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: discord.js
|
||||
// DESC: Provides discord bridging and connection functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Discord Webhook Types
|
||||
const AGRP_DISCORD_WEBHOOK_NONE = 0;
|
||||
const AGRP_DISCORD_WEBHOOK_LOG = 1;
|
||||
const AGRP_DISCORD_WEBHOOK_ADMIN = 2;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initDiscordScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Discord]: Initializing discord script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Discord]: Discord script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Discord]: Initializing discord script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Discord]: Discord script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -53,7 +61,7 @@ function messageDiscordUser(discordUser, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function sendDiscordSocketData(socketData) {
|
||||
if(!getDiscordSocket()) {
|
||||
if (!getDiscordSocket()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,11 +71,11 @@ function sendDiscordSocketData(socketData) {
|
||||
// ===========================================================================
|
||||
|
||||
function isClientFromDiscord(client) {
|
||||
if(client == null) {
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(client instanceof Client) {
|
||||
if (client instanceof Client) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -89,58 +97,135 @@ function getDiscordUserData(discordUserId) {
|
||||
// ===========================================================================
|
||||
|
||||
function messageDiscordChatChannel(messageString) {
|
||||
if(getServerConfig().devServer == true) {
|
||||
if (getServerConfig().devServer == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getGlobalConfig().discord.sendChat) {
|
||||
if (!getGlobalConfig().discord.sendChat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getServerConfig().discord.sendChat) {
|
||||
if (!getServerConfig().discord.sendChat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function messageDiscordEventChannel(messageString) {
|
||||
if(getServerConfig().devServer == true) {
|
||||
if (getServerConfig().devServer == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getGlobalConfig().discord.sendEvents) {
|
||||
if (!getGlobalConfig().discord.sendEvents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getServerConfig().discord.sendEvents) {
|
||||
if (!getServerConfig().discord.sendEvents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_LOG);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function messageDiscordAdminChannel(messageString) {
|
||||
if(getServerConfig().devServer == true) {
|
||||
if (getServerConfig().devServer == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getGlobalConfig().discord.sendAdmin) {
|
||||
if (!getGlobalConfig().discord.sendAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getServerConfig().discord.sendAdmin) {
|
||||
if (!getServerConfig().discord.sendAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerWebHook(messageString, getServerId(), VRR_DISCORD_WEBHOOK_ADMIN);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_ADMIN);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function messageDiscordClanWebhook(clanIndex, requiredFlagValue, messageString) {
|
||||
if (getServerConfig().devServer == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getGlobalConfig().discord.sendClan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getServerConfig().discord.sendClan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasBitFlag(getClanData(clanIndex).discordWebhookFlags, requiredFlagValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
triggerClanDiscordWebHook(clanIndex, messageString);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = AGRP_DISCORD_WEBHOOK_LOG) {
|
||||
if (!getGlobalConfig().discord.webhook.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
|
||||
tempURL = tempURL.replace("{0}", encodeURIComponent(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) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerClanDiscordWebHook(clanIndex, messageString) {
|
||||
if (!getGlobalConfig().discord.webhook.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
let webhookURL = getClanData(clanIndex).discordWebhookURL;
|
||||
|
||||
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
|
||||
tempURL = tempURL.replace("{0}", encodeURIComponent(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) {
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: economy.js
|
||||
// DESC: Provides economy/financial utils, functions and usage
|
||||
@@ -8,20 +9,20 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initEconomyScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Economy]: Initializing economy script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Economy]: Economy script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Economy]: Initializing economy script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Economy]: Economy script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getTimeDisplayUntilPlayerPayDay(client) {
|
||||
return getTimeDifferenceDisplay(sdl.ticks-getPlayerData(client).payDayTickStart);
|
||||
return getTimeDifferenceDisplay(sdl.ticks - getPlayerData(client).payDayTickStart);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function applyServerInflationMultiplier(value) {
|
||||
return toInteger(Math.round(value*getServerConfig().inflationMultiplier))
|
||||
return toInteger(Math.round(value * getServerConfig().inflationMultiplier))
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -31,30 +32,30 @@ function playerPayDay(client) {
|
||||
let grossIncome = getPlayerData(client).payDayAmount;
|
||||
|
||||
// Passive income
|
||||
grossIncome = grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay;
|
||||
grossIncome = Math.round(grossIncome + getGlobalConfig().economy.passiveIncomePerPayDay);
|
||||
|
||||
// Payday bonus
|
||||
grossIncome = grossIncome*getGlobalConfig().economy.grossIncomeMultiplier;
|
||||
grossIncome = Math.round(grossIncome * getGlobalConfig().economy.grossIncomeMultiplier);
|
||||
|
||||
// Double bonus
|
||||
if(isDoubleBonusActive()) {
|
||||
grossIncome = grossIncome*2;
|
||||
if (isDoubleBonusActive()) {
|
||||
grossIncome = Math.round(grossIncome * 2);
|
||||
}
|
||||
|
||||
let incomeTaxAmount = Math.round(calculateIncomeTax(wealth));
|
||||
|
||||
let netIncome = grossIncome-incomeTaxAmount;
|
||||
let netIncome = Math.round(grossIncome - incomeTaxAmount);
|
||||
|
||||
messagePlayerAlert(client, "== Payday! =============================");
|
||||
messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}$${grossIncome}`);
|
||||
messagePlayerInfo(client, `Taxes: {ALTCOLOUR}$${incomeTaxAmount}`);
|
||||
messagePlayerInfo(client, `You receive: {ALTCOLOUR}$${netIncome}`);
|
||||
if(netIncome < incomeTaxAmount) {
|
||||
messagePlayerInfo(client, `Paycheck: {ALTCOLOUR}${getCurrencyString(grossIncome)}`);
|
||||
messagePlayerInfo(client, `Taxes: {ALTCOLOUR}${getCurrencyString(incomeTaxAmount)}`);
|
||||
messagePlayerInfo(client, `You receive: {ALTCOLOUR}${getCurrencyString(netIncome)}`);
|
||||
if (netIncome < incomeTaxAmount) {
|
||||
let totalCash = getPlayerCash(client);
|
||||
let canPayNow = totalCash+netIncome;
|
||||
if(incomeTaxAmount <= canPayNow) {
|
||||
let canPayNow = totalCash + netIncome;
|
||||
if (incomeTaxAmount <= canPayNow) {
|
||||
takePlayerCash(client, canPayNow);
|
||||
messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${canPayNow}{MAINCOLOUR}`)}`);
|
||||
messagePlayerInfo(client, `{orange}${getLocaleString(client, "RemainingTaxPaidInCash", `{ALTCOLOUR}${getCurrencyString(canPayNow)}{MAINCOLOUR}`)}`);
|
||||
messagePlayerAlert(client, `{orange}${getLocaleString(client, "LostMoneyFromTaxes")}`);
|
||||
messagePlayerAlert(client, `{orange}${getLocaleString(client, "NextPaycheckRepossessionWarning")}`);
|
||||
} else {
|
||||
@@ -65,12 +66,12 @@ function playerPayDay(client) {
|
||||
let houseCount = getAllHousesOwnedByPlayer(client).length;
|
||||
let businessCount = getAllBusinessesOwnedByPlayer(client).length;
|
||||
|
||||
attemptRepossession(client, incomeTaxAmount-canPayNow);
|
||||
attemptRepossession(client, incomeTaxAmount - canPayNow);
|
||||
|
||||
let newVehicleCount = getAllVehiclesOwnedByPlayer(client).length;
|
||||
let newHouseCount = getAllHousesOwnedByPlayer(client).length;
|
||||
let newBusinessCount = getAllBusinessesOwnedByPlayer(client).length;
|
||||
messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount-vehicleCount, newHouseCount-houseCount, newBusinessCount-businessCount)}`);
|
||||
messagePlayerInfo(client, `{orange}${getLocaleString(client, "AssetsRepossessedForTaxes", newVehicleCount - vehicleCount, newHouseCount - houseCount, newBusinessCount - businessCount)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,29 +85,29 @@ function calculateWealth(client) {
|
||||
let houses = getAllHousesOwnedByPlayer(client);
|
||||
let businesses = getAllBusinessesOwnedByPlayer(client);
|
||||
|
||||
let vehicleUpKeep = applyServerInflationMultiplier(vehicles.length*getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle);
|
||||
let houseUpKeep = applyServerInflationMultiplier(houses.length*getGlobalConfig().economy.upKeepCosts.upKeepPerHouse);
|
||||
let businessUpKeep = applyServerInflationMultiplier(businesses.length*getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness);
|
||||
let vehicleUpKeep = applyServerInflationMultiplier(vehicles.length * getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle);
|
||||
let houseUpKeep = applyServerInflationMultiplier(houses.length * getGlobalConfig().economy.upKeepCosts.upKeepPerHouse);
|
||||
let businessUpKeep = applyServerInflationMultiplier(businesses.length * getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness);
|
||||
|
||||
return vehicleUpKeep+houseUpKeep+businessUpKeep;
|
||||
return vehicleUpKeep + houseUpKeep + businessUpKeep;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function calculateIncomeTax(amount) {
|
||||
return amount*getGlobalConfig().economy.incomeTaxRate;
|
||||
return amount * getGlobalConfig().economy.incomeTaxRate;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function forcePlayerPayDayCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getPlayerFromParams(params);
|
||||
if(!targetClient) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, "That player is not connected!");
|
||||
return false;
|
||||
}
|
||||
@@ -118,21 +119,21 @@ function forcePlayerPayDayCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setPayDayBonusMultiplier(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let newMultiplier = params;
|
||||
|
||||
if(isNaN(newMultiplier)) {
|
||||
if (isNaN(newMultiplier)) {
|
||||
messagePlayerError(client, getLocaleString(client, "AmountNotNumber"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
|
||||
|
||||
announceAdminAction(`PaydayBonusSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
|
||||
announceAdminAction(`PaydayBonusSet`, `{adminOrange}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier * 100}%{MAINCOLOUR}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -140,14 +141,14 @@ function setPayDayBonusMultiplier(command, params, client) {
|
||||
function taxInfoCommand(command, params, client) {
|
||||
let wealth = calculateWealth(client);
|
||||
let tax = calculateIncomeTax(wealth);
|
||||
messagePlayerInfo(client, `Your tax on payday is: $${tax}. Use {ALTCOLOUR}/help tax {MAINCOLOUR}for more information.`);
|
||||
messagePlayerInfo(client, getLocaleString(client, "YourTax", `{ALTCOLOUR}${getCurrencyString(tax)}{MAINCOLOUR}`, `{ALTCOLOUR}/help tax{MAINCOLOUR}`));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function wealthInfoCommand(command, params, client) {
|
||||
let wealth = calculateWealth(client);
|
||||
messagePlayerInfo(client, `Your wealth is: {ALTCOLOUR}$${wealth}{MAINCOLOUR}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`);
|
||||
messagePlayerInfo(client, getLocaleString(client, "YourWealth", `{ALTCOLOUR}${getCurrencyString(wealth)}{MAINCOLOUR}`, `{ALTCOLOUR}/help wealth{MAINCOLOUR}`));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -155,7 +156,7 @@ function wealthInfoCommand(command, params, client) {
|
||||
function attemptRepossession(client, totalToPay) {
|
||||
let leftToPay = totalToPay;
|
||||
|
||||
while(leftToPay > 0) {
|
||||
while (leftToPay > 0) {
|
||||
let repossessionValue = repossessFirstAsset(client);
|
||||
leftToPay = leftToPay - repossessionValue;
|
||||
}
|
||||
@@ -166,19 +167,19 @@ function attemptRepossession(client, totalToPay) {
|
||||
|
||||
function repossessFirstAsset(client) {
|
||||
let vehicles = getAllVehiclesOwnedByPlayer(client);
|
||||
if(vehicles.length > 0) {
|
||||
deleteVehicle(vehicles[0])
|
||||
if (vehicles.length > 0) {
|
||||
deleteVehicle(vehicles[0]);
|
||||
return getGlobalConfig().economy.upKeepCosts.upKeepPerVehicle;
|
||||
}
|
||||
|
||||
let houses = getAllHousesOwnedByPlayer(client);
|
||||
if(houses.length > 0) {
|
||||
if (houses.length > 0) {
|
||||
deleteHouse(houses[0].index);
|
||||
return getGlobalConfig().economy.upKeepCosts.upKeepPerHouse;
|
||||
}
|
||||
|
||||
let businesses = getAllBusinessesOwnedByPlayer(client);
|
||||
if(businesses.length > 0) {
|
||||
if (businesses.length > 0) {
|
||||
deleteBusiness(businesses[0].index);
|
||||
return getGlobalConfig().economy.upKeepCosts.upKeepPerBusiness;
|
||||
}
|
||||
@@ -187,29 +188,37 @@ function repossessFirstAsset(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getAllVehiclesOwnedByPlayer(client) {
|
||||
return getServerData().vehicles.filter((v) => v.ownerType == VRR_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().vehicles.filter((v) => v.ownerType == AGRP_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAllBusinessesOwnedByPlayer(client) {
|
||||
return getServerData().businesses.filter((b) => b.ownerType == VRR_BIZOWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().businesses.filter((b) => b.ownerType == AGRP_BIZ_OWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAllHousesOwnedByPlayer(client) {
|
||||
return getServerData().houses.filter((h) => h.ownerType == VRR_HOUSEOWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
return getServerData().houses.filter((h) => h.ownerType == AGRP_HOUSE_OWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isDoubleBonusActive() {
|
||||
if(isWeekend()) {
|
||||
if (isWeekend()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getCurrencyString(amount) {
|
||||
let tempString = getGlobalConfig().economy.currencyString;
|
||||
tempString = tempString.replace("{AMOUNT}", toString(makeLargeNumberReadable(amount)));
|
||||
return tempString;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,36 +1,75 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: email.js
|
||||
// DESC: Provides email handling, functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Email Methods
|
||||
const AGRP_EMAIL_METHOD_NONE = 0; // None
|
||||
const AGRP_EMAIL_METHOD_SMTP_MODULE = "smtp"; // Use SMTP module
|
||||
const AGRP_EMAIL_METHOD_GET_REQUEST = "http"; // Use HTTP request (httpGet to custom PHP page)
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initEmailScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Email]: Initializing email script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Email]: Email script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Email]: Initializing email script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Email]: Email script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function sendEmail(toEmail, toName, subject, body) {
|
||||
if(!checkForSMTPModule()) {
|
||||
return false;
|
||||
async function sendEmail(toEmail, toName, subject, body) {
|
||||
switch (getEmailConfig().method) {
|
||||
case AGRP_EMAIL_METHOD_SMTP_MODULE:
|
||||
if (!checkForSMTPModule()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
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
|
||||
);
|
||||
});
|
||||
break;
|
||||
|
||||
case AGRP_EMAIL_METHOD_GET_REQUEST:
|
||||
let tempURL = getEmailConfig().http.baseURL;
|
||||
tempURL = tempURL.replace("{0}", encodeURIComponent(getEmailConfig().http.password));
|
||||
tempURL = tempURL.replace("{1}", encodeURIComponent(toEmail));
|
||||
tempURL = tempURL.replace("{2}", encodeURIComponent(toName));
|
||||
tempURL = tempURL.replace("{3}", encodeURIComponent(subject));
|
||||
tempURL = tempURL.replace("{4}", encodeURIComponent(body));
|
||||
|
||||
httpGet(
|
||||
tempURL,
|
||||
"",
|
||||
function (data) {
|
||||
|
||||
},
|
||||
function (data) {
|
||||
}
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,209 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: fishing.js
|
||||
// DESC: Provides fishing functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Fishing Catch Types (Probably not going to be used, in favor of items and their use type)
|
||||
const AGRP_FISHING_CATCH_TYPE_NONE = 0;
|
||||
const AGRP_FISHING_CATCH_TYPE_FISH = 1;
|
||||
const AGRP_FISHING_CATCH_TYPE_JUNK = 2;
|
||||
|
||||
// Fishing Line States
|
||||
const AGRP_FISHING_LINE_STATE_NONE = 0;
|
||||
const AGRP_FISHING_LINE_STATE_READY = 1;
|
||||
const AGRP_FISHING_LINE_STATE_CASTING = 2;
|
||||
const AGRP_FISHING_LINE_STATE_CASTED = 3;
|
||||
const AGRP_FISHING_LINE_STATE_REELING = 4;
|
||||
const AGRP_FISHING_LINE_STATE_HOOKED = 5;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingCollectables = [
|
||||
// Fish
|
||||
["Salmon", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Tuna", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Crab", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Trout", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Sea Bass", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Shark", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Turtle", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Manta Ray", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Cat Fish", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
["Blue Marlin", AGRP_FISHING_CATCH_TYPE_FISH],
|
||||
|
||||
// Junk
|
||||
["Rusty Can", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Pants", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Shoes", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Garbage", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Baby Diaper", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Tire", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Old Car Battery", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Horse Hoove", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Soggy Log", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Soggy Dildo", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
["Clump of Seaweed", AGRP_FISHING_CATCH_TYPE_JUNK],
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingAnimations = {
|
||||
[AGRP_GAME_GTA_III]: {
|
||||
"fishingLineCasting": "bathit1",
|
||||
"fishingLineReeling": "aimdown",
|
||||
},
|
||||
[AGRP_GAME_GTA_VC]: {
|
||||
"fishingLineCasting": "frontpunch",
|
||||
"fishingLineReeling": "aimdown",
|
||||
},
|
||||
[AGRP_GAME_GTA_SA]: {
|
||||
"fishingLineCasting": "none",
|
||||
"fishingLineReeling": "none",
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let fishingParticleEffects = {
|
||||
[AGRP_GAME_GTA_III]: {
|
||||
"fishingLineCast": [
|
||||
"MediumSprayingWater",
|
||||
0.2,
|
||||
500
|
||||
],
|
||||
"fishingLineReel": [
|
||||
"MediumSprayingWater",
|
||||
0.2,
|
||||
500
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initFishingScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Fishing]: Initializing fishing script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Fishing]: Fishing script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function castFishingLineCommand(command, params, client) {
|
||||
if (!isPlayerInFishingSpot(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveFishingLineCast(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "FishingLineAlreadyCast"));
|
||||
return false;
|
||||
}
|
||||
|
||||
let maxStrength = getGlobalConfig().fishingCastMaxStrength;
|
||||
let minStrength = getGlobalConfig().fishingCastMinStrength;
|
||||
let keyDuration = getPlayerData(client).keyBindDuration;
|
||||
|
||||
let strength = Math.round((maxStrength - minStrength) * (keyDuration / getGlobalConfig().fishingLineCastDuration));
|
||||
|
||||
castPlayerFishingLine(client, strength);
|
||||
|
||||
let messageText = getLocaleString(client, "FishingCastCommandHelp");
|
||||
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
|
||||
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
|
||||
}
|
||||
showSmallGameMessage(client, messageText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetFishingLineCommand(client) {
|
||||
if (doesPlayerHaveFishingLineCast(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "FishingLineNotCast"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isPlayerInFishingSpot(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantFishHere"));
|
||||
return false;
|
||||
}
|
||||
|
||||
makePedStopAnimation(getPlayerPed(client));
|
||||
|
||||
let messageText = getLocaleString(client, "FishingCastCommandHelp");
|
||||
if (doesPlayerHaveKeyBindForCommand(client, "fish")) {
|
||||
messageText = getLocaleString(client, "FishingCastKeyPressHelp");
|
||||
}
|
||||
|
||||
showSmallGameMessage(client, messageText);
|
||||
|
||||
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_NONE;
|
||||
getPlayerData(client).fishingLineCastStart = 0;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveFishingLineCast(client) {
|
||||
return getPlayerData(client).fishingLineCastStart != 0;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function castPlayerFishingLine(client, strength) {
|
||||
let frontPosition = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), strength * 2);
|
||||
|
||||
makePlayerPlayAnimation(client, getAnimationFromParams(fishingAnimations[getGame()]["fishingLineCasting"]));
|
||||
|
||||
setTimeout(function () {
|
||||
let particleEffectName = fishingParticleEffects[getGame()].fishingLineCast[1];
|
||||
showParticleEffect(frontPosition, getGameConfig().particleEffects[getGame()][particleEffectName], fishingParticleEffects[getGame()].fishingLineCast[1], fishingParticleEffects[getGame()].fishingLineCast[2]);
|
||||
|
||||
getPlayerData(client).fishingLineCastPosition = frontPosition;
|
||||
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_CASTED;
|
||||
}, strength * 10);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInFishingSpot(client) {
|
||||
if (isPlayerOnBoat(client)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let closestFishingLocation = getClosestFishingLocation(getPlayerPosition(client));
|
||||
if (closestFishingLocation != false) {
|
||||
if (getDistance(getPlayerPosition(client), closestFishingLocation) < getGlobalConfig().fishingSpotDistance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerFishing(client) {
|
||||
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerFishing(client) {
|
||||
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
21
scripts/server/forensics.js
Normal file
21
scripts/server/forensics.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: forensics.js
|
||||
// DESC: Provides forensics functions and commands (bullet casings, blood, etc)
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Forensic Types
|
||||
const AGRP_FORENSICS_NONE = 0;
|
||||
const AGRP_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
|
||||
const AGRP_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit and outfit worn when somebody is shot
|
||||
const AGRP_FORENSICS_BODY = 3; // Body. A dead body lol
|
||||
const AGRP_FORENSICS_HAIR = 4; // Hair.
|
||||
const AGRP_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
|
||||
const AGRP_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank and unfinished food items when eaten
|
||||
const AGRP_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,15 +1,53 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gate.js
|
||||
// DESC: Provides gate functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Gate Owner Types
|
||||
const AGRP_GATEOWNER_NONE = 0; // Not owned
|
||||
const AGRP_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
|
||||
const AGRP_GATEOWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_GATEOWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_GATEOWNER_FACTION = 4; // Owned by a faction
|
||||
const AGRP_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
|
||||
const AGRP_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
|
||||
const AGRP_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class GateData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.scriptName = "";
|
||||
this.enabled = false;
|
||||
this.position = toVector3(0.0, 0.0, 0.0);
|
||||
this.locked = true;
|
||||
this.ownerType = AGRP_GATEOWNER_NONE;
|
||||
this.ownerId = 0;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["gate_id"]);
|
||||
this.name = toString(dbAssoc["gate_name"]);
|
||||
this.scriptName = toString(dbAssoc["gate_script_name"]);
|
||||
this.enabled = intToBool(toInteger(dbAssoc["gate_enabled"]));
|
||||
this.position = toVector3(toFloat(dbAssoc["gate_pos_x"]), toFloat(dbAssoc["gate_pos_y"]), toFloat(dbAssoc["gate_pos_z"]));
|
||||
this.ownerType = toInteger(dbAssoc["gate_owner_type"]);
|
||||
this.ownerId = toInteger(dbAssoc["gate_owner_id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initGateScript() {
|
||||
logToConsole(LOG_INFO, `[VRR.Gate]: Initializing gate script ...`);
|
||||
logToConsole(LOG_INFO, `[VRR.Gate]: Gate script initialized successfully!`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Gate]: Initializing gate script ...`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Gate]: Gate script initialized successfully!`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -17,66 +55,66 @@ function initGateScript() {
|
||||
function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
let gateData = getGateData(vehicle);
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_PUBLIC) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_PUBLIC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_PLAYER) {
|
||||
if(gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_PLAYER) {
|
||||
if (gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_CLAN) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_CLAN) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(gateData.ownerId == getPlayerCurrentSubAccount(client).clan) {
|
||||
if(gateData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) {
|
||||
if (gateData.ownerId == getPlayerCurrentSubAccount(client).clan) {
|
||||
if (gateData.clanRank <= getPlayerCurrentSubAccount(client).clanRank) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_FACTION) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_FACTION) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(gateData.ownerId == getPlayerCurrentSubAccount(client).faction) {
|
||||
if(gateData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) {
|
||||
if (gateData.ownerId == getPlayerCurrentSubAccount(client).faction) {
|
||||
if (gateData.factionRank <= getPlayerCurrentSubAccount(client).factionRank) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_JOB) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_JOB) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(gateData.ownerId == getPlayerCurrentSubAccount(client).job) {
|
||||
if (gateData.ownerId == getPlayerCurrentSubAccount(client).job) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_BUSINESS) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_BUSINESS) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(gateData.ownerId))) {
|
||||
if (canPlayerManageBusiness(client, getBusinessIdFromDatabaseId(gateData.ownerId))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(gateData.ownerType == VRR_GATEOWNER_HOUSE) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
|
||||
if (gateData.ownerType == AGRP_GATEOWNER_HOUSE) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(canPlayerManageHouse(client, getHouseIdFromDatabaseId(gateData.ownerId))) {
|
||||
if (canPlayerManageHouse(client, getHouseIdFromDatabaseId(gateData.ownerId))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -87,7 +125,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
|
||||
// ===========================================================================
|
||||
|
||||
function getGateData(gateId) {
|
||||
if(typeof getServerData().gates[gateId] != "undefined") {
|
||||
if (typeof getServerData().gates[gateId] != "undefined") {
|
||||
return getServerData().gates[gateId];
|
||||
}
|
||||
|
||||
@@ -98,8 +136,8 @@ function getGateData(gateId) {
|
||||
|
||||
function getClosestGate(position) {
|
||||
let closest = 0;
|
||||
for(let i in getServerData().gates[getGame()]) {
|
||||
if(getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) {
|
||||
for (let i in getServerData().gates[getGame()]) {
|
||||
if (getDistance(getServerData().gates[i].position, position) < getDistance(getServerData().gates[closest].position, position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
@@ -112,11 +150,11 @@ function getClosestGate(position) {
|
||||
function triggerGateCommand(command, params, client) {
|
||||
let closestGate = getClosestGate(getPlayerPosition(client));
|
||||
|
||||
if(!getGateData(closestGate)) {
|
||||
if (!getGateData(closestGate)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidGate"));
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveGateKeys(client, closestGate)) {
|
||||
if (!doesPlayerHaveGateKeys(client, closestGate)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoGateAccess"));
|
||||
return false;
|
||||
}
|
||||
@@ -127,11 +165,11 @@ function triggerGateCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function saveAllGatesToDatabase() {
|
||||
if(getServerConfig().devServer) {
|
||||
if (getServerConfig().devServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(let i in getServerData().gates) {
|
||||
for (let i in getServerData().gates) {
|
||||
saveGateToDatabase(i);
|
||||
}
|
||||
}
|
||||
@@ -139,26 +177,26 @@ function saveAllGatesToDatabase() {
|
||||
// ===========================================================================
|
||||
|
||||
function saveGateToDatabase(gateId) {
|
||||
if(getGateData(gateId) == null) {
|
||||
if (getGateData(gateId) == null) {
|
||||
// Invalid gate data
|
||||
return false;
|
||||
}
|
||||
|
||||
let tempGateData = getGateData(gateId);
|
||||
|
||||
if(tempGateData.databaseId == -1) {
|
||||
if (tempGateData.databaseId == -1) {
|
||||
// Temp gate, no need to save
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!tempGateData.needsSaved) {
|
||||
if (!tempGateData.needsSaved) {
|
||||
// Gate hasn't changed. No need to save.
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saving gate ${tempGateData.databaseId} to database ...`);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Gate]: Saving gate ${tempGateData.databaseId} to database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeGateName = escapeDatabaseString(tempGateData.name);
|
||||
let safeGateScriptName = escapeDatabaseString(tempGateData.scriptName);
|
||||
|
||||
@@ -175,7 +213,7 @@ function saveGateToDatabase(gateId) {
|
||||
];
|
||||
|
||||
let dbQuery = null;
|
||||
if(tempGateData.databaseId == 0) {
|
||||
if (tempGateData.databaseId == 0) {
|
||||
let queryString = createDatabaseInsertQuery("gate_main", data);
|
||||
dbQuery = queryDatabase(dbConnection, queryString);
|
||||
tempGateData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
@@ -190,7 +228,7 @@ function saveGateToDatabase(gateId) {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return true;
|
||||
}
|
||||
logToConsole(LOG_VERBOSE, `[VRR.Gate]: Saved gate ${gateDataId} to database!`);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Gate]: Saved gate ${gateDataId} to database!`);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -198,20 +236,20 @@ function saveGateToDatabase(gateId) {
|
||||
// ===========================================================================
|
||||
|
||||
function loadGatesFromDatabase() {
|
||||
logToConsole(LOG_INFO, "[VRR.Gate]: Loading gates from database ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Gate]: Loading gates from database ...");
|
||||
|
||||
let tempGates = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc;
|
||||
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
let tempGateData = new GateData(dbAssoc);
|
||||
tempGates.push(tempGateData);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
|
||||
}
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -219,7 +257,7 @@ function loadGatesFromDatabase() {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.Gate]: ${tempGates.length} gates loaded from database successfully!`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Gate]: ${tempGates.length} gates loaded from database successfully!`);
|
||||
return tempGates;
|
||||
}
|
||||
|
||||
|
||||
149
scripts/server/gps.js
Normal file
149
scripts/server/gps.js
Normal file
@@ -0,0 +1,149 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gps.js
|
||||
// DESC: Provides GPS functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// GPS State Types
|
||||
const AGRP_GPS_TYPE_NONE = 0; // None (invalid)
|
||||
const AGRP_GPS_TYPE_BUSINESS = 1; // Business
|
||||
const AGRP_GPS_TYPE_POLICE = 2; // Police Station
|
||||
const AGRP_GPS_TYPE_HOSPITAL = 3; // Hospital
|
||||
const AGRP_GPS_TYPE_JOB = 4; // Job
|
||||
const AGRP_GPS_TYPE_GAMELOC = 5; // Game Location
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function gpsCommand(command, params, client) {
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
|
||||
|
||||
let locationType = AGRP_GPS_TYPE_NONE;
|
||||
let useType = AGRP_ITEM_USE_TYPE_NONE;
|
||||
let blipColour = "white";
|
||||
|
||||
switch (toLowerCase(params)) {
|
||||
case "police":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_POLICE;
|
||||
break;
|
||||
|
||||
case "hospital":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_HOSPITAL;
|
||||
break;
|
||||
|
||||
case "job":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_JOB;
|
||||
break;
|
||||
|
||||
case "skin":
|
||||
case "skins":
|
||||
case "clothes":
|
||||
case "player":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_SKIN;
|
||||
break;
|
||||
|
||||
case "gun":
|
||||
case "guns":
|
||||
case "weapon":
|
||||
case "weapons":
|
||||
case "wep":
|
||||
case "weps":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_WEAPON;
|
||||
break;
|
||||
|
||||
case "food":
|
||||
case "eat":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_FOOD;
|
||||
break;
|
||||
|
||||
case "drink":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_DRINK;
|
||||
break;
|
||||
|
||||
case "alcohol":
|
||||
case "booze":
|
||||
case "bar":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_ALCOHOL;
|
||||
break;
|
||||
|
||||
case "repair":
|
||||
case "carrepair":
|
||||
case "vehrepair":
|
||||
case "spray":
|
||||
case "fix":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_VEHREPAIR;
|
||||
break;
|
||||
|
||||
case "vehiclecolour":
|
||||
case "vehcolour":
|
||||
case "carcolour":
|
||||
case "colour":
|
||||
blipColour = "businessBlue"
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
useType = AGRP_ITEM_USE_TYPE_VEHCOLOUR;
|
||||
break;
|
||||
|
||||
default: {
|
||||
let itemTypeId = getItemTypeFromParams(params);
|
||||
if (getItemTypeData(itemTypeId) != false) {
|
||||
locationType = AGRP_GPS_TYPE_BUSINESS;
|
||||
blipColour = "businessBlue";
|
||||
useType = getItemTypeData(itemTypeId).useType;
|
||||
} else {
|
||||
let gameLocationId = getGameLocationFromParams(params);
|
||||
if (gameLocationId != false) {
|
||||
position = getGameConfig().locations[getServerGame()][gameLocationId][1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (locationType == AGRP_GPS_TYPE_NONE) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (locationType == AGRP_GPS_TYPE_BUSINESS) {
|
||||
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
|
||||
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
|
||||
}
|
||||
|
||||
if (locationType == AGRP_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;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,81 +1,99 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: gui.js
|
||||
// DESC: Provides GUI functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Prompts (used for client GUI prompt responses)
|
||||
const AGRP_PROMPT_NONE = 0;
|
||||
const AGRP_PROMPT_CREATEFIRSTCHAR = 1;
|
||||
const AGRP_PROMPT_BIZORDER = 2;
|
||||
const AGRP_PROMPT_GIVEVEHTOCLAN = 3;
|
||||
const AGRP_PROMPT_GIVEBIZTOCLAN = 4;
|
||||
const AGRP_PROMPT_GIVEHOUSETOCLAN = 5;
|
||||
const AGRP_PROMPT_BUYBIZ = 6;
|
||||
const AGRP_PROMPT_BUYHOUSE = 7;
|
||||
const AGRP_PROMPT_RESETKEYBINDS = 8;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initGUIScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.GUI]: Initializing GUI script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.GUI]: GUI script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.GUI]: Initializing GUI script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.GUI]: GUI script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playerPromptAnswerNo(client) {
|
||||
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
|
||||
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
|
||||
|
||||
switch(getPlayerData(client).promptType) {
|
||||
case VRR_PROMPT_CREATEFIRSTCHAR:
|
||||
switch (getPlayerData(client).promptType) {
|
||||
case AGRP_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() { disconnectPlayer(client); }, 5000);
|
||||
showPlayerErrorGUI(client, getLocaleString(client, "DidNotCreateCharacter"), getLocaleString(client, getLocaleString(client, "GUIWarningTitle")));
|
||||
getPlayerData(targetClient).customDisconnectReason = "FailedToCreateCharacter";
|
||||
setTimeout(function () { disconnectPlayer(client); }, 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!");
|
||||
}
|
||||
case AGRP_PROMPT_BIZORDER:
|
||||
if (getPlayerData(client).businessOrderAmount > 0) {
|
||||
if (canPlayerUseGUI(client)) {
|
||||
showPlayerErrorGUI(client, getLocaleString(client, "BusinessOrderCanceled"), getLocaleString(client, "Alert"));
|
||||
} else {
|
||||
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
|
||||
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, getLocaleString(client, "BusinessOrderCanceled"));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
showPlayerErrorGUI(client, getLocaleString(client, "NotOrderingAnyBusinessItems"), getLocaleString(client, getLocaleString(client, "GUIWarningTitle")));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
messagePlayerError(client, getLocaleString(client, "NoPromptReject"));
|
||||
submitBugReport(client, `[AUTOMATED REPORT] Tried to reject invalid prompt type: ${getPlayerData(client).promptType}`);
|
||||
break;
|
||||
}
|
||||
|
||||
getPlayerData(client).promptType = VRR_PROMPT_NONE;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playerPromptAnswerYes(client) {
|
||||
if(getPlayerData(client).promptType == VRR_PROMPT_NONE) {
|
||||
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
|
||||
|
||||
switch(getPlayerData(client).promptType) {
|
||||
case VRR_PROMPT_CREATEFIRSTCHAR: {
|
||||
switch (getPlayerData(client).promptType) {
|
||||
case AGRP_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");
|
||||
case AGRP_PROMPT_BIZORDER: {
|
||||
if (getPlayerData(client).businessOrderAmount > 0) {
|
||||
if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.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, getLocaleString(client, "BusinessOrderNotEnoughMoney"), getLocaleString(client, "BusinessOrderCanceled"));
|
||||
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);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.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, getLocaleString(client, "BusinessOrderSuccessInfo", getPlayerData(client).businessOrderAmount, getItemTypeData(getPlayerData(client).businessOrderItem).name, getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue), getPlayerData(client).businessOrderCost), getLocaleString(client, "GUIInfoTitle"));
|
||||
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, AGRP_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);
|
||||
@@ -90,100 +108,100 @@ function playerPromptAnswerYes(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEVEHTOCLAN: {
|
||||
if(!isPlayerInAnyVehicle(client)) {
|
||||
case AGRP_PROMPT_GIVEVEHTOCLAN: {
|
||||
if (!isPlayerInAnyVehicle(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getVehicleData(getPlayerVehicle(client))) {
|
||||
if (!getVehicleData(getPlayerVehicle(client))) {
|
||||
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getVehicleData(getPlayerVehicle(client)).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getVehicleData(getPlayerVehicle(client)).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
||||
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)).ownerType = AGRP_VEHOWNER_CLAN;
|
||||
getVehicleData(getPlayerVehicle(client)).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveVehicleToClan", getVehicleName(getPlayerVehicle(client))));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEHOUSETOCLAN: {
|
||||
case AGRP_PROMPT_GIVEHOUSETOCLAN: {
|
||||
let houseId = getPlayerHouse(client);
|
||||
if(!houseId) {
|
||||
if (!houseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getHouseData(houseId).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_CLAN;
|
||||
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_CLAN;
|
||||
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveHouseToClan"));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_GIVEBIZTOCLAN: {
|
||||
case AGRP_PROMPT_GIVEBIZTOCLAN: {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if(!businessId) {
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getBusinessData(businessId).ownerType != VRR_VEHOWNER_PLAYER) {
|
||||
if (getBusinessData(businessId).ownerType != AGRP_VEHOWNER_PLAYER) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
||||
if (getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_CLAN;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_CLAN;
|
||||
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).clan;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "GaveBusinessToClan"));
|
||||
//messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}set their {vehiclePurple}${getVehicleName(vehicle)} {MAINCOLOUR}owner to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan`);
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_BUYHOUSE: {
|
||||
case AGRP_PROMPT_BUYHOUSE: {
|
||||
let houseId = getPlayerHouse(client);
|
||||
if(!houseId) {
|
||||
if (!houseId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getHouseData(houseId).buyPrice <= 0) {
|
||||
if (getHouseData(houseId).buyPrice <= 0) {
|
||||
messagePlayerError(client, getLocaleString(client, "HouseNotForSale"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) {
|
||||
if (getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) {
|
||||
messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getHouseData(houseId).ownerType = VRR_HOUSEOWNER_PLAYER;
|
||||
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER;
|
||||
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
|
||||
getHouseData(houseId).buyPrice = 0;
|
||||
getHouseData(houseId).needsSaved = true;
|
||||
@@ -194,41 +212,52 @@ function playerPromptAnswerYes(client) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VRR_PROMPT_BUYBIZ: {
|
||||
case AGRP_PROMPT_BUYBIZ: {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if(!businessId) {
|
||||
if (!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getBusinessData(businessId).buyPrice <= 0) {
|
||||
if (getBusinessData(businessId).buyPrice <= 0) {
|
||||
messagePlayerError(client, getLocaleString(client, "BusinessNotForSale"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) {
|
||||
if (getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) {
|
||||
messagePlayerError(client, getLocaleString(client, "BusinessPurchaseNotEnoughMoney"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getBusinessData(businessId).ownerType = VRR_BIZOWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerType = AGRP_BIZ_OWNER_PLAYER;
|
||||
getBusinessData(businessId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
|
||||
getBusinessData(businessId).buyPrice = 0;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
updateBusinessPickupLabelData(businessId);
|
||||
|
||||
messageDiscordEventChannel(`🏢 ${getCharacterFullName(client)} is now the owner of *${getBusinessData(businessId).name}*!`);
|
||||
messagePlayerSuccess(client, `🏢 You are now the owner of {businessBlue}${getBusinessData(businessId).name}`);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "BusinessPurchased", `{businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR}`));
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROMPT_RESETKEYBINDS: {
|
||||
messagePlayerSuccess(client, getLocaleString(client, "KeyBindsReset"));
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_PROMPT_COPYKEYBINDSTOSERVER: {
|
||||
//messagePlayerSuccess(client, getLocaleString(client, "KeyBindsCopiedToServer", serverName));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`);
|
||||
messagePlayerError(client, getLocaleString(client, "NoPromptAccept"));
|
||||
submitBugReport(client, `[AUTOMATED REPORT] Tried to accept invalid prompt type: ${getPlayerData(client).promptType}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getPlayerData(client).promptType = VRR_PROMPT_NONE;
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -258,7 +287,7 @@ function playerToggledGUI(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function showPlayerTwoFactorAuthenticationGUI(client) {
|
||||
sendNetworkEventToPlayer("vrr.2fa", client);
|
||||
sendNetworkEventToPlayer("agrp.2fa", client);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: help.js
|
||||
// DESC: Provides update info, help commands, and documentation
|
||||
@@ -8,8 +9,8 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initHelpScript() {
|
||||
logToConsole(LOG_INFO, `[VRR.Help]: Initializing help script ...`);
|
||||
logToConsole(LOG_INFO, `[VRR.Help]: Help script initialized successfully!`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Help]: Initializing help script ...`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Help]: Help script initialized successfully!`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -48,14 +49,12 @@ let randomTips = [
|
||||
// ===========================================================================
|
||||
|
||||
function helpCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
showMainHelpMessage(client);
|
||||
return false;
|
||||
}
|
||||
|
||||
let splitParams = params.split(" ");
|
||||
|
||||
switch(toLowerCase(getParam(params, " ", 1))) {
|
||||
switch (toLowerCase(getParam(params, " ", 1))) {
|
||||
case "account":
|
||||
showAccountHelpMessage(client);
|
||||
break;
|
||||
@@ -195,8 +194,8 @@ function showMainHelpMessage(client) {
|
||||
function showAccountHelpMessage(client) {
|
||||
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", 0, getServerName()));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 1, `{ALTCOLOUR}/changepass{MAINCOLOUR}`, `{ALTCOLOUR}/resetpass{MAINCOLOUR}`));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "AccountHelp", 2, `{ALTCOLOUR}/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert{MAINCOLOUR}`));
|
||||
}
|
||||
|
||||
@@ -244,7 +243,7 @@ function showChatHelpMessage(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function showRulesHelpMessage(client) {
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRulesList")));
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderServerRules")));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 0));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 1));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "RulesHelp", 2));
|
||||
@@ -328,7 +327,7 @@ function showRadioHelpMessage(client) {
|
||||
|
||||
function showWealthAndTaxHelpMessage(client) {
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderWealthandTaxHelp")));
|
||||
messagePlayerHelpContent(client, getGroupedLocaleString(client, "WealthAndTaxHelp", 0, `{ALTCOLOUR}${100*getGlobalConfig().economy.incomeTaxRate}%{MAINCOLOUR}`));
|
||||
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}`));
|
||||
@@ -337,7 +336,7 @@ function showWealthAndTaxHelpMessage(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function showCommandHelpMessage(client, commandName) {
|
||||
if(!commandName) {
|
||||
if (!commandName) {
|
||||
messagePlayerSyntax(client, `${getCommandSyntaxText("help")}command <command name>`);
|
||||
return false;
|
||||
}
|
||||
@@ -345,7 +344,7 @@ function showCommandHelpMessage(client, commandName) {
|
||||
commandName = toLowerCase(commandName);
|
||||
commandName = commandName.trim();
|
||||
|
||||
if(commandName.slice(0, 1) == "/") {
|
||||
if (commandName.slice(0, 1) == "/") {
|
||||
commandName = commandName.slice(1);
|
||||
}
|
||||
|
||||
@@ -355,7 +354,7 @@ function showCommandHelpMessage(client, commandName) {
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
|
||||
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`);
|
||||
|
||||
if(aliases.length > 0) {
|
||||
if (aliases.length > 0) {
|
||||
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
|
||||
} else {
|
||||
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
|
||||
@@ -394,9 +393,29 @@ function helpGetCarCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function helpGetSkinCommand(command, params, client) {
|
||||
function helpGetSkinCommand(command, params, client) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "SkinCommandHelp", `{ALTCOLOUR}/info skin{MAINCOLOUR}`));
|
||||
messagePlayerAlert(client, ``);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function hasPlayerSeenActionTip(client, seenActionTipFlagName) {
|
||||
let seenActionTipFlagValue = getSeenActionTipsValue(seenActionTipFlagName);
|
||||
|
||||
if (hasBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function markPlayerActionTipSeen(client, seenActionTipFlagName) {
|
||||
let seenActionTipFlagValue = getSeenActionTipsValue(seenActionTipFlagName);
|
||||
|
||||
getPlayerData(client).accountData.seenActionTips = addBitFlag(getPlayerData(client).accountData.seenActionTips, seenActionTipFlagValue);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,86 +0,0 @@
|
||||
// Shared Scripts
|
||||
require("../scripts/shared/const.js");
|
||||
require("../scripts/shared/utilities.js");
|
||||
require("../scripts/shared/gamedata.js");
|
||||
|
||||
// Multiplayer Mod (Wrapped Natives)
|
||||
require("scripts/server/native/ragemp.js");
|
||||
|
||||
// Server Scripts
|
||||
require("scripts/server/class.js");
|
||||
require("scripts/server/accent.js");
|
||||
require("scripts/server/account.js");
|
||||
require("scripts/server/animation.js");
|
||||
require("scripts/server/anticheat.js");
|
||||
require("scripts/server/ban.js");
|
||||
require("scripts/server/bitflag.js");
|
||||
require("scripts/server/business.js");
|
||||
require("scripts/server/chat.js");
|
||||
require("scripts/server/clan.js");
|
||||
require("scripts/server/client.js");
|
||||
require("scripts/server/colour.js");
|
||||
require("scripts/server/const.js");
|
||||
require("scripts/server/database.js");
|
||||
require("scripts/server/developer.js");
|
||||
require("scripts/server/discord.js");
|
||||
require("scripts/server/economy.js");
|
||||
require("scripts/server/email.js");
|
||||
require("scripts/server/event.js");
|
||||
require("scripts/server/fishing.js");
|
||||
require("scripts/server/gui.js");
|
||||
require("scripts/server/help.js");
|
||||
require("scripts/server/house.js");
|
||||
require("scripts/server/item.js");
|
||||
require("scripts/server/job.js");
|
||||
require("scripts/server/keybind.js");
|
||||
require("scripts/server/locale.js");
|
||||
require("scripts/server/messaging.js");
|
||||
require("scripts/server/misc.js");
|
||||
require("scripts/server/npc.js");
|
||||
require("scripts/server/staff.js");
|
||||
require("scripts/server/race.js");
|
||||
require("scripts/server/radio.js");
|
||||
require("scripts/server/security.js");
|
||||
require("scripts/server/subaccount.js");
|
||||
require("scripts/server/timers.js");
|
||||
require("scripts/server/trigger.js");
|
||||
require("scripts/server/utilities.js");
|
||||
require("scripts/server/vehicle.js");
|
||||
require("scripts/server/config.js");
|
||||
require("scripts/server/core.js");
|
||||
require("scripts/server/command.js");
|
||||
|
||||
// Server Business Scripts
|
||||
require("scripts/server/business/bakery.js");
|
||||
require("scripts/server/business/bar.js");
|
||||
require("scripts/server/business/burger.js");
|
||||
require("scripts/server/business/clothing.js");
|
||||
require("scripts/server/business/club.js");
|
||||
require("scripts/server/business/fuel.js");
|
||||
require("scripts/server/business/mechanic.js");
|
||||
require("scripts/server/business/pizza.js");
|
||||
require("scripts/server/business/restaurant.js");
|
||||
require("scripts/server/business/vehicle.js");
|
||||
require("scripts/server/business/weapon.js");
|
||||
|
||||
// Server Job Scripts
|
||||
require("scripts/server/job/bus.js");
|
||||
require("scripts/server/job/drug.js");
|
||||
require("scripts/server/job/fire.js");
|
||||
require("scripts/server/job/garbage.js");
|
||||
require("scripts/server/job/medic.js");
|
||||
require("scripts/server/job/police.js");
|
||||
require("scripts/server/job/taxi.js");
|
||||
require("scripts/server/job/weapon.js");
|
||||
|
||||
// Server Item Scripts
|
||||
require("scripts/server/item/food.js");
|
||||
require("scripts/server/item/drink.js");
|
||||
require("scripts/server/item/walkie-talkie.js");
|
||||
require("scripts/server/item/phone.js");
|
||||
require("scripts/server/item/handcuff.js");
|
||||
require("scripts/server/item/rope.js");
|
||||
require("scripts/server/item/tazer.js");
|
||||
|
||||
// Startup
|
||||
require("scripts/server/startup.js");
|
||||
41
scripts/server/insurance.js
Normal file
41
scripts/server/insurance.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: insurance.js
|
||||
// DESC: Provides insurance commands, functions, and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Insurance Account Owner Types
|
||||
const AGRP_INS_ACCT_OWNER_NONE = 0; // None
|
||||
const AGRP_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
|
||||
const AGRP_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
|
||||
const AGRP_INS_ACCT_OWNER_CLAN = 3; // Clan owns insurance company
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Insurance Account Entity Types
|
||||
const AGRP_INS_ACCT_ENTITY_NONE = 0; // None
|
||||
const AGRP_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
|
||||
const AGRP_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
|
||||
const AGRP_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
|
||||
const AGRP_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
|
||||
const AGRP_INS_ACCT_ENTITY_HOUSE = 5; // House Insurance
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Insurance Account History Types
|
||||
const AGRP_INS_ACCT_HISTORY_NONE = 0; // None
|
||||
const AGRP_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
|
||||
const AGRP_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
|
||||
const AGRP_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
|
||||
const AGRP_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
|
||||
const AGRP_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
|
||||
const AGRP_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
|
||||
const AGRP_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
|
||||
const AGRP_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
|
||||
const AGRP_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: drink.js
|
||||
// DESC: Provides features and usage for the drink item type
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: food.js
|
||||
// DESC: Provides features and usage for the food item type
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: handcuff.js
|
||||
// DESC: Provides features and usage for the handcuff item type
|
||||
@@ -10,27 +11,21 @@
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerHandCuffed(client) {
|
||||
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
|
||||
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function handCuffPlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED;
|
||||
setPlayerControlState(client, false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function unHandCuffPlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
setPlayerControlState(client, true);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerSurrendered(client) {
|
||||
return true; //(getPlayerData(client).pedState == VRR_PEDSTATE_TAZED || getPlayerData(client).pedState == VRR_PEDSTATE_HANDSUP);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: phone.js
|
||||
// DESC: Provides features and usage for the phone item type
|
||||
@@ -8,9 +9,9 @@
|
||||
// ===========================================================================
|
||||
|
||||
function getItemWithPhoneNumber(phoneNumber) {
|
||||
for(let i in getServerData().items) {
|
||||
if(getItemTypeData(getItemData(i).itemTypeIndex).useType == VRR_ITEM_USETYPE_PHONE) {
|
||||
if(getItemData(i).value == phoneNumber) {
|
||||
for (let i in getServerData().items) {
|
||||
if (getItemTypeData(getItemData(i).itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_PHONE) {
|
||||
if (getItemData(i).value == phoneNumber) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -30,15 +31,15 @@ function ringPhoneForNearbyPlayers(itemIndex) {
|
||||
/*
|
||||
if(isPhoneItemEnabled(itemIndex)) {
|
||||
switch(getItemData(itemIndex).ownerType) {
|
||||
case VRR_ITEM_OWNER_GROUND:
|
||||
case AGRP_ITEM_OWNER_GROUND:
|
||||
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
|
||||
break;
|
||||
|
||||
case VRR_ITEM_OWNER_VEHTRUNK:
|
||||
case AGRP_ITEM_OWNER_VEHTRUNK:
|
||||
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
|
||||
break;
|
||||
|
||||
case VRR_ITEM_OWNER_VEHDASH:
|
||||
case AGRP_ITEM_OWNER_VEHDASH:
|
||||
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: handcuff.js
|
||||
// DESC: Provides features and usage for the handcuff item type
|
||||
@@ -10,20 +11,20 @@
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerTied(client) {
|
||||
return (getPlayerData(client).pedState == VRR_PEDSTATE_BINDED);
|
||||
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function ropeTiePlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_BINDED;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED;
|
||||
setPlayerControlState(client, false);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function ropeUnTiePlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
setPlayerControlState(client, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: tazer.js
|
||||
// DESC: Provides features and usage for the tazer item type
|
||||
@@ -10,21 +11,21 @@
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerTazed(client) {
|
||||
return (getPlayerData(client).pedState == VRR_PEDSTATE_TAZED);
|
||||
return (getPlayerData(client).pedState == AGRP_PEDSTATE_TAZED);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function tazePlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_TAZED;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_TAZED;
|
||||
setPlayerControlState(client, false);
|
||||
|
||||
let animationId = getAnimationFromParams("tazed");
|
||||
if(animationId != false) {
|
||||
if (animationId != false) {
|
||||
forcePlayerPlayAnimation(client, animationId);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
unTazePlayer(client);
|
||||
doActionToNearbyPlayers(client, `The tazer effect wears off`);
|
||||
}, getGlobalConfig().tazerEffectDuration);
|
||||
@@ -33,7 +34,7 @@ function tazePlayer(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function unTazePlayer(client) {
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_READY;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
|
||||
setPlayerControlState(client, true);
|
||||
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: walkie-talkie.js
|
||||
// DESC: Provides features and usage for the walkie-talkie item type
|
||||
@@ -8,11 +9,11 @@
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerActiveWalkieTalkieFrequency(client) {
|
||||
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_WALKIETALKIE);
|
||||
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE);
|
||||
|
||||
if(walkieTalkieSlot != -1) {
|
||||
if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
|
||||
if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
|
||||
if (walkieTalkieSlot != -1) {
|
||||
if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
|
||||
if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
|
||||
return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +32,7 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
|
||||
// if(isPlayerSpawned(clients[i])) {
|
||||
// if(!isSamePlayer(transmittingPlayer, clients[i])) {
|
||||
// if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) {
|
||||
// if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], VRR_ITEM_USETYPE_WALKIETALKIE)]).enabled) {
|
||||
// if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], AGRP_ITEM_USE_TYPE_WALKIETALKIE)]).enabled) {
|
||||
// walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
|
||||
// }
|
||||
// }
|
||||
@@ -40,10 +41,10 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
|
||||
//}
|
||||
|
||||
let items = getServerData().items;
|
||||
for(let i in items) {
|
||||
if(items[i].enabled) {
|
||||
if(getItemTypeData(items[i].itemTypeIndex).useType == VRR_ITEM_USETYPE_WALKIETALKIE) {
|
||||
if(items[i].value == radioFrequency) {
|
||||
for (let i in items) {
|
||||
if (items[i].enabled) {
|
||||
if (getItemTypeData(items[i].itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_WALKIETALKIE) {
|
||||
if (items[i].value == radioFrequency) {
|
||||
walkieTalkieIncomingToNearbyPlayers(null, messageText, getItemPosition(i));
|
||||
}
|
||||
}
|
||||
@@ -55,7 +56,7 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
|
||||
|
||||
function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
|
||||
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
|
||||
for(let i in clients) {
|
||||
for (let i in clients) {
|
||||
messagePlayerNormal(clients[i], `[#CCCCCC]${getCharacterFullName(client)} {ALTCOLOUR}(to radio): {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -64,12 +65,12 @@ function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
|
||||
|
||||
function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = null) {
|
||||
let prefix = `{ALTCOLOUR}(Nearby radio)`;
|
||||
if(client != null) {
|
||||
if (client != null) {
|
||||
prefix = `${getCharacterFullName(client)} {ALTCOLOUR}(from radio)`;
|
||||
}
|
||||
|
||||
let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance);
|
||||
for(let i in clients) {
|
||||
for (let i in clients) {
|
||||
messagePlayerNormal(clients[i], `[#CCCCCC]${prefix}: {MAINCOLOUR}${messageText}`);
|
||||
}
|
||||
}
|
||||
@@ -77,35 +78,35 @@ function walkieTalkieIncomingToNearbyPlayers(client, messageText, position = nul
|
||||
// ===========================================================================
|
||||
|
||||
function setWalkieTalkieFrequencyCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isNaN(params)) {
|
||||
if (isNaN(params)) {
|
||||
messagePlayerError(client, `The frequency channel must be a number!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
params = toInteger(params);
|
||||
|
||||
if(params < 100 || params > 500) {
|
||||
if (params < 100 || params > 500) {
|
||||
messagePlayerError(client, `The frequency channel must be between 100 and 500!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getPlayerActiveItem(client)) {
|
||||
if (!getPlayerActiveItem(client)) {
|
||||
messagePlayerError(client, `You aren't holding a walkie talkie!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getItemData(getPlayerActiveItem(client))) {
|
||||
if (!getItemData(getPlayerActiveItem(client))) {
|
||||
messagePlayerError(client, `You aren't holding a walkie talkie!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getItemData(getPlayerActiveItem(client)).enabled) {
|
||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) {
|
||||
if (getItemData(getPlayerActiveItem(client)).enabled) {
|
||||
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "use")) {
|
||||
messagePlayerError(client, `Your walkie talkie is turned off. Press ${toUpperCase(getKeyNameFromId(getPlayerKeyBindForCommand(client, "use")).key)} to turn it on`);
|
||||
} else {
|
||||
messagePlayerError(client, `Your walkie talkie is turned off. Type {ALTCOLOUR}/use {MAINCOLOUR}to turn it on`);
|
||||
@@ -113,24 +114,27 @@ function setWalkieTalkieFrequencyCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
getItemData(getPlayerActiveItem(client)).value = params*100;
|
||||
messagePlayerSuccess(client, `You set the frequency of you walkie talkie in slot ${getPlayerData(client).activeHotBarSlot} to ${getItemValueDisplayForItem(getPlayerActiveItem(client))}`)
|
||||
getItemData(getPlayerActiveItem(client)).value = params * 100;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "FrequencyChannelChanged", `Walkie Talkie`, `${getPlayerData(client).activeHotBarSlot + 1}`, `${getItemValueDisplayForItem(getPlayerActiveItem(client))}`));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function walkieTalkieChatCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, VRR_ITEM_USETYPE_WALKIETALKIE);
|
||||
if(!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
|
||||
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE);
|
||||
if (!getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
|
||||
messagePlayerError(client, "Please turn on a walkie talkie first!");
|
||||
return false;
|
||||
}
|
||||
|
||||
walkieTalkieTransmit(getPlayerActiveWalkieTalkieFrequency(client), params, client);
|
||||
|
||||
markPlayerActionTipSeen(client, "RadioCommandAfterEnablingWalkieTalkie");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: bus.js
|
||||
// DESC: Provides bus driver job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: drug.js
|
||||
// DESC: Provides drug runner/dealer job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: fire.js
|
||||
// DESC: Provides firefighter job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: garbage.js
|
||||
// DESC: Provides garbage collector job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: medic.js
|
||||
// DESC: Provides paramedic job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: pizza-delivery.js
|
||||
// DESC: Provides pizza delivery driver job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: police.js
|
||||
// DESC: Provides police officer job functions and usage
|
||||
@@ -8,22 +9,22 @@
|
||||
// ===========================================================================
|
||||
|
||||
function policeTazerCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
@@ -34,22 +35,22 @@ function policeTazerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function policeCuffCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
@@ -60,22 +61,22 @@ function policeCuffCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function policeArrestCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
@@ -86,22 +87,22 @@ function policeArrestCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function policeSearchCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
@@ -112,22 +113,22 @@ function policeSearchCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function policeDragCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
@@ -138,22 +139,22 @@ function policeDragCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function policeDetainCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUsePoliceJob(client)) {
|
||||
if (!canPlayerUsePoliceJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_POLICE)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_POLICE)) {
|
||||
messagePlayerError(client, "You don't have a police job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: taxi.js
|
||||
// DESC: Provides taxi driver job functions and usage
|
||||
@@ -8,22 +9,22 @@
|
||||
// ===========================================================================
|
||||
|
||||
function taxiSetFareCommand(command, params, client) {
|
||||
if(!canPlayerUseJobs(client)) {
|
||||
if (!canPlayerUseJobs(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use jobs.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!canPlayerUseTaxiJob(client)) {
|
||||
if (!canPlayerUseTaxiJob(client)) {
|
||||
messagePlayerError(client, "You are not allowed to use the taxi job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerWorking(client)) {
|
||||
if (!isPlayerWorking(client)) {
|
||||
messagePlayerError(client, "You are not working! Use /startwork first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveJobType(client, VRR_JOB_TAXI)) {
|
||||
if (!doesPlayerHaveJobType(client, AGRP_JOB_TAXI)) {
|
||||
messagePlayerError(client, "You don't have a taxi job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: weapon.js
|
||||
// DESC: Provides weapons dealer job functions and usage
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: keybind.js
|
||||
// DESC: Provides keybind handlers and functions
|
||||
@@ -8,76 +9,115 @@
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class KeyBindData {
|
||||
constructor(dbAssoc = false, key = 0, commandString = "", keyState = AGRP_KEYSTATE_UP) {
|
||||
this.databaseId = 0;
|
||||
this.key = key;
|
||||
this.account = 0;
|
||||
this.commandString = commandString;
|
||||
this.whenAdded = 0;
|
||||
this.enabled = true;
|
||||
this.keyState = false;
|
||||
this.index = -1;
|
||||
this.needsSaved = false;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_hotkey_id"];
|
||||
this.key = toInteger(dbAssoc["acct_hotkey_key"]);
|
||||
this.account = toInteger(dbAssoc["acct_hotkey_acct"]);
|
||||
this.commandString = dbAssoc["acct_hotkey_cmdstr"];
|
||||
this.whenAdded = dbAssoc["acct_hotkey_when_added"];
|
||||
this.enabled = intToBool(dbAssoc["acct_hotkey_enabled"]);
|
||||
this.keyState = intToBool(dbAssoc["acct_hotkey_down"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initKeyBindScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.KeyBind]: Initializing key bind script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.KeyBind]: Key bind script initialized!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.KeyBind]: Initializing key bind script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.KeyBind]: Key bind script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addKeyBindCommand(command, params, client) {
|
||||
if (areParamsEmpty(command)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let splitParams = params.split(" ");
|
||||
|
||||
let keyId = getKeyIdFromParams(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(!keyId) {
|
||||
messagePlayerError(client, "That key name/id is invalid!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(tempCommand)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
if (!keyId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidKeyBindName"));
|
||||
messagePlayerTip(client, getLocaleString(client, "KeyBindNameTip"));
|
||||
messagePlayerInfo(client, getLocaleString(client, "UniversalInlineExampleList", `{ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl{MAINCOLOR}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
addPlayerKeyBind(client, keyId, tempCommand, tempParams);
|
||||
messagePlayerSuccess(client, `You binded the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key to command: {ALTCOLOUR}/${tempCommand} ${tempParams}`);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "KeyBindRemoved", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))}{MAINCOLOUR}`, `{ALTCOLOUR}/${tempCommand} ${tempParams}`));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function removeKeyBindCommand(command, params, client) {
|
||||
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`);
|
||||
if (areParamsEmpty(command)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!keyId) {
|
||||
messagePlayerError(client, "That key name/id is invalid!");
|
||||
let keyId = getKeyIdFromParams(getParam(params, " ", 1));
|
||||
|
||||
if (!keyId) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidKeyBindName"));
|
||||
messagePlayerTip(client, getLocaleString(client, "KeyBindNameTip"));
|
||||
messagePlayerInfo(client, getLocaleString(client, "UniversalInlineExamplesList", `{ALTCOLOUR}1, 2, a, b, numplus, num1, f1, f2, pageup, delete, insert, rightshift, leftctrl{MAINCOLOR}`));
|
||||
return false;
|
||||
}
|
||||
|
||||
removePlayerKeyBind(client, keyId);
|
||||
messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
|
||||
messagePlayerSuccess(client, getLocaleString(client, "KeyBindRemoved", `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))}{MAINCOLOUR}`));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetKeyBindsCommand(command, params, client) {
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_RESETKEYBINDS;
|
||||
showPlayerPrompt(client, getLocaleString(client, "ResetAllKeyBindsConfirm"), getLocaleString(client, "GUIWarningTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
//removePlayerKeyBind(client, keyId);
|
||||
//messagePlayerSuccess(client, `You removed the keybind for the {ALTCOLOUR}${toUpperCase(getKeyNameFromId(keyId))} {MAINCOLOUR}key`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function copyKeyBindsToServerCommand(command, params, client) {
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_COPYKEYBINDSTOSERVER;
|
||||
showPlayerPrompt(client, getLocaleString(client, "CopyAllKeyBindsToServerConfirm"), getLocaleString(client, "GUIWarningTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
//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) {
|
||||
if (tempKey == true) {
|
||||
keyBindData.databaseId = -1;
|
||||
}
|
||||
|
||||
getPlayerData(client).keyBinds.push(keyBindData);
|
||||
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? VRR_KEYSTATE_COMBO : VRR_KEYSTATE_UP);
|
||||
sendAddAccountKeyBindToClient(client, keys, (keys.length > 1) ? AGRP_KEYSTATE_COMBO : AGRP_KEYSTATE_UP);
|
||||
|
||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
|
||||
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)}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
|
||||
sendPlayerEnterPropertyKey(client, keyId.key);
|
||||
} else {
|
||||
sendPlayerEnterPropertyKey(client, false);
|
||||
@@ -99,9 +139,9 @@ function removePlayerKeyBind(client, keyId) {
|
||||
getPlayerData(client).keyBinds = getPlayerData(client).keyBinds.filter(keyBind => keyBind.key != keyId);
|
||||
sendRemoveAccountKeyBindToClient(client, keyId);
|
||||
|
||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
|
||||
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)}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
|
||||
sendPlayerEnterPropertyKey(client, keyId.key);
|
||||
} else {
|
||||
sendPlayerEnterPropertyKey(client, false);
|
||||
@@ -111,8 +151,8 @@ function removePlayerKeyBind(client, keyId) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveKeyBindForCommand(client, command) {
|
||||
for(let i in getPlayerData(client).keyBinds) {
|
||||
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
|
||||
for (let i in getPlayerData(client).keyBinds) {
|
||||
if (toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -122,8 +162,8 @@ function doesPlayerHaveKeyBindForCommand(client, command) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerKeyBindForCommand(client, command) {
|
||||
for(let i in getPlayerData(client).keyBinds) {
|
||||
if(toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
|
||||
for (let i in getPlayerData(client).keyBinds) {
|
||||
if (toLowerCase(getPlayerData(client).keyBinds[i].commandString.split(" ")[0]) == toLowerCase(command)) {
|
||||
return getPlayerData(client).keyBinds[i];
|
||||
}
|
||||
}
|
||||
@@ -133,8 +173,8 @@ function getPlayerKeyBindForCommand(client, command) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesPlayerHaveKeyBindForKey(client, key) {
|
||||
for(let i in getPlayerData(client).keyBinds) {
|
||||
if(getPlayerData(client).keyBinds[i].key == key) {
|
||||
for (let i in getPlayerData(client).keyBinds) {
|
||||
if (getPlayerData(client).keyBinds[i].key == key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -150,8 +190,8 @@ function doesPlayerHaveKeyBindsDisabled(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerKeyBindForKey(client, key) {
|
||||
for(let i in getPlayerData(client).keyBinds) {
|
||||
if(getPlayerData(client).keyBinds[i].key == key) {
|
||||
for (let i in getPlayerData(client).keyBinds) {
|
||||
if (getPlayerData(client).keyBinds[i].key == key) {
|
||||
return getPlayerData(client).keyBinds[i];
|
||||
}
|
||||
}
|
||||
@@ -160,26 +200,28 @@ function getPlayerKeyBindForKey(client, key) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function playerUsedKeyBind(client, key) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
function playerUsedKeyBind(client, key, duration = 0) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerSpawned(client)) {
|
||||
if (!isPlayerSpawned(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
if(!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.KeyBind] ${getPlayerDisplayForConsole(client)} used keybind ${toUpperCase(getKeyNameFromId(key))} (${key})`);
|
||||
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForKey(client, key)) {
|
||||
let keyBindData = getPlayerKeyBindForKey(client, key);
|
||||
if(keyBindData.enabled) {
|
||||
if (keyBindData.enabled) {
|
||||
let splitCommandString = keyBindData.commandString.split(" ");
|
||||
let tempCommand = splitCommandString[0];
|
||||
let tempParams = "";
|
||||
if(splitCommandString.length > 1) {
|
||||
if (splitCommandString.length > 1) {
|
||||
tempParams = splitCommandString.slice(1).join(" ");
|
||||
}
|
||||
getPlayerData(client).keyBindDuration = duration;
|
||||
getCommand(toLowerCase(tempCommand)).handlerFunction(tempCommand, tempParams, client);
|
||||
getPlayerData(client).keyBindDuration = 0;
|
||||
//triggerEvent("OnPlayerCommand", null, tempCommand, tempParams, client);
|
||||
}
|
||||
}
|
||||
@@ -189,7 +231,7 @@ function playerUsedKeyBind(client, key) {
|
||||
|
||||
function sendAccountKeyBindsToClient(client) {
|
||||
sendClearKeyBindsToClient(client);
|
||||
for(let i in getPlayerData(client).keyBinds) {
|
||||
for (let i in getPlayerData(client).keyBinds) {
|
||||
sendAddAccountKeyBindToClient(client, getPlayerData(client).keyBinds[i].key, getPlayerData(client).keyBinds[i].keyState);
|
||||
}
|
||||
}
|
||||
@@ -197,13 +239,13 @@ function sendAccountKeyBindsToClient(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function showKeyBindListCommand(command, params, client) {
|
||||
let keybindList = getPlayerData(client).keyBinds.map(function(x) { return `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(x.key))}: {MAINCOLOUR}${x.commandString}`; });
|
||||
let keybindList = getPlayerData(client).keyBinds.map(function (x) { return `{ALTCOLOUR}${toUpperCase(getKeyNameFromId(x.key))}: {MAINCOLOUR}${x.commandString}`; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(keybindList, 6);
|
||||
|
||||
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderKeyBindsList")));
|
||||
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,53 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: locale.js
|
||||
// DESC: Provides locale structures, functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
class LocaleData {
|
||||
constructor() {
|
||||
this.id = 0;
|
||||
this.name = "";
|
||||
this.englishName = "";
|
||||
this.stringsFile = "";
|
||||
this.flagImagePath = "";
|
||||
this.contributors = "";
|
||||
this.countries = [];
|
||||
this.requiresUnicode = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let englishLocale = 0;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initLocaleScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Locale]: Initializing locale script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Locale]: Locale script initialized!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Locale]: Initializing locale script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Locale]: Locale script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getLocaleString(client, stringName, ...args) {
|
||||
let tempString = getRawLocaleString(stringName, getPlayerData(client).locale);
|
||||
if(tempString == "" || tempString == null || typeof tempString == "undefined") {
|
||||
logToConsole(LOG_WARN, `[VRR.Locale] Locale string missing for ${stringName} on language ${getLocaleData(getPlayerData(client).locale).englishName}`);
|
||||
if (client == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let tempString = getRawLocaleString(getPlayerData(client).locale, stringName);
|
||||
if (tempString == "" || tempString == null || typeof tempString == "undefined") {
|
||||
logToConsole(LOG_WARN, `[AGRP.Locale] Locale string missing for ${stringName} on language ${getLocaleData(getPlayerData(client).locale).englishName}`);
|
||||
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
|
||||
return "";
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -32,14 +56,32 @@ function getLocaleString(client, stringName, ...args) {
|
||||
// ===========================================================================
|
||||
|
||||
function getLanguageLocaleString(localeId, stringName, ...args) {
|
||||
let tempString = getRawLocaleString(stringName, localeId);
|
||||
if(tempString == "" || tempString == null || typeof tempString == "undefined") {
|
||||
logToConsole(LOG_WARN, `[VRR.Locale] Locale string missing for ${stringName} on language ${getLocaleData(getPlayerData(client).locale).englishName}`);
|
||||
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
|
||||
let tempString = getRawLocaleString(localeId, stringName);
|
||||
if (tempString == "" || tempString == null || typeof tempString == "undefined") {
|
||||
logToConsole(LOG_WARN, `[AGRP.Locale] Locale string missing for ${stringName} on language ${getLocaleData(localeId).englishName}`);
|
||||
submitBugReport(null, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getLocaleData(localeId).englishName}"`);
|
||||
return "";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getLanguageGroupedLocaleString(localeId, stringName, index, ...args) {
|
||||
let tempString = getRawGroupedLocaleString(localeId, stringName, index);
|
||||
if (tempString == "" || tempString == null || typeof tempString == "undefined") {
|
||||
logToConsole(LOG_WARN, `[AGRP.Locale] Locale string missing for index ${index} of "${stringName}" on language ${getLocaleData(localeId).englishName}`);
|
||||
submitBugReport(null, `(AUTOMATED REPORT) Locale string index ${index} of "${stringName}" is missing for "${getLocaleData(localeId).englishName}"`);
|
||||
return "";
|
||||
}
|
||||
|
||||
for (let i = 1; i <= args.length; i++) {
|
||||
tempString = tempString.replace(`{${i}}`, args[i - 1]);
|
||||
}
|
||||
|
||||
return tempString;
|
||||
@@ -48,10 +90,14 @@ function getLanguageLocaleString(localeId, stringName, ...args) {
|
||||
// ===========================================================================
|
||||
|
||||
function getGroupedLocaleString(client, stringName, index, ...args) {
|
||||
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);
|
||||
if (client == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
for(let i = 1; i <= args.length; i++) {
|
||||
tempString = tempString.replace(`{${i}}`, args[i-1]);
|
||||
let tempString = getRawGroupedLocaleString(getPlayerData(client).locale, stringName, index);
|
||||
|
||||
for (let i = 1; i <= args.length; i++) {
|
||||
tempString = tempString.replace(`{${i}}`, args[i - 1]);
|
||||
}
|
||||
|
||||
return tempString;
|
||||
@@ -59,7 +105,13 @@ function getGroupedLocaleString(client, stringName, index, ...args) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getRawLocaleString(stringName, localeId) {
|
||||
function getRawLocaleString(localeId, stringName) {
|
||||
if (typeof getLocaleStrings()[localeId][stringName] == "undefined") {
|
||||
logToConsole(LOG_WARN, `[AGRP.Locale] Locale string missing for ${getLocaleStrings()[localeId][stringName]} on language ${getLocaleData(localeId).englishName}[${localeId}]`);
|
||||
submitBugReport(null, `(AUTOMATED REPORT) Locale string is missing for "${getLocaleStrings()[localeId][stringName]}" on language ${getLocaleData(localeId).englishName}[${localeId}]`);
|
||||
return "";
|
||||
}
|
||||
|
||||
return getLocaleStrings()[localeId][stringName];
|
||||
|
||||
//if(findResourceByName("agrp_locale").exports.doesLocaleStringExist(localeId, stringName) == false) {
|
||||
@@ -74,7 +126,13 @@ function getRawLocaleString(stringName, localeId) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getRawGroupedLocaleString(stringName, localeId, index) {
|
||||
function getRawGroupedLocaleString(localeId, stringName, index) {
|
||||
if (typeof getLocaleStrings()[localeId][stringName][index] == "undefined") {
|
||||
logToConsole(LOG_WARN, `[AGRP.Locale] Grouped locale string missing for index ${index} of string ${getLocaleStrings()[localeId][stringName][index]} on language ${getLocaleData(localeId).englishName}[${localeId}]`);
|
||||
submitBugReport(null, `(AUTOMATED REPORT) Grouped locale string is missing for index ${index} of string "${getLocaleStrings()[localeId][stringName][index]}" on language ${getLocaleData(localeId).englishName}[${localeId}]`);
|
||||
return "";
|
||||
}
|
||||
|
||||
return getLocaleStrings()[localeId][stringName][index];
|
||||
|
||||
//if(findResourceByName("agrp_locale").exports.doesLocaleStringExist(localeId, stringName) == false) {
|
||||
@@ -90,6 +148,10 @@ function getRawGroupedLocaleString(stringName, localeId, index) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerLocaleName(client) {
|
||||
if (client == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let localeId = getPlayerData(client).locale;
|
||||
return getLocales()[localeId].englishName;
|
||||
}
|
||||
@@ -100,7 +162,7 @@ function loadAllLocaleStrings() {
|
||||
let tempLocaleStrings = {};
|
||||
|
||||
let locales = getGlobalConfig().locale.locales;
|
||||
for(let i in locales) {
|
||||
for (let i in locales) {
|
||||
let localeData = locales[i];
|
||||
let localeFile = JSON.parse(loadTextFile(`locale/${localeData.stringsFile}`));
|
||||
tempLocaleStrings[i] = localeFile;
|
||||
@@ -119,13 +181,13 @@ function getLocaleStrings() {
|
||||
|
||||
function getLocaleFromParams(params) {
|
||||
let locales = getLocales();
|
||||
if(isNaN(params)) {
|
||||
for(let i in locales) {
|
||||
if(toLowerCase(locales[i].isoCode).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in locales) {
|
||||
if (toLowerCase(locales[i].isoCode).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
|
||||
if(toLowerCase(locales[i].englishName).indexOf(toLowerCase(params)) != -1) {
|
||||
if (toLowerCase(locales[i].englishName).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -143,11 +205,11 @@ function getLocales() {
|
||||
// ===========================================================================
|
||||
|
||||
function showLocaleListCommand(command, params, client) {
|
||||
let localeList = getLocales().map(function(x) { return x[0]; });
|
||||
let localeList = getLocales().map(function (x) { return x[0]; });
|
||||
let chunkedList = splitArrayIntoChunks(localeList, 10);
|
||||
|
||||
messagePlayerInfo(client, getLocaleString(client, "HeaderLocaleList"));
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
@@ -155,14 +217,14 @@ function showLocaleListCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setLocaleCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let localeId = getLocaleFromParams(params);
|
||||
|
||||
if(!getLocaleData(localeId)) {
|
||||
if (!getLocaleData(localeId)) {
|
||||
messagePlayerInfo(client, getLocaleString(client, "InvalidLocale"));
|
||||
return false;
|
||||
}
|
||||
@@ -170,13 +232,14 @@ function setLocaleCommand(command, params, client) {
|
||||
getPlayerData(client).accountData.locale = localeId;
|
||||
getPlayerData(client).locale = localeId;
|
||||
messagePlayerSuccess(client, getLocaleString(client, "LocaleChanged1", getLocaleString(client, "LocaleNativeName")));
|
||||
//sendPlayerLocaleStrings(client);
|
||||
sendPlayerLocaleId(client, localeId);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getLocaleData(localeId) {
|
||||
if(typeof getLocales()[localeId] != "undefined") {
|
||||
if (typeof getLocales()[localeId] != "undefined") {
|
||||
return getLocales()[localeId];
|
||||
}
|
||||
|
||||
@@ -195,39 +258,53 @@ function reloadLocaleConfigurationCommand(command, params, client) {
|
||||
getServerData().cachedTranslationFrom.fill([]);
|
||||
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
|
||||
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`);
|
||||
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
|
||||
|
||||
messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function translateMessage(messageText, translateFrom = getGlobalConfig().locale.defaultLanguageId, translateTo = getGlobalConfig().locale.defaultLanguageId) {
|
||||
return new Promise(resolve => {
|
||||
if(translateFrom == translateTo) {
|
||||
if (translateFrom == translateTo) {
|
||||
resolve(messageText);
|
||||
}
|
||||
|
||||
for(let i in cachedTranslations[translateFrom][translateTo]) {
|
||||
if(cachedTranslations[translateFrom][translateTo][i][0] == 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].englishName} to ${getGlobalConfig().locale.locales[translateTo].englishName} - (${messageText}), (${cachedTranslations[translateFrom][translateTo][i][1]})`);
|
||||
resolve(cachedTranslations[translateFrom][translateTo][i][1]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let thisTranslationURL = getGlobalConfig().locale.translateURL.format(encodeURI(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
|
||||
let thisTranslationURL = getGlobalConfig().locale.translateURL.format(encodeURIComponent(messageText), toUpperCase(getGlobalConfig().locale.locales[translateFrom].isoCode), toUpperCase(getGlobalConfig().locale.locales[translateTo].isoCode), getGlobalConfig().locale.apiEmail);
|
||||
httpGet(
|
||||
thisTranslationURL,
|
||||
"",
|
||||
function(data) {
|
||||
function (data) {
|
||||
data = ArrayBufferToString(data);
|
||||
let translationData = JSON.parse(data);
|
||||
cachedTranslations[translateFrom][translateTo].push([messageText, translationData.responseData.translatedText]);
|
||||
resolve(translationData.responseData.translatedText);
|
||||
},
|
||||
function(data) {
|
||||
function (data) {
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getLocaleFromCountryISO(isoCode) {
|
||||
for (let i in getLocales()) {
|
||||
for (let j in getLocales()[i].countries) {
|
||||
if (toLowerCase(getLocales()[i].countries[j]) == toLowerCase(isoCode)) {
|
||||
return getLocales()[i].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: messaging.js
|
||||
// DESC: Provides messaging functions and usage
|
||||
@@ -8,15 +9,15 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initMessagingScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Messaging]: Initializing messaging script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Messaging]: Messaging script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Messaging]: Initializing messaging script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Messaging]: Messaging script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function announceAdminAction(localeString, ...args) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
for (let i in clients) {
|
||||
let argsArray = [clients[i], localeString];
|
||||
argsArray = argsArray.concat(args);
|
||||
let messageText = getLocaleString.apply(null, argsArray);
|
||||
@@ -38,9 +39,14 @@ function announceAdminAction(localeString, ...args) {
|
||||
*
|
||||
*/
|
||||
function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
|
||||
//if(isConsole(client) || client == null) {
|
||||
// logToConsole(LOG_INFO, `${removeColoursInMessage(messageText)}`);
|
||||
//}
|
||||
if (client != null) {
|
||||
if (client.console) {
|
||||
logToConsole(LOG_INFO, `${messageText}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//logToConsole(LOG_INFO, `${messageText}`);
|
||||
|
||||
//messageText = replaceColoursInMessage(messageText);
|
||||
|
||||
@@ -57,12 +63,9 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
|
||||
// ===========================================================================
|
||||
|
||||
function messageAdmins(messageText, colour = getColourByName("softRed")) {
|
||||
//
|
||||
//logToConsole(LOG_WARN, `🛡️ ${plainMessage}`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
|
||||
for (let i in clients) {
|
||||
if (doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
|
||||
messagePlayerNormal(clients[i], `🛡️ ${messageText}`, colour);
|
||||
}
|
||||
}
|
||||
@@ -74,12 +77,7 @@ function messageAdmins(messageText, colour = getColourByName("softRed")) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerError(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `❌ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `❌ ${messageText}`, getColourByName("white"));
|
||||
} else {
|
||||
messageDiscordUser(client, `❌ ${messageText}`);
|
||||
@@ -89,12 +87,7 @@ function messagePlayerError(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerSyntax(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `⌨️ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `⌨️ USAGE: {MAINCOLOUR} ${messageText}`, getColourByType("syntaxMessage"));
|
||||
} else {
|
||||
messageDiscordUser(client, `⌨️ ${messageText}`);
|
||||
@@ -104,12 +97,7 @@ function messagePlayerSyntax(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerAlert(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `⚠️ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `⚠️ ${messageText}`, getColourByName("white"));
|
||||
} else {
|
||||
messageDiscordUser(client, `⚠️ ${messageText}`);
|
||||
@@ -119,12 +107,7 @@ function messagePlayerAlert(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerSuccess(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `✔️ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `✔️ ${messageText}`, getColourByName("white"));
|
||||
} else {
|
||||
messageDiscordUser(client, `✔️ ${messageText}`);
|
||||
@@ -134,12 +117,7 @@ function messagePlayerSuccess(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerInfo(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `ℹ️ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `ℹ️ ${messageText}`, getColourByName("white"));
|
||||
} else {
|
||||
messageDiscordUser(client, `:information_source: ${messageText}`);
|
||||
@@ -149,15 +127,10 @@ function messagePlayerInfo(client, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerTip(client, messageText) {
|
||||
if(isConsole(client)) {
|
||||
logToConsole(LOG_INFO, `ℹ️ ${messageText}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `ℹ️ ${messageText}`, getColourByName("white"));
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `💡 ${messageText}`, getColourByName("white"));
|
||||
} else {
|
||||
messageDiscordUser(client, `:information_source: ${messageText}`);
|
||||
messageDiscordUser(client, `:bulb: ${messageText}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +161,7 @@ function messagePlayerShout(client, shoutingClient, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerDoAction(client, doingActionClient, messageText) {
|
||||
if(!isClientFromDiscord(client)) {
|
||||
if (!isClientFromDiscord(client)) {
|
||||
messagePlayerNormal(client, `${messageText} * (${getClientSubAccountName(doingActionClient)})`, getColourByType("doActionMessage"));
|
||||
}
|
||||
}
|
||||
@@ -202,7 +175,7 @@ function messagePlayerMeAction(client, doingActionClient, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
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")}${(getPlayerClanRank(client) != -1) ? getClanRankData(getPlayerClan(client), getPlayerClanRank(client)).name : "No Rank"} ${getCharacterFullName(clanChattingClient)} {MAINCOLOUR}says (clan): {ALTCOLOUR}${messageText}`, getColourByType("clanChatMessage"));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -214,7 +187,7 @@ function messagePlayerAdminChat(client, adminChattingClient, messageText) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerNewbieTip(client, message) {
|
||||
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
|
||||
if (!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoActionTips"))) {
|
||||
messagePlayerNormal(client, `💡 ${message}`);
|
||||
}
|
||||
}
|
||||
@@ -222,8 +195,8 @@ function messagePlayerNewbieTip(client, message) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerTimedRandomTip(client, message) {
|
||||
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
|
||||
if(!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
|
||||
if (isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
|
||||
if (!hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("NoRandomTips"))) {
|
||||
messagePlayerNormal(client, `💡 ${message}`);
|
||||
}
|
||||
}
|
||||
@@ -233,7 +206,7 @@ function messagePlayerTimedRandomTip(client, message) {
|
||||
|
||||
function makeChatBoxSectionHeader(name) {
|
||||
let resultString = `{clanOrange}== {jobYellow}${name} `;
|
||||
let endFiller = fillStringWithCharacter("=", getGlobalConfig().chatSectionHeaderLength-resultString.length);
|
||||
let endFiller = fillStringWithCharacter("=", getGlobalConfig().chatSectionHeaderLength - resultString.length);
|
||||
return `${resultString} {clanOrange}${endFiller}`;
|
||||
}
|
||||
|
||||
@@ -241,7 +214,7 @@ function makeChatBoxSectionHeader(name) {
|
||||
|
||||
function clearChatBox(client) {
|
||||
//game.messages.clear();
|
||||
for(let i = 0; i <= 20; i++) {
|
||||
for (let i = 0; i <= 20; i++) {
|
||||
messageClient(" ", client, COLOUR_WHITE);
|
||||
}
|
||||
}
|
||||
@@ -255,11 +228,17 @@ function messagePlayerHelpContent(client, messageString) {
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayersInRace(raceId, message) {
|
||||
for(let i in clients) {
|
||||
if(getPlayerRace(clients[i]) == raceId) {
|
||||
for (let i in clients) {
|
||||
if (getPlayerRace(clients[i]) == raceId) {
|
||||
messagePlayerNormal(clients[i], message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function messagePlayerPrivateMessage(toClient, fromClient, messageText) {
|
||||
messagePlayerNormal(toClient, `{yellow}[DM] ${getCharacterFullName(fromClient)}{MAINCOLOUR}says: {ALTCOLOUR}${messageText}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,17 +1,62 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: misc.js
|
||||
// DESC: Provides any uncategorized functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Pickup Types
|
||||
const AGRP_PICKUP_NONE = 0;
|
||||
const AGRP_PICKUP_JOB = 1;
|
||||
const AGRP_PICKUP_BUSINESS_ENTRANCE = 2;
|
||||
const AGRP_PICKUP_BUSINESS_EXIT = 3;
|
||||
const AGRP_PICKUP_HOUSE_ENTRANCE = 4;
|
||||
const AGRP_PICKUP_HOUSE_EXIT = 5;
|
||||
const AGRP_PICKUP_EXIT = 6;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Blip Owner Types
|
||||
const AGRP_BLIP_NONE = 0;
|
||||
const AGRP_BLIP_JOB = 1;
|
||||
const AGRP_BLIP_BUSINESS_ENTRANCE = 2;
|
||||
const AGRP_BLIP_BUSINESS_EXIT = 3;
|
||||
const AGRP_BLIP_HOUSE_ENTRANCE = 4;
|
||||
const AGRP_BLIP_HOUSE_EXIT = 5;
|
||||
const AGRP_BLIP_EXIT = 6;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Ped States
|
||||
const AGRP_PEDSTATE_NONE = 0; // None
|
||||
const AGRP_PEDSTATE_READY = 1; // Ready
|
||||
const AGRP_PEDSTATE_DRIVER = 2; // Driving a vehicle
|
||||
const AGRP_PEDSTATE_PASSENGER = 3; // In a vehicle as passenger
|
||||
const AGRP_PEDSTATE_DEAD = 4; // Dead
|
||||
const AGRP_PEDSTATE_ENTERINGPROPERTY = 5; // Entering a property
|
||||
const AGRP_PEDSTATE_EXITINGPROPERTY = 6; // Exiting a property
|
||||
const AGRP_PEDSTATE_ENTERINGVEHICLE = 7; // Entering a vehicle
|
||||
const AGRP_PEDSTATE_EXITINGVEHICLE = 8; // Exiting a vehicle
|
||||
const AGRP_PEDSTATE_BINDED = 9; // Binded by rope or handcuffs
|
||||
const AGRP_PEDSTATE_TAZED = 10; // Under incapacitating effect of tazer
|
||||
const AGRP_PEDSTATE_INTRUNK = 11; // In vehicle trunk
|
||||
const AGRP_PEDSTATE_INITEM = 12; // In item (crate, box, etc)
|
||||
const AGRP_PEDSTATE_HANDSUP = 13; // Has hands up (surrendering)
|
||||
const AGRP_PEDSTATE_SPAWNING = 14; // Spawning
|
||||
|
||||
// Property Types
|
||||
const AGRP_PROPERTY_TYPE_NONE = 0; // None
|
||||
const AGRP_PROPERTY_TYPE_BUSINESS = 1; // Business
|
||||
const AGRP_PROPERTY_TYPE_HOUSE = 2; // House
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initMiscScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Misc]: Initializing misc script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Misc]: Misc script initialized successfully!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Misc]: Initializing misc script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Misc]: Misc script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,8 +79,44 @@ function toggleMouseCursorCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function suicideCommand(command, params, client) {
|
||||
if (!isPlayerSpawned(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeSpawned"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerSurrendered(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerRestrained(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPlayerCurrentSubAccount(client).inJail) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerInAnyVehicle(client)) {
|
||||
removePlayerFromVehicle(client);
|
||||
}
|
||||
|
||||
processPlayerDeath(client);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleMouseCameraCommand(command, params, client) {
|
||||
if(getGame() != VRR_GAME_GTA_VC) {
|
||||
if (getGame() != AGRP_GAME_GTA_VC) {
|
||||
sendPlayerMouseCameraToggle(client);
|
||||
}
|
||||
return true;
|
||||
@@ -58,24 +139,24 @@ function setNewCharacterSpawnPositionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setNewCharacterMoneyCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let amount = toInteger(getParam(params, " ", 1)) || 1000;
|
||||
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 ${getCurrencyString(amount)}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setNewCharacterSkinCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -92,7 +173,7 @@ function setNewCharacterSkinCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitIdeaCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -106,7 +187,7 @@ function submitIdeaCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function submitBugReportCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -124,34 +205,40 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
let isEntrance = false;
|
||||
let isBusiness = false;
|
||||
|
||||
if(areServerElementsSupported()) {
|
||||
if(!getPlayerData(client).currentPickup) {
|
||||
// Make sure they aren't already trying to enter/exit a property
|
||||
if (getPlayerData(client).pedState == AGRP_PEDSTATE_ENTERINGPROPERTY || getPlayerData(client).pedState == AGRP_PEDSTATE_EXITINGPROPERTY) {
|
||||
messagePlayerError(client, getLocaleString(client, "UnableToDoThat"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
|
||||
if (!getPlayerData(client).currentPickup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let ownerType = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.type");
|
||||
let ownerId = getEntityData(getPlayerData(client).currentPickup, "vrr.owner.id");
|
||||
let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type");
|
||||
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id");
|
||||
|
||||
switch(ownerType) {
|
||||
case VRR_PICKUP_BUSINESS_ENTRANCE:
|
||||
switch (ownerType) {
|
||||
case AGRP_PICKUP_BUSINESS_ENTRANCE:
|
||||
isBusiness = true;
|
||||
isEntrance = true;
|
||||
closestProperty = getServerData().businesses[ownerId];
|
||||
break;
|
||||
|
||||
case VRR_PICKUP_BUSINESS_EXIT:
|
||||
case AGRP_PICKUP_BUSINESS_EXIT:
|
||||
isBusiness = true;
|
||||
isEntrance = false;
|
||||
closestProperty = getServerData().businesses[ownerId];
|
||||
break;
|
||||
|
||||
case VRR_PICKUP_HOUSE_ENTRANCE:
|
||||
case AGRP_PICKUP_HOUSE_ENTRANCE:
|
||||
isBusiness = false;
|
||||
isEntrance = true;
|
||||
closestProperty = getServerData().houses[ownerId];
|
||||
break;
|
||||
|
||||
case VRR_PICKUP_HOUSE_EXIT:
|
||||
case AGRP_PICKUP_HOUSE_EXIT:
|
||||
isBusiness = false;
|
||||
isEntrance = false;
|
||||
closestProperty = getServerData().houses[ownerId];
|
||||
@@ -161,8 +248,8 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for(let i in getServerData().businesses) {
|
||||
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
|
||||
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;
|
||||
@@ -175,8 +262,8 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
}
|
||||
}
|
||||
|
||||
for(let j in getServerData().houses) {
|
||||
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
|
||||
for (let j in getServerData().houses) {
|
||||
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
|
||||
let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
|
||||
isBusiness = false;
|
||||
isEntrance = true;
|
||||
@@ -190,93 +277,88 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
}
|
||||
}
|
||||
|
||||
if(closestProperty == null) {
|
||||
if (closestProperty == null) {
|
||||
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is null`);
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is ${(isBusiness) ? closestProperty.name : closestProperty.description} ${(isEntrance) ? "entrance" : "exit"}`);
|
||||
|
||||
if(isEntrance) {
|
||||
if(getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
|
||||
if(closestProperty.locked) {
|
||||
let englishId = getLocaleFromParams("English");
|
||||
let typeString = (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House");
|
||||
let nameString = (isBusiness) ? closestProperty.name : closestProperty.description;
|
||||
|
||||
if (isEntrance) {
|
||||
if (getDistance(closestProperty.entrancePosition, getPlayerPosition(client)) <= getGlobalConfig().enterPropertyDistance) {
|
||||
if (closestProperty.locked) {
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House")));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!closestProperty.hasInterior) {
|
||||
if (!closestProperty.hasInterior) {
|
||||
messagePlayerAlert(client, getLocaleString(client, "PropertyNoInterior", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House")));
|
||||
return false;
|
||||
}
|
||||
|
||||
clearPlayerStateToEnterExitProperty(client);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_ENTERINGPROPERTY;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "EntersProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House")));
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_ENTERINGPROPERTY;
|
||||
getPlayerData(client).enteringExitingProperty = [(isBusiness) ? AGRP_PROPERTY_TYPE_BUSINESS : AGRP_PROPERTY_TYPE_HOUSE, closestProperty.index];
|
||||
|
||||
if(isFadeCameraSupported()) {
|
||||
meActionToNearbyPlayers(client, getLanguageLocaleString(englishId, "EntersProperty", typeString, nameString));
|
||||
|
||||
if (closestProperty.exitScene != "" && isGameFeatureSupported("interiorScene")) {
|
||||
getPlayerCurrentSubAccount(client).spawnPosition = closestProperty.exitPosition;
|
||||
if (isMainWorldScene(closestProperty.exitScene) || closestProperty.exitScene == "AGRP.MAINWORLD") {
|
||||
setPlayerScene(client, getGameConfig().mainWorldScene[getGame()]);
|
||||
} else {
|
||||
setPlayerScene(client, closestProperty.exitScene);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, false, 1.0);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
|
||||
setPlayerPosition(client, closestProperty.exitPosition);
|
||||
setPlayerHeading(client, closestProperty.exitRotation);
|
||||
setPlayerDimension(client, closestProperty.exitDimension);
|
||||
setPlayerInterior(client, closestProperty.exitInterior);
|
||||
setTimeout(function() {
|
||||
if(isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
updateInteriorLightsForPlayer(client, closestProperty.interiorLights);
|
||||
}, 1000);
|
||||
//setPlayerInCutsceneInterior(client, closestProperty.exitCutscene);
|
||||
//updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension);
|
||||
setTimeout(function () {
|
||||
processPlayerEnteringExitingProperty(client);
|
||||
}, 1100);
|
||||
if(closestProperty.streamingRadioStation != -1) {
|
||||
if(getRadioStationData(closestProperty.streamingRadioStation)) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(closestProperty.streamingRadioStation).url);
|
||||
getPlayerData(client).streamingRadioStation = closestProperty.streamingRadioStation;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
|
||||
if(closestProperty.locked) {
|
||||
if (getDistance(closestProperty.exitPosition, getPlayerPosition(client)) <= getGlobalConfig().exitPropertyDistance) {
|
||||
if (closestProperty.locked) {
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "EnterExitPropertyDoorLocked", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House")));
|
||||
return false;
|
||||
}
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_EXITINGPROPERTY;
|
||||
clearPlayerStateToEnterExitProperty(client)
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ExitsProperty", (isBusiness) ? getLocaleString(client, "Business") : getLocaleString(client, "House")));
|
||||
|
||||
if(isFadeCameraSupported()) {
|
||||
clearPlayerStateToEnterExitProperty(client);
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGPROPERTY;
|
||||
getPlayerData(client).enteringExitingProperty = [(isBusiness) ? AGRP_PROPERTY_TYPE_BUSINESS : AGRP_PROPERTY_TYPE_HOUSE, closestProperty.index];
|
||||
|
||||
meActionToNearbyPlayers(client, getLanguageLocaleString(englishId, "ExitsProperty", typeString, nameString));
|
||||
|
||||
if (closestProperty.entranceScene != "" && isGameFeatureSupported("interiorScene")) {
|
||||
getPlayerCurrentSubAccount(client).spawnPosition = closestProperty.entrancePosition;
|
||||
if (isMainWorldScene(closestProperty.entranceScene) || closestProperty.entranceScene == "AGRP.MAINWORLD") {
|
||||
setPlayerScene(client, getGameConfig().mainWorldScene[getGame()]);
|
||||
} else {
|
||||
setPlayerScene(client, closestProperty.entranceScene);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, false, 1.0);
|
||||
}
|
||||
|
||||
disableCityAmbienceForPlayer(client, true);
|
||||
setTimeout(function() {
|
||||
setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene);
|
||||
setPlayerPosition(client, closestProperty.entrancePosition);
|
||||
setPlayerHeading(client, closestProperty.entranceRotation);
|
||||
setPlayerDimension(client, closestProperty.entranceDimension);
|
||||
setPlayerInterior(client, closestProperty.entranceInterior);
|
||||
setTimeout(function() {
|
||||
if(isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
|
||||
updateInteriorLightsForPlayer(client, true);
|
||||
}, 1000);
|
||||
setTimeout(function () {
|
||||
processPlayerEnteringExitingProperty(client);
|
||||
}, 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;
|
||||
}
|
||||
}
|
||||
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -285,39 +367,62 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
function getPlayerInfoCommand(command, params, client) {
|
||||
let targetClient = client;
|
||||
|
||||
if(!areParamsEmpty(params)) {
|
||||
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
|
||||
if (!areParamsEmpty(params)) {
|
||||
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
|
||||
targetClient = getPlayerFromParams(params);
|
||||
|
||||
if(!getPlayerData(targetClient)) {
|
||||
if (!targetClient) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidPlayer"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerInfo")));
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderPlayerInfo", `${getPlayerName(client)} - ${getCharacterFullName(targetClient)}`)));
|
||||
|
||||
let clan = (getPlayerCurrentSubAccount(targetClient).clan != 0) ? `{ALTCOLOUR}${getClanData(getClanIdFromDatabaseId(getPlayerCurrentSubAccount(targetClient).clan)).name}[${getPlayerCurrentSubAccount(targetClient).clan}] (Rank: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).name}[Level: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).level}, DBID: ${getClanRankData(getPlayerCurrentSubAccount(targetClient).clan, getPlayerCurrentSubAccount(targetClient).clanRank).databaseId}` : `(None)`;
|
||||
let job = (getPlayerCurrentSubAccount(targetClient).job != 0) ? `{ALTCOLOUR}${getJobData(getJobIdFromDatabaseId(getPlayerCurrentSubAccount(targetClient).job)).name}[${getPlayerCurrentSubAccount(targetClient).job}] (Rank: ${getPlayerCurrentSubAccount(targetClient).jobRank})` : `(None)`;
|
||||
let clanIndex = getClanIndexFromDatabaseId(getPlayerCurrentSubAccount(targetClient).clan);
|
||||
let clanRankIndex = getClanRankIndexFromDatabaseId(clanIndex, getPlayerCurrentSubAccount(targetClient).clanRank);
|
||||
let clanData = getClanData(clanIndex);
|
||||
let clanRankData = getClanRankData(clanIndex, clanRankIndex);
|
||||
|
||||
let jobIndex = getPlayerCurrentSubAccount(targetClient).jobIndex;
|
||||
let jobRankIndex = getPlayerCurrentSubAccount(targetClient).jobRankIndex;
|
||||
let jobData = getJobData(jobIndex);
|
||||
|
||||
let jobRankText = "(Rank: None)";
|
||||
if (jobRankIndex != -1) {
|
||||
let jobRankData = getJobRankData(jobIndex, jobRankIndex);
|
||||
jobRankText = `(Rank ${jobRankData.level}: ${jobRankData.name}{mediumGrey}[${jobRankData.databaseId}]{ALTCOLOUR})`;
|
||||
}
|
||||
|
||||
let clan = (getPlayerCurrentSubAccount(targetClient).clan != 0) ? `{ALTCOLOUR}${clanData.name}{mediumGrey}[${clanData.databaseId}]{ALTCOLOUR} (Rank ${clanRankData.level}: ${clanRankData.name}{mediumGrey}[${clanRankData.databaseId}]{ALTCOLOUR})` : `None`;
|
||||
let job = (getPlayerCurrentSubAccount(targetClient).jobIndex != -1) ? `{ALTCOLOUR}${jobData.name}{mediumGrey}[${jobData.databaseId}]{ALTCOLOUR} ${jobRankText}` : `None`;
|
||||
let skinIndex = getPlayerCurrentSubAccount(targetClient).skin;
|
||||
let skinModel = getGameConfig().skins[getGame()][skinIndex][0];
|
||||
let skinName = getSkinNameFromModel(skinModel);
|
||||
let registerDate = new Date(getPlayerData(targetClient).accountData.registerDate * 1000);
|
||||
let currentDate = new Date();
|
||||
|
||||
let tempStats = [
|
||||
["Account", `${getPlayerData(targetClient).accountData.name}[${getPlayerData(targetClient).accountData.databaseId}]`],
|
||||
["Character", `${getCharacterFullName(targetClient)}[${getPlayerCurrentSubAccount(targetClient).databaseId}]`],
|
||||
["Account", `${getPlayerData(targetClient).accountData.name}{mediumGrey}[${getPlayerData(targetClient).accountData.databaseId}]{ALTCOLOUR}`],
|
||||
["Character", `${getCharacterFullName(targetClient)}{mediumGrey}[${getPlayerCurrentSubAccount(targetClient).databaseId}]{ALTCOLOUR}`],
|
||||
["Connected", `${getTimeDifferenceDisplay(getCurrentUnixTimestamp(), getPlayerData(targetClient).connectTime)} ago`],
|
||||
["Registered", `${getPlayerData(targetClient).accountData.registerDate}`],
|
||||
["Registered", `${registerDate.toLocaleDateString()}`],
|
||||
["Game Version", `${targetClient.gameVersion}`],
|
||||
["Script Version", `${scriptVersion}`],
|
||||
["Client Version", `${getPlayerData(targetClient).clientVersion}`],
|
||||
["Skin", `${getSkinNameFromModel(getPlayerCurrentSubAccount(targetClient).skin)}[${getPlayerCurrentSubAccount(targetClient).skin}]`],
|
||||
["Client Version", `${getPlayerData(targetClient).clientVersion}`],
|
||||
["Cash", `${getCurrencyString(getPlayerCurrentSubAccount(client).cash)}`],
|
||||
["Skin", `${skinName}{mediumGrey}[Model: ${skinModel}/Index: ${skinIndex}]{ALTCOLOUR}`],
|
||||
["Clan", `${clan}`],
|
||||
["Job", `${job}`],
|
||||
["Cash", `${getPlayerCurrentSubAccount(client).cash}`],
|
||||
["Current Date", `${currentDate.toLocaleDateString()}`],
|
||||
]
|
||||
|
||||
let stats = tempStats.map(stat => `{MAINCOLOUR}${stat[0]}: {ALTCOLOUR}${stat[1]}{MAINCOLOUR}`);
|
||||
let stats = tempStats.map(stat => `{MAINCOLOUR}${stat[0]}: {ALTCOLOUR}${stat[1]} {MAINCOLOUR}`);
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(stats, 6);
|
||||
for(let i in chunkedList) {
|
||||
let chunkedList = splitArrayIntoChunks(stats, 5);
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
@@ -325,7 +430,7 @@ function getPlayerInfoCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function playerChangeAFKState(client, afkState) {
|
||||
if(!getPlayerData(client)) {
|
||||
if (!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -337,12 +442,12 @@ function playerChangeAFKState(client, afkState) {
|
||||
|
||||
function checkPlayerSpawning() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(!isConsole(clients[i])) {
|
||||
if(getPlayerData(clients[i])) {
|
||||
if(isPlayerLoggedIn(clients[i])) {
|
||||
if(!getPlayerData(clients[i]).ped) {
|
||||
if(clients[i].player != null) {
|
||||
for (let i in clients) {
|
||||
if (!isConsole(clients[i])) {
|
||||
if (getPlayerData(clients[i])) {
|
||||
if (isPlayerLoggedIn(clients[i])) {
|
||||
if (!getPlayerData(clients[i]).ped) {
|
||||
if (clients[i].player != null) {
|
||||
//getPlayerData(clients[i]).ped = clients[i].player;
|
||||
onPlayerSpawn(clients[i].player);
|
||||
}
|
||||
@@ -356,10 +461,10 @@ function checkPlayerSpawning() {
|
||||
// ===========================================================================
|
||||
|
||||
function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noButtonText) {
|
||||
if(canPlayerUseGUI(client)) {
|
||||
if (canPlayerUseGUI(client)) {
|
||||
showPlayerPromptGUI(client, promptMessage, promptTitle, yesButtonText, noButtonText);
|
||||
} else {
|
||||
messagePlayerNormal(client, `❓ ${promptMessage}`);
|
||||
messagePlayerNormal(client, `❓ ${promptMessage} `);
|
||||
messagePlayerInfo(client, getLocaleString(client, "PromptResponseTip", `{ALTCOLOUR}/yes{MAINCOLOUR}`, `{ALTCOLOUR}/no{MAINCOLOUR}`));
|
||||
}
|
||||
}
|
||||
@@ -376,7 +481,7 @@ function showPlayerPrompt(client, promptMessage, promptTitle, yesButtonText, noB
|
||||
*
|
||||
*/
|
||||
function updateServerGameTime() {
|
||||
if(isTimeSupported()) {
|
||||
if (isTimeSupported()) {
|
||||
game.time.hour = getServerConfig().hour;
|
||||
game.time.minute = getServerConfig().minute;
|
||||
}
|
||||
@@ -399,164 +504,24 @@ function listOnlineAdminsCommand(command, params, client) {
|
||||
|
||||
let admins = [];
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerData(clients[i])) {
|
||||
if(typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") {
|
||||
if(getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) {
|
||||
admins.push(`{ALTCOLOUR}[${getPlayerData(clients[i]).accountData.staffTitle}] {MAINCOLOUR}${getCharacterFullName(clients[i])}`);
|
||||
for (let i in clients) {
|
||||
if (getPlayerData(clients[i])) {
|
||||
if (typeof getPlayerData(clients[i]).accountData.flags.admin != "undefined") {
|
||||
if (getPlayerData(clients[i]).accountData.flags.admin > 0 || getPlayerData(clients[i]).accountData.flags.admin == -1) {
|
||||
admins.push(`{ALTCOLOUR}[${getPlayerData(clients[i]).accountData.staffTitle}]{MAINCOLOUR} ${getCharacterFullName(clients[i])}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(admins, 3);
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* 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 gpsCommand(command, params, client) {
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderBusinessList")));
|
||||
|
||||
let locationType = VRR_GPS_TYPE_NONE;
|
||||
let useType = VRR_ITEM_USETYPE_NONE;
|
||||
let blipColour = "white";
|
||||
|
||||
switch(toLowerCase(params)) {
|
||||
case "police":
|
||||
case "policestation":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_POLICE;
|
||||
break;
|
||||
|
||||
case "hospital":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_HOSPITAL;
|
||||
break;
|
||||
|
||||
case "job":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_JOB;
|
||||
break;
|
||||
|
||||
case "skin":
|
||||
case "skins":
|
||||
case "clothes":
|
||||
case "player":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_SKIN;
|
||||
break;
|
||||
|
||||
case "gun":
|
||||
case "guns":
|
||||
case "weapon":
|
||||
case "weapons":
|
||||
case "wep":
|
||||
case "weps":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_WEAPON;
|
||||
break;
|
||||
|
||||
case "food":
|
||||
case "eat":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_FOOD;
|
||||
break;
|
||||
|
||||
case "drink":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_DRINK;
|
||||
break;
|
||||
|
||||
case "alcohol":
|
||||
case "booze":
|
||||
case "bar":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_ALCOHOL;
|
||||
break;
|
||||
|
||||
case "repair":
|
||||
case "carrepair":
|
||||
case "vehrepair":
|
||||
case "spray":
|
||||
case "fix":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_VEHREPAIR;
|
||||
break;
|
||||
|
||||
case "vehiclecolour":
|
||||
case "vehcolour":
|
||||
case "carcolour":
|
||||
case "colour":
|
||||
blipColour = "mediumGrey"
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
useType = VRR_ITEM_USETYPE_VEHCOLOUR;
|
||||
break;
|
||||
|
||||
default: {
|
||||
let itemTypeId = getItemTypeFromParams(params);
|
||||
if(getItemTypeData(itemTypeId) != false) {
|
||||
locationType = VRR_GPS_TYPE_BUSINESS;
|
||||
blipColour = "mediumGrey";
|
||||
useType = getItemTypeData(itemTypeId).useType;
|
||||
} else {
|
||||
let gameLocationId = getGameLocationFromParams(params);
|
||||
if(gameLocationId != false) {
|
||||
position = getGameConfig().locations[getGame()][gameLocationId][1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(locationType == VRR_GPS_TYPE_NONE) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(locationType == VRR_GPS_TYPE_BUSINESS) {
|
||||
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
|
||||
if(!businessId) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getBusinessData(businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
hideAllBlipsForPlayerGPS(client);
|
||||
blinkGenericGPSBlipForPlayer(client, getBusinessData(businessId).entrancePosition, getBusinessData(businessId).entranceBlipModel, getColourByType(blipColour), 10);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* This is a command handler function.
|
||||
*
|
||||
@@ -567,7 +532,7 @@ function gpsCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function stuckPlayerCommand(command, params, client) {
|
||||
if((getCurrentUnixTimestamp()-getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
|
||||
if ((getCurrentUnixTimestamp() - getPlayerData(client).lastStuckCommand) < getGlobalConfig().stuckCommandInterval) {
|
||||
messagePlayerError(client, "CantUseCommandYet");
|
||||
return false;
|
||||
}
|
||||
@@ -577,8 +542,8 @@ function stuckPlayerCommand(command, params, client) {
|
||||
|
||||
messagePlayerAlert(client, getLocaleString(client, "FixingStuck"));
|
||||
|
||||
if(getGameConfig().skinChangePosition[getGame()].length > 0) {
|
||||
if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_SKINSELECT) {
|
||||
if (getGameConfig().skinChangePosition[getGame()].length > 0) {
|
||||
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == AGRP_RETURNTO_TYPE_SKINSELECT) {
|
||||
messagePlayerAlert(client, "You canceled the skin change.");
|
||||
restorePlayerCamera(client);
|
||||
|
||||
@@ -592,19 +557,19 @@ function stuckPlayerCommand(command, params, client) {
|
||||
getPlayerData(client).returnToInterior = null;
|
||||
getPlayerData(client).returnToDimension = null;
|
||||
|
||||
getPlayerData(client).returnToType = VRR_RETURNTO_TYPE_NONE;
|
||||
getPlayerData(client).returnToType = AGRP_RETURNTO_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == VRR_RETURNTO_TYPE_ADMINGET) {
|
||||
//if(getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType == AGRP_RETURNTO_TYPE_ADMINGET) {
|
||||
// messagePlayerError(client, `You were teleported by an admin and can't use the stuck command`);
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if(dimension > 0) {
|
||||
if (dimension > 0) {
|
||||
let businesses = getServerData().businesses;
|
||||
for(let i in businesses) {
|
||||
if(businesses[i].exitDimension == dimension) {
|
||||
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);
|
||||
@@ -614,8 +579,8 @@ function stuckPlayerCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let houses = getServerData().houses;
|
||||
for(let i in houses) {
|
||||
if(houses[i].exitDimension == dimension) {
|
||||
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);
|
||||
@@ -646,7 +611,7 @@ function stuckPlayerCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function playerPedSpeakCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -666,15 +631,15 @@ function playerPedSpeakCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function lockCommand(command, params, client) {
|
||||
if(isPlayerInAnyVehicle(client)) {
|
||||
if (isPlayerInAnyVehicle(client)) {
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!getVehicleData(vehicle)) {
|
||||
if (!getVehicleData(vehicle)) {
|
||||
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerInFrontVehicleSeat(client)) {
|
||||
if (!isPlayerInFrontVehicleSeat(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
|
||||
return false;
|
||||
}
|
||||
@@ -687,13 +652,13 @@ function lockCommand(command, params, client) {
|
||||
return true;
|
||||
} else {
|
||||
let vehicle = getClosestVehicle(getPlayerPosition(client));
|
||||
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) {
|
||||
if(!getVehicleData(vehicle)) {
|
||||
if (getDistance(getPlayerPosition(client), getVehiclePosition(vehicle)) <= getGlobalConfig().vehicleLockDistance) {
|
||||
if (!getVehicleData(vehicle)) {
|
||||
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||
if (!doesPlayerHaveVehicleKeys(client, vehicle)) {
|
||||
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
|
||||
return false;
|
||||
}
|
||||
@@ -708,8 +673,8 @@ function lockCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if(businessId != -1) {
|
||||
if(!canPlayerManageBusiness(client, businessId)) {
|
||||
if (businessId != -1) {
|
||||
if (!canPlayerManageBusiness(client, businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
|
||||
return false;
|
||||
}
|
||||
@@ -723,8 +688,8 @@ function lockCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let houseId = getPlayerHouse(client);
|
||||
if(houseId != -1) {
|
||||
if(!canPlayerManageHouse(client, houseId)) {
|
||||
if (houseId != -1) {
|
||||
if (!canPlayerManageHouse(client, houseId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
|
||||
return false;
|
||||
}
|
||||
@@ -750,16 +715,16 @@ function lockCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
function lightsCommand(command, params, client) {
|
||||
if(isPlayerInAnyVehicle(client)) {
|
||||
function lightsCommand(command, params, client) {
|
||||
if (isPlayerInAnyVehicle(client)) {
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!getVehicleData(vehicle)) {
|
||||
if (!getVehicleData(vehicle)) {
|
||||
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerInFrontVehicleSeat(client)) {
|
||||
if (!isPlayerInFrontVehicleSeat(client)) {
|
||||
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
|
||||
return false;
|
||||
}
|
||||
@@ -797,8 +762,8 @@ function lockCommand(command, params, client) {
|
||||
*/
|
||||
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if(businessId != -1) {
|
||||
if(!canPlayerManageBusiness(client, businessId)) {
|
||||
if (businessId != -1) {
|
||||
if (!canPlayerManageBusiness(client, businessId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
|
||||
return false;
|
||||
}
|
||||
@@ -807,8 +772,8 @@ function lockCommand(command, params, client) {
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) {
|
||||
for (let i in clients) {
|
||||
if (getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) {
|
||||
updateInteriorLightsForPlayer(clients[i], getBusinessData(businessId).interiorLights);
|
||||
}
|
||||
}
|
||||
@@ -818,8 +783,8 @@ function lockCommand(command, params, client) {
|
||||
}
|
||||
|
||||
let houseId = getPlayerHouse(client);
|
||||
if(houseId != -1) {
|
||||
if(!canPlayerManageHouse(client, houseId)) {
|
||||
if (houseId != -1) {
|
||||
if (!canPlayerManageHouse(client, houseId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
|
||||
return false;
|
||||
}
|
||||
@@ -828,8 +793,8 @@ function lockCommand(command, params, client) {
|
||||
getHouseData(houseId).needsSaved = true;
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) {
|
||||
for (let i in clients) {
|
||||
if (getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) {
|
||||
updateInteriorLightsForPlayer(clients[i], getHouseData(houseId).interiorLights);
|
||||
}
|
||||
}
|
||||
@@ -838,4 +803,151 @@ function lockCommand(command, params, client) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetPlayerBlip(client) {
|
||||
deletePlayerBlip(client);
|
||||
createPlayerBlip(client);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createPlayerBlip(client) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isGameFeatureSupported("attachedBlip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getServerConfig().createPlayerBlips) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let blip = createAttachedGameBlip(getPlayerPed(client), 0, 1, getPlayerColour(client));
|
||||
if (blip) {
|
||||
if (getGlobalConfig().playerBlipStreamInDistance == -1 || getGlobalConfig().playerBlipStreamOutDistance == -1) {
|
||||
//getPlayerPed(client).netFlags.distanceStreaming = false;
|
||||
getPlayerPed(client).streamInDistance = 999998;
|
||||
getPlayerPed(client).streamOutDistance = 999999;
|
||||
} else {
|
||||
//getPlayerPed(client).netFlags.distanceStreaming = true;
|
||||
setElementStreamInDistance(getPlayerPed(client), getGlobalConfig().playerBlipStreamInDistance);
|
||||
setElementStreamOutDistance(getPlayerPed(client), getGlobalConfig().playerBlipStreamOutDistance);
|
||||
}
|
||||
//getPlayerPed(client).netFlags.defaultExistance = true;
|
||||
blip.netFlags.defaultExistance = true;
|
||||
blip.setExistsFor(client, false);
|
||||
getPlayerData(client).playerBlip = blip;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deletePlayerBlip(client) {
|
||||
if (!isGameFeatureSupported("attachedBlip")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPlayerData(client).playerBlip != null) {
|
||||
deleteGameElement(getPlayerData(client).playerBlip);
|
||||
getPlayerData(client).playerBlip = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processPlayerDeath(client) {
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_DEAD;
|
||||
updatePlayerSpawnedState(client, false);
|
||||
setPlayerControlState(client, false);
|
||||
setTimeout(function () {
|
||||
fadePlayerCamera(client, false, 1000);
|
||||
setTimeout(function () {
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
respawnPlayerForPaintBall(client);
|
||||
} else {
|
||||
if (getPlayerCurrentSubAccount(client).inJail) {
|
||||
let closestJail = getClosestPoliceStation(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestJail.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
|
||||
fadePlayerCamera(client, true, 1000);
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
} else {
|
||||
let closestHospital = getClosestHospital(getPlayerPosition(client));
|
||||
despawnPlayer(client);
|
||||
getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
|
||||
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
|
||||
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
fadePlayerCamera(client, true, 1000);
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
|
||||
//let queryData = [
|
||||
// ["log_death_server", getServerId()]
|
||||
// ["log_death_who_died", getPlayerCurrentSubAccount(client).databaseId],
|
||||
// ["log_death_when_died", getCurrentUnixTimestamp()],
|
||||
// ["log_death_pos_x", position.x],
|
||||
// ["log_death_pos_y", position.y],
|
||||
// ["log_death_pos_z", position.x],
|
||||
//];
|
||||
//let queryString = createDatabaseInsertQuery("log_death", queryData);
|
||||
//queryDatabase(queryString);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerSurrendered(client) {
|
||||
return (getPlayerData(client).pedState == AGRP_PEDSTATE_TAZED || getPlayerData(client).pedState == AGRP_PEDSTATE_HANDSUP);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerRestrained(client) {
|
||||
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerInPropertyData(client) {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if (businessId != -1) {
|
||||
getPlayerData(client).inProperty = [AGRP_PROPERTY_TYPE_BUSINESS, businessId];
|
||||
return false;
|
||||
}
|
||||
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (houseId != -1) {
|
||||
getPlayerData(client).inProperty = [AGRP_PROPERTY_TYPE_HOUSE, houseId];
|
||||
return false;
|
||||
}
|
||||
|
||||
getPlayerData(client).inProperty = null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: connected.js
|
||||
// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods
|
||||
@@ -22,28 +23,11 @@ let builtInCommands = [
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let disconnectReasons = [
|
||||
"Lost Connection",
|
||||
"Disconnected",
|
||||
"Unsupported Client",
|
||||
"Wrong Game",
|
||||
"Incorrect Password",
|
||||
"Unsupported Executable",
|
||||
"Disconnected",
|
||||
"Banned",
|
||||
"Failed",
|
||||
"Invalid Name",
|
||||
"Crashed",
|
||||
"Modified Game"
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerPosition(client) {
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return getPlayerData(client).syncPosition;
|
||||
} else {
|
||||
if(getPlayerPed(client) != null) {
|
||||
if (getPlayerPed(client) != null) {
|
||||
return getPlayerPed(client).position;
|
||||
}
|
||||
}
|
||||
@@ -59,10 +43,10 @@ function setPlayerPosition(client, position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerHeading(client) {
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return getPlayerData(client).syncHeading;
|
||||
} else {
|
||||
if(getPlayerPed(client) != null) {
|
||||
if (getPlayerPed(client) != null) {
|
||||
return getPlayerPed(client).heading;
|
||||
}
|
||||
}
|
||||
@@ -78,10 +62,10 @@ function setPlayerHeading(client, heading) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerVehicle(client) {
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return getPlayerData().syncVehicle;
|
||||
} else {
|
||||
if(getPlayerPed(client).vehicle) {
|
||||
if (getPlayerPed(client).vehicle) {
|
||||
return getPlayerPed(client).vehicle;
|
||||
}
|
||||
}
|
||||
@@ -91,10 +75,10 @@ function getPlayerVehicle(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerDimension(client) {
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return getPlayerData(client).syncDimension;
|
||||
} else {
|
||||
if(getPlayerPed(client) != null) {
|
||||
if (getPlayerPed(client) != null) {
|
||||
return getPlayerPed(client).dimension;
|
||||
}
|
||||
}
|
||||
@@ -110,10 +94,10 @@ function getPlayerInterior(client) {
|
||||
|
||||
function setPlayerDimension(client, dimension) {
|
||||
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s dimension to ${dimension}`);
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
getPlayerData(client).syncDimension = dimension;
|
||||
} else {
|
||||
if(getPlayerPed(client) != null) {
|
||||
if (getPlayerPed(client) != null) {
|
||||
getPlayerPed(client).dimension = dimension;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +108,7 @@ function setPlayerDimension(client, dimension) {
|
||||
function setPlayerInterior(client, interior) {
|
||||
logToConsole(LOG_VERBOSE, `Setting ${getPlayerDisplayForConsole(client)}'s interior to ${interior}`);
|
||||
sendPlayerSetInterior(client, interior);
|
||||
if(isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
|
||||
if (isPlayerLoggedIn(client) && isPlayerSpawned(client)) {
|
||||
getPlayerCurrentSubAccount(client).interior = interior;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +116,7 @@ function setPlayerInterior(client, interior) {
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInAnyVehicle(client) {
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return (getPlayerData().syncVehicle != null);
|
||||
} else {
|
||||
return (getPlayerPed(client).vehicle != null);
|
||||
@@ -142,15 +126,15 @@ function isPlayerInAnyVehicle(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerVehicleSeat(client) {
|
||||
if(!isPlayerInAnyVehicle(client)) {
|
||||
if (!isPlayerInAnyVehicle(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!areServerElementsSupported()) {
|
||||
if (!areServerElementsSupported()) {
|
||||
return getPlayerData().syncVehicleSeat;
|
||||
} else {
|
||||
for(let i = 0 ; i <= 8 ; i++) {
|
||||
if(getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) {
|
||||
for (let i = 0; i <= 8; i++) {
|
||||
if (getPlayerVehicle(client).getOccupant(i) == getPlayerPed(client)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -180,8 +164,8 @@ function getVehicleHeading(vehicle) {
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleHeading(vehicle, heading) {
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
return sendNetworkEventToPlayer("vrr.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
return sendNetworkEventToPlayer("agrp.vehPosition", null, getVehicleForNetworkEvent(vehicle), heading);
|
||||
}
|
||||
return vehicle.heading = heading;
|
||||
}
|
||||
@@ -189,20 +173,20 @@ function setVehicleHeading(vehicle, heading) {
|
||||
// ===========================================================================
|
||||
|
||||
function getElementTransient(element) {
|
||||
if(typeof element.transient != "undefined") {
|
||||
if (typeof element.transient != "undefined") {
|
||||
return element.transient;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setElementTransient(element, state) {
|
||||
if(typeof element.transient != "undefined") {
|
||||
if (typeof element.transient != "undefined") {
|
||||
element.transient = state;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -214,8 +198,8 @@ function getVehicleSyncer(vehicle) {
|
||||
// ===========================================================================
|
||||
|
||||
function getVehicleForNetworkEvent(vehicle) {
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if(getVehicleData(vehicle).ivNetworkId != -1) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
if (getVehicleData(vehicle).ivNetworkId != -1) {
|
||||
return getVehicleData(vehicle).ivNetworkId;
|
||||
}
|
||||
return -1;
|
||||
@@ -227,11 +211,11 @@ function getVehicleForNetworkEvent(vehicle) {
|
||||
|
||||
function deleteGameElement(element) {
|
||||
try {
|
||||
if(element != null) {
|
||||
if (element != null) {
|
||||
destroyElement(element);
|
||||
return true;
|
||||
}
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -254,8 +238,8 @@ function removePlayerFromVehicle(client) {
|
||||
|
||||
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]})`);
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
triggerNetworkEvent("vrr.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
triggerNetworkEvent("agrp.localPlayerSkin", client, getGameConfig().skins[getGame()][skinIndex][0]);
|
||||
} else {
|
||||
getPlayerPed(client).modelIndex = getGameConfig().skins[getGame()][skinIndex][0];
|
||||
}
|
||||
@@ -264,7 +248,7 @@ function setPlayerSkin(client, skinIndex) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerSkin(client) {
|
||||
return getSkinIndexFromModel(client.player.modelIndex);
|
||||
return getPlayerCurrentSubAccount(client).skin; //getSkinIndexFromModel(client.player.modelIndex);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -292,7 +276,7 @@ function setPlayerArmour(client, armour) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerArmour(client) {
|
||||
if(areServerElementsSupported(client)) {
|
||||
if (areServerElementsSupported(client)) {
|
||||
return getPlayerPed(client).armour;
|
||||
} else {
|
||||
return getPlayerData(client).syncArmour;
|
||||
@@ -302,11 +286,11 @@ function getPlayerArmour(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setPlayerCash(client, amount) {
|
||||
if(client == null) {
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isNaN(amount)) {
|
||||
if (isNaN(amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,11 +301,11 @@ function setPlayerCash(client, amount) {
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerCash(client, amount) {
|
||||
if(client == null) {
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isNaN(amount)) {
|
||||
if (isNaN(amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -332,11 +316,11 @@ function givePlayerCash(client, amount) {
|
||||
// ===========================================================================
|
||||
|
||||
function takePlayerCash(client, amount) {
|
||||
if(client == null) {
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isNaN(amount)) {
|
||||
if (isNaN(amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -368,7 +352,7 @@ function getPlayerWeaponAmmo(client) {
|
||||
|
||||
function setPlayerVelocity(client, velocity) {
|
||||
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s velocity to ${velocity.x}, ${velocity.y}, ${velocity.z}`);
|
||||
if(typeof getPlayerPed(client).velocity != "undefined") {
|
||||
if (typeof getPlayerPed(client).velocity != "undefined") {
|
||||
getPlayerPed(client).velocity = velocity;
|
||||
}
|
||||
}
|
||||
@@ -376,7 +360,7 @@ function setPlayerVelocity(client, velocity) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerVelocity(client) {
|
||||
if(typeof getPlayerPed(client).velocity != "undefined") {
|
||||
if (typeof getPlayerPed(client).velocity != "undefined") {
|
||||
return getPlayerPed(client).velocity;
|
||||
}
|
||||
return toVector3(0.0, 0.0, 0.0);
|
||||
@@ -385,7 +369,7 @@ function getPlayerVelocity(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getElementDimension(element) {
|
||||
if(typeof element.dimension != "undefined") {
|
||||
if (typeof element.dimension != "undefined") {
|
||||
return element.dimension;
|
||||
}
|
||||
return 0;
|
||||
@@ -394,18 +378,18 @@ function getElementDimension(element) {
|
||||
// ===========================================================================
|
||||
|
||||
function setElementDimension(element, dimension) {
|
||||
if(typeof element.dimension != "undefined") {
|
||||
if (typeof element.dimension != "undefined") {
|
||||
logToConsole(LOG_VERBOSE, `Setting element ${element} (${element.id}) dimension to ${dimension}`);
|
||||
element.dimension = dimension;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
element.dimension = dimension;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setElementRotation(element, rotation) {
|
||||
if(typeof element.setRotation != "undefined") {
|
||||
if (typeof element.setRotation != "undefined") {
|
||||
element.setRotation(rotation);
|
||||
} else {
|
||||
return element.rotation = rotation;
|
||||
@@ -415,24 +399,24 @@ function setElementRotation(element, rotation) {
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerHealth(client, amount) {
|
||||
if(getPlayerHealth(client)+amount > 100) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s armour to ${getPlayerArmour(client) + amount}`);
|
||||
setPlayerArmour(client, getPlayerArmour(client) + amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +453,7 @@ function getServerName() {
|
||||
// ===========================================================================
|
||||
|
||||
function createGamePickup(modelIndex, position, type) {
|
||||
if(!isGameFeatureSupported("pickups")) {
|
||||
if (!isGameFeatureSupported("pickup")) {
|
||||
return false;
|
||||
}
|
||||
return game.createPickup(modelIndex, position, type);
|
||||
@@ -478,7 +462,7 @@ function createGamePickup(modelIndex, position, type) {
|
||||
// ===========================================================================
|
||||
|
||||
function createGameBlip(position, type = 0, colour = toColour(255, 255, 255, 255)) {
|
||||
if(!isGameFeatureSupported("blips")) {
|
||||
if (!isGameFeatureSupported("blip")) {
|
||||
return false;
|
||||
}
|
||||
return game.createBlip(type, position, 1, colour);
|
||||
@@ -487,7 +471,7 @@ function createGameBlip(position, type = 0, colour = toColour(255, 255, 255, 255
|
||||
// ===========================================================================
|
||||
|
||||
function createGameObject(modelIndex, position) {
|
||||
if(!isGameFeatureSupported("objects")) {
|
||||
if (!isGameFeatureSupported("object")) {
|
||||
return false;
|
||||
}
|
||||
return game.createObject(getGameConfig().objects[getGame()][modelIndex][0], position);
|
||||
@@ -496,13 +480,13 @@ function createGameObject(modelIndex, position) {
|
||||
// ===========================================================================
|
||||
|
||||
function setElementOnAllDimensions(element, state) {
|
||||
if(!isNull(element) && element != false) {
|
||||
if(typeof element.netFlags != "undefined") {
|
||||
if(typeof element.netFlags.onAllDimensions != "undefined") {
|
||||
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") {
|
||||
if (typeof element.onAllDimensions != "undefined") {
|
||||
element.onAllDimensions = state;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +496,7 @@ function setElementOnAllDimensions(element, state) {
|
||||
// ===========================================================================
|
||||
|
||||
function destroyGameElement(element) {
|
||||
if(!isNull(element) && element != false) {
|
||||
if (!isNull(element) && element != false) {
|
||||
destroyElement(element);
|
||||
}
|
||||
}
|
||||
@@ -532,7 +516,7 @@ function getPlayerLastVehicle(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isVehicleObject(vehicle) {
|
||||
if(vehicle == null || vehicle == undefined) {
|
||||
if (vehicle == null || vehicle == undefined) {
|
||||
return false;
|
||||
}
|
||||
return (vehicle.type == ELEMENT_VEHICLE);
|
||||
@@ -547,15 +531,15 @@ function repairVehicle(vehicle) {
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleLights(vehicle, lights) {
|
||||
setEntityData(vehicle, "vrr.lights", lights, true);
|
||||
sendNetworkEventToPlayer("vrr.veh.lights", null, vehicle.id, lights);
|
||||
setEntityData(vehicle, "agrp.lights", lights, true);
|
||||
sendNetworkEventToPlayer("agrp.veh.lights", null, vehicle.id, lights);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleEngine(vehicle, engine) {
|
||||
vehicle.engine = engine;
|
||||
setEntityData(vehicle, "vrr.engine", engine, true);
|
||||
setEntityData(vehicle, "agrp.engine", engine, true);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -600,11 +584,11 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1
|
||||
vehicle.colour1 = colour1;
|
||||
vehicle.colour2 = colour2;
|
||||
|
||||
if(colour3 != -1) {
|
||||
if (colour3 != -1) {
|
||||
vehicle.colour3 = colour3;
|
||||
}
|
||||
|
||||
if(colour4 != -1) {
|
||||
if (colour4 != -1) {
|
||||
vehicle.colour4 = colour4;
|
||||
}
|
||||
}
|
||||
@@ -612,7 +596,7 @@ function setVehicleColours(vehicle, colour1, colour2, colour3 = -1, colour4 = -1
|
||||
// ===========================================================================
|
||||
|
||||
function createGameVehicle(modelIndex, position, heading) {
|
||||
if(areServerElementsSupported()) {
|
||||
if (areServerElementsSupported()) {
|
||||
return mp.vehicles.new(getGameConfig().vehicles[getGame()][modelIndex][0], position, {
|
||||
heading: heading,
|
||||
numberPlate: "",
|
||||
@@ -628,7 +612,7 @@ function createGameVehicle(modelIndex, position, heading) {
|
||||
// ===========================================================================
|
||||
|
||||
function createGameCivilian(modelIndex, position, heading) {
|
||||
if(areServerElementsSupported()) {
|
||||
if (areServerElementsSupported()) {
|
||||
return mp.peds.new(getGameConfig().skins[getGame()][modelIndex][1], position, heading, 0);
|
||||
}
|
||||
|
||||
@@ -644,7 +628,7 @@ function getIsland(position) {
|
||||
// ===========================================================================
|
||||
|
||||
function isValidVehicleModel(model) {
|
||||
if(getVehicleModelIndexFromModel(model) != false) {
|
||||
if (getVehicleModelIndexFromModel(model) != false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -654,7 +638,7 @@ function isValidVehicleModel(model) {
|
||||
// ===========================================================================
|
||||
|
||||
function setGameTime(hour, minute, minuteDuration = 1000) {
|
||||
if(isTimeSupported()) {
|
||||
if (isTimeSupported()) {
|
||||
game.time.hour = hour;
|
||||
game.time.minute = minute;
|
||||
game.time.minuteDuration = minuteDuration;
|
||||
@@ -664,7 +648,7 @@ function setGameTime(hour, minute, minuteDuration = 1000) {
|
||||
// ===========================================================================
|
||||
|
||||
function setGameWeather(weather) {
|
||||
if(isWeatherSupported()) {
|
||||
if (isWeatherSupported()) {
|
||||
mp.world.weather = weather;
|
||||
}
|
||||
}
|
||||
@@ -690,7 +674,7 @@ function getPlayerElement(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setElementPosition(element, position) {
|
||||
sendNetworkEventToPlayer("vrr.elementPosition", null, element.id, position);
|
||||
sendNetworkEventToPlayer("agrp.elementPosition", null, element.id, position);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -714,13 +698,13 @@ function setElementInterior(element, interior) {
|
||||
// ===========================================================================
|
||||
|
||||
function setElementCollisionsEnabled(element, state) {
|
||||
//sendNetworkEventToPlayer("vrr.elementCollisions", null, element.id, state);
|
||||
//sendNetworkEventToPlayer("agrp.elementCollisions", null, element.id, state);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isTaxiVehicle(vehicle) {
|
||||
if(getGameConfig().taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) {
|
||||
if (getGameConfig().taxiModels[getGame()].indexOf(vehicle.modelIndex) != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -737,7 +721,7 @@ function getVehicleName(vehicle) {
|
||||
// ===========================================================================
|
||||
|
||||
function getElementModel(element) {
|
||||
if(typeof element.model != "undefined") {
|
||||
if (typeof element.model != "undefined") {
|
||||
return element.model;
|
||||
}
|
||||
}
|
||||
@@ -757,26 +741,26 @@ function getPlayerWeapon(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function connectToDatabase() {
|
||||
if(getDatabaseConfig().usePersistentConnection) {
|
||||
if(persistentDatabaseConnection == null) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Initializing database connection ...`);
|
||||
if (getDatabaseConfig().usePersistentConnection) {
|
||||
if (persistentDatabaseConnection == null) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Initializing database connection ...`);
|
||||
persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if(persistentDatabaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
if (persistentDatabaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
persistentDatabaseConnection = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection successful!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection successful!`);
|
||||
return persistentDatabaseConnection;
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Using existing database connection.`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Using existing database connection.`);
|
||||
return persistentDatabaseConnection;
|
||||
}
|
||||
} else {
|
||||
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if(databaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
if (databaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
return false;
|
||||
} else {
|
||||
return databaseConnection;
|
||||
@@ -787,12 +771,12 @@ function connectToDatabase() {
|
||||
// ===========================================================================
|
||||
|
||||
function disconnectFromDatabase(dbConnection) {
|
||||
if(!getDatabaseConfig().usePersistentConnection) {
|
||||
if (!getDatabaseConfig().usePersistentConnection) {
|
||||
try {
|
||||
dbConnection.close();
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`);
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection closed successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -801,8 +785,8 @@ function disconnectFromDatabase(dbConnection) {
|
||||
// ===========================================================================
|
||||
|
||||
function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`);
|
||||
if(useThread == true) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
if (useThread == true) {
|
||||
Promise.resolve().then(() => {
|
||||
let queryResult = dbConnection.query(queryString);
|
||||
return queryResult;
|
||||
@@ -815,11 +799,11 @@ function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
// ===========================================================================
|
||||
|
||||
function escapeDatabaseString(dbConnection, unsafeString = "") {
|
||||
if(!dbConnection) {
|
||||
if (!dbConnection) {
|
||||
dbConnection = connectToDatabase();
|
||||
}
|
||||
|
||||
if(typeof unsafeString == "string") {
|
||||
if (typeof unsafeString == "string") {
|
||||
return dbConnection.escapeString(unsafeString);
|
||||
}
|
||||
return unsafeString;
|
||||
@@ -846,7 +830,7 @@ function getDatabaseError(dbConnection) {
|
||||
// ===========================================================================
|
||||
|
||||
function freeDatabaseQuery(dbQuery) {
|
||||
if(dbQuery != null) {
|
||||
if (dbQuery != null) {
|
||||
dbQuery.free();
|
||||
}
|
||||
return;
|
||||
@@ -863,26 +847,26 @@ function fetchQueryAssoc(dbQuery) {
|
||||
function quickDatabaseQuery(queryString) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let insertId = 0;
|
||||
if(dbConnection) {
|
||||
//logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`);
|
||||
if (dbConnection) {
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
let dbQuery = queryDatabase(dbConnection, queryString);
|
||||
if(getDatabaseInsertId(dbConnection)) {
|
||||
if (getDatabaseInsertId(dbConnection)) {
|
||||
insertId = getDatabaseInsertId(dbConnection);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query returned insert id ${insertId}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query returned insert id ${insertId}`);
|
||||
}
|
||||
|
||||
if(dbQuery) {
|
||||
if (dbQuery) {
|
||||
try {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query result free'd successfully`);
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query result free'd successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
|
||||
disconnectFromDatabase(dbConnection);
|
||||
|
||||
if(insertId != 0) {
|
||||
if (insertId != 0) {
|
||||
return insertId;
|
||||
}
|
||||
|
||||
@@ -915,8 +899,8 @@ function getElementId(element) {
|
||||
|
||||
function getClientFromIndex(index) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(clients[i].index == index) {
|
||||
for (let i in clients) {
|
||||
if (clients[i].index == index) {
|
||||
return clients[i];
|
||||
}
|
||||
}
|
||||
@@ -955,7 +939,7 @@ function getClosestCivilian(position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getVehiclesInRange(position, range) {
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
return getServerData().vehicles.reduce((i, j) => (getDistance(position, i.syncPosition) <= getDistance(position, j.syncPosition)) ? i : j);
|
||||
}
|
||||
return getElementsByTypeInRange(ELEMENT_VEHICLE, position, range);
|
||||
@@ -976,8 +960,8 @@ function getClosestElementByType(elementType, position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getVehicleFirstEmptySeat(vehicle) {
|
||||
for(let i = 0; i <= 4; i++) {
|
||||
if(vehicle.getOccupant(i) == null) {
|
||||
for (let i = 0; i <= 4; i++) {
|
||||
if (vehicle.getOccupant(i) == null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -1013,15 +997,15 @@ 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, `[AGRP.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
|
||||
//sendNetworkEventToPlayer("agrp.giveWeapon", client, weaponId, ammo, active);
|
||||
client.giveWeapon(weaponId, ammo);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setPlayerWantedLevel(client, wantedLevel) {
|
||||
//sendNetworkEventToPlayer("vrr.wantedLevel", client, wantedLevel);
|
||||
//sendNetworkEventToPlayer("agrp.wantedLevel", client, wantedLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1046,9 +1030,9 @@ function getPlayerPed(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setEntityData(entity, dataName, dataValue, syncToClients = true) {
|
||||
if(entity != null) {
|
||||
if(areServerElementsSupported()) {
|
||||
if(syncToClients) {
|
||||
if (entity != null) {
|
||||
if (areServerElementsSupported()) {
|
||||
if (syncToClients) {
|
||||
return entity.setVariable(dataName, dataValue);
|
||||
} else {
|
||||
return entity.setOwnVariable(dataName, dataValue);
|
||||
@@ -1061,8 +1045,8 @@ function setEntityData(entity, dataName, dataValue, syncToClients = true) {
|
||||
// ===========================================================================
|
||||
|
||||
function removeEntityData(entity, dataName) {
|
||||
if(entity != null) {
|
||||
if(areServerElementsSupported()) {
|
||||
if (entity != null) {
|
||||
if (areServerElementsSupported()) {
|
||||
return entity.setVariable(dataName, null);
|
||||
}
|
||||
}
|
||||
@@ -1072,8 +1056,8 @@ function removeEntityData(entity, dataName) {
|
||||
// ===========================================================================
|
||||
|
||||
function doesEntityDataExist(entity, dataName) {
|
||||
if(entity != null) {
|
||||
if(areServerElementsSupported()) {
|
||||
if (entity != null) {
|
||||
if (areServerElementsSupported()) {
|
||||
return (entity.getVariable(dataName) != null);
|
||||
} else {
|
||||
return false;
|
||||
@@ -1124,7 +1108,7 @@ function despawnPlayer(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getGame() {
|
||||
return VRR_GAME_GTA_V;
|
||||
return AGRP_GAME_GTA_V;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1169,7 +1153,7 @@ function serverBanIP(ip) {
|
||||
// ===========================================================================
|
||||
|
||||
function setVehicleTrunkState(vehicle, trunkState) {
|
||||
//sendNetworkEventToPlayer("vrr.veh.trunk", null, getVehicleForNetworkEvent(vehicle), trunkState);
|
||||
//sendNetworkEventToPlayer("agrp.veh.trunk", null, getVehicleForNetworkEvent(vehicle), trunkState);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1201,7 +1185,7 @@ function addAllEventHandlers() {
|
||||
// ===========================================================================
|
||||
|
||||
function addServerCommandHandler(command, handlerFunction) {
|
||||
mp.events.addCommand(command, function(client, ...args) {
|
||||
mp.events.addCommand(command, function (client, ...args) {
|
||||
handlerFunction.call(command, args.join(" "), client);
|
||||
});
|
||||
}
|
||||
@@ -1209,7 +1193,7 @@ function addServerCommandHandler(command, handlerFunction) {
|
||||
// ===========================================================================
|
||||
|
||||
function addServerEventHandler(eventName, handlerFunction) {
|
||||
mp.events.add(eventName, function(event, ...args) {
|
||||
mp.events.add(eventName, function (event, ...args) {
|
||||
let result = handlerFunction.apply(this, args);
|
||||
});
|
||||
}
|
||||
@@ -1217,7 +1201,7 @@ function addServerEventHandler(eventName, handlerFunction) {
|
||||
// ===========================================================================
|
||||
|
||||
function bindServerEventHandler(eventName, bindTo, handlerFunction) {
|
||||
mp.events.add(eventName, function(event, ...args) {
|
||||
mp.events.add(eventName, function (event, ...args) {
|
||||
let result = handlerFunction.apply(this, args);
|
||||
});
|
||||
}
|
||||
@@ -1243,7 +1227,44 @@ function showElementForPlayer(element, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setElementShownByDefault(element, state) {
|
||||
element.netFlags.defaultExistance(state);
|
||||
element.netFlags.defaultExistance = state;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createAttachedGameBlip(element, type, size, colour = toColour(255, 255, 255, 255)) {
|
||||
if (isGameFeatureSupported("attachedBlip")) {
|
||||
return game.createBlipAttachedTo(element, type, size, colour, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deletePlayerPed(client) {
|
||||
if (areServerElementsSupported()) {
|
||||
destroyElement(client.player);
|
||||
} else {
|
||||
sendNetworkEventToPlayer("agrp.deleteLocalPlayerPed", client);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerOnBoat(client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setServerName(name) {
|
||||
server.name = name;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setServerPassword(password) {
|
||||
server.setPassword(password);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
1320
scripts/server/netevents.js
Normal file
1320
scripts/server/netevents.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,213 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: npc.js
|
||||
// DESC: Provides NPC usage and functions
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// NPC Trigger Condition Match Types
|
||||
const AGRP_NPC_COND_MATCH_NONE = 0; // None (invalid)
|
||||
const AGRP_NPC_COND_MATCH_EQ = 1; // Must be equal to
|
||||
const AGRP_NPC_COND_MATCH_GT = 2; // Must be greater than
|
||||
const AGRP_NPC_COND_MATCH_LT = 3; // Must be less than
|
||||
const AGRP_NPC_COND_MATCH_GTEQ = 4; // Must be greater than or equal to
|
||||
const AGRP_NPC_COND_MATCH_LTEQ = 5; // Must be less than or equal to
|
||||
const AGRP_NPC_COND_MATCH_CONTAINS = 6; // Must contain string (case insensitive)
|
||||
const AGRP_NPC_COND_MATCH_CONTAINS_CASE = 7; // Must contain string (case sensitive)
|
||||
const AGRP_NPC_COND_MATCH_EXACT = 8; // Must match string exactly (case insensitive)
|
||||
const AGRP_NPC_COND_MATCH_EXACT_CASE = 9; // Must match string exactly (case insensitive)
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// NPC Owner Types
|
||||
const AGRP_NPC_OWNER_NONE = 0; // Not owned
|
||||
const AGRP_NPC_OWNER_PLAYER = 1; // Owned by a player (character/subaccount)
|
||||
const AGRP_NPC_OWNER_JOB = 2; // Owned by a job
|
||||
const AGRP_NPC_OWNER_CLAN = 3; // Owned by a clan
|
||||
const AGRP_NPC_OWNER_FACTION = 4; // Owned by a faction (not used at the moment)
|
||||
const AGRP_NPC_OWNER_PUBLIC = 5; // Public NPC. Anybody can do stuff with it.
|
||||
const AGRP_NPC_OWNER_BIZ = 6; // Owned by a business
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class NPCData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.serverId = 0;
|
||||
this.name = "NPC";
|
||||
this.skin = 0;
|
||||
this.cash = 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.rank = 0;
|
||||
this.isWorking = false;
|
||||
this.jobUniform = this.skin;
|
||||
this.lastJobVehicle = null;
|
||||
this.job = 0;
|
||||
this.weapons = [];
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
this.walkStyle = 0;
|
||||
this.fightStyle = 0;
|
||||
this.health = 100;
|
||||
this.armour = 100;
|
||||
this.currentAction = AGRP_NPC_ACTION_NONE;
|
||||
this.triggers = [];
|
||||
this.typeFlags = 0;
|
||||
this.heedThreats = false;
|
||||
this.threats = 0;
|
||||
this.invincible = false;
|
||||
this.animationName = "";
|
||||
this.ownerType = AGRP_NPC_OWNER_NONE;
|
||||
this.ownerId = 0;
|
||||
this.enabled = false;
|
||||
|
||||
this.bodyParts = {
|
||||
hair: [0, 0],
|
||||
head: [0, 0],
|
||||
upper: [0, 0],
|
||||
lower: [0, 0],
|
||||
};
|
||||
|
||||
this.bodyProps = {
|
||||
hair: [0, 0],
|
||||
eyes: [0, 0],
|
||||
head: [0, 0],
|
||||
leftHand: [0, 0],
|
||||
rightHand: [0, 0],
|
||||
leftWrist: [0, 0],
|
||||
rightWrist: [0, 0],
|
||||
hip: [0, 0],
|
||||
leftFoot: [0, 0],
|
||||
rightFoot: [0, 0],
|
||||
};
|
||||
|
||||
this.triggers = [];
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["npc_id"]);
|
||||
this.serverId = toInteger(dbAssoc["npc_server"]);
|
||||
this.name = dbAssoc["npc_name"];
|
||||
this.skin = toInteger(dbAssoc["npc_skin"]);
|
||||
this.cash = toInteger(dbAssoc["npc_cash"]);
|
||||
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.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.walkStyle = toInteger(dbAssoc["npc_walk_style"]);
|
||||
this.fightStyle = toInteger(dbAssoc["npc_fight_style"]);
|
||||
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.animationName = toString(dbAssoc["npc_animation"]);
|
||||
this.enabled = intToBool(dbAssoc["npc_enabled"]);
|
||||
this.lookAtPlayer = intToBool(dbAssoc["npc_lookatplr"]);
|
||||
|
||||
this.bodyParts = {
|
||||
hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0],
|
||||
head: [toInteger(dbAssoc["npc_hd_part_head_model"]) || 0, toInteger(dbAssoc["npc_hd_part_head_texture"]) || 0],
|
||||
upper: [toInteger(dbAssoc["npc_hd_part_upper_model"]) || 0, toInteger(dbAssoc["npc_hd_part_upper_texture"]) || 0],
|
||||
lower: [toInteger(dbAssoc["npc_hd_part_lower_model"]) || 0, toInteger(dbAssoc["npc_hd_part_lower_texture"]) || 0],
|
||||
};
|
||||
|
||||
this.bodyProps = {
|
||||
hair: [toInteger(dbAssoc["npc_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hair_texture"]) || 0],
|
||||
eyes: [toInteger(dbAssoc["npc_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_eyes_texture"]) || 0],
|
||||
head: [toInteger(dbAssoc["npc_hd_prop_head_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_head_texture"]) || 0],
|
||||
leftHand: [toInteger(dbAssoc["npc_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_lefthand_texture"]) || 0],
|
||||
rightHand: [toInteger(dbAssoc["npc_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_righthand_texture"]) || 0],
|
||||
leftWrist: [toInteger(dbAssoc["npc_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftwrist_texture"]) || 0],
|
||||
rightWrist: [toInteger(dbAssoc["npc_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightwrist_texture"]) || 0],
|
||||
hip: [toInteger(dbAssoc["npc_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_hip_texture"]) || 0],
|
||||
leftFoot: [toInteger(dbAssoc["npc_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_leftfoot_texture"]) || 0],
|
||||
rightFoot: [toInteger(dbAssoc["npc_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["npc_hd_prop_rightfoot_texture"]) || 0],
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class NPCTriggerData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.npcId = 0;
|
||||
this.index = 0;
|
||||
this.npc = 0;
|
||||
this.npcIndex = -1;
|
||||
this.triggerType = 0;
|
||||
this.conditions = [];
|
||||
this.responses = [];
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["npc_trig_id"]);
|
||||
this.npc = toInteger(dbAssoc["npc_trig_npc"]);
|
||||
this.triggerType = toInteger(dbAssoc["npc_trig_type"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class NPCTriggerConditionData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.triggerId = 0;
|
||||
this.index = 0;
|
||||
this.triggerIndex = 0;
|
||||
this.conditionType = 0;
|
||||
this.conditionValue = false;
|
||||
this.matchType = false;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["npc_trig_cond_id"]);
|
||||
this.npc = toInteger(dbAssoc["npc_trig_cond_trig"]);
|
||||
this.conditionType = toInteger(dbAssoc["npc_trig_cond_type"]);
|
||||
this.conditionValue = toInteger(dbAssoc["npc_trig_cond_val"]);
|
||||
this.matchType = toInteger(dbAssoc["npc_trig_cond_val"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class NPCTriggerResponseData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.triggerId = 0;
|
||||
this.index = 0;
|
||||
this.triggerIndex = 0;
|
||||
this.responseType = 0;
|
||||
this.responseValue = false;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc["npc_trig_resp_id"]);
|
||||
this.npc = toInteger(dbAssoc["npc_trig_resp_trig"]);
|
||||
this.responseType = toInteger(dbAssoc["npc_trig_resp_type"]);
|
||||
this.responseValue = toInteger(dbAssoc["npc_trig_resp_val"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initNPCScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.NPC]: Initializing NPC script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.NPC]: NPC script initialized successfully!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.NPC]: Initializing NPC script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.NPC]: NPC script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -19,7 +217,7 @@ function initNPCScript() {
|
||||
* @return {NPCData} The NPC's data (class instancee)
|
||||
*/
|
||||
function getNPCData(npcId) {
|
||||
if(typeof getServerData().npcs[npcId] != "undefined") {
|
||||
if (typeof getServerData().npcs[npcId] != "undefined") {
|
||||
return getServerData().npcs[npcId];
|
||||
}
|
||||
return false;
|
||||
@@ -28,14 +226,14 @@ function getNPCData(npcId) {
|
||||
// ===========================================================================
|
||||
|
||||
function createNPCCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let skinIndex = getSkinModelIndexFromParams(params);
|
||||
|
||||
if(!skinIndex) {
|
||||
if (!skinIndex) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidSkin"));
|
||||
return false;
|
||||
}
|
||||
@@ -48,15 +246,16 @@ function createNPCCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadNPCsFromDatabase() {
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: Loading NPCs from database ...`);
|
||||
async function loadNPCsFromDatabase() {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: Loading NPCs from database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempNPCs = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_main WHERE npc_server = ${getServerId()} AND npc_enabled = 1`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCData = new NPCData(dbAssoc[i]);
|
||||
tempNPCData.triggers = loadNPCTriggersFromDatabase();
|
||||
tempNPCs.push(tempNPCData);
|
||||
@@ -64,21 +263,22 @@ function loadNPCsFromDatabase() {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: ${tempNPCs.length} NPCs loaded from database successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: ${tempNPCs.length} NPCs loaded from database successfully!`);
|
||||
return tempNPCs;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadNPCTriggersFromDatabase(npcDatabaseId) {
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: Loading NPC triggers for NPC ${npcDatabaseId} from database ...`);
|
||||
async function loadNPCTriggersFromDatabase(npcDatabaseId) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: Loading NPC triggers for NPC ${npcDatabaseId} from database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempNPCTriggers = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_trig WHERE npc_trig_npc = ${npcDatabaseId} AND npc_trig_enabled = 1`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCTriggerData = new NPCTriggerData(dbAssoc[i]);
|
||||
tempNPCTriggerData.conditions = loadNPCTriggerConditionsFromDatabase(tempNPCTriggerData.databaseId);
|
||||
tempNPCTriggerData.responses = loadNPCTriggerResponsesFromDatabase(tempNPCTriggerData.databaseId);
|
||||
@@ -87,60 +287,62 @@ function loadNPCTriggersFromDatabase(npcDatabaseId) {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: ${tempNPCTriggers.length} NPC triggers loaded for NPC ${npcDatabaseId} from database successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: ${tempNPCTriggers.length} NPC triggers loaded for NPC ${npcDatabaseId} from database successfully!`);
|
||||
return tempNPCTriggers;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadNPCTriggerConditionsFromDatabase(npcTriggerDatabaseId) {
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: Loading NPC trigger conditions for trigger ${npcTriggerDatabaseId} from database ...`);
|
||||
async function loadNPCTriggerConditionsFromDatabase(npcTriggerDatabaseId) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: Loading NPC trigger conditions for trigger ${npcTriggerDatabaseId} from database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempNPCTriggerConditions = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_cond WHERE npc_cond_trig = ${npcTriggerDatabaseId} AND npc_cond_enabled = 1`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc[i]);
|
||||
tempNPCTriggerConditions.push(tempNPCTriggerConditionData);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: ${tempNPCTriggerConditions.length} conditions loaded for trigger ${npcTriggerDatabaseId} from database successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: ${tempNPCTriggerConditions.length} conditions loaded for trigger ${npcTriggerDatabaseId} from database successfully!`);
|
||||
return tempNPCTriggerConditions;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: Loading NPC trigger responses for trigger ${npcTriggerDatabaseId} from database ...`);
|
||||
async function loadNPCTriggerResponsesFromDatabase(npcTriggerDatabaseId) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: Loading NPC trigger responses for trigger ${npcTriggerDatabaseId} from database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempNPCTriggerResponses = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_resp WHERE npc_resp_trig = ${npcTriggerDatabaseId} AND npc_resp_enabled = 1`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCTriggerResponseData = new NPCTriggerResponseData(dbAssoc[i]);
|
||||
tempNPCTriggerResponses.push(tempNPCTriggerResponseData);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.NPC]: ${tempNPCTriggerResponses.length} responses loaded for trigger ${npcTriggerDatabaseId} from database successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: ${tempNPCTriggerResponses.length} responses loaded for trigger ${npcTriggerDatabaseId} from database successfully!`);
|
||||
return tempNPCTriggerResponses;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function saveAllNPCsToDatabase() {
|
||||
if(getServerConfig().devServer) {
|
||||
if (getServerConfig().devServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(let i in getServerData().npcs) {
|
||||
for (let i in getServerData().npcs) {
|
||||
saveNPCToDatabase(i);
|
||||
}
|
||||
}
|
||||
@@ -148,34 +350,34 @@ function saveAllNPCsToDatabase() {
|
||||
// ===========================================================================
|
||||
|
||||
function saveNPCToDatabase(npcDataId) {
|
||||
if(getServerConfig().devServer) {
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} can't be saved because server is running as developer only. Aborting save ...`);
|
||||
if (getServerConfig().devServer) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: NPC ${npcDataId} can't be saved because server is running as developer only. Aborting save ...`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getNPCData(npcDataId) == false) {
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} data is invalid. Aborting save ...`);
|
||||
if (getNPCData(npcDataId) == false) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: NPC ${npcDataId} data is invalid. Aborting save ...`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let tempNPCData = getNPCData(npcDataId);
|
||||
|
||||
if(tempNPCData.databaseId == -1) {
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} is a temp NPC. Aborting save ...`);
|
||||
if (tempNPCData.databaseId == -1) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: NPC ${npcDataId} is a temp NPC. Aborting save ...`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!tempNPCData.needsSaved) {
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: NPC ${npcDataId} hasn't changed data. Aborting save ...`);
|
||||
if (!tempNPCData.needsSaved) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: NPC ${npcDataId} hasn't changed data. Aborting save ...`);
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: Saving NPC ${tempNPCData.databaseId} to database ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if(tempNPCData.ped != false) {
|
||||
if(!tempNPCData.spawnLocked) {
|
||||
if(areServerElementsSupported()) {
|
||||
if (dbConnection) {
|
||||
if (tempNPCData.ped != false) {
|
||||
if (!tempNPCData.spawnLocked) {
|
||||
if (areServerElementsSupported()) {
|
||||
tempNPCData.position = tempNPCData.ped.position;
|
||||
tempNPCData.heading = tempNPCData.ped.heading;
|
||||
} else {
|
||||
@@ -187,6 +389,7 @@ function saveNPCToDatabase(npcDataId) {
|
||||
|
||||
let safeAnimationName = escapeDatabaseString(dbConnection, tempNPCData.animationName);
|
||||
let safeName = escapeDatabaseString(dbConnection, tempNPCData.name);
|
||||
let safeTitle = escapeDatabaseString(dbConnection, tempNPCData.title);
|
||||
|
||||
let data = [
|
||||
["npc_server", getServerId()],
|
||||
@@ -209,10 +412,19 @@ function saveNPCToDatabase(npcDataId) {
|
||||
["npc_threats", toInteger(tempNPCData.threats)],
|
||||
["npc_stay", boolToInt(tempNPCData.stay)],
|
||||
["npc_type_flags", toInteger(tempNPCData.typeFlags)],
|
||||
["npc_int", toInteger(tempNPCData.interior)],
|
||||
["npc_vw", toInteger(tempNPCData.dimension)],
|
||||
["npc_fight_style", toInteger(tempNPCData.fightStyle)],
|
||||
["npc_walk_style", toInteger(tempNPCData.walkStyle)],
|
||||
["npc_rank", toInteger(tempNPCData.rank)],
|
||||
["npc_title", toString(safeTitle)],
|
||||
["npc_enabled", boolToInt(tempNPCData.enabled)],
|
||||
["npc_lookatplr", boolToInt(tempNPCData.lookAtPlayer)],
|
||||
//["npc_recreate", toInteger(tempNPCData.recreateOnDeath)],
|
||||
];
|
||||
|
||||
let dbQuery = null;
|
||||
if(tempNPCData.databaseId == 0) {
|
||||
if (tempNPCData.databaseId == 0) {
|
||||
let queryString = createDatabaseInsertQuery("npc_main", data);
|
||||
dbQuery = queryDatabase(dbConnection, queryString);
|
||||
tempNPCData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
@@ -227,7 +439,7 @@ function saveNPCToDatabase(npcDataId) {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return true;
|
||||
}
|
||||
logToConsole(LOG_VERBOSE, `[VRR.NPC]: Saved NPC ${npcDataId} to database!`);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.NPC]: Saved NPC ${npcDataId} to database!`);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -235,19 +447,19 @@ function saveNPCToDatabase(npcDataId) {
|
||||
// ===========================================================================
|
||||
|
||||
function setNPCDataIndexes() {
|
||||
for(let i in getServerData().npcs) {
|
||||
for (let i in getServerData().npcs) {
|
||||
getServerData().npcs[i].index = i;
|
||||
|
||||
for(let j in getServerData().npcs[i].triggers) {
|
||||
for (let j in getServerData().npcs[i].triggers) {
|
||||
getServerData().npcs[i].triggers[j].index = j;
|
||||
getServerData().npcs[i].triggers[j].npcIndex = i;
|
||||
|
||||
for(let k in getServerData().npcs[i].triggers[j].conditions) {
|
||||
for (let k in getServerData().npcs[i].triggers[j].conditions) {
|
||||
getServerData().npcs[i].triggers[j].conditions[k].index = k;
|
||||
getServerData().npcs[i].triggers[j].conditions[m].triggerIndex = j;
|
||||
}
|
||||
|
||||
for(let m in getServerData().npcs[i].triggers[j].responses) {
|
||||
for (let m in getServerData().npcs[i].triggers[j].responses) {
|
||||
getServerData().npcs[i].triggers[j].responses[m].index = m;
|
||||
getServerData().npcs[i].triggers[j].responses[m].triggerIndex = j;
|
||||
}
|
||||
@@ -260,13 +472,13 @@ function setNPCDataIndexes() {
|
||||
function spawnNPC(npcIndex) {
|
||||
let npcData = getNPCData(npcIndex);
|
||||
let ped = createGamePed(npcData.skin, npcData.position, npcData.rotation.z);
|
||||
if(ped) {
|
||||
if (ped) {
|
||||
getNPCData(npcIndex).ped = ped;
|
||||
setEntityData(ped, "vrr.dataIndex", npcIndex, false);
|
||||
if(npcData.animationName != "") {
|
||||
setEntityData(ped, "agrp.dataIndex", npcIndex, false);
|
||||
if (npcData.animationName != "") {
|
||||
let animationId = getAnimationFromParams(npcData.animationName);
|
||||
if(animationId != false) {
|
||||
setEntityData(ped, "vrr.anim", animationId, true);
|
||||
if (animationId != false) {
|
||||
setEntityData(ped, "agrp.anim", animationId, true);
|
||||
}
|
||||
}
|
||||
setElementDimension(ped, npcData.dimension);
|
||||
@@ -277,7 +489,7 @@ function spawnNPC(npcIndex) {
|
||||
// ===========================================================================
|
||||
|
||||
function spawnAllNPCs() {
|
||||
for(let i in getServerData().npcs) {
|
||||
for (let i in getServerData().npcs) {
|
||||
spawnNPC(i);
|
||||
}
|
||||
}
|
||||
@@ -285,9 +497,9 @@ function spawnAllNPCs() {
|
||||
// ===========================================================================
|
||||
|
||||
function deleteNPCCommand(command, params, client) {
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
|
||||
if(!getNPCData(closestNPC)) {
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
@@ -303,9 +515,9 @@ function deleteNPCCommand(command, params, client) {
|
||||
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);
|
||||
if (getNPCData(npcId)) {
|
||||
if (getNPCData(npcId).ped != false) {
|
||||
deleteGameElement(getNPCData(npcId).ped);
|
||||
}
|
||||
getServerData().npcs.splice(npcId, 1);
|
||||
}
|
||||
@@ -316,27 +528,27 @@ function deleteNPC(npcId) {
|
||||
// ===========================================================================
|
||||
|
||||
function setNPCAnimationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
let animationId = getAnimationFromParams(getParam(params, " ", 1));
|
||||
let animationPositionOffset = 1;
|
||||
|
||||
if(!getNPCData(closestNPC)) {
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getAnimationData(animationId)) {
|
||||
if (!getAnimationData(animationId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areThereEnoughParams(params, 2, " ")) {
|
||||
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
if (areThereEnoughParams(params, 2, " ")) {
|
||||
if (toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidAnimationDistance"));
|
||||
return false;
|
||||
}
|
||||
@@ -353,15 +565,15 @@ function setNPCAnimationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setNPCNameCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
let name = params;
|
||||
|
||||
if(!getNPCData(closestNPC)) {
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
@@ -376,17 +588,75 @@ function setNPCNameCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||
function setNPCClanCommand(command, params, client) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getNPCData(closestNPC)) {
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
let clanId = getClanFromParams(params);
|
||||
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getClanData(clanId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidClan"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getNPCData(closestNPC).ownerType = AGRP_NPC_OWNER_CLAN;
|
||||
getNPCData(closestNPC).ownerId = getClanData(clanId).databaseId;
|
||||
getNPCData(closestNPC).needsSaved = true;
|
||||
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {npcPink}${getNPCData(closestNPC).name}${MAINCOLOUR}'s clan to {clanOrange}${getClanData(clanId).name}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function addNPCTriggerCommand(command, params, client) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
let clanId = getClanFromParams(params);
|
||||
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getClanData(clanId)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidClan"));
|
||||
return false;
|
||||
}
|
||||
|
||||
//let triggerData = new TriggerData();
|
||||
|
||||
getNPCData(closestNPC).ownerType = AGRP_NPC_OWNER_CLAN;
|
||||
getNPCData(closestNPC).ownerId = getClanData(clanId).databaseId;
|
||||
getNPCData(closestNPC).needsSaved = true;
|
||||
|
||||
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set {npcPink}${getNPCData(closestNPC).name}${MAINCOLOUR}'s clan to {clanOrange}${getClanData(clanId).name}`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
|
||||
getNPCData(closestNPC).lookAtClosestPlayer = !getNPCData(closestNPC).lookAtClosestPlayer;
|
||||
getNPCData(closestNPC).needsSaved = true;
|
||||
setEntityData(getNPCData(closestNPC).ped, "vrr.lookAtClosestPlayer", getNPCData(closestNPC).lookAtClosestPlayer, true);
|
||||
setEntityData(getNPCData(closestNPC).ped, "agrp.lookAtClosestPlayer", getNPCData(closestNPC).lookAtClosestPlayer, true);
|
||||
forcePlayerToSyncElementProperties(null, getNPCData(closestNPC).ped);
|
||||
//messagePlayerSuccess(client, getLocaleString(client, "NPCLookAtClosestPlayerSet", `{ALTCOLOUR}${getNPCData(closestNPC).name}{MAINCOLOUR}));
|
||||
}
|
||||
@@ -394,14 +664,14 @@ function toggleNPCLookAtClosestPlayerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getNPCInfoCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client));
|
||||
let closestNPC = getClosestNPC(getPlayerPosition(client), getPlayerDimension(client), getPlayerInterior(client));
|
||||
|
||||
if(!getNPCData(closestNPC)) {
|
||||
if (!getNPCData(closestNPC)) {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidNPC"));
|
||||
return false;
|
||||
}
|
||||
@@ -410,29 +680,29 @@ function getNPCInfoCommand(command, params, client) {
|
||||
|
||||
let ownerName = "Nobody";
|
||||
let ownerType = "None";
|
||||
switch(npcData.ownerType) {
|
||||
case VRR_NPCOWNER_CLAN:
|
||||
ownerName = getClanData(getClanIdFromDatabaseId(npcData.ownerId)).name;
|
||||
switch (npcData.ownerType) {
|
||||
case AGRP_NPC_OWNER_CLAN:
|
||||
ownerName = getClanData(getClanIndexFromDatabaseId(npcData.ownerId)).name;
|
||||
ownerType = "clan";
|
||||
break;
|
||||
|
||||
case VRR_NPCOWNER_JOB:
|
||||
ownerName = getJobData(getJobIdFromDatabaseId(npcData.ownerId)).name;
|
||||
case AGRP_NPC_OWNER_JOB:
|
||||
ownerName = getJobData(getJobIndexFromDatabaseId(npcData.ownerId)).name;
|
||||
ownerType = "job";
|
||||
break;
|
||||
|
||||
case VRR_NPCOWNER_PLAYER:
|
||||
case AGRP_NPC_OWNER_PLAYER:
|
||||
let subAccountData = loadSubAccountFromId(npcData.ownerId);
|
||||
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
|
||||
ownerType = "player";
|
||||
break;
|
||||
|
||||
case VRR_NPCOWNER_BIZ:
|
||||
case AGRP_NPC_OWNER_BIZ:
|
||||
ownerName = getBusinessData(getBusinessIdFromDatabaseId(npcData.ownerId)).name;
|
||||
ownerType = "business";
|
||||
break;
|
||||
|
||||
case VRR_NPCOWNER_PUBLIC:
|
||||
case AGRP_NPC_OWNER_PUBLIC:
|
||||
ownerName = "Nobody";
|
||||
ownerType = "public";
|
||||
break;
|
||||
@@ -452,23 +722,22 @@ function getNPCInfoCommand(command, params, client) {
|
||||
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderNPCInfo")));
|
||||
let chunkedList = splitArrayIntoChunks(stats, 6);
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestNPC(position) {
|
||||
function getClosestNPC(position, dimension, interior) {
|
||||
let npcs = getServerData().npcs;
|
||||
|
||||
let interior = getPlayerInterior(client);
|
||||
let dimension = getPlayerDimension(client);
|
||||
|
||||
let closest = 0;
|
||||
for(let i in npcs) {
|
||||
if(getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position) && npcs[closest].interior == interior && npcs[closest].dimension == dimension) {
|
||||
closest = i;
|
||||
for (let i in npcs) {
|
||||
if (npcs[i].interior == interior && npcs[i].dimension == dimension) {
|
||||
if (getDistance(npcs[i].ped.position, position) < getDistance(npcs[closest].ped.position, position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,9 +759,9 @@ function createNPC(skinIndex, position, heading, interior, dimension) {
|
||||
let npcIndex = getServerData().npcs.push(tempNPCData);
|
||||
setNPCDataIndexes();
|
||||
|
||||
spawnNPC(npcIndex-1);
|
||||
spawnNPC(npcIndex - 1);
|
||||
|
||||
return npcIndex-1;
|
||||
return npcIndex - 1;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: biker.js
|
||||
// DESC: Provides biker NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: drugdealer.js
|
||||
// DESC: Provides drug dealer NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: firefighter.js
|
||||
// DESC: Provides firefighter NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: gangsta.js
|
||||
// DESC: Provides street gang/hoodlum NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: mafia.js
|
||||
// DESC: Provides mafia/mafioso NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: normal.js
|
||||
// DESC: Provides normal/generic civilian NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: paramedic.js
|
||||
// DESC: Provides paramedic NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,8 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: police.js
|
||||
// DESC: Provides police officer NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
@@ -1,28 +0,0 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// ===========================================================================
|
||||
// FILE: taxi.js
|
||||
// DESC: Provides taxi driver NPC interaction and functionality
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
function attemptToSignalToNearbyTaxi(client) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerSpawned(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
setVehicleLocked(closestTaxi, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
167
scripts/server/paintball.js
Normal file
167
scripts/server/paintball.js
Normal file
@@ -0,0 +1,167 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: paintball.js
|
||||
// DESC: Provides paintball/airsoft arena functions and commands
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let paintBallItems = [];
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let paintBallItemNames = {
|
||||
[AGRP_GAME_GTA_III]: [
|
||||
"Colt 45",
|
||||
"Uzi",
|
||||
"Shotgun",
|
||||
"AK-47",
|
||||
"Sniper Rifle",
|
||||
],
|
||||
|
||||
[AGRP_GAME_GTA_VC]: [
|
||||
"Colt 45",
|
||||
"Pump Shotgun",
|
||||
"Ingram",
|
||||
"MP5",
|
||||
"Ruger",
|
||||
"Sniper Rifle",
|
||||
],
|
||||
|
||||
[AGRP_GAME_GTA_SA]: [
|
||||
"Desert Eagle",
|
||||
"Shotgun",
|
||||
"MP5",
|
||||
"AK-47",
|
||||
"Sniper Rifle",
|
||||
],
|
||||
|
||||
[AGRP_GAME_GTA_IV]: [
|
||||
"Glock 9mm",
|
||||
"Micro Uzi",
|
||||
"Stubby Shotgun",
|
||||
"AK-47",
|
||||
"Sniper Rifle",
|
||||
],
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initPaintBallScript() {
|
||||
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Initializing paintball script ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.PaintBall]: Paintball script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function startPaintBall(client) {
|
||||
if (isPlayerInPaintBall(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Starting paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (isPlayerWorking(client)) {
|
||||
stopWorking(client);
|
||||
}
|
||||
|
||||
storePlayerItemsInTempLocker(client);
|
||||
getPlayerData(client).tempLockerType = AGRP_TEMP_LOCKER_TYPE_PAINTBALL;
|
||||
|
||||
getPlayerData(client).inPaintBall = true;
|
||||
getPlayerData(client).paintBallBusiness = getPlayerBusiness(client);
|
||||
|
||||
givePlayerPaintBallItems(client);
|
||||
|
||||
messagePlayerAlert(client, getLocaleString(client, "JoinedPaintBall"));
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Started paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function stopPaintBall(client) {
|
||||
if (!isPlayerInPaintBall(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Stopping paintball for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
clearPlayerWeapons(client);
|
||||
deletePaintBallItems(client);
|
||||
restorePlayerTempLockerItems(client);
|
||||
|
||||
messagePlayerAlert(client, getLocaleString(client, "LeftPaintBall"));
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Stopped paintball for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerPaintBallItems(client) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Giving ${getPlayerDisplayForConsole(client)} paintball items ...`);
|
||||
for (let i in paintBallItems) {
|
||||
let itemId = createItem(paintBallItems[i], 999999, AGRP_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
|
||||
getItemData(itemId).needsSaved = false;
|
||||
getItemData(itemId).databaseId = -1; // Make sure it doesnt save
|
||||
let freeSlot = getPlayerFirstEmptyHotBarSlot(client);
|
||||
getPlayerData(client).hotBarItems[freeSlot] = itemId;
|
||||
getPlayerData(client).paintBallItemCache.push(itemId);
|
||||
updatePlayerHotBar(client);
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Gave ${getPlayerDisplayForConsole(client)} paintball items successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function deletePaintBallItems(client) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} ...`);
|
||||
for (let i in getPlayerData(client).paintBallItemCache) {
|
||||
deleteItem(getPlayerData(client).paintBallItemCache[i]);
|
||||
}
|
||||
|
||||
cachePlayerHotBarItems(client);
|
||||
updatePlayerHotBar(client);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Deleting paintball items for ${getPlayerDisplayForConsole(client)} successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function cacheAllPaintBallItemTypes() {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Cacheing all paintball item types ...`);
|
||||
for (let i in paintBallItemNames[getGame()]) {
|
||||
let itemTypeId = getItemTypeFromParams(paintBallItemNames[getGame()][i]);
|
||||
if (itemTypeId != -1 && getItemTypeData(itemTypeId) != false) {
|
||||
paintBallItems.push(itemTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Cached all paintball item types`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function respawnPlayerForPaintBall(client) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Respawning ${getPlayerDisplayForConsole(client)} for paintball ...`);
|
||||
despawnPlayer(client);
|
||||
|
||||
let businessId = getPlayerData(client).paintBallBusiness;
|
||||
//let spawnId = getRandom(0, getBusinessData(businessId).paintBallSpawns.length - 1);
|
||||
//spawnPlayer(client, getBusinessData(businessId).paintBallSpawns[spawnId], 0.0, getPlayerSkin(client), getBusinessData(businessId).exitInterior, getBusinessData(businessId).exitPosition, getBusinessData(businessId).exitDimension);
|
||||
|
||||
spawnPlayer(client, getBusinessData(businessId).exitPosition, 0.0, getPlayerSkin(client), getBusinessData(businessId).exitInterior, getBusinessData(businessId).exitDimension);
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 0.5);
|
||||
}
|
||||
updatePlayerSpawnedState(client, true);
|
||||
makePlayerStopAnimation(client);
|
||||
setPlayerControlState(client, true);
|
||||
resetPlayerBlip(client);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Respawned ${getPlayerDisplayForConsole(client)} for paintball successfully`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerInPaintBall(client) {
|
||||
return getPlayerData(client).inPaintBall;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
2658
scripts/server/property.js
Normal file
2658
scripts/server/property.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: race.js
|
||||
// DESC: Provides racing usage and functions
|
||||
@@ -8,8 +9,8 @@
|
||||
// ===========================================================================
|
||||
|
||||
function initRaceScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Race]: Initializing race script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Race]: Race script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Race]: Initializing race script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Race]: Race script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -19,7 +20,7 @@ function initRaceScript() {
|
||||
* @return {RaceData} The race's data (class instance)
|
||||
*/
|
||||
function getRaceData(raceId) {
|
||||
if(typeof getServerData().races[raceId] != "undefined") {
|
||||
if (typeof getServerData().races[raceId] != "undefined") {
|
||||
return getServerData().races[raceId];
|
||||
}
|
||||
return false;
|
||||
@@ -28,7 +29,7 @@ function getRaceData(raceId) {
|
||||
// ===========================================================================
|
||||
|
||||
function setAllRaceDataIndexes() {
|
||||
for(let i in getServerData().races) {
|
||||
for (let i in getServerData().races) {
|
||||
getServerData().races[i].index = i;
|
||||
}
|
||||
}
|
||||
@@ -43,11 +44,11 @@ function loadRacesFromDatabase() {
|
||||
// ===========================================================================
|
||||
|
||||
function saveRacesToDatabase() {
|
||||
if(getServerConfig().devServer) {
|
||||
if (getServerConfig().devServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(let i in getServerData().races) {
|
||||
for (let i in getServerData().races) {
|
||||
saveRaceToDatabase(getServerData().races[i]);
|
||||
}
|
||||
}
|
||||
@@ -61,14 +62,14 @@ function saveRaceToDatabase(raceData) {
|
||||
// ===========================================================================
|
||||
|
||||
function createRaceCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let raceId = getRaceFromParams(params);
|
||||
|
||||
if(raceId == false) {
|
||||
if (raceId == false) {
|
||||
messagePlayerError(client, "A race with that name already exists!");
|
||||
return false;
|
||||
}
|
||||
@@ -80,7 +81,7 @@ function createRaceCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function createRaceCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -95,13 +96,13 @@ function createRaceCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function createRaceLocationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let raceId = getPlayerRace(client);
|
||||
if(raceId == false) {
|
||||
if (raceId == false) {
|
||||
messagePlayerError(client, "You are not in a race!");
|
||||
return false;
|
||||
}
|
||||
@@ -115,13 +116,13 @@ function createRaceLocationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function createRaceLocationCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let raceId = getPlayerRace(client);
|
||||
if(raceId == false) {
|
||||
if (raceId == false) {
|
||||
messagePlayerError(client, "You are not in a race!");
|
||||
return false;
|
||||
}
|
||||
@@ -135,7 +136,7 @@ function createRaceLocationCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function stopRacingCommand(command, params, client) {
|
||||
if(!isPlayerInARace(client)) {
|
||||
if (!isPlayerInARace(client)) {
|
||||
messagePlayerError(client, "You aren't in a race!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,59 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: radio.js
|
||||
// DESC: Provides radio station streaming
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
class RadioStationData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.url = "";
|
||||
this.genre = "";
|
||||
this.codec = "";
|
||||
this.index = -1;
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = dbAssoc["radio_id"];
|
||||
this.name = dbAssoc["radio_name"];
|
||||
this.url = dbAssoc["radio_url"];
|
||||
this.genre = dbAssoc["radio_genre"];
|
||||
this.codec = dbAssoc["radio_codec"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initRadioScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Radio]: Initializing radio script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Radio]: Radio script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadRadioStationsFromDatabase() {
|
||||
logToConsole(LOG_INFO, "[VRR.Radio]: Loading radio stations from database ...");
|
||||
async function loadRadioStationsFromDatabase() {
|
||||
logToConsole(LOG_INFO, "[AGRP.Radio]: Loading radio stations from database ...");
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempRadioStations = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM radio_main`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempRadioStationData = new RadioStationData(dbAssoc[i]);
|
||||
tempRadioStations.push(tempRadioStationData);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_INFO, `[VRR.Radio]: ${tempRadioStations.length} radio stations loaded from database successfully!`);
|
||||
logToConsole(LOG_INFO, `[AGRP.Radio]: ${tempRadioStations.length} radio stations loaded from database successfully!`);
|
||||
return tempRadioStations;
|
||||
}
|
||||
|
||||
@@ -46,7 +69,7 @@ function loadRadioStationsFromDatabase() {
|
||||
*
|
||||
*/
|
||||
function playStreamingRadioCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
messagePlayerInfo(client, "Use /radiostations for a list of available radio stations.");
|
||||
return false;
|
||||
@@ -54,96 +77,100 @@ function playStreamingRadioCommand(command, params, client) {
|
||||
|
||||
let radioStationId = getRadioStationFromParams(params);
|
||||
|
||||
if(radioStationId != 0 && typeof getServerData().radioStations[radioStationId-1] == "undefined") {
|
||||
if (radioStationId != 0 && typeof getServerData().radioStations[radioStationId - 1] == "undefined") {
|
||||
messagePlayerError(client, getLocaleString(client, "InvalidRadioStation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerInAnyVehicle(client)) {
|
||||
if (isPlayerInAnyVehicle(client)) {
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!getVehicleData(vehicle)) {
|
||||
if (!getVehicleData(vehicle)) {
|
||||
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(radioStationId == 0) {
|
||||
if (radioStationId == 0) {
|
||||
getVehicleData(vehicle).streamingRadioStation = -1;
|
||||
getVehicleData(vehicle).needsSaved = true;
|
||||
getPlayerData(client).streamingRadioStation = -1;
|
||||
meActionToNearbyPlayers(client, `turns off their vehicle's radio`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerVehicle(client) == getPlayerVehicle(clients[i])) {
|
||||
for (let i in clients) {
|
||||
if (getPlayerVehicle(client) == getPlayerVehicle(clients[i])) {
|
||||
playRadioStreamForPlayer(clients[i], "");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getVehicleData(vehicle).streamingRadioStation = radioStationId-1;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionVehicleRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
|
||||
getVehicleData(vehicle).streamingRadioStation = radioStationId - 1;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId - 1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionVehicleRadioStationChange", getRadioStationData(radioStationId - 1).name, getRadioStationData(radioStationId - 1).genre));
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(vehicle == getPlayerVehicle(clients[i])) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client));
|
||||
for (let i in clients) {
|
||||
if (vehicle == getPlayerVehicle(clients[i])) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId - 1).url, true, getPlayerStreamingRadioVolume(client));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(doesEntityDataExist(client, "vrr.inHouse")) {
|
||||
let houseId = getEntityData(client, "vrr.inHouse");
|
||||
if(radioStationId == 0) {
|
||||
getHouseData(houseId).streamingRadioStation = -1;
|
||||
if (isPlayerInAnyHouse(client)) {
|
||||
let houseId = getPlayerHouse(client);
|
||||
if (radioStationId == 0) {
|
||||
getHouseData(houseId).streamingRadioStationIndex = -1;
|
||||
getHouseData(houseId).streamingRadioStationIndex = 0;
|
||||
getHouseData(houseId).needsSaved = true;
|
||||
getPlayerData(client).streamingRadioStation = -1;
|
||||
meActionToNearbyPlayers(client, `turns off the house radio`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getEntityData(clients[i], "vrr.inHouse") == houseId) {
|
||||
for (let i in clients) {
|
||||
if (getEntityData(clients[i], "agrp.inHouse") == houseId) {
|
||||
playRadioStreamForPlayer(clients[i], "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getHouseData(houseId).streamingRadioStation = radioStationId-1;
|
||||
getHouseData(houseId).streamingRadioStationIndex = radioStationId - 1;
|
||||
getHouseData(houseId).streamingRadioStation = getRadioStationData(radioStationId - 1).databaseId;
|
||||
getHouseData(houseId).needsSaved = true;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionHouseRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
|
||||
getPlayerData(client).streamingRadioStation = radioStationId - 1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionHouseRadioStationChange", getRadioStationData(radioStationId - 1).name, getRadioStationData(radioStationId - 1).genre));
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getEntityData(clients[i], "vrr.inHouse") == houseId) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
for (let i in clients) {
|
||||
if (getEntityData(clients[i], "agrp.inHouse") == houseId) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId - 1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(isPlayerInAnyBusiness(client)) {
|
||||
} else if (isPlayerInAnyBusiness(client)) {
|
||||
let businessId = getPlayerBusiness(client);
|
||||
if(radioStationId == 0) {
|
||||
getBusinessData(businessId).streamingRadioStation = -1;
|
||||
if (radioStationId == 0) {
|
||||
getBusinessData(businessId).streamingRadioStation = 0;
|
||||
getBusinessData(businessId).streamingRadioStationIndex = -1;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
getPlayerData(client).streamingRadioStation = -1;
|
||||
meActionToNearbyPlayers(client, `turns off the business radio`);
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerBusiness(clients[i]) == businessId) {
|
||||
for (let i in clients) {
|
||||
if (getPlayerBusiness(clients[i]) == businessId) {
|
||||
stopRadioStreamForPlayer(clients[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getBusinessData(businessId).streamingRadioStation = radioStationId-1;
|
||||
getBusinessData(businessId).streamingRadioStationIndex = radioStationId - 1;
|
||||
getBusinessData(businessId).streamingRadioStation = getRadioStationData(radioStationId - 1).databaseId;
|
||||
getBusinessData(businessId).needsSaved = true;
|
||||
getPlayerData(client).streamingRadioStation = radioStationId-1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionBusinessRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
|
||||
getPlayerData(client).streamingRadioStation = radioStationId - 1;
|
||||
meActionToNearbyPlayers(client, getLocaleString(client, "ActionBusinessRadioStationChange", getRadioStationData(radioStationId - 1).name, getRadioStationData(radioStationId - 1).genre));
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerBusiness(clients[i]) == businessId) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
for (let i in clients) {
|
||||
if (getPlayerBusiness(clients[i]) == businessId) {
|
||||
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId - 1).url, true, getPlayerStreamingRadioVolume(clients[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,14 +193,14 @@ function playStreamingRadioCommand(command, params, client) {
|
||||
*
|
||||
*/
|
||||
function setStreamingRadioVolumeCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let volumeLevel = params;
|
||||
|
||||
if(isNaN(volumeLevel)) {
|
||||
if (isNaN(volumeLevel)) {
|
||||
messagePlayerError(client, getLocaleString(client, "RadioVolumeNotNumber"));
|
||||
return false;
|
||||
}
|
||||
@@ -181,13 +208,13 @@ function setStreamingRadioVolumeCommand(command, params, client) {
|
||||
setPlayerStreamingRadioVolume(client, toInteger(volumeLevel));
|
||||
getPlayerData(client).accountData.streamingRadioVolume = toInteger(volumeLevel);
|
||||
let volumeEmoji = '';
|
||||
if(volumeLevel >= 60) {
|
||||
if (volumeLevel >= 60) {
|
||||
volumeEmoji = '🔊';
|
||||
} else if(volumeLevel >= 30 && volumeLevel < 60) {
|
||||
} else if (volumeLevel >= 30 && volumeLevel < 60) {
|
||||
volumeEmoji = '🔉';
|
||||
} else if(volumeLevel > 0 && volumeLevel < 30) {
|
||||
} else if (volumeLevel > 0 && volumeLevel < 30) {
|
||||
volumeEmoji = '🔈';
|
||||
} else if(volumeLevel <= 0) {
|
||||
} else if (volumeLevel <= 0) {
|
||||
volumeEmoji = '🔇';
|
||||
}
|
||||
|
||||
@@ -197,7 +224,7 @@ function setStreamingRadioVolumeCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerStreamingRadioVolume(client) {
|
||||
if(!getPlayerData(client) || !isPlayerLoggedIn(client) || !isPlayerSpawned(client)) {
|
||||
if (!getPlayerData(client) || !isPlayerLoggedIn(client) || !isPlayerSpawned(client)) {
|
||||
return 20;
|
||||
}
|
||||
return getPlayerData(client).accountData.streamingRadioVolume;
|
||||
@@ -215,13 +242,13 @@ function getPlayerStreamingRadioVolume(client) {
|
||||
*
|
||||
*/
|
||||
function showRadioStationListCommand(command, params, client) {
|
||||
let stationList = getServerData().radioStations.map(function(x) { return `{ALTCOLOUR}${toInteger(x.index)+1}: {MAINCOLOUR}${x.name}`; });
|
||||
let stationList = getServerData().radioStations.map(function (x) { return `{ALTCOLOUR}${toInteger(x.index) + 1}: {MAINCOLOUR}${x.name}`; });
|
||||
|
||||
let chunkedList = splitArrayIntoChunks(stationList, 4);
|
||||
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderRadioStationsList")));
|
||||
|
||||
for(let i in chunkedList) {
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerInfo(client, chunkedList[i].join(", "));
|
||||
}
|
||||
}
|
||||
@@ -229,7 +256,7 @@ function showRadioStationListCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setAllRadioStationIndexes() {
|
||||
for(let i in getServerData().radioStations) {
|
||||
for (let i in getServerData().radioStations) {
|
||||
getServerData().radioStations[i].index = i;
|
||||
}
|
||||
}
|
||||
@@ -267,14 +294,14 @@ function reloadAllRadioStationsCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getRadioStationFromParams(params) {
|
||||
if(isNaN(params)) {
|
||||
for(let i in getServerData().radioStations) {
|
||||
if(toLowerCase(getServerData().radioStations[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in getServerData().radioStations) {
|
||||
if (toLowerCase(getServerData().radioStations[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getServerData().radioStations[params] != "undefined") {
|
||||
if (typeof getServerData().radioStations[params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
@@ -282,4 +309,34 @@ function getRadioStationFromParams(params) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getRadioStationIdFromDatabaseId(databaseId) {
|
||||
if (databaseId <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (let i in getServerData().radioStations) {
|
||||
if (getServerData().radioStations[i].databaseId == databaseId) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getRadioStationData(radioStationIndex) {
|
||||
if (radioStationIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof getServerData().radioStations[radioStationIndex] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getServerData().radioStations[radioStationIndex];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: security.js
|
||||
// DESC: Provides security functions and usage
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: startup.js
|
||||
// DESC: Provides startup/shutdown procedures
|
||||
@@ -10,7 +11,6 @@
|
||||
function initServerScripts() {
|
||||
checkForAllRequiredModules();
|
||||
|
||||
initClassScript();
|
||||
initDatabaseScript();
|
||||
initConfigScript();
|
||||
initEmailScript();
|
||||
@@ -48,8 +48,10 @@ function initServerScripts() {
|
||||
// Load all the server data
|
||||
loadServerDataFromDatabase();
|
||||
setAllServerDataIndexes();
|
||||
createAllServerElements();
|
||||
|
||||
checkServerGameTime();
|
||||
createAllServerElements();
|
||||
addAllNetworkEventHandlers();
|
||||
initAllClients();
|
||||
initTimers();
|
||||
|
||||
@@ -59,7 +61,16 @@ function initServerScripts() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkForHashingModule() {
|
||||
if(typeof module.hashing == "undefined") {
|
||||
if (typeof module.hashing == "undefined") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkForGeoIPModule() {
|
||||
if (typeof module.geoip == "undefined") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -68,7 +79,7 @@ function checkForHashingModule() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkForMySQLModule() {
|
||||
if(typeof module.mysql == "undefined") {
|
||||
if (typeof module.mysql == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,9 +89,9 @@ function checkForMySQLModule() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkForSMTPModule() {
|
||||
if(typeof module.smtp == "undefined") {
|
||||
return false;
|
||||
}
|
||||
//if (typeof module.smtp == "undefined") {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -88,37 +99,38 @@ function checkForSMTPModule() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkForAllRequiredModules() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Startup]: Checking for required modules ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Startup]: Checking for required modules ...");
|
||||
|
||||
if(!checkForHashingModule()) {
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: Hashing module is not loaded!");
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown.");
|
||||
thisResource.stop();
|
||||
if (!checkForHashingModule()) {
|
||||
logToConsole(LOG_WARN, "[AGRP.Startup]: Hashing module is not loaded!");
|
||||
logToConsole(LOG_ERROR, "[AGRP.Startup]: This server will now shutdown.");
|
||||
shutdownServer();
|
||||
}
|
||||
|
||||
if(!checkForMySQLModule()) {
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: MySQL module is not loaded!");
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: This resource will now shutdown.");
|
||||
thisResource.stop();
|
||||
if (!checkForMySQLModule()) {
|
||||
logToConsole(LOG_WARN, "[AGRP.Startup]: MySQL module is not loaded!");
|
||||
logToConsole(LOG_ERROR, "[AGRP.Startup]: This server will now shutdown.");
|
||||
shutdownServer();
|
||||
}
|
||||
|
||||
if(!checkForSMTPModule()) {
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: SMTP Email module is not loaded!");
|
||||
logToConsole(LOG_WARN, "[VRR.Startup]: Email features will NOT be available!");
|
||||
}
|
||||
//if (!checkForSMTPModule()) {
|
||||
// logToConsole(LOG_WARN, "[AGRP.Startup]: SMTP Email module is not loaded!");
|
||||
// logToConsole(LOG_WARN, "[AGRP.Startup]: Email features will NOT be available!");
|
||||
//}
|
||||
|
||||
logToConsole(LOG_DEBUG, "[VRR.Startup]: All required modules loaded!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Startup]: All required modules loaded!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadServerDataFromDatabase() {
|
||||
logToConsole(LOG_INFO, "[VRR.Config]: Loading server data ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Config]: Loading server data ...");
|
||||
|
||||
// Always load these regardless of "test server" status
|
||||
getServerData().localeStrings = loadAllLocaleStrings();
|
||||
getServerData().allowedSkins = getAllowedSkins(getGame());
|
||||
getServerData().itemTypes = loadItemTypesFromDatabase();
|
||||
|
||||
// Translation Cache
|
||||
getServerData().cachedTranslations = new Array(getGlobalConfig().locale.locales.length);
|
||||
@@ -127,8 +139,7 @@ function loadServerDataFromDatabase() {
|
||||
getServerData().cachedTranslations.fill(getServerData().cachedTranslationFrom);
|
||||
|
||||
// Only load these if the server isn't a testing/dev server
|
||||
if(!getServerConfig().devServer) {
|
||||
getServerData().itemTypes = loadItemTypesFromDatabase();
|
||||
if (!getServerConfig().devServer) {
|
||||
getServerData().items = loadItemsFromDatabase();
|
||||
getServerData().businesses = loadBusinessesFromDatabase();
|
||||
getServerData().houses = loadHousesFromDatabase();
|
||||
@@ -158,7 +169,9 @@ function setAllServerDataIndexes() {
|
||||
setAllRadioStationIndexes();
|
||||
cacheAllGroundItems();
|
||||
cacheAllBusinessItems();
|
||||
cacheAllItemItems();
|
||||
cacheAllCommandsAliases();
|
||||
cacheAllPaintBallItemTypes();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -174,6 +187,9 @@ function createAllServerElements() {
|
||||
spawnAllVehicles();
|
||||
spawnAllNPCs();
|
||||
addAllCommandHandlers();
|
||||
|
||||
// Using client-side spheres since server-side ones don't show on GTAC atm (bug)
|
||||
//createAllJobRouteLocationMarkers();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -1,26 +1,147 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: subaccount.js
|
||||
// DESC: Provides subaccount (character) functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
/**
|
||||
* @class Representing a character's (subaccount) data. Loaded and saved in the database
|
||||
*/
|
||||
class SubAccountData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.serverId = 0;
|
||||
this.firstName = "John";
|
||||
this.lastName = "Doe";
|
||||
this.middleName = "Q";
|
||||
this.account = 0;
|
||||
this.skin = 0;
|
||||
this.cash = 0;
|
||||
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
|
||||
this.spawnHeading = 0.0;
|
||||
this.lastLogin = 0;
|
||||
this.clan = 0;
|
||||
this.clanFlags = 0;
|
||||
this.clanRank = 0;
|
||||
this.clanTitle = 0;
|
||||
this.isWorking = false;
|
||||
this.jobUniform = this.skin;
|
||||
this.job = 0;
|
||||
this.jobIndex = -1;
|
||||
this.jobRank = 0;
|
||||
this.jobRankIndex = -1;
|
||||
this.weapons = [];
|
||||
this.inJail = false;
|
||||
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.inHouse = 0;
|
||||
this.inBusiness = 0;
|
||||
this.accent = "";
|
||||
|
||||
this.bodyParts = {
|
||||
hair: [0, 0],
|
||||
head: [0, 0],
|
||||
upper: [0, 0],
|
||||
lower: [0, 0],
|
||||
};
|
||||
|
||||
this.bodyProps = {
|
||||
hair: [0, 0],
|
||||
eyes: [0, 0],
|
||||
head: [0, 0],
|
||||
leftHand: [0, 0],
|
||||
rightHand: [0, 0],
|
||||
leftWrist: [0, 0],
|
||||
rightWrist: [0, 0],
|
||||
hip: [0, 0],
|
||||
leftFoot: [0, 0],
|
||||
rightFoot: [0, 0],
|
||||
};
|
||||
|
||||
if (dbAssoc) {
|
||||
this.databaseId = dbAssoc["sacct_id"];
|
||||
this.serverId = toInteger(dbAssoc["sacct_server"]);
|
||||
this.firstName = dbAssoc["sacct_name_first"];
|
||||
this.lastName = dbAssoc["sacct_name_last"];
|
||||
this.middleName = dbAssoc["sacct_name_middle"] || "";
|
||||
this.account = toInteger(dbAssoc["sacct_acct"]);
|
||||
this.skin = toInteger(dbAssoc["sacct_svr_skin"]);
|
||||
this.cash = toInteger(dbAssoc["sacct_cash"]);
|
||||
this.spawnPosition = toVector3(toFloat(dbAssoc["sacct_pos_x"]), toFloat(dbAssoc["sacct_pos_y"]), toFloat(dbAssoc["sacct_pos_z"]));
|
||||
this.spawnHeading = toFloat(dbAssoc["sacct_rot_z"]);
|
||||
this.lastLogin = toInteger(dbAssoc["sacct_when_lastlogin"]);
|
||||
this.clan = toInteger(dbAssoc["sacct_svr_clan"]);
|
||||
this.clanFlags = toInteger(dbAssoc["sacct_svr_clan_flags"]);
|
||||
this.clanRank = toInteger(dbAssoc["sacct_svr_clan_rank"]);
|
||||
this.clanTitle = toInteger(dbAssoc["sacct_svr_clan_title"]);
|
||||
this.job = toInteger(dbAssoc["sacct_svr_job"]);
|
||||
this.jobRank = toInteger(dbAssoc["sacct_svr_job_rank"]);
|
||||
this.interior = toInteger(dbAssoc["sacct_int"]);
|
||||
this.dimension = toInteger(dbAssoc["sacct_vw"]);
|
||||
this.pedScale = toVector3(toFloat(dbAssoc["sacct_svr_scale_x"]), toFloat(dbAssoc["sacct_svr_scale_y"]), toFloat(dbAssoc["sacct_svr_scale_z"]));
|
||||
this.walkStyle = toInteger(dbAssoc["sacct_svr_walkstyle"]);
|
||||
this.fightStyle = toInteger(dbAssoc["sacct_svr_fightstyle"]);
|
||||
this.health = toInteger(dbAssoc["sacct_health"]);
|
||||
this.armour = toInteger(dbAssoc["sacct_armour"]);
|
||||
this.inHouse = toInteger(dbAssoc["sacct_inhouse"]);
|
||||
this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]);
|
||||
this.accent = toString(dbAssoc["sacct_accent"]);
|
||||
|
||||
this.bodyParts = {
|
||||
hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0],
|
||||
head: [toInteger(dbAssoc["sacct_svr_hd_part_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_head_texture"]) || 0],
|
||||
upper: [toInteger(dbAssoc["sacct_svr_hd_part_upper_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_upper_texture"]) || 0],
|
||||
lower: [toInteger(dbAssoc["sacct_svr_hd_part_lower_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_lower_texture"]) || 0],
|
||||
};
|
||||
|
||||
this.bodyProps = {
|
||||
hair: [toInteger(dbAssoc["sacct_svr_hd_prop_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hair_texture"]) || 0],
|
||||
eyes: [toInteger(dbAssoc["sacct_svr_hd_prop_eyes_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_eyes_texture"]) || 0],
|
||||
head: [toInteger(dbAssoc["sacct_svr_hd_prop_head_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_head_texture"]) || 0],
|
||||
leftHand: [toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_lefthand_texture"]) || 0],
|
||||
rightHand: [toInteger(dbAssoc["sacct_svr_hd_prop_righthand_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_righthand_texture"]) || 0],
|
||||
leftWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftwrist_texture"]) || 0],
|
||||
rightWrist: [toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightwrist_texture"]) || 0],
|
||||
hip: [toInteger(dbAssoc["sacct_svr_hd_prop_hip_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_hip_texture"]) || 0],
|
||||
leftFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_leftfoot_texture"]) || 0],
|
||||
rightFoot: [toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_prop_rightfoot_texture"]) || 0],
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initSubAccountScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.SubAccount]: Initializing subaccount script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.SubAccount]: SubAccount script initialized!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.SubAccount]: Initializing subaccount script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.SubAccount]: SubAccount script initialized!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadSubAccountFromName(firstName, lastName) {
|
||||
async function loadSubAccountFromName(firstName, lastName) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
firstName = escapeDatabaseString(dbConnection, firstName);
|
||||
lastName = escapeDatabaseString(dbConnection, lastName);
|
||||
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_name_first = '${firstName}' AND sacct_name_last = '${lastName}' LIMIT 1;`;
|
||||
let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new SubAccountData(dbAssoc);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
}
|
||||
@@ -30,11 +151,16 @@ function loadSubAccountFromName(firstName, lastName) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadSubAccountFromId(subAccountId) {
|
||||
async function loadSubAccountFromId(subAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_id = ${subAccountId} LIMIT 1;`;
|
||||
let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new SubAccountData(dbAssoc);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
}
|
||||
@@ -44,35 +170,70 @@ function loadSubAccountFromId(subAccountId) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadSubAccountsFromAccount(accountId) {
|
||||
async function loadSubAccountsFromAccount(accountId) {
|
||||
let tempSubAccounts = [];
|
||||
let dbAssoc = false;
|
||||
if(accountId > 0) {
|
||||
if (accountId > 0) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_acct = ${accountId} AND sacct_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempSubAccount = new SubAccountData(dbAssoc[i]);
|
||||
|
||||
// Make sure skin is valid
|
||||
if(tempSubAccount.skin == -1) {
|
||||
if (tempSubAccount.skin == -1) {
|
||||
tempSubAccount.skin = getServerConfig().newCharacter.skin;
|
||||
}
|
||||
|
||||
// Check if clan and rank are still valid
|
||||
if(tempSubAccount.clan != 0) {
|
||||
let clanId = getClanIdFromDatabaseId(tempSubAccount.clan);
|
||||
if(!getClanData(clanId)) {
|
||||
if (tempSubAccount.clan != 0) {
|
||||
let clanIndex = getClanIndexFromDatabaseId(tempSubAccount.clan);
|
||||
if (!getClanData(clanIndex)) {
|
||||
tempSubAccount.clan = 0;
|
||||
tempSubAccount.clanRank = 0;
|
||||
tempSubAccount.clanIndex = -1;
|
||||
tempSubAccount.clanRankIndex = -1;
|
||||
tempSubAccount.clanTitle = "";
|
||||
tempSubAccount.clanFlags = 0;
|
||||
} else {
|
||||
let rankId = getClanRankIdFromDatabaseId(clanId, tempSubAccount.clanRank);
|
||||
if(!getClanRankData(clanId, rankId)) {
|
||||
tempSubAccount.clanRank = 0;
|
||||
let clanRankIndex = getClanRankIndexFromDatabaseId(clanIndex, tempSubAccount.clanRank);
|
||||
if (!getClanRankData(clanIndex, clanRankIndex)) {
|
||||
let newClanRankIndex = getLowestClanRank(clanIndex);
|
||||
tempSubAccount.clanRank = getClanRankData(clanIndex, newClanRankIndex).databaseId
|
||||
tempSubAccount.clanRankIndex = newClanRankIndex;
|
||||
} else {
|
||||
tempSubAccount.clanRankIndex = clanRankIndex;
|
||||
}
|
||||
|
||||
tempSubAccount.clanIndex = clanIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if job and rank are still valid
|
||||
if (tempSubAccount.job != 0) {
|
||||
let jobIndex = getJobIndexFromDatabaseId(tempSubAccount.job);
|
||||
if (!getJobData(jobIndex)) {
|
||||
tempSubAccount.job = 0;
|
||||
tempSubAccount.jobRank = 0;
|
||||
tempSubAccount.jobIndex = -1;
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
} else {
|
||||
if (getJobData(jobIndex).ranks.length > 0) {
|
||||
let jobRankIndex = getJobRankIndexFromDatabaseId(jobIndex, tempSubAccount.jobRank);
|
||||
if (!getJobRankData(jobIndex, jobRankIndex)) {
|
||||
let newJobRankIndex = getLowestJobRank(jobIndex);
|
||||
console.log(`[AGRP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}! Using lowest rank ${newJobRankIndex} instead.`);
|
||||
tempSubAccount.jobRank = getJobRankData(jobIndex, newJobRankIndex).databaseId;
|
||||
tempSubAccount.jobRankIndex = newJobRankIndex;
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = jobRankIndex;
|
||||
}
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
}
|
||||
|
||||
tempSubAccount.jobIndex = jobIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +251,7 @@ function loadSubAccountsFromAccount(accountId) {
|
||||
function saveSubAccountToDatabase(subAccountData) {
|
||||
let dbConnection = connectToDatabase();
|
||||
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeClanTag = escapeDatabaseString(dbConnection, subAccountData.ClanTag);
|
||||
let safeClanTitle = escapeDatabaseString(dbConnection, subAccountData.clanTitle);
|
||||
let safeFirstName = escapeDatabaseString(dbConnection, subAccountData.firstName);
|
||||
@@ -160,7 +321,7 @@ function saveSubAccountToDatabase(subAccountData) {
|
||||
["sacct_svr_hd_prop_rightwrist_model", subAccountData.bodyProps.rightWrist[0]],
|
||||
["sacct_svr_hd_prop_rightwrist_texture", subAccountData.bodyProps.rightWrist[1]],
|
||||
["sacct_svr_hd_prop_hip_model", subAccountData.bodyProps.hip[0]],
|
||||
["sacct_svr_hd_prop_hip_texture",subAccountData.bodyProps.hip[1]],
|
||||
["sacct_svr_hd_prop_hip_texture", subAccountData.bodyProps.hip[1]],
|
||||
["sacct_svr_hd_prop_leftfoot_model", subAccountData.bodyProps.leftFoot[0]],
|
||||
["sacct_svr_hd_prop_leftfoot_texture", subAccountData.bodyProps.leftFoot[1]],
|
||||
["sacct_svr_hd_prop_rightfoot_model", subAccountData.bodyProps.rightFoot[0]],
|
||||
@@ -180,12 +341,12 @@ function saveSubAccountToDatabase(subAccountData) {
|
||||
// ===========================================================================
|
||||
|
||||
function createSubAccount(accountId, firstName, lastName) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Account] Attempting to create subaccount ${firstName} ${lastName} in database`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account] Attempting to create subaccount ${firstName} ${lastName} in database`);
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
firstName = fixCharacterName(firstName);
|
||||
lastName = fixCharacterName(lastName);
|
||||
let safeFirstName = escapeDatabaseString(dbConnection, firstName);
|
||||
@@ -193,13 +354,13 @@ function createSubAccount(accountId, firstName, lastName) {
|
||||
|
||||
dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_rot_z, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${getServerId()}, 100, CURRENT_TIMESTAMP(), 0)`);
|
||||
//if(dbQuery) {
|
||||
if(getDatabaseInsertId(dbConnection) > 0) {
|
||||
let dbInsertId = getDatabaseInsertId(dbConnection);
|
||||
createDefaultSubAccountServerData(dbInsertId, getServerConfig().newCharacter.skin);
|
||||
let tempSubAccount = loadSubAccountFromId(dbInsertId);
|
||||
return tempSubAccount;
|
||||
}
|
||||
//freeDatabaseQuery(dbQuery);
|
||||
if (getDatabaseInsertId(dbConnection) > 0) {
|
||||
let dbInsertId = getDatabaseInsertId(dbConnection);
|
||||
createDefaultSubAccountServerData(dbInsertId, getServerConfig().newCharacter.skin);
|
||||
let tempSubAccount = loadSubAccountFromId(dbInsertId);
|
||||
return tempSubAccount;
|
||||
}
|
||||
//freeDatabaseQuery(dbQuery);
|
||||
//}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -212,64 +373,61 @@ function createSubAccount(accountId, firstName, lastName) {
|
||||
function showCharacterSelectToClient(client) {
|
||||
getPlayerData(client).switchingCharacter = true;
|
||||
|
||||
if(doesPlayerHaveAutoSelectLastCharacterEnabled(client)) {
|
||||
if(getPlayerData(client).subAccounts.length > 0) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being auto-spawned as character ID ${getPlayerLastUsedSubAccount(client)}`);
|
||||
if (doesPlayerHaveAutoSelectLastCharacterEnabled(client)) {
|
||||
if (getPlayerData(client).subAccounts.length > 0) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is being auto-spawned as character ID ${getPlayerLastUsedSubAccount(client)}`);
|
||||
selectCharacter(client, getPlayerLastUsedSubAccount(client));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
getPlayerData(client).currentSubAccount = 0;
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
let tempSubAccount = getPlayerData(client).subAccounts[0];
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIndexFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never";
|
||||
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
|
||||
|
||||
//spawnPlayer(client, getServerConfig().characterSelectPedPosition, getServerConfig().characterSelectPedHeading, getPlayerCurrentSubAccount(client).skin, getServerConfig().characterSelectInterior, getServerConfig().characterSelectDimension);
|
||||
//setTimeout(function() {
|
||||
// showCharacterSelectCameraToPlayer(client);
|
||||
//}, 500);
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
|
||||
} else {
|
||||
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
|
||||
//let emojiNumbers = ["①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"];
|
||||
//let emojiNumbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"];
|
||||
messagePlayerNormal(client, `You have the following characters. Use /usechar <id> to select one:`, getColourByName("teal"));
|
||||
getPlayerData(client).subAccounts.forEach(function(subAccount, index) {
|
||||
let tempSubAccount = getPlayerData(client).subAccounts[0];
|
||||
//let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
|
||||
messagePlayerNormal(client, `${index+1} • [#BBBBBB]${subAccount.firstName} ${subAccount.lastName} ($${tempSubAccount.cash}, ${lastPlayedText})`);
|
||||
});
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
|
||||
let charactersList = getPlayerData(client).subAccounts.map((sacct, index) => `{teal}${index + 1}: {ALTCOLOUR}${sacct.firstName} ${sacct.lastName}`);
|
||||
let chunkedList = splitArrayIntoChunks(charactersList, 5);
|
||||
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCharactersListSelf")));
|
||||
for (let i in chunkedList) {
|
||||
messagePlayerNormal(client, chunkedList[i].join("{MAINCOLOUR} • "));
|
||||
}
|
||||
messagePlayerInfo(client, getLocaleString(client, "CharacterSelectHelpText", `{ALTCOLOUR}/usechar{MAINCOLOUR}`, `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is being shown the character select/list message (GUI disabled)`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkNewCharacter(client, firstName, lastName) {
|
||||
if(areParamsEmpty(firstName)) {
|
||||
if (areParamsEmpty(firstName)) {
|
||||
showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!");
|
||||
return false;
|
||||
}
|
||||
firstName = firstName.trim();
|
||||
|
||||
if(areParamsEmpty(lastName)) {
|
||||
if (areParamsEmpty(lastName)) {
|
||||
showPlayerNewCharacterFailedGUI(client, "Last name cannot be blank!");
|
||||
return false;
|
||||
}
|
||||
lastName = lastName.trim();
|
||||
|
||||
if(doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) {
|
||||
logToConsole(LOG_INFO|LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
|
||||
if (doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) {
|
||||
logToConsole(LOG_INFO | LOG_WARN, `[AGRP.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`);
|
||||
showPlayerNewCharacterFailedGUI(client, "Invalid characters in name!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getPlayerData(client).changingCharacterName) {
|
||||
if (getPlayerData(client).changingCharacterName) {
|
||||
getPlayerCurrentSubAccount(client).firstName = fixCharacterName(firstName);
|
||||
getPlayerCurrentSubAccount(client).lastName = fixCharacterName(lastName);
|
||||
updateAllPlayerNameTags(client);
|
||||
@@ -278,8 +436,8 @@ function checkNewCharacter(client, firstName, lastName) {
|
||||
}
|
||||
|
||||
let subAccountData = createSubAccount(getPlayerData(client).accountData.databaseId, firstName, lastName);
|
||||
if(!subAccountData) {
|
||||
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
if (!subAccountData) {
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
showPlayerNewCharacterFailedGUI(client, "Your character could not be created!");
|
||||
} else {
|
||||
messagePlayerError(client, "Your character could not be created!");
|
||||
@@ -291,16 +449,15 @@ function checkNewCharacter(client, firstName, lastName) {
|
||||
getPlayerData(client).subAccounts = loadSubAccountsFromAccount(getPlayerData(client).accountData.databaseId);
|
||||
getPlayerData(client).currentSubAccount = 0;
|
||||
getPlayerData(client).creatingCharacter = false;
|
||||
let tempSubAccount = getPlayerData(client).subAccounts[0];
|
||||
showCharacterSelectToClient(client);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkPreviousCharacter(client) {
|
||||
if(getPlayerData(client).subAccounts.length > 1) {
|
||||
if(getPlayerData(client).currentSubAccount <= 0) {
|
||||
getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length-1;
|
||||
if (getPlayerData(client).subAccounts.length > 1) {
|
||||
if (getPlayerData(client).currentSubAccount <= 0) {
|
||||
getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length - 1;
|
||||
} else {
|
||||
getPlayerData(client).currentSubAccount--;
|
||||
}
|
||||
@@ -308,19 +465,19 @@ function checkPreviousCharacter(client) {
|
||||
let subAccountId = getPlayerData(client).currentSubAccount;
|
||||
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
|
||||
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIndexFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never";
|
||||
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkNextCharacter(client) {
|
||||
if(getPlayerData(client).subAccounts.length > 1) {
|
||||
if(getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length-1) {
|
||||
if (getPlayerData(client).subAccounts.length > 1) {
|
||||
if (getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length - 1) {
|
||||
getPlayerData(client).currentSubAccount = 0;
|
||||
} else {
|
||||
getPlayerData(client).currentSubAccount++;
|
||||
@@ -329,20 +486,20 @@ function checkNextCharacter(client) {
|
||||
let subAccountId = getPlayerData(client).currentSubAccount;
|
||||
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
|
||||
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIdFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp()-tempSubAccount.lastLogin)} ago` : "Never";
|
||||
let clanName = (tempSubAccount.clan != 0) ? getClanData(getClanIndexFromDatabaseId(tempSubAccount.clan)).name : "None";
|
||||
let lastPlayedText = (tempSubAccount.lastLogin != 0) ? `${msToTime(getCurrentUnixTimestamp() - tempSubAccount.lastLogin)} ago` : "Never";
|
||||
showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.cash, clanName, lastPlayedText, getGameConfig().skins[getGame()][tempSubAccount.skin][0]);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Setting ${getPlayerDisplayForConsole(client)}'s character to ID ${getPlayerData(client).currentSubAccount}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function selectCharacter(client, characterId = -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} character select called (Character ID ${characterId})`);
|
||||
if(characterId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} provided character ID (${characterId}) to spawn with`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} character select called (Character ID ${characterId})`);
|
||||
if (characterId != -1) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} provided character ID (${characterId}) to spawn with`);
|
||||
getPlayerData(client).currentSubAccount = characterId;
|
||||
}
|
||||
|
||||
@@ -356,36 +513,36 @@ function selectCharacter(client, characterId = -1) {
|
||||
|
||||
getPlayerData(client).switchingCharacter = false;
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`);
|
||||
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
|
||||
getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_SPAWNING;
|
||||
|
||||
if(getGame() <= VRR_GAME_GTA_SA) {
|
||||
if (getGame() <= AGRP_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);
|
||||
onPlayerSpawn(client);
|
||||
} else if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
|
||||
clearPlayerWeapons(client);
|
||||
setPlayerPosition(client, spawnPosition);
|
||||
setPlayerHeading(client, spawnHeading);
|
||||
//setPlayerInterior(client, spawnInterior);
|
||||
//setPlayerDimension(client, spawnDimension);
|
||||
//restorePlayerCamera(client);
|
||||
} else if(getGame() == VRR_GAME_MAFIA_ONE) {
|
||||
restorePlayerCamera(client);
|
||||
setPlayerSkin(client, skin);
|
||||
setTimeout(function () {
|
||||
onPlayerSpawn(client);
|
||||
//stopRadioStreamForPlayer(client);
|
||||
}, 500);
|
||||
} else if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
//spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]);
|
||||
logToConsole(LOG_DEBUG, `[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);
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`);
|
||||
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]);
|
||||
onPlayerSpawn(client);
|
||||
}
|
||||
|
||||
removePlayerKeyBind(client, getKeyIdFromParams("insert"));
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawned ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`);
|
||||
|
||||
setTimeout(function() {
|
||||
onPlayerSpawn(client);
|
||||
}, 500);
|
||||
|
||||
stopRadioStreamForPlayer(client);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] Spawned ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`);
|
||||
|
||||
getPlayerCurrentSubAccount(client).lastLogin = getCurrentUnixTimestamp();
|
||||
}
|
||||
@@ -393,14 +550,14 @@ function selectCharacter(client, characterId = -1) {
|
||||
// ===========================================================================
|
||||
|
||||
function switchCharacterCommand(command, params, client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is requesting to switch characters (current character: ${getCharacterFullName(client)} [${getPlayerData(client).currentSubAccount}/${getPlayerCurrentSubAccount(client).databaseId}])`);
|
||||
if(!isPlayerSpawned(client)) {
|
||||
logToConsole(LOG_WARN, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (not spawned)`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is requesting to switch characters (current character: ${getCharacterFullName(client)} [${getPlayerData(client).currentSubAccount}/${getPlayerCurrentSubAccount(client).databaseId}])`);
|
||||
if (!isPlayerSpawned(client)) {
|
||||
logToConsole(LOG_WARN, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (not spawned)`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerSwitchingCharacter(client)) {
|
||||
logToConsole(LOG_WARN, `[VRR.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (already in switch char mode)`);
|
||||
if (isPlayerSwitchingCharacter(client)) {
|
||||
logToConsole(LOG_WARN, `[AGRP.SubAccount] ${getPlayerDisplayForConsole(client)} is not allowed to switch characters (already in switch char mode)`);
|
||||
messagePlayerError(client, "You are already selecting/switching characters!");
|
||||
return false;
|
||||
}
|
||||
@@ -411,12 +568,12 @@ function switchCharacterCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function newCharacterCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let firstName = getParam(params, " ", 1);
|
||||
let firstName = getParam(params, " ", 1);
|
||||
let lastName = getParam(params, " ", 2);
|
||||
|
||||
checkNewCharacter(client, firstName, lastName);
|
||||
@@ -425,19 +582,19 @@ let firstName = getParam(params, " ", 1);
|
||||
// ===========================================================================
|
||||
|
||||
function useCharacterCommand(command, params, client) {
|
||||
if(!getPlayerData(client).switchingCharacter) {
|
||||
if (!getPlayerData(client).switchingCharacter) {
|
||||
messagePlayerError(client, "Use /switchchar to save this character and return to the characters screen first!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let characterId = toInteger(params) || 1;
|
||||
|
||||
selectCharacter(client, characterId-1);
|
||||
selectCharacter(client, characterId - 1);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -445,8 +602,8 @@ function useCharacterCommand(command, params, client) {
|
||||
function getPlayerLastUsedSubAccount(client) {
|
||||
let subAccounts = getPlayerData(client).subAccounts;
|
||||
let lastUsed = 0;
|
||||
for(let i in subAccounts) {
|
||||
if(subAccounts[i].lastLogin > subAccounts[lastUsed].lastLogin) {
|
||||
for (let i in subAccounts) {
|
||||
if (subAccounts[i].lastLogin > subAccounts[lastUsed].lastLogin) {
|
||||
lastUsed = i;
|
||||
}
|
||||
}
|
||||
@@ -474,7 +631,7 @@ function isPlayerSwitchingCharacter(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerCreatingCharacter(client) {
|
||||
return getPlayerData(client).creatingCharacter;
|
||||
return false; //getPlayerData(client).creatingCharacter;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -485,16 +642,16 @@ function isPlayerCreatingCharacter(client) {
|
||||
*
|
||||
*/
|
||||
function getPlayerCurrentSubAccount(client) {
|
||||
if(!getPlayerData(client)) {
|
||||
if (!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let subAccountId = getPlayerData(client).currentSubAccount;
|
||||
if(subAccountId == -1) {
|
||||
if (subAccountId == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(typeof getPlayerData(client).subAccounts[subAccountId] == "undefined") {
|
||||
if (typeof getPlayerData(client).subAccounts[subAccountId] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -511,21 +668,21 @@ function getClientSubAccountName(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function setFightStyleCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let fightStyleId = getFightStyleFromParams(params);
|
||||
|
||||
if(!fightStyle) {
|
||||
if (!fightStyle) {
|
||||
messagePlayerError(client, `That fight style doesn't exist!`);
|
||||
messagePlayerError(client, `Fight styles: ${getGameConfig().fightStyles[getGame()].map(fs => fs[0]).join(", ")}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerAtGym(client)) {
|
||||
if(!doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
|
||||
if (!isPlayerAtGym(client)) {
|
||||
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
|
||||
messagePlayerError(client, `You need to be at a gym!`);
|
||||
return false
|
||||
}
|
||||
@@ -540,8 +697,8 @@ function setFightStyleCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function createDefaultSubAccountServerData(databaseId, thisServerSkin) {
|
||||
for(let i = 1 ; i <= 5 ; i++) {
|
||||
if(i == getServerId()) {
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
if (i == getServerId()) {
|
||||
let dbQueryString = `INSERT INTO sacct_svr (sacct_svr_sacct, sacct_svr_server, sacct_svr_skin) VALUES (${databaseId}, ${i}, ${thisServerSkin})`;
|
||||
quickDatabaseQuery(dbQueryString);
|
||||
} else {
|
||||
@@ -556,10 +713,25 @@ function createDefaultSubAccountServerData(databaseId, thisServerSkin) {
|
||||
function forcePlayerIntoSwitchCharacterScreen(client) {
|
||||
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
|
||||
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
|
||||
getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
|
||||
getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
|
||||
getPlayerCurrentSubAccount(client).health = getPlayerHealth(client);
|
||||
getPlayerCurrentSubAccount(client).armour = getPlayerArmour(client);
|
||||
|
||||
if (isGameFeatureSupported("dimension")) {
|
||||
getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
|
||||
} else {
|
||||
getPlayerCurrentSubAccount(client).dimension = 0;
|
||||
}
|
||||
|
||||
if (isGameFeatureSupported("interior")) {
|
||||
getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
|
||||
} else {
|
||||
getPlayerCurrentSubAccount(client).interior = 0;
|
||||
}
|
||||
|
||||
if (isGameFeatureSupported("pedArmour")) {
|
||||
getPlayerCurrentSubAccount(client).armour = getPlayerArmour(client);
|
||||
} else {
|
||||
getPlayerCurrentSubAccount(client).armour = 0;
|
||||
}
|
||||
|
||||
logToConsole(client, `Saving ${getPlayerDisplayForConsole(client)}'s subaccount (${getCharacterFullName(client)} [${getPlayerData(client).currentSubAccount}/${getPlayerCurrentSubAccount(client).databaseId}] to database`)
|
||||
saveSubAccountToDatabase(getPlayerCurrentSubAccount(client));
|
||||
@@ -571,5 +743,8 @@ function forcePlayerIntoSwitchCharacterScreen(client) {
|
||||
getPlayerData(client).switchingCharacter = true;
|
||||
|
||||
showConnectCameraToPlayer(client);
|
||||
|
||||
showCharacterSelectToClient(client);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -1,9 +1,9 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: theme.js
|
||||
// DESC: Provides server theme content
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: timers.js
|
||||
// DESC: Provides timer functions and features
|
||||
@@ -12,132 +13,140 @@ let serverTimers = {};
|
||||
// ===========================================================================
|
||||
|
||||
function saveServerDataToDatabase() {
|
||||
if(getServerConfig().pauseSavingToDatabase) {
|
||||
if (getServerConfig().pauseSavingToDatabase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saving all server data to database ...");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Utilities]: Saving all server data to database ...");
|
||||
|
||||
try {
|
||||
saveAllPlayersToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save players to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllClansToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save clans to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllHousesToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save houses to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllBusinessesToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save businesses to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllVehiclesToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save vehicles to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllItemTypesToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save item types to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllItemsToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save items to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllJobsToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save jobs to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllNPCsToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save NPCs to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveAllGatesToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save gates to database: ${error}`);
|
||||
}
|
||||
|
||||
try {
|
||||
saveServerConfigToDatabase();
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `Could not save server config to database: ${error}`);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, "[VRR.Utilities]: Saved all server data to database!");
|
||||
logToConsole(LOG_DEBUG, "[AGRP.Utilities]: Saved all server data to database!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initTimers() {
|
||||
//if(!isDevelopmentServer()) {
|
||||
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
|
||||
serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000);
|
||||
serverTimers.fifteenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000);
|
||||
serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000);
|
||||
//if (isDevelopmentServer()) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
|
||||
serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000);
|
||||
serverTimers.tenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000);
|
||||
serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function oneMinuteTimerFunction() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking server game time`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Checking server game time`);
|
||||
checkServerGameTime();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking rentable vehicles`);
|
||||
checkVehicleRenting();
|
||||
if (getClients().length > 0) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Checking rentable vehicles`);
|
||||
checkVehicleRenting();
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
||||
updateAllPlayerNameTags();
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Updating all player name tags`);
|
||||
updateAllPlayerNameTags();
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Event] Collecting all garbage`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Event] Collecting all garbage`);
|
||||
collectAllGarbage();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function tenMinuteTimerFunction() {
|
||||
showRandomTipToAllPlayers();
|
||||
//showRandomTipToAllPlayers();
|
||||
//saveServerDataToDatabase();
|
||||
//checkInactiveVehicleRespawns();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function thirtyMinuteTimerFunction() {
|
||||
if (getClients().length > 0) {
|
||||
checkPayDays();
|
||||
}
|
||||
saveServerDataToDatabase();
|
||||
checkInactiveVehicleRespawns();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function thirtyMinuteTimerFunction() {
|
||||
checkPayDays();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function checkVehicleRenting() {
|
||||
let renting = getServerData().rentingVehicleCache;
|
||||
for(let i in renting) {
|
||||
if(isClientInitialized(renting[i])) {
|
||||
if(getPlayerData(renting[i]) != false) {
|
||||
if(isPlayerLoggedIn(renting[i] && isPlayerSpawned(renting[i]))) {
|
||||
if(getPlayerData(renting[i]).rentingVehicle != false) {
|
||||
if(getPlayerCurrentSubAccount(renting[i]).cash < getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice) {
|
||||
for (let i in renting) {
|
||||
if (isClientInitialized(renting[i])) {
|
||||
if (getPlayerData(renting[i]) != false) {
|
||||
if (isPlayerLoggedIn(renting[i] && isPlayerSpawned(renting[i]))) {
|
||||
if (getPlayerData(renting[i]).rentingVehicle != false) {
|
||||
if (getPlayerCurrentSubAccount(renting[i]).cash < getServerData().vehicles[getPlayerData(renting[i]).rentingVehicle].rentPrice) {
|
||||
messagePlayerAlert(renting[i], `You do not have enough money to continue renting this vehicle!`);
|
||||
stopRentingVehicle(renting[i]);
|
||||
} else {
|
||||
@@ -173,12 +182,16 @@ function checkVehicleRenting() {
|
||||
// ===========================================================================
|
||||
|
||||
function updatePings() {
|
||||
if (getClients().length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(!clients[i].console) {
|
||||
for (let i in clients) {
|
||||
if (isClientInitialized(clients[i])) {
|
||||
if (!clients[i].console) {
|
||||
updatePlayerPing(clients[i]);
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
if (isPlayerSpawned(clients[i])) {
|
||||
updatePlayerCash(clients[i]);
|
||||
}
|
||||
}
|
||||
@@ -189,10 +202,16 @@ function updatePings() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkServerGameTime() {
|
||||
//if(!getServerConfig().useRealTime) {
|
||||
if(getServerConfig().minute >= 59) {
|
||||
//logToConsole(LOG_DEBUG | LOG_WARN, "[AGRP.Timers] Checking server game time");
|
||||
|
||||
//if (isGameFeatureSupported("time")) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (!getServerConfig().useRealTime) {
|
||||
if (getServerConfig().minute >= 59) {
|
||||
getServerConfig().minute = 0;
|
||||
if(getServerConfig().hour >= 23) {
|
||||
if (getServerConfig().hour >= 23) {
|
||||
getServerConfig().hour = 0;
|
||||
} else {
|
||||
getServerConfig().hour = getServerConfig().hour + 1;
|
||||
@@ -200,11 +219,48 @@ function checkServerGameTime() {
|
||||
} else {
|
||||
getServerConfig().minute = getServerConfig().minute + 1;
|
||||
}
|
||||
//} else {
|
||||
// let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
|
||||
// getServerConfig().hour = dateTime.getHours();
|
||||
// getServerConfig().minute = dateTime.getMinutes();
|
||||
//}
|
||||
} else {
|
||||
let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
|
||||
getServerConfig().hour = dateTime.getHours();
|
||||
getServerConfig().minute = dateTime.getMinutes();
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (getGameConfig().mainWorldScene[getGame()] == "FREERIDE") {
|
||||
if (isServerGoingToChangeMapsSoon(getServerConfig().hour, getServerConfig().minute)) {
|
||||
sendMapChangeWarningToPlayer(null, true);
|
||||
}
|
||||
|
||||
if (isNightTime(getServerConfig().hour)) {
|
||||
getGameConfig().mainWorldScene[getGame()] = "FREERIDENOC";
|
||||
removeAllPlayersFromProperties();
|
||||
removeAllPlayersFromVehicles();
|
||||
saveServerDataToDatabase();
|
||||
logToConsole(LOG_INFO | LOG_WARN, `[AGRP.Timers] Changing server map to night`);
|
||||
messageDiscordEventChannel("🌙 Changing server map to night");
|
||||
game.changeMap(getGameConfig().mainWorldScene[getGame()]);
|
||||
}
|
||||
} else if (getGameConfig().mainWorldScene[getGame()] == "FREERIDENOC") {
|
||||
if (isServerGoingToChangeMapsSoon(getServerConfig().hour, getServerConfig().minute)) {
|
||||
sendMapChangeWarningToPlayer(null, true);
|
||||
}
|
||||
|
||||
if (!isNightTime(getServerConfig().hour)) {
|
||||
getGameConfig().mainWorldScene[getGame()] = "FREERIDE";
|
||||
removeAllPlayersFromProperties();
|
||||
removeAllPlayersFromVehicles();
|
||||
saveServerDataToDatabase();
|
||||
logToConsole(LOG_INFO | LOG_WARN, `[AGRP.Timers] Changing server map to day`);
|
||||
messageDiscordEventChannel("🌞 Changing server map to day");
|
||||
game.changeMap(getGameConfig().mainWorldScene[getGame()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isGameFeatureSupported("time")) {
|
||||
game.time.hour = getServerConfig().hour;
|
||||
game.time.minute = getServerConfig().minute;
|
||||
}
|
||||
|
||||
updateTimeRule();
|
||||
}
|
||||
@@ -212,10 +268,14 @@ function checkServerGameTime() {
|
||||
// ===========================================================================
|
||||
|
||||
function checkPayDays() {
|
||||
if (getClients().length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
for (let i in clients) {
|
||||
if (isClientInitialized(clients[i])) {
|
||||
if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||
playerPayDay(clients[i]);
|
||||
|
||||
@@ -227,8 +287,8 @@ function checkPayDays() {
|
||||
}
|
||||
}
|
||||
|
||||
for(let i in getServerData().businesses) {
|
||||
if(getBusinessData(i).ownerType != VRR_BIZOWNER_NONE && getBusinessData(i).ownerType != VRR_BIZOWNER_PUBLIC && getBusinessData(i).ownerType != VRR_BIZOWNER_FACTION) {
|
||||
for (let i in getServerData().businesses) {
|
||||
if (getBusinessData(i).ownerType != AGRP_BIZ_OWNER_NONE && getBusinessData(i).ownerType != AGRP_BIZ_OWNER_PUBLIC && getBusinessData(i).ownerType != AGRP_BIZ_OWNER_FACTION) {
|
||||
getBusinessData(i).till += 1000;
|
||||
}
|
||||
}
|
||||
@@ -237,14 +297,18 @@ function checkPayDays() {
|
||||
// ===========================================================================
|
||||
|
||||
function showRandomTipToAllPlayers() {
|
||||
let tipId = getRandom(0, randomTips.length-1);
|
||||
if (getClients().length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
||||
for (let i in clients) {
|
||||
if (isClientInitialized(clients[i])) {
|
||||
if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
if (!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||
let localeId = getPlayerData(clients[i]).locale;
|
||||
let tipId = getRandom(0, getServerData().localeStrings[localeId]["RandomTips"].length - 1);
|
||||
messagePlayerTip(clients[i], getGroupedLocaleString(clients[i], "RandomTips", tipId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,11 +319,11 @@ 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,68 +1,250 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: trigger.js
|
||||
// DESC: Provides trigger system functions and usage
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
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",
|
||||
"onPlayerShout",
|
||||
"onPlayerTalk",
|
||||
"onPlayerWhisper",
|
||||
];
|
||||
const AGRP_TRIG_TYPE_NONE = 0;
|
||||
const AGRP_TRIG_TYPE_BIZ_OWNER_CHANGE = 1;
|
||||
const AGRP_TRIG_TYPE_BIZ_NAME_CHANGE = 2;
|
||||
const AGRP_TRIG_TYPE_BIZ_LOCK_CHANGE = 3;
|
||||
const AGRP_TRIG_TYPE_BIZ_PLAYER_ENTER = 4;
|
||||
const AGRP_TRIG_TYPE_BIZ_PLAYER_EXIT = 5;
|
||||
const AGRP_TRIG_TYPE_BIZ_NPC_ENTER = 6;
|
||||
const AGRP_TRIG_TYPE_BIZ_NPC_EXIT = 7;
|
||||
const AGRP_TRIG_TYPE_BIZ_DAMAGE = 8;
|
||||
const AGRP_TRIG_TYPE_BIZ_ROBBED = 9;
|
||||
const AGRP_TRIG_TYPE_BIZ_PLAYER_PURCHASE = 10;
|
||||
const AGRP_TRIG_TYPE_BIZ_NPC_PURCHASE = 11;
|
||||
const AGRP_TRIG_TYPE_HOUSE_OWNER_CHANGE = 12;
|
||||
const AGRP_TRIG_TYPE_HOUSE_NAME_CHANGE = 13;
|
||||
const AGRP_TRIG_TYPE_HOUSE_LOCK_CHANGE = 14;
|
||||
const AGRP_TRIG_TYPE_HOUSE_PLAYER_ENTER = 15;
|
||||
const AGRP_TRIG_TYPE_HOUSE_PLAYER_EXIT = 16;
|
||||
const AGRP_TRIG_TYPE_HOUSE_NPC_ENTER = 17;
|
||||
const AGRP_TRIG_TYPE_HOUSE_NPC_EXIT = 18;
|
||||
const AGRP_TRIG_TYPE_HOUSE_DAMAGE = 19;
|
||||
const AGRP_TRIG_TYPE_HOUSE_ROBBED = 20;
|
||||
const AGRP_TRIG_TYPE_VEH_OWNER_CHANGE = 21;
|
||||
const AGRP_TRIG_TYPE_VEH_PLAYER_ENTER = 22;
|
||||
const AGRP_TRIG_TYPE_VEH_PLAYER_EXIT = 23;
|
||||
const AGRP_TRIG_TYPE_VEH_NPC_ENTER = 24;
|
||||
const AGRP_TRIG_TYPE_VEH_NPC_EXIT = 25;
|
||||
const AGRP_TRIG_TYPE_VEH_COLLISION = 26;
|
||||
const AGRP_TRIG_TYPE_VEH_DAMAGED = 27;
|
||||
const AGRP_TRIG_TYPE_VEH_SHOT = 28;
|
||||
const AGRP_TRIG_TYPE_VEH_TRUNK_CHANGE = 29;
|
||||
const AGRP_TRIG_TYPE_VEH_ITEM_TAKEN = 30;
|
||||
const AGRP_TRIG_TYPE_VEH_ITEM_STORED = 31;
|
||||
const AGRP_TRIG_TYPE_VEH_ENGINE_CHANGE = 32;
|
||||
const AGRP_TRIG_TYPE_VEH_LIGHTS_CHANGE = 33;
|
||||
const AGRP_TRIG_TYPE_VEH_SIREN_CHANGE = 34;
|
||||
const AGRP_TRIG_TYPE_VEH_LOCK_CHANGE = 35;
|
||||
const AGRP_TRIG_TYPE_VEH_REPAIRED = 36;
|
||||
const AGRP_TRIG_TYPE_VEH_COLOUR_CHANGE = 37;
|
||||
const AGRP_TRIG_TYPE_VEH_EXTRA_CHANGE = 38;
|
||||
const AGRP_TRIG_TYPE_PLAYER_SHOUT = 39;
|
||||
const AGRP_TRIG_TYPE_PLAYER_TALK = 40;
|
||||
const AGRP_TRIG_TYPE_PLAYER_WHISPER = 41;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Need to plan this out
|
||||
const AGRP_TRIG_COND_TYPE_NONE = 0;
|
||||
const AGRP_TRIG_COND_TYPE_VEH_OCCUPANT = 1;
|
||||
const AGRP_TRIG_COND_TYPE_VEH_DRIVER = 3;
|
||||
const AGRP_TRIG_COND_TYPE_VEH_OWNER_TYPE = 2;
|
||||
const AGRP_TRIG_COND_TYPE_VEH_OWNER_ID = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Need to plan this out
|
||||
const AGRP_TRIG_COND_MATCH_NONE = 0;
|
||||
const AGRP_TRIG_COND_MATCH_EXACT_VALUE = 1;
|
||||
const AGRP_TRIG_COND_MATCH_GREATER_THAN = 2;
|
||||
const AGRP_TRIG_COND_MATCH_LESS_THAN = 2;
|
||||
const AGRP_TRIG_COND_MATCH_NOT_EQUAL = 3;
|
||||
const AGRP_TRIG_COND_MATCH_CLAN = 4;
|
||||
const AGRP_TRIG_COND_MATCH_JOB = 5;
|
||||
const AGRP_TRIG_COND_MATCH_BIZ = 6;
|
||||
const AGRP_TRIG_COND_MATCH_HOUSE = 7;
|
||||
const AGRP_TRIG_COND_MATCH_VEH = 8;
|
||||
const AGRP_TRIG_COND_MATCH_NPC = 9;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
const AGRP_TRIG_RESP_TYPE_NONE = 0;
|
||||
const AGRP_TRIG_RESP_SHOUT = 1;
|
||||
const AGRP_TRIG_RESP_TALK = 2;
|
||||
const AGRP_TRIG_RESP_WHISPER = 3;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
let triggerTypes = {
|
||||
BusinessOwnerChange: AGRP_TRIG_TYPE_BIZ_OWNER_CHANGE,
|
||||
BusinessNameChange: AGRP_TRIG_TYPE_BIZ_NAME_CHANGE,
|
||||
BusinessLockChange: AGRP_TRIG_TYPE_BIZ_LOCK_CHANGE,
|
||||
BusinessPlayerEnter: AGRP_TRIG_TYPE_BIZ_PLAYER_ENTER,
|
||||
BusinessPlayerExit: AGRP_TRIG_TYPE_BIZ_PLAYER_EXIT,
|
||||
BusinessNPCEnter: AGRP_TRIG_TYPE_BIZ_NPC_ENTER,
|
||||
BusinessNPCExit: AGRP_TRIG_TYPE_BIZ_NPC_EXIT,
|
||||
BusinessDamage: AGRP_TRIG_TYPE_BIZ_DAMAGE,
|
||||
BusinessRobbed: AGRP_TRIG_TYPE_BIZ_ROBBED,
|
||||
BusinessPlayerPurchase: AGRP_TRIG_TYPE_BIZ_PLAYER_PURCHASE,
|
||||
BusinessNPCPurchase: AGRP_TRIG_TYPE_BIZ_NPC_PURCHASE,
|
||||
HouseOwnerChange: AGRP_TRIG_TYPE_HOUSE_OWNER_CHANGE,
|
||||
HouseNameChange: AGRP_TRIG_TYPE_HOUSE_NAME_CHANGE,
|
||||
HouseLockChange: AGRP_TRIG_TYPE_HOUSE_LOCK_CHANGE,
|
||||
HousePlayerEnter: AGRP_TRIG_TYPE_HOUSE_PLAYER_ENTER,
|
||||
HousePlayerExit: AGRP_TRIG_TYPE_HOUSE_PLAYER_EXIT,
|
||||
HouseNPCEnter: AGRP_TRIG_TYPE_HOUSE_NPC_ENTER,
|
||||
HouseNPCExit: AGRP_TRIG_TYPE_HOUSE_NPC_EXIT,
|
||||
HouseDamage: AGRP_TRIG_TYPE_HOUSE_DAMAGE,
|
||||
HouseRobbed: AGRP_TRIG_TYPE_HOUSE_ROBBED,
|
||||
VehicleOwnerChange: AGRP_TRIG_TYPE_VEH_OWNER_CHANGE,
|
||||
VehiclePlayerEnter: AGRP_TRIG_TYPE_VEH_PLAYER_ENTER,
|
||||
VehiclePlayerExit: AGRP_TRIG_TYPE_VEH_PLAYER_EXIT,
|
||||
VehicleNPCEnter: AGRP_TRIG_TYPE_VEH_NPC_ENTER,
|
||||
VehicleNPCExit: AGRP_TRIG_TYPE_VEH_NPC_EXIT,
|
||||
VehicleCollision: AGRP_TRIG_TYPE_VEH_COLLISION,
|
||||
VehicleDamaged: AGRP_TRIG_TYPE_VEH_DAMAGED,
|
||||
VehicleShot: AGRP_TRIG_TYPE_VEH_SHOT,
|
||||
VehicleTrunkChange: AGRP_TRIG_TYPE_VEH_TRUNK_CHANGE,
|
||||
VehicleItemTaken: AGRP_TRIG_TYPE_VEH_ITEM_TAKEN,
|
||||
VehicleItemStored: AGRP_TRIG_TYPE_VEH_ITEM_STORED,
|
||||
VehicleEngineChange: AGRP_TRIG_TYPE_VEH_ENGINE_CHANGE,
|
||||
VehicleLightsChange: AGRP_TRIG_TYPE_VEH_LIGHTS_CHANGE,
|
||||
VehicleSirenChange: AGRP_TRIG_TYPE_VEH_SIREN_CHANGE,
|
||||
VehicleLockChange: AGRP_TRIG_TYPE_VEH_LOCK_CHANGE,
|
||||
VehicleRepaired: AGRP_TRIG_TYPE_VEH_REPAIRED,
|
||||
VehicleColourChange: AGRP_TRIG_TYPE_VEH_COLOUR_CHANGE,
|
||||
VehicleExtraChange: AGRP_TRIG_TYPE_VEH_EXTRA_CHANGE,
|
||||
PlayerShout: AGRP_TRIG_TYPE_PLAYER_SHOUT,
|
||||
PlayerTalk: AGRP_TRIG_TYPE_PLAYER_TALK,
|
||||
PlayerWhisper: AGRP_TRIG_TYPE_PLAYER_WHISPER,
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a trigger's data. Loaded and saved in the database
|
||||
* @property {Array.<TriggerConditionData>} conditions
|
||||
* @property {Array.<TriggerResponseData>} responses
|
||||
*/
|
||||
class TriggerData {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0
|
||||
this.type = AGRP_TRIG_TYPE_NONE;
|
||||
this.enabled = false;
|
||||
this.whoAdded = 0;
|
||||
this.whenAdded = 0;
|
||||
|
||||
|
||||
this.conditions = [];
|
||||
this.responses = [];
|
||||
|
||||
if (dbAssoc != false) {
|
||||
this.databaseId = toInteger(dbAssoc["trig_id"]);
|
||||
this.type = toInteger(dbAssoc["trig_type"]);
|
||||
this.enabled = intToBool(dbAssoc["trig_enabled"]);
|
||||
this.whoAdded = toInteger(dbAssoc["trig_who_added"]);
|
||||
this.whenAdded = toInteger(dbAssoc["trig_when_added"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a trigger condition's data. Loaded and saved in the database
|
||||
*/
|
||||
class TriggerConditionData {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0
|
||||
this.index = -1;
|
||||
this.triggerId = 0;
|
||||
this.triggerIndex = -1;
|
||||
this.type = AGRP_TRIG_COND_TYPE_NONE;
|
||||
this.matchType = AGRP_TRIG_COND_MATCH_NONE;
|
||||
this.enabled = false;
|
||||
this.whoAdded = 0;
|
||||
this.whenAdded = 0;
|
||||
|
||||
if (dbAssoc != false) {
|
||||
this.databaseId = toInteger(dbAssoc["trig_cond_id"]);
|
||||
this.type = toInteger(dbAssoc["trig_cond_type"]);
|
||||
this.triggerId = toInteger(dbAssoc["trig_cond_trig"]);
|
||||
this.data = dbAssoc["trig_cond_data"];
|
||||
this.matchType = toInteger(dbAssoc["trig_cond_match_type"]);
|
||||
this.enabled = intToBool(dbAssoc["trig_cond_enabled"]);
|
||||
this.whoAdded = toInteger(dbAssoc["trig_cond_who_added"]);
|
||||
this.whenAdded = toInteger(dbAssoc["trig_cond_when_added"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing a trigger response's data. Loaded and saved in the database
|
||||
*/
|
||||
class TriggerResponseData {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0
|
||||
this.index = -1;
|
||||
this.triggerId = 0;
|
||||
this.triggerIndex = -1;
|
||||
this.priority = 0;
|
||||
this.type = AGRP_TRIG_RESP_TYPE_NONE;
|
||||
this.enabled = false;
|
||||
this.whoAdded = 0;
|
||||
this.whenAdded = 0;
|
||||
|
||||
if (dbAssoc != false) {
|
||||
this.databaseId = toInteger(dbAssoc["trig_resp_id"]);
|
||||
this.type = toInteger(dbAssoc["trig_resp_type"]);
|
||||
this.triggerId = toInteger(dbAssoc["trig_resp_trig"]);
|
||||
this.enabled = intToBool(dbAssoc["trig_resp_enabled"]);
|
||||
this.whoAdded = toInteger(dbAssoc["trig_resp_who_added"]);
|
||||
this.whenAdded = toInteger(dbAssoc["trig_resp_when_added"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initTriggerScript() {
|
||||
logToConsole(LOG_INFO, "[VRR.Trigger]: Initializing trigger script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Trigger]: Trigger script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[AGRP.Trigger]: Initializing trigger script ...");
|
||||
logToConsole(LOG_INFO, "[AGRP.Trigger]: Trigger script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadTriggersFromDatabase() {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadTriggerConditionsFromDatabase(triggerDatabaseId) {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadTriggerResponsesFromDatabase(triggerDatabaseId) {
|
||||
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function createTriggerCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -71,7 +253,7 @@ function createTriggerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function deleteTriggerCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -80,7 +262,7 @@ function deleteTriggerCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function addTriggerConditionCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +271,7 @@ function addTriggerConditionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function removeTriggerConditionCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +280,7 @@ function removeTriggerConditionCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function addTriggerResponseCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -107,7 +289,7 @@ function addTriggerResponseCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function removeTriggerResponseCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -116,7 +298,7 @@ function removeTriggerResponseCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function listTriggersCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -125,7 +307,7 @@ function listTriggersCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function listTriggerConditionsCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -134,7 +316,7 @@ function listTriggerConditionsCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function listTriggerResponsesCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
@@ -143,7 +325,7 @@ function listTriggerResponsesCommand(command, params, client) {
|
||||
// ===========================================================================
|
||||
|
||||
function toggleTriggerEnabledCommand(command, params, client) {
|
||||
if(areParamsEmpty(params)) {
|
||||
if (areParamsEmpty(params)) {
|
||||
messagePlayerSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: tutorial.js
|
||||
// DESC: Provides tutorial functions and features
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// ===========================================================================
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/gtac_roleplay
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// ===========================================================================
|
||||
// FILE: utilities.js
|
||||
// DESC: Provides util functions and arrays with data
|
||||
@@ -12,13 +13,13 @@
|
||||
// ===========================================================================
|
||||
|
||||
function getPositionArea(position) {
|
||||
if(typeof position == "Vec3") {
|
||||
if (typeof position == "Vec3") {
|
||||
position = vec3ToVec2(position);
|
||||
}
|
||||
|
||||
let gameAreas = getGameAreas(getGame());
|
||||
for(let i in gameAreas) {
|
||||
if(isPositionInArea(position, gameAreas[i][1])) {
|
||||
for (let i in gameAreas) {
|
||||
if (isPositionInArea(position, gameAreas[i][1])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +31,7 @@ function getPositionArea(position) {
|
||||
|
||||
function getAreaName(position) {
|
||||
let areaId = getPositionArea(position);
|
||||
if(!areaId) {
|
||||
if (!areaId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,18 +51,25 @@ function getGameAreas(gameId) {
|
||||
* @return {ClientData} The player/client's data (class instancee)
|
||||
*/
|
||||
function getPlayerData(client) {
|
||||
if(client != null) {
|
||||
if(isClientInitialized(client)) {
|
||||
return getServerData().clients[getPlayerId(client)];
|
||||
}
|
||||
if (client == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!isClientInitialized(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof getServerData().clients[getPlayerId(client)] == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getServerData().clients[getPlayerId(client)];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initAllClients() {
|
||||
getClients().forEach(function(client) {
|
||||
getClients().forEach(function (client) {
|
||||
initClient(client);
|
||||
});
|
||||
}
|
||||
@@ -69,48 +77,48 @@ function initAllClients() {
|
||||
// ===========================================================================
|
||||
|
||||
function updateServerRules() {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Updating all server rules ...`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Updating all server rules ...`);
|
||||
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Time support: ${isTimeSupported()}`);
|
||||
if(isTimeSupported()) {
|
||||
if(getServerConfig() != false) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Time support: ${isTimeSupported()}`);
|
||||
if (isTimeSupported()) {
|
||||
if (getServerConfig() != false) {
|
||||
let value = makeReadableTime(getServerConfig().hour, getServerConfig().minute);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Time" as ${value}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Setting server rule "Time" as ${value}`);
|
||||
server.setRule("Time", value);
|
||||
}
|
||||
}
|
||||
|
||||
if(isWeatherSupported()) {
|
||||
if(getServerConfig() != false) {
|
||||
if(typeof getGameConfig().weatherNames[getGame()] != "undefined") {
|
||||
if (isWeatherSupported()) {
|
||||
if (getServerConfig() != false) {
|
||||
if (typeof getGameConfig().weatherNames[getGame()] != "undefined") {
|
||||
let value = getGameConfig().weatherNames[getGame()][getServerConfig().weather];
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Weather" as ${value}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Setting server rule "Weather" as ${value}`);
|
||||
server.setRule("Weather", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isSnowSupported()) {
|
||||
if(getServerConfig() != false) {
|
||||
if (isSnowSupported()) {
|
||||
if (getServerConfig() != false) {
|
||||
let value = getYesNoFromBool(getServerConfig().fallingSnow);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: Setting server rule "Snowing" as ${value}`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Setting server rule "Snowing" as ${value}`);
|
||||
server.setRule("Snowing", value);
|
||||
}
|
||||
}
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities]: All server rules updated successfully!`);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: All server rules updated successfully!`);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getWeatherFromParams(params) {
|
||||
if(isNaN(params)) {
|
||||
for(let i in getGameConfig().weatherNames[getGame()]) {
|
||||
if(toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in getGameConfig().weatherNames[getGame()]) {
|
||||
if (toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
|
||||
if (typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
@@ -121,14 +129,14 @@ function getWeatherFromParams(params) {
|
||||
// ===========================================================================
|
||||
|
||||
function getFightStyleFromParams(params) {
|
||||
if(isNaN(params)) {
|
||||
for(let i in getGameConfig().fightStyles[getGame()]) {
|
||||
if(toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in getGameConfig().fightStyles[getGame()]) {
|
||||
if (toLowerCase(getGameConfig().fightStyles[getGame()][i][0]).indexOf(toLowerCase(params)) != -1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof getGameConfig().fightStyles[getGame()][params] != "undefined") {
|
||||
if (typeof getGameConfig().fightStyles[getGame()][params] != "undefined") {
|
||||
return toInteger(params);
|
||||
}
|
||||
}
|
||||
@@ -139,12 +147,12 @@ function getFightStyleFromParams(params) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestHospital(position) {
|
||||
if(typeof getGameConfig().hospitals[getGame()] == "undefined") {
|
||||
return {position: getServerConfig().newCharacter.spawnPosition};
|
||||
if (typeof getGameConfig().hospitals[getGame()] == "undefined") {
|
||||
return { position: getServerConfig().newCharacter.spawnPosition };
|
||||
} else {
|
||||
let closest = 0;
|
||||
for(let i in getGameConfig().hospitals[getGame()]) {
|
||||
if(getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) {
|
||||
for (let i in getGameConfig().hospitals[getGame()]) {
|
||||
if (getDistance(getGameConfig().hospitals[getGame()][i].position, position) < getDistance(getGameConfig().hospitals[getGame()][closest].position, position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
@@ -156,12 +164,12 @@ function getClosestHospital(position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getClosestPoliceStation(position) {
|
||||
if(typeof getGameConfig().policeStations[getGame()] == "undefined") {
|
||||
return {position: getServerConfig().newCharacter.spawnPosition};
|
||||
if (typeof getGameConfig().policeStations[getGame()] == "undefined") {
|
||||
return { position: getServerConfig().newCharacter.spawnPosition };
|
||||
} else {
|
||||
let closest = 0;
|
||||
for(let i in getGameConfig().policeStations[getGame()]) {
|
||||
if(getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) {
|
||||
for (let i in getGameConfig().policeStations[getGame()]) {
|
||||
if (getDistance(getGameConfig().policeStations[getGame()][i].position, position) < getDistance(getGameConfig().policeStations[getGame()][closest].position, position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +181,7 @@ function getClosestPoliceStation(position) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerDisplayForConsole(client) {
|
||||
if(isNull(client)) {
|
||||
if (isNull(client)) {
|
||||
return "(Unknown client)";
|
||||
}
|
||||
return `${getPlayerName(client)}[${getPlayerId(client)}]`;
|
||||
@@ -182,7 +190,7 @@ function getPlayerDisplayForConsole(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerNameForNameTag(client) {
|
||||
if(isPlayerSpawned(client)) {
|
||||
if (isPlayerSpawned(client)) {
|
||||
return `${getPlayerCurrentSubAccount(client).firstName} ${getPlayerCurrentSubAccount(client).lastName}`;
|
||||
}
|
||||
return getPlayerName(client);
|
||||
@@ -191,7 +199,7 @@ function getPlayerNameForNameTag(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isPlayerSpawned(client) {
|
||||
if(!getPlayerData(client)) {
|
||||
if (!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
return getPlayerData(client).spawned;
|
||||
@@ -206,8 +214,8 @@ function getPlayerIsland(client) {
|
||||
// ===========================================================================
|
||||
|
||||
function isAtPayAndSpray(position) {
|
||||
for(let i in getGameConfig().payAndSprays[getGame()]) {
|
||||
if(getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
|
||||
for (let i in getGameConfig().payAndSprays[getGame()]) {
|
||||
if (getDistance(position, getGameConfig().payAndSprays[getGame()][i]) <= getGlobalConfig().payAndSprayDistance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -217,33 +225,11 @@ function isAtPayAndSpray(position) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function resetClientStuff(client) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
|
||||
|
||||
if(!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerOnJobRoute(client)) {
|
||||
stopJobRoute(client, false, false);
|
||||
}
|
||||
|
||||
if(getPlayerData(client).rentingVehicle) {
|
||||
stopRentingVehicle(client);
|
||||
}
|
||||
|
||||
deleteJobItems(client);
|
||||
|
||||
getPlayerData(client).lastVehicle = null;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerFromCharacterId(subAccountId) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
for(let j in getPlayerData(clients[i]).subAccounts) {
|
||||
if(getPlayerData(clients[i]).subAccounts[j].databaseId == subAccountId) {
|
||||
for (let i in clients) {
|
||||
for (let j in getPlayerData(clients[i]).subAccounts) {
|
||||
if (getPlayerData(clients[i]).subAccounts[j].databaseId == subAccountId) {
|
||||
return clients[i];
|
||||
}
|
||||
}
|
||||
@@ -256,12 +242,12 @@ function getPlayerFromCharacterId(subAccountId) {
|
||||
|
||||
function checkPlayerPedStates() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerData(clients[i])) {
|
||||
if(getPlayerData(clients[i]).pedState) {
|
||||
if(isPlayerInAnyVehicle(clients[i])) {
|
||||
if(getPlayerData(clients[i]).pedState == VRR_PEDSTATE_EXITINGVEHICLE) {
|
||||
getPlayerData(clients[i]).pedState == VRR_PEDSTATE_READY;
|
||||
for (let i in clients) {
|
||||
if (getPlayerData(clients[i])) {
|
||||
if (getPlayerData(clients[i]).pedState) {
|
||||
if (isPlayerInAnyVehicle(clients[i])) {
|
||||
if (getPlayerData(clients[i]).pedState == AGRP_PEDSTATE_EXITINGVEHICLE) {
|
||||
getPlayerData(clients[i]).pedState == AGRP_PEDSTATE_READY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,11 +258,11 @@ function checkPlayerPedStates() {
|
||||
// ===========================================================================
|
||||
|
||||
function showConnectCameraToPlayer(client) {
|
||||
if(isFadeCameraSupported()) {
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1);
|
||||
}
|
||||
|
||||
if(isCustomCameraSupported()) {
|
||||
if (isCustomCameraSupported()) {
|
||||
//setPlayerInterior(client, 0);
|
||||
//setPlayerDimension(client, 0);
|
||||
setPlayerCameraLookAt(client, getServerConfig().connectCameraPosition, getServerConfig().connectCameraLookAt);
|
||||
@@ -295,9 +281,9 @@ function showCharacterSelectCameraToPlayer(client) {
|
||||
function getClosestPlayer(position, exemptPlayer) {
|
||||
let clients = getClients();
|
||||
let closest = 0;
|
||||
for(let i in clients) {
|
||||
if(exemptClient != clients[i]) {
|
||||
if(getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
|
||||
for (let i in clients) {
|
||||
if (exemptPlayer != clients[i]) {
|
||||
if (getDistance(getPlayerPosition(clients[i]), position) < getDistance(getPlayerPosition(clients[closest]), position)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
@@ -315,20 +301,20 @@ function isPlayerMuted(client) {
|
||||
|
||||
function getPlayerFromParams(params) {
|
||||
let clients = getClients();
|
||||
if(isNaN(params)) {
|
||||
for(let i in clients) {
|
||||
if(!clients[i].console) {
|
||||
if(toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
if (isNaN(params)) {
|
||||
for (let i in clients) {
|
||||
if (!clients[i].console) {
|
||||
if (toLowerCase(clients[i].name).indexOf(toLowerCase(params)) != -1) {
|
||||
return clients[i];
|
||||
}
|
||||
|
||||
if(toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) {
|
||||
if (toLowerCase(getCharacterFullName(clients[i])).indexOf(toLowerCase(params)) != -1) {
|
||||
return clients[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(typeof clients[toInteger(params)] != "undefined") {
|
||||
if (typeof clients[toInteger(params)] != "undefined") {
|
||||
return clients[toInteger(params)];
|
||||
}
|
||||
}
|
||||
@@ -338,9 +324,9 @@ function getPlayerFromParams(params) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateConnectionLogOnQuit(client, quitReasonId) {
|
||||
if(getPlayerData(client) != false) {
|
||||
quickDatabaseQuery(`UPDATE conn_main SET conn_when_disconnect=NOW(), conn_how_disconnect=${quitReasonId} WHERE conn_id = ${getPlayerData(client).sessionId}`);
|
||||
function updateConnectionLogOnQuit(client) {
|
||||
if (getPlayerData(client) != false) {
|
||||
quickDatabaseQuery(`UPDATE conn_main SET conn_when_disconnect=NOW() WHERE conn_id = ${getPlayerData(client).sessionId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,12 +339,12 @@ function updateConnectionLogOnAuth(client, authId) {
|
||||
// ===========================================================================
|
||||
|
||||
function updateConnectionLogOnClientInfoReceive(client, clientVersion, screenWidth, screenHeight) {
|
||||
if(getPlayerData(client) != false) {
|
||||
if (getPlayerData(client) != false) {
|
||||
getPlayerData(client).clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
if (dbConnection) {
|
||||
let safeClientVersion = escapeDatabaseString(dbConnection, clientVersion);
|
||||
let safeScreenWidth = escapeDatabaseString(dbConnection, toString(screenWidth));
|
||||
let safeScreenHeight = escapeDatabaseString(dbConnection, toString(screenHeight));
|
||||
@@ -377,8 +363,8 @@ function generateRandomPhoneNumber() {
|
||||
function doesNameContainInvalidCharacters(name) {
|
||||
let disallowedCharacters = getGlobalConfig().subAccountNameAllowedCharacters;
|
||||
name = toLowerCase(name);
|
||||
for(let i = 0; i < name.length; i++) {
|
||||
if(disallowedCharacters.toLowerCase().indexOf(name.charAt(i)) == -1) {
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
if (disallowedCharacters.toLowerCase().indexOf(name.charAt(i)) == -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -394,36 +380,12 @@ function getClientFromSyncerId(syncerId) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function triggerWebHook(messageString, serverId = getServerId(), type = VRR_DISCORD_WEBHOOK_LOG) {
|
||||
if(!getGlobalConfig().discord.webhook.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function clearTemporaryVehicles() {
|
||||
let vehicles = getElementsByType(ELEMENT_VEHICLE);
|
||||
for(let i in vehicles) {
|
||||
if(!getVehicleData(vehicles[i])) {
|
||||
for (let i in vehicles) {
|
||||
if (!getVehicleData(vehicles[i])) {
|
||||
let occupants = vehicles[i].getOccupants();
|
||||
for(let j in occupants) {
|
||||
for (let j in occupants) {
|
||||
destroyGameElement(occupants[j]);
|
||||
}
|
||||
destroyGameElement(vehicles[i]);
|
||||
@@ -435,11 +397,11 @@ function clearTemporaryVehicles() {
|
||||
|
||||
function clearTemporaryPeds() {
|
||||
let peds = getElementsByType(ELEMENT_PED);
|
||||
for(let i in peds) {
|
||||
if(peds[i].owner == -1) {
|
||||
if(!peds[i].isType(ELEMENT_PLAYER)) {
|
||||
if(peds[i].vehicle == null) {
|
||||
if(!getNPCData(peds[i])) {
|
||||
for (let i in peds) {
|
||||
if (peds[i].owner == -1) {
|
||||
if (!peds[i].isType(ELEMENT_PLAYER)) {
|
||||
if (peds[i].vehicle == null) {
|
||||
if (!getNPCData(peds[i])) {
|
||||
destroyElement(peds[i]);
|
||||
}
|
||||
}
|
||||
@@ -450,30 +412,38 @@ function clearTemporaryPeds() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function kickAllClients() {
|
||||
getClients().forEach((client) => {
|
||||
disconnectPlayer(client);
|
||||
})
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateTimeRule() {
|
||||
if(isTimeSupported()) {
|
||||
if (isTimeSupported()) {
|
||||
server.setRule("Time", makeReadableTime(game.time.hour, game.time.minute));
|
||||
}
|
||||
|
||||
if (getGame() == AGRP_GAME_MAFIA_ONE) {
|
||||
if (isNightTime(getServerConfig().hour)) {
|
||||
server.setRule("Time", "Night");
|
||||
} else {
|
||||
server.setRule("Time", "Day");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function isClientInitialized(client) {
|
||||
return (typeof getServerData().clients[getPlayerId(client)] != "undefined");
|
||||
//if (typeof getServerData().clients[getPlayerId(client)] == "undefined") {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (playerInitialized[getPlayerId(client)] == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPedForNetworkEvent(ped) {
|
||||
if(getGame() == VRR_GAME_GTA_IV) {
|
||||
if (getGame() == AGRP_GAME_GTA_IV) {
|
||||
return ped;
|
||||
} else {
|
||||
return ped.id;
|
||||
@@ -485,10 +455,10 @@ function getPedForNetworkEvent(ped) {
|
||||
// Get how many times a player connected in the last month by name
|
||||
function getPlayerConnectionsInLastMonthByName(name) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
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) {
|
||||
if (result) {
|
||||
return result[0].count;
|
||||
}
|
||||
}
|
||||
@@ -500,10 +470,179 @@ function getPlayerConnectionsInLastMonthByName(name) {
|
||||
|
||||
function addPrefixNumberFill(number, amount) {
|
||||
let numberString = toString(number);
|
||||
while(numberString.length < amount) {
|
||||
while (numberString.length < amount) {
|
||||
numberString = toString(`0${numberString}`);
|
||||
}
|
||||
return toString(numberString);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function updateAllPlayerWeaponDamageStates() {
|
||||
let clients = getClients();
|
||||
for (let i in players) {
|
||||
if (isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
setPlayerWeaponDamageEvent(clients[i], getPlayerData(clients[i]).weaponDamageEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function removeAllPlayersFromProperties() {
|
||||
let clients = getClients();
|
||||
for (let i in clients) {
|
||||
if (isPlayerInAnyBusiness(clients[i])) {
|
||||
removePlayerFromBusiness(clients[i]);
|
||||
}
|
||||
|
||||
if (isPlayerInAnyHouse(clients[i])) {
|
||||
removePlayerFromHouse(clients[i]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function removeAllPlayersFromVehicles() {
|
||||
let clients = getClients();
|
||||
for (let i in clients) {
|
||||
if (isPlayerInAnyVehicle(clients[i])) {
|
||||
removePlayerFromVehicle(clients[i]);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function processPlayerEnteringExitingProperty(client) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Utilities]: Processing property enter/exit for player ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (getPlayerData(client).enteringExitingProperty == null) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Utilities]: Aborting property enter/exit for player ${getPlayerDisplayForConsole(client)}. Assigned property data is null.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let pedState = getPlayerData(client).pedState;
|
||||
if (pedState != AGRP_PEDSTATE_ENTERINGPROPERTY && pedState != AGRP_PEDSTATE_EXITINGPROPERTY) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Utilities]: Aborting property enter/exit for player ${getPlayerDisplayForConsole(client)}. Ped state is not entering or exiting property.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let propertyData = null;
|
||||
if (getPlayerData(client).enteringExitingProperty[0] == AGRP_PROPERTY_TYPE_BUSINESS) {
|
||||
propertyData = getBusinessData(getPlayerData(client).enteringExitingProperty[1]);
|
||||
} else if (getPlayerData(client).enteringExitingProperty[0] == AGRP_PROPERTY_TYPE_HOUSE) {
|
||||
propertyData = getHouseData(getPlayerData(client).enteringExitingProperty[1]);
|
||||
}
|
||||
|
||||
if (propertyData == null || propertyData == false) {
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Utilities]: Aborting property enter/exit for player ${getPlayerDisplayForConsole(client)}. Property is invalid.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pedState == AGRP_PEDSTATE_ENTERINGPROPERTY) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Utilities]: Processing property ENTER for player ${getPlayerDisplayForConsole(client)} ...`);
|
||||
if (isGameFeatureSupported("interiorScene") && propertyData.exitScene != "") {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is entering a property with interior scene (${propertyData.exitScene})`);
|
||||
spawnPlayer(client, propertyData.exitPosition, propertyData.exitRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
onPlayerSpawn(client);
|
||||
} else {
|
||||
setPlayerPosition(client, propertyData.exitPosition);
|
||||
setPlayerHeading(client, propertyData.exitRotation);
|
||||
}
|
||||
|
||||
setPlayerDimension(client, propertyData.exitDimension);
|
||||
setPlayerInterior(client, propertyData.exitInterior);
|
||||
|
||||
setTimeout(function () {
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
updateInteriorLightsForPlayer(client, propertyData.interiorLights);
|
||||
}, 1000);
|
||||
|
||||
if (getPlayerData(client).enteringExitingProperty[0] == AGRP_PROPERTY_TYPE_BUSINESS) {
|
||||
if (propertyData.type == AGRP_BIZ_TYPE_PAINTBALL) {
|
||||
startPaintBall(client);
|
||||
}
|
||||
}
|
||||
|
||||
let radioStationIndex = propertyData.streamingRadioStationIndex;
|
||||
if (radioStationIndex != -1) {
|
||||
if (getRadioStationData(radioStationIndex)) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url);
|
||||
getPlayerData(client).streamingRadioStation = radioStationIndex;
|
||||
}
|
||||
}
|
||||
|
||||
getPlayerData(client).inProperty = [getPlayerData(client).enteringExitingProperty[0], getPlayerData(client).enteringExitingProperty[1]];
|
||||
getPlayerData(client).enteringExitingProperty = null;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
} else if (pedState == AGRP_PEDSTATE_EXITINGPROPERTY) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Utilities]: Processing property EXIT for player ${getPlayerDisplayForConsole(client)} from property ID ${propertyData.index}/${propertyData.databaseId} ...`);
|
||||
if (isGameFeatureSupported("interiorScene") && propertyData.entranceScene != "") {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is exiting a property with external interior scene (${propertyData.entranceScene})`);
|
||||
spawnPlayer(client, propertyData.entrancePosition, propertyData.entranceRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
|
||||
onPlayerSpawn(client);
|
||||
} else {
|
||||
setPlayerPosition(client, propertyData.entrancePosition);
|
||||
setPlayerHeading(client, propertyData.entranceRotation);
|
||||
}
|
||||
|
||||
setPlayerDimension(client, propertyData.entranceDimension);
|
||||
setPlayerInterior(client, propertyData.entranceInterior);
|
||||
|
||||
// Check if exiting property was into another house/business
|
||||
let inProperty = false;
|
||||
let inPropertyType = AGRP_PROPERTY_TYPE_NONE;
|
||||
|
||||
let inBusiness = getPlayerBusiness(client);
|
||||
if (inBusiness != -1) {
|
||||
inProperty = getBusinessData(inBusiness);
|
||||
inPropertyType = AGRP_PROPERTY_TYPE_BUSINESS;
|
||||
} else {
|
||||
let inHouse = getPlayerHouse(client);
|
||||
if (inHouse != -1) {
|
||||
inProperty = getHouseData(inHouse);
|
||||
inPropertyType = AGRP_PROPERTY_TYPE_HOUSE;
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
if (getGame() != AGRP_GAME_MAFIA_ONE && getGame() != AGRP_GAME_GTA_IV) {
|
||||
if (isFadeCameraSupported()) {
|
||||
fadeCamera(client, true, 1.0);
|
||||
}
|
||||
}
|
||||
updateInteriorLightsForPlayer(client, (inProperty != false) ? inProperty.interiorLights : true);
|
||||
}, 1000);
|
||||
|
||||
stopPaintBall(client);
|
||||
|
||||
if (inProperty != false) {
|
||||
if (getBusinessData(inBusiness).streamingRadioStationIndex != -1) {
|
||||
if (getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex)) {
|
||||
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex).url);
|
||||
getPlayerData(client).streamingRadioStation = getBusinessData(inBusiness).streamingRadioStationIndex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stopRadioStreamForPlayer(client);
|
||||
getPlayerData(client).streamingRadioStation = -1;
|
||||
}
|
||||
|
||||
getPlayerData(client).inProperty = [inPropertyType, inProperty.index];
|
||||
getPlayerData(client).enteringExitingProperty = null;
|
||||
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerCountryISOCode(client) {
|
||||
return module.geoip.getCountryISO(getGlobalConfig().geoIPCountryDatabaseFilePath, getPlayerIP(client));
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user