Merge branch 'nightly'

This commit is contained in:
Vortrex
2022-12-19 10:38:05 -06:00
137 changed files with 10501 additions and 5713 deletions

View File

@@ -7,7 +7,8 @@
"flagImageFile": "uk.png",
"countries": ["gb", "us", "au", "bz", "ca", "ie", "jm", "nz", "za", "tt"],
"requiresUnicode": false,
"contributor": "Vortrex"
"contributor": "Vortrex",
"enabled": true
},
{
"id": 1,
@@ -17,7 +18,8 @@
"flagImageFile": "ru.png",
"countries": ["ru", "ua"],
"requiresUnicode": false,
"contributor": "VNDTTS"
"contributor": "VNDTTS",
"enabled": true
},
{
"id": 2,
@@ -27,7 +29,8 @@
"flagImageFile": "pl.png",
"countries": ["pl"],
"requiresUnicode": false,
"contributor": "Suprise444"
"contributor": "Suprise444",
"enabled": true
},
{
"id": 3,
@@ -37,7 +40,8 @@
"flagImageFile": "es.png",
"countries": ["es", "ar", "bo", "cl", "co", "cr", "do", "ec", "sv", "gt", "hn", "mx", "ni", "pa", "py", "pe", "pr", "uy", "ve"],
"requiresUnicode": false,
"contributor": "PerikiyoXD"
"contributor": "PerikiyoXD",
"enabled": true
},
{
"id": 4,
@@ -47,7 +51,8 @@
"flagImageFile": "cn.png",
"countries": ["cn", "hk", "sg", "tw"],
"requiresUnicode": true,
"contributor": "Renzuko_Ctone"
"contributor": "Renzuko_Ctone",
"enabled": true
},
{
"id": 5,
@@ -57,7 +62,8 @@
"flagImageFile": "sa.png",
"countries": ["dz", "bh", "eg", "iq", "jo", "kw", "lb", "ly", "ma", "om", "qa", "sa", "sy", "tn", "ae", "ye"],
"requiresUnicode": true,
"contributor": "! KASIR"
"contributor": "! KASIR",
"enabled": true
},
{
"id": 6,
@@ -67,7 +73,8 @@
"flagImageFile": "sk.png",
"countries": ["sk"],
"requiresUnicode": false,
"contributor": "UAKLAUS"
"contributor": "UAKLAUS",
"enabled": false
},
{
"id": 7,
@@ -77,7 +84,8 @@
"flagImageFile": "de.png",
"countries": ["de", "at", "be", "ch", "li", "lu"],
"requiresUnicode": false,
"contributor": "Sladernimo"
"contributor": "Sladernimo",
"enabled": true
},
{
"id": 8,
@@ -87,7 +95,8 @@
"flagImageFile": "fr.png",
"countries": ["fr", "cd", "bj", "bf", "cd", "cg", "ga", "gn", "ml", "mc", "ne", "sn"],
"requiresUnicode": false,
"contributor": "Cocam"
"contributor": "Cocam",
"enabled": false
},
{
"id": 9,
@@ -97,7 +106,8 @@
"flagImageFile": "jp.png",
"countries": ["jp"],
"requiresUnicode": true,
"contributor": "Cocam"
"contributor": "Cocam",
"enabled": false
},
{
"id": 10,
@@ -107,6 +117,29 @@
"flagImageFile": "fi.png",
"countries": ["fi"],
"requiresUnicode": false,
"contributor": "SIMBA_MEOW"
"contributor": "SIMBA_MEOW",
"enabled": true
},
{
"id": 11,
"englishName": "Lithuanian",
"stringsFile": "lithuanian.json",
"isoCode": "lt",
"flagImageFile": "lt.png",
"countries": ["lt"],
"requiresUnicode": false,
"contributor": "dovis",
"enabled": false
},
{
"id": 12,
"englishName": "Latvian",
"stringsFile": "latvian.json",
"isoCode": "lv",
"flagImageFile": "lv.png",
"countries": ["lv"],
"requiresUnicode": false,
"contributor": "YuOn",
"enabled": false
}
]

View File

@@ -5,6 +5,8 @@
"sendVehicleEvents": false,
"sendDeathEvents": false,
"sendAdmin": false,
"sendClan": false,
"sendAction": false,
"webhook": {
"enabled": false,
"webhookBaseURL": "http://127.0.0.1:8090/discord.php?message={0}&server={1}&type={2}&pass={3}",

View File

@@ -4,6 +4,7 @@
"applyUpkeep": true,
"grossIncomeMultiplier": 1.0,
"incomeTaxRate": 0.7,
"currencyString": "${AMOUNT}",
"upKeepCosts": {
"upKeepPerVehicle": 250,
"upKeepPerHouse": 350,

View File

@@ -11,7 +11,8 @@
"flagImageFile": "uk.png",
"countries": ["gb", "us", "au", "bz", "ca", "ie", "jm", "nz", "za", "tt"],
"requiresUnicode": false,
"contributor": "Vortrex"
"contributor": "Vortrex",
"enabled": true
},
{
"id": 1,
@@ -21,7 +22,8 @@
"flagImageFile": "ru.png",
"countries": ["ru", "ua"],
"requiresUnicode": false,
"contributor": "VNDTTS"
"contributor": "VNDTTS",
"enabled": true
},
{
"id": 2,
@@ -31,7 +33,8 @@
"flagImageFile": "pl.png",
"countries": ["pl"],
"requiresUnicode": false,
"contributor": "Suprise444"
"contributor": "Suprise444",
"enabled": true
},
{
"id": 3,
@@ -41,7 +44,8 @@
"flagImageFile": "es.png",
"countries": ["es", "ar", "bo", "cl", "co", "cr", "do", "ec", "sv", "gt", "hn", "mx", "ni", "pa", "py", "pe", "pr", "uy", "ve"],
"requiresUnicode": false,
"contributor": "PerikiyoXD"
"contributor": "PerikiyoXD",
"enabled": true
},
{
"id": 4,
@@ -51,7 +55,8 @@
"flagImageFile": "cn.png",
"countries": ["cn", "hk", "sg", "tw"],
"requiresUnicode": true,
"contributor": "Renzuko_Ctone"
"contributor": "Renzuko_Ctone",
"enabled": true
},
{
"id": 5,
@@ -61,7 +66,8 @@
"flagImageFile": "sa.png",
"countries": ["dz", "bh", "eg", "iq", "jo", "kw", "lb", "ly", "ma", "om", "qa", "sa", "sy", "tn", "ae", "ye"],
"requiresUnicode": true,
"contributor": "! KASIR"
"contributor": "! KASIR",
"enabled": true
},
{
"id": 6,
@@ -71,7 +77,8 @@
"flagImageFile": "sk.png",
"countries": ["sk"],
"requiresUnicode": false,
"contributor": "UAKLAUS"
"contributor": "UAKLAUS",
"enabled": false
},
{
"id": 7,
@@ -81,7 +88,8 @@
"flagImageFile": "de.png",
"countries": ["de", "at", "be", "ch", "li", "lu"],
"requiresUnicode": false,
"contributor": "Sladernimo"
"contributor": "Sladernimo",
"enabled": true
},
{
"id": 8,
@@ -91,7 +99,8 @@
"flagImageFile": "fr.png",
"countries": ["fr", "cd", "bj", "bf", "cd", "cg", "ga", "gn", "ml", "mc", "ne", "sn"],
"requiresUnicode": false,
"contributor": "Cocam"
"contributor": "Cocam",
"enabled": false
},
{
"id": 9,
@@ -101,7 +110,8 @@
"flagImageFile": "jp.png",
"countries": ["jp"],
"requiresUnicode": true,
"contributor": "Cocam"
"contributor": "Cocam",
"enabled": false
},
{
"id": 10,
@@ -111,7 +121,30 @@
"flagImageFile": "fi.png",
"countries": ["fi"],
"requiresUnicode": false,
"contributor": "SIMBA_MEOW"
"contributor": "SIMBA_MEOW",
"enabled": true
},
{
"id": 11,
"englishName": "Lithuanian",
"stringsFile": "lithuanian.json",
"isoCode": "lt",
"flagImageFile": "lt.png",
"countries": ["lt"],
"requiresUnicode": false,
"contributor": "dovis",
"enabled": false
},
{
"id": 12,
"englishName": "Latvian",
"stringsFile": "latvian.json",
"isoCode": "lv",
"flagImageFile": "lv.png",
"countries": ["lv"],
"requiresUnicode": false,
"contributor": "YuOn",
"enabled": false
}
]
}

Binary file not shown.

BIN
files/images/cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

View File

@@ -1,5 +1,5 @@
<meta>
<info author="Vortrex" version="1.0" description="Vortrex's Roleplay Resource" />
<info author="Vortrex" version="1.0" description="Asshat Gaming Roleplay - Main Script" />
<!-- Shared -->
<script src="scripts/shared/const.js" type="server" language="javascript" />
@@ -10,7 +10,7 @@
<script src="scripts/shared/gamedata.js" type="client" language="javascript" />
<!-- Multiplayer Mod (Wrapped Natives) -->
<!-- The goal is to just swap only these out when I port the script to a new mod, like Oakwood -->
<!-- The goal is to just swap only these out when I port the script to a new MP mod -->
<script src="scripts/server/native/connected.js" type="server" language="javascript" />
<script src="scripts/client/native/connected.js" type="client" language="javascript" />
@@ -50,6 +50,7 @@
<script src="scripts/server/npc.js" type="server" language="javascript" />
<script src="scripts/server/netevents.js" type="server" language="javascript" />
<script src="scripts/server/paintball.js" type="server" language="javascript" />
<script src="scripts/server/prompt.js" type="server" language="javascript" />
<script src="scripts/server/race.js" type="server" language="javascript" />
<script src="scripts/server/radio.js" type="server" language="javascript" />
<script src="scripts/server/security.js" type="server" language="javascript" />
@@ -85,9 +86,11 @@
<!-- Extra Client Files -->
<file type="client" src="files/fonts/roboto-regular.ttf" />
<file type="client" src="files/fonts/pricedown.ttf" />
<file type="client" src="files/fonts/aurora-bold-condensed.ttf" />
<file type="client" src="files/images/skins/none.png" />
<!--<file type="client" src="files/images/server-logo.png" />-->
<file type="client" src="files/images/asshat-logo.png" />
<file type="client" src="files/images/cursor.png" />
<!-- GUI -->
<script src="scripts/client/gui/2fa.js" type="client" language="javascript" />
@@ -98,19 +101,28 @@
<script src="scripts/client/gui/error.js" type="client" language="javascript" />
<script src="scripts/client/gui/housemgr.js" type="client" language="javascript" />
<script src="scripts/client/gui/info.js" type="client" language="javascript" />
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
<script src="scripts/client/gui/inventory.js" type="client" language="javascript" />
<script src="scripts/client/gui/inventorybulk.js" type="client" language="javascript" />
<script src="scripts/client/gui/list.js" type="client" language="javascript" />
<script src="scripts/client/gui/login.js" type="client" language="javascript" />
<script src="scripts/client/gui/localechooser.js" type="client" language="javascript" />
<script src="scripts/client/gui/newchar.js" type="client" language="javascript" />
<script src="scripts/client/gui/register.js" type="client" language="javascript" />
<script src="scripts/client/gui/resetpass.js" type="client" language="javascript" />
<script src="scripts/client/gui/yesno.js" type="client" language="javascript" />
<script src="scripts/client/gui/localechooser.js" type="client" language="javascript" />
<script src="scripts/client/gui/games/blackjack.js" type="client" language="javascript" />
<script src="scripts/client/gui/games/betting.js" type="client" language="javascript" />
<script src="scripts/client/gui/games/5cardpoker.js" type="client" language="javascript" />
<!-- Client Scripts -->
<script src="scripts/client/afk.js" type="client" language="javascript" />
<script src="scripts/client/animation.js" type="client" language="javascript" />
<script src="scripts/client/business.js" type="client" language="javascript" />
<script src="scripts/client/core.js" type="client" language="javascript" />
<script src="scripts/client/chat.js" type="client" language="javascript" />
<script src="scripts/client/cursor.js" type="client" language="javascript" />
<script src="scripts/client/economy.js" type="client" language="javascript" />
<script src="scripts/client/event.js" type="client" language="javascript" />
<script src="scripts/client/gui.js" type="client" language="javascript" />
<script src="scripts/client/gps.js" type="client" language="javascript" />
@@ -121,19 +133,17 @@
<script src="scripts/client/label.js" type="client" language="javascript" />
<script src="scripts/client/locale.js" type="client" language="javascript" />
<script src="scripts/client/logo.js" type="client" language="javascript" />
<script src="scripts/client/main.js" type="client" language="javascript" />
<script src="scripts/client/messaging.js" type="client" language="javascript" />
<script src="scripts/client/mousecam.js" type="client" language="javascript" />
<script src="scripts/client/nametag.js" type="client" language="javascript" />
<script src="scripts/client/npc.js" type="client" language="javascript" />
<script src="scripts/client/radio.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
<script src="scripts/client/netevents.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/time.nut" type="client" language="squirrel" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/vehicle.js" type="client" language="javascript" />
<script src="scripts/client/netevents.js" type="client" language="javascript" />
<!-- Locale Files -->
<file type="client" src="config/client/locale.json" />

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: afk.js
// DESC: Provides AFK detection
@@ -10,8 +9,8 @@
// Init AFK script
function initAFKScript() {
logToConsole(LOG_DEBUG, "[VRR.AFK]: Initializing AFK script ...");
logToConsole(LOG_DEBUG, "[VRR.AFK]: AFK script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.AFK]: Initializing AFK script ...");
logToConsole(LOG_DEBUG, "[AGRP.AFK]: AFK script initialized!");
}
// ===========================================================================

View File

@@ -1,13 +1,19 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: animation.js
// DESC: Provides animation functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
function initAnimationScript() {
logToConsole(LOG_DEBUG, "[AGRP.Animation]: Initializing animation script ...");
logToConsole(LOG_DEBUG, "[AGRP.Animation]: Animation script initialized!");
}
// ===========================================================================
function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
let ped = getElementFromId(pedId);
@@ -16,11 +22,11 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
}
let animationData = getAnimationData(animationSlot);
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
logToConsole(LOG_DEBUG, `[AGRP.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
let freezePlayer = false;
switch (animationData.moveType) {
case AGRP_ANIMMOVE_FORWARD: {
case V_ANIMMOVE_FORWARD: {
setElementCollisionsEnabled(ped, false);
if (ped.isSyncer) {
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
@@ -29,7 +35,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
break;
}
case AGRP_ANIMMOVE_BACK: {
case V_ANIMMOVE_BACK: {
setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) {
setElementPosition(pedId, getPosBehindPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
@@ -38,7 +44,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
break;
}
case AGRP_ANIMMOVE_LEFT: {
case V_ANIMMOVE_LEFT: {
setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) {
setElementPosition(pedId, getPosToLeftOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
@@ -47,7 +53,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
break;
}
case AGRP_ANIMMOVE_RIGHT: {
case V_ANIMMOVE_RIGHT: {
setElementCollisionsEnabled(pedId, false);
if (ped.isSyncer) {
setElementPosition(pedId, getPosToRightOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
@@ -61,9 +67,9 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
}
}
if (getGame() < AGRP_GAME_GTA_IV) {
if (animationData.animType == AGRP_ANIMTYPE_NORMAL || animationData.animType == AGRP_ANIMTYPE_SURRENDER) {
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) {
if (getGame() < V_GAME_GTA_IV) {
if (animationData.animType == V_ANIMTYPE_NORMAL || animationData.animType == V_ANIMTYPE_SURRENDER) {
if (getGame() == V_GAME_GTA_VC || getGame() == V_GAME_GTA_SA) {
ped.clearAnimations();
} else {
ped.clearObjective();
@@ -75,7 +81,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
setLocalPlayerControlState(false, false);
localPlayer.collisionsEnabled = false;
}
} else if (animationData.animType == AGRP_ANIMTYPE_BLEND) {
} else if (animationData.animType == V_ANIMTYPE_BLEND) {
ped.position = ped.position;
ped.blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed);
}
@@ -96,7 +102,7 @@ function forcePedAnimation(pedId, animSlot) {
let animationData = getAnimationData(animSlot);
if (getGame() < AGRP_GAME_GTA_IV) {
if (getGame() < V_GAME_GTA_IV) {
ped.position = ped.position;
ped.addAnimation(animationData.groupId, animationData.animId);
@@ -120,8 +126,8 @@ function makePedStopAnimation(pedId) {
return false;
}
if (getGame() != AGRP_GAME_GTA_IV) {
if (getGame() == AGRP_GAME_GTA_VC || getGame() == AGRP_GAME_GTA_SA) {
if (getGame() != V_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_VC || getGame() == V_GAME_GTA_SA) {
ped.clearAnimations();
} else {
ped.clearObjective();
@@ -129,7 +135,7 @@ function makePedStopAnimation(pedId) {
}
if (ped == localPlayer) {
if (getGame() != AGRP_GAME_GTA_IV) {
if (getGame() != V_GAME_GTA_IV) {
localPlayer.collisionsEnabled = true;
}
setLocalPlayerControlState(true, false);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: business.js
// DESC: Provides business functions and usage
@@ -17,18 +16,29 @@ class BusinessData {
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.rentPrice = 0;
this.buyPrice = 0;
this.hasItems = hasItems;
this.blipId = -1;
this.labelInfoType = 0;
this.locked = false;
this.entranceFee = 0;
}
}
// ===========================================================================
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems) {
logToConsole(LOG_DEBUG, `[VRR.Business] Received business ${businessId} (${name}) from server`);
function initBusinessScript() {
logToConsole(LOG_DEBUG, "[AGRP.Business]: Initializing business script ...");
logToConsole(LOG_INFO, "[AGRP.Business]: Business script initialized!");
}
if (!areServerElementsSupported()) {
// ===========================================================================
function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems, entranceFee) {
logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`);
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
if (getBusinessData(businessId) != false) {
let businessData = getBusinessData(businessId);
businessData.name = name;
@@ -36,13 +46,27 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
businessData.blipModel = blipModel;
businessData.pickupModel = pickupModel;
businessData.hasInterior = hasInterior;
businessData.buyPrice = buyPrice;
businessData.rentPrice = rentPrice;
businessData.hasItems = hasItems;
businessData.locked = locked;
businessData.entranceFee = entranceFee;
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} already exists. Checking blip ...`);
if (hasInterior && !hasItems) {
businessData.labelInfoType = V_PROPLABEL_INFO_ENTER;
} else if (!hasInterior && hasItems) {
businessData.labelInfoType = V_PROPLABEL_INFO_BUY;
} else {
if (businessData.buyPrice > 0) {
businessData.labelInfoType = V_PROPLABEL_INFO_BUYBIZ;
}
}
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} already exists. Checking blip ...`);
if (blipModel == -1) {
if (businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been removed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getBusinessData(businessId).blipId);
} else {
destroyElement(getElementFromId(blipId));
@@ -51,12 +75,12 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
//businesses.splice(businessData.index, 1);
//setAllBusinessDataIndexes();
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip is unchanged`);
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip is unchanged`);
}
} else {
if (businessData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been changed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.setBlipCoordinates(businessData.blipId, businessData.entrancePosition);
natives.changeBlipSprite(businessData.blipId, businessData.blipModel);
natives.setBlipMarkerLongDistance(businessData.blipId, false);
@@ -68,20 +92,20 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
if (blipId != -1) {
tempBusinessData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} doesn't exist. Adding ...`);
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} doesn't exist. Adding ...`);
let tempBusinessData = new BusinessData(businessId, name, entrancePosition, blipModel, pickupModel, hasInterior, hasItems);
if (blipModel != -1) {
let blipId = createGameBlip(tempBusinessData.blipModel, tempBusinessData.entrancePosition, tempBusinessData.name);
if (blipId != -1) {
tempBusinessData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.Business] Business ${businessId} has no blip.`);
logToConsole(LOG_DEBUG, `[AGRP.Business] Business ${businessId} has no blip.`);
}
getServerData().businesses.push(tempBusinessData);
setAllBusinessDataIndexes();

38
scripts/client/camera.js Normal file
View File

@@ -0,0 +1,38 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: camera.js
// DESC: Provides camera functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
let cameraFadeEnabled = false;
let cameraFadeIn = false;
let cameraFadeStart = 0;
let cameraFadeDuration = 0;
let cameraFadeColour = 0;
// ===========================================================================
function processCameraFadeRendering() {
if (cameraFadeEnabled) {
let finishTime = cameraFadeStart + cameraFadeDuration;
if (sdl.ticks >= finishTime) {
cameraFadeEnabled = false;
cameraFadeDuration = 0;
cameraFadeStart = 0;
} else {
let currentTick = sdl.ticks - cameraFadeStart;
let progressPercent = Math.ceil(currentTick * 100 / cameraFadeDuration);
let rgbaArray = rgbaArrayFromToColour(cameraFadeColour);
let alpha = (cameraFadeIn) ? Math.ceil(255 / progressPercent) : Math.ceil(progressPercent / 255);
cameraFadeColour = toColour(rgbaArray[0], rgbaArray[1], rgbaArray[2], alpha);
graphics.drawRectangle(null, toVector2(0, 0), toVector2(game.width, game.height), cameraFadeColour, cameraFadeColour, cameraFadeColour, cameraFadeColour);
}
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: chatbox.js
// DESC: Provides extra chatbox features
@@ -29,11 +28,11 @@ let scrollDownKey = false;
// ===========================================================================
function initChatBoxScript() {
logToConsole(LOG_DEBUG, "[VRR.Chat]: Initializing chat script ...");
logToConsole(LOG_DEBUG, "[AGRP.Chat]: Initializing chat script ...");
scrollUpKey = getKeyIdFromParams("pageup");
scrollDownKey = getKeyIdFromParams("pagedown");
bindChatBoxKeys();
logToConsole(LOG_DEBUG, "[VRR.Chat]: Chat script initialized!");
logToConsole(LOG_INFO, "[AGRP.Chat]: Chat script initialized!");
}
// ===========================================================================
@@ -53,7 +52,7 @@ function unBindChatBoxKeys() {
// ===========================================================================
function receiveChatBoxMessageFromServer(messageString, colour, hour, minute, second) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Received chatbox message from server: ${messageString}`);
logToConsole(LOG_DEBUG, `[AGRP.Chat]: Received chatbox message from server: ${messageString}`);
// Just in case it's hidden by auto hide
//setChatWindowEnabled(true);
@@ -73,21 +72,21 @@ function receiveChatBoxMessageFromServer(messageString, colour, hour, minute, se
let outputString = messageString;
if (chatTimeStampsEnabled == true) {
//timeStampString = `{TIMESTAMPCOLOUR}[${findResourceByName("agrp_time").exports.getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`;
let timeStampString = `{TIMESTAMPCOLOUR}[${hour}:${minute}:${second}] `;
let colourRGBA = rgbaArrayFromToColour(colour);
let timeStampString = `{TIMESTAMPCOLOUR}[${hour}:${minute}:${second}][${rgbToHex(colourRGBA[0], colourRGBA[1], colourRGBA[2])}] `;
outputString = `${timeStampString}${messageString}`;
}
logToConsole(LOG_DEBUG, `[VRR.Chat]: Changed colours in string: ${outputString}`);
logToConsole(LOG_DEBUG, `[AGRP.Chat]: Changed colours in string: ${outputString}`);
outputString = replaceColoursInMessage(`${outputString}`);
if (chatEmojiEnabled == true) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Enabled emoji in string: ${outputString}`);
logToConsole(LOG_DEBUG, `[AGRP.Chat]: Enabled emoji in string: ${outputString}`);
outputString = replaceEmojiInMessage(outputString);
}
if (profanityFilterEnabled == true) {
logToConsole(LOG_DEBUG, `[VRR.Chat]: Removed profanity in string: ${outputString}`);
logToConsole(LOG_DEBUG, `[AGRP.Chat]: Removed profanity in string: ${outputString}`);
outputString = replaceProfanityInMessage(outputString);
}
@@ -163,12 +162,9 @@ function updateChatBox() {
if (typeof chatBoxHistory[i] != "undefined") {
let outputString = chatBoxHistory[i][0];
if (chatTimeStampsEnabled == true) {
//let timeStampDate = new Date(chatBoxHistory[i][2]);
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
//let timeStampText = findResourceByName("agrp_time").exports.getTimeStampOutput(chatBoxHistory[i][2]);
let timeStampText = `${chatBoxHistory[i][2]}:${chatBoxHistory[i][3]}:${chatBoxHistory[i][4]}`;
outputString = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`;
let colourRGBA = rgbaArrayFromToColour(chatBoxHistory[i][1]);
outputString = `{TIMESTAMPCOLOUR}[${timeStampText}][${rgbToHex(colourRGBA[0], colourRGBA[1], colourRGBA[2])}] ${chatBoxHistory[i][0]}`;
}
outputString = replaceColoursInMessage(outputString);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: content.js
// DESC: Provides connection to extra content resources

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: main.js
// DESC: Main client script (will be reorganized into individual files later)
@@ -19,8 +18,8 @@ let isSpawned = false;
let garbageCollectorInterval = null;
let parkedVehiclePosition = false;
let parkedVehicleHeading = false;
//let parkedVehiclePosition = false;
//let parkedVehicleHeading = false;
let renderHUD = true;
let renderLabels = true;
@@ -31,7 +30,7 @@ let renderHotBar = true;
let renderItemActionDelay = true;
let renderInteriorLights = true;
let logLevel = LOG_DEBUG;
let logLevel = LOG_INFO | LOG_DEBUG;
let weaponDamageEnabled = {};
let weaponDamageEvent = {};
@@ -61,10 +60,11 @@ let interiorLightsEnabled = true;
let interiorLightsColour = toColour(0, 0, 0, 150);
let mouseCameraEnabled = false;
let mouseCursorEnabled = false;
let currentPickup = false;
let vehiclePurchaseState = AGRP_VEHBUYSTATE_NONE;
let vehiclePurchaseState = V_VEHBUYSTATE_NONE;
let vehiclePurchasing = null;
let vehiclePurchasePosition = null;
@@ -83,6 +83,15 @@ let profanityFilterEnabled = false;
let localLocaleId = 0;
/**
* @typedef {Object} ServerData
* @property {Array.<HouseData>} houses
* @property {Array.<BusinessData>} businesses
* @property {Array.<VehicleData>} vehicles
* @property {Array} localeStrings
* @property {Array} localeOptions
* @property {Object} cvars
*/
let serverData = {
houses: [],
businesses: [],
@@ -90,6 +99,19 @@ let serverData = {
localeOptions: [],
vehicles: [],
jobs: [],
cvars: {},
};
let localPlayerMoney = 0;
let localPlayerMoneyInterval = null;
let currencyString = "${AMOUNT}";
let mapChangeWarning = false;
let cruiseControlEnabled = false;
let cruiseControlSpeed = 0.0;
let myToken = "";
// ===========================================================================

39
scripts/client/cursor.js Normal file
View File

@@ -0,0 +1,39 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: cursor.js
// DESC: Provides cursor functions and usage
// TYPE: Client (JavaScript)
// ===========================================================================
let cursorImage = null;
let cursorImagePath = "files/images/cursor.png";
let cursorSize = toVector2(16.0, 24.0);
// ===========================================================================
function initCursorScript() {
logToConsole(LOG_DEBUG, "[AGRP.Cursor]: Initializing cursor script ...");
let cursorStream = openFile(cursorImagePath);
if (cursorStream != null) {
cursorImage = graphics.loadPNG(cursorStream);
cursorStream.close();
}
logToConsole(LOG_INFO, "[AGRP.Cursor]: Cursor script initialized!");
}
// ===========================================================================
function processMouseCursorRendering() {
if (isGameFeatureSupported("mouseCursor")) {
return false;
}
if (gui.cursorEnabled) {
graphics.drawRectangle(cursorImage, gui.cursorPosition, cursorSize);
}
}
// ===========================================================================

View File

@@ -1,9 +1,12 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: 5cardpoker.js
// DESC: Provides 5-card poker games GUI
// FILE: economy.js
// DESC: Provides economy functions
// TYPE: Client (JavaScript)
// ===========================================================================
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -9,9 +8,9 @@
// ===========================================================================
function initEventScript() {
logToConsole(LOG_DEBUG, "[VRR.Event]: Initializing event script ...");
logToConsole(LOG_DEBUG, "[AGRP.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_DEBUG, "[VRR.Event]: Event script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Event]: Event script initialized!");
}
// ===========================================================================
@@ -41,15 +40,15 @@ function addAllEventHandlers() {
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
}
}
if (getGame() == V_GAME_MAFIA_ONE) {
addEventHandler("OnMapLoaded", onMapLoaded);
}
}
// ===========================================================================
function onResourceStart(event, resource) {
if (resource == thisResource) {
sendResourceStartedSignalToServer();
}
if (resource == findResourceByName("v-events")) {
// Remove and re-add events, in case v-events was loaded after agrp_main
removeEventHandler("OnPedEnteredVehicleEx");
@@ -62,13 +61,20 @@ function onResourceStart(event, resource) {
addEventHandler("OnPedEnteredSphereEx", onPedEnteredSphere);
addEventHandler("OnPedExitedSphereEx", onPedExitedSphere);
}
//garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
if (resource == thisResource) {
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Event] onResourceStart called - Sending signal to server`);
garbageCollectorInterval = setInterval(collectAllGarbage, 1000 * 60);
localPlayerMoneyInterval = setInterval(updateLocalPlayerMoney, 1000 * 5);
sendResourceStartedSignalToServer();
}
}
// ===========================================================================
function onResourceStop(event, resource) {
if (resource == thisResource) {
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Event] onResourceStop called - Sending signal to server`);
sendResourceStoppedSignalToServer();
}
}
@@ -77,6 +83,8 @@ function onResourceStop(event, resource) {
function onResourceReady(event, resource) {
if (resource == thisResource) {
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.Event] onResourceReady called - Sending signal to server`);
loadLocaleConfig();
sendResourceReadySignalToServer();
}
}
@@ -84,6 +92,7 @@ function onResourceReady(event, resource) {
// ===========================================================================
function onProcess(event, deltaTime) {
logToConsole(LOG_VERBOSE, `[AGRP.Event] onProcess`);
if (localPlayer == null) {
return false;
}
@@ -101,9 +110,9 @@ function onProcess(event, deltaTime) {
processNearbyPickups();
processVehiclePurchasing();
processVehicleBurning();
processVehicleCruiseControl();
//checkChatBoxAutoHide(); // Will be uncommented on 1.4.0 GTAC update
//processVehicleFires();
}
// ===========================================================================
@@ -118,6 +127,9 @@ function onKeyUp(event, keyCode, scanCode, keyModifiers) {
// ===========================================================================
function onDrawnHUD(event) {
logToConsole(LOG_VERBOSE, `[AGRP.Event] HUD drawn`);
processMouseCursorRendering();
if (!renderHUD) {
return false;
}
@@ -139,7 +151,7 @@ function onDrawnHUD(event) {
// ===========================================================================
function onPedWasted(event, wastedPed, killerPed, weapon, pedPiece) {
logToConsole(LOG_DEBUG, `[VRR.Event] Ped ${wastedPed.name} died`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Ped ${wastedPed.name} died`);
wastedPed.clearWeapons();
}
@@ -152,27 +164,62 @@ function onElementStreamIn(event, element) {
// ===========================================================================
function onPedExitedVehicle(event, ped, vehicle, seat) {
//logToConsole(LOG_DEBUG, `[VRR.Event] Local player exited vehicle`);
//sendNetworkEventToServer("agrp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
//logToConsole(LOG_DEBUG, `[AGRP.Event] Local player exited vehicle`);
//sendNetworkEventToServer("v.rp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
cruiseControlEnabled = false;
cruiseControlSpeed = 0.0;
if (localPlayer != null) {
if (ped == localPlayer) {
if (areServerElementsSupported()) {
if (inVehicleSeat == 0) {
//setVehicleEngine(vehicle.id, false);
//if (!inVehicle.engine) {
// parkedVehiclePosition = false;
// parkedVehicleHeading = false;
//}
}
}
}
}
}
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle, seat) {
//logToConsole(LOG_DEBUG, `[AGRP.Event] Local player exited vehicle`);
//sendNetworkEventToServer("v.rp.onPlayerExitVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (localPlayer != null) {
if (ped == localPlayer) {
cruiseControlEnabled = false;
cruiseControlSpeed = 0.0;
}
}
}
// ===========================================================================
function onPedEnteredVehicle(event, ped, vehicle, seat) {
logToConsole(LOG_DEBUG, `[VRR.Event] Local player entered vehicle`);
//sendNetworkEventToServer("agrp.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
logToConsole(LOG_DEBUG, `[AGRP.Event] Ped entered vehicle`);
//sendNetworkEventToServer("v.rp.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if (areServerElementsSupported()) {
if (inVehicleSeat == 0) {
setVehicleEngine(vehicle.id, false);
if (!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
cruiseControlEnabled = false;
cruiseControlSpeed = 0.0;
if (localPlayer != null) {
if (ped == localPlayer) {
if (areServerElementsSupported()) {
if (inVehicleSeat == 0) {
//parkedVehiclePosition = inVehicle.position;
//parkedVehicleHeading = inVehicle.heading;
if (doesEntityDataExist(vehicle, "v.rp.server") == true) {
//setVehicleEngine(vehicle.id, false);
setVehicleEngine(vehicle.id, getEntityData(vehicle, "v.rp.engine"));
//setLocalPlayerControlState(false, false);
}
}
}
}
}
@@ -183,14 +230,14 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healthLoss, pedPiece) {
//let damagerEntityString = (!isNull(damagedEntity)) ? `${damagerEntity.name} (${damagerEntity.name}, ${damagerEntity.type} - ${typeof damagerEntity})` : `Unknown ped`;
//let damagedEntityString = (!isNull(damagedEntity)) ? `${damagedEntity.name} (${damagedEntity.name}, ${damagedEntity.type} - ${typeof damagedEntity})` : `Unknown ped`;
//logToConsole(LOG_DEBUG, `[VRR.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
//logToConsole(LOG_DEBUG, `[AGRP.Event] ${damagerEntityString} damaged ${damagedEntityString}'s '${pedPiece} with weapon ${weaponId}`);
if (!isNull(damagedEntity) && !isNull(damagerEntity)) {
if (damagedEntity.isType(ELEMENT_PLAYER)) {
if (damagedEntity == localPlayer) {
if (!weaponDamageEnabled[damagerEntity.name]) {
preventDefaultEventAction(event);
}
sendNetworkEventToServer("agrp.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
sendNetworkEventToServer("v.rp.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
}
}
}
@@ -246,4 +293,10 @@ function onEntityProcess(event, entity) {
}
// ===========================================================================
function onMapLoaded(mapName) {
sendNetworkEventToServer("v.rp.mapLoaded", mapName);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: gps.js
// DESC: Provides GPS functions and usage
@@ -17,9 +16,9 @@ let gpsBlipBlinkTimer = null;
// ===========================================================================
function showGPSLocation(position, colour) {
logToConsole(LOG_DEBUG, `[VRR.GPS] Showing gps location`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
if (getGame() == AGRP_GAME_GTA_SA) {
logToConsole(LOG_DEBUG, `[AGRP.GPS] Showing gps location`);
if (getMultiplayerMod() == V_MPMOD_GTAC) {
if (getGame() == V_GAME_GTA_SA) {
// Server-side spheres don't show in GTA SA for some reason.
gpsSphere = game.createPickup(1318, position, 1);
} else {

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: gui.js
// DESC: Provides GUI functionality and styles (using MexUI)
@@ -41,14 +40,14 @@ let creatingCharacter = false;
// ===========================================================================
function initGUIScript() {
logToConsole(LOG_DEBUG, "[VRR.GUI]: Initializing GUI script ...");
logToConsole(LOG_DEBUG, "[VRR.GUI]: GUI script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.GUI]: Initializing GUI script ...");
logToConsole(LOG_DEBUG, "[AGRP.GUI]: GUI script initialized!");
}
// ===========================================================================
function initGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Initializing GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Initializing GUI ...`);
initLoginGUI();
initRegisterGUI();
@@ -62,21 +61,27 @@ function initGUI() {
initResetPasswordGUI();
initChangePasswordGUI();
initLocaleChooserGUI();
//initInventoryGUI();
//initInventoryBulkGUI();
//initClanManagerGUI();
//initBusinessManagerGUI();
//initHouseManagerGUI();
//initFiveCardPokerGUI();
//initBettingGUI();
//initBlackJackGUI();
closeAllWindows();
guiReady = true;
logToConsole(LOG_DEBUG, `[VRR.GUI] All GUI created successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] All GUI created successfully!`);
loadLocaleConfig();
sendNetworkEventToServer("agrp.guiReady", true);
sendNetworkEventToServer("v.rp.guiReady", true);
};
// ===========================================================================
function closeAllWindows() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing all GUI windows`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing all GUI windows`);
infoDialog.window.shown = false;
yesNoDialog.window.shown = false;
errorDialog.window.shown = false;
@@ -89,6 +94,14 @@ function closeAllWindows() {
passwordReset.window.shown = false;
passwordChange.window.shown = false;
localeChooser.window.shown = false;
//houseManager.window.shown = false;
//businessManager.window.shown = false;
//clanManager.window.shown = false;
//inventoryGUI.window.shown = false;
//inventoryBulkGUI.window.shown = false;
//bettingGUI.window.shown = false;
//blackJackGUI.window.shown = false;
//fiveCardPokerGUI.window.shown = false;
mexui.setInput(false);
mexui.focusedControl = false;
@@ -157,13 +170,45 @@ function isAnyGUIActive() {
return true;
}
//if (clanManager.window.shown == true) {
// return true;
//}
//if (businessManager.window.shown == true) {
// return true;
//}
//if (houseManager.window.shown == true) {
// return true;
//}
//if (inventoryGUI.window.shown == true) {
// return true;
//}
//if (inventoryBulkGUI.window.shown == true) {
// return true;
//}
//if (bettingGUI.window.shown == true) {
// return true;
//}
//if (blackJackGUI.window.shown == true) {
// return true;
//}
//if (fiveCardPokerGUI.window.shown == true) {
// return true;
//}
return false;
}
// ===========================================================================
function setGUIColours(red1, green1, blue1, red2, green2, blue2, red3, green3, blue3) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Received new GUI colours from server: ${red1}, ${green1}, ${blue1} / ${red2}, ${green2}, ${blue2} / ${red3}, ${green3}, ${blue3}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Received new GUI colours from server: ${red1}, ${green1}, ${blue1} / ${red2}, ${green2}, ${blue2} / ${red3}, ${green3}, ${blue3}`);
primaryColour = [red1, green1, blue1];
secondaryColour = [red2, green2, blue2];
primaryTextColour = [red3, green3, blue3];
@@ -183,41 +228,45 @@ function hideAllGUI() {
// ===========================================================================
function processGUIKeyPress(keyCode) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Processing key press: ${keyCode}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Processing key press: ${keyCode}`);
if (!guiReady) {
return false;
}
if (!isAnyGUIActive()) {
logToConsole(LOG_DEBUG, `[VRR.GUI] GUI is not active. Cancelling keypress processing.`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] GUI is not active. Cancelling keypress processing.`);
return false;
}
if (keyCode == SDLK_RETURN || keyCode == SDLK_RETURN2) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is submit (${guiSubmitKey})`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Key press is submit (${guiSubmitKey})`);
if (guiSubmitKey != false) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling submit key function`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Calling submit key function`);
guiSubmitKey.call();
}
} else if (keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is left (${guiLeftKey})`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Key press is left (${guiLeftKey})`);
if (guiLeftKey != false) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling left key function`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Calling left key function`);
guiLeftKey.call();
}
} else if (keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is right (${guiRightKey})`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Key press is right (${guiRightKey})`);
if (guiRightKey != false) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling right key function`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Calling right key function`);
guiRightKey.call();
}
} else if (keyCode == getKeyIdFromParams("down") || keyCode == getKeyIdFromParams("s")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is down (${guiDownKey})`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Key press is down (${guiDownKey})`);
if (guiDownKey != false) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling down key function`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Calling down key function`);
guiDownKey.call();
}
} else if (keyCode == getKeyIdFromParams("up") || keyCode == getKeyIdFromParams("w")) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Key press is up (${guiUpKey})`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Key press is up (${guiUpKey})`);
if (guiUpKey != false) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Calling up key function`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Calling up key function`);
guiUpKey.call();
}
}
@@ -227,13 +276,17 @@ function processGUIKeyPress(keyCode) {
function processToggleGUIKeyPress(keyCode) {
if (keyCode == disableGUIKey) {
sendNetworkEventToServer("agrp.toggleGUI");
sendNetworkEventToServer("v.rp.toggleGUI");
}
}
// ===========================================================================
function resetGUIStrings() {
if (!guiReady) {
return false;
}
// Login GUI
login.messageLabel.text = getLocaleString("GUILoginWindowLabelEnterPassword");
login.passwordInput.placeholder = getLocaleString("GUILoginWindowPasswordPlaceholder");
@@ -277,4 +330,16 @@ function resetGUIStrings() {
newCharacter.firstNameInput.placeholder = getLocaleString("GUINewCharacterFirstNamePlaceholder");
newCharacter.lastNameInput.placeholder = getLocaleString("GUINewCharacterLastNamePlaceholder");
newCharacter.createCharacterButton.text = toUpperCase(getLocaleString("GUINewCharacterSubmitButton"));
}
}
// ===========================================================================
function dimAllGUIElementsInWindow(guiObject) {
for (let i in guiObject) {
if (i != "window") {
guiObject[i].shown = false;
}
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: 2fa.js
// DESC: Provides two factor authentication GUI
@@ -21,7 +20,7 @@ let twoFactorAuth = {
// ===========================================================================
function initTwoFactorAuthenticationGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating two factor auth GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating two factor auth GUI ...`);
twoFactorAuth.window = mexui.window(game.width / 2 - 150, game.height / 2 - 129, 300, 258, 'LOGIN', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -95,14 +94,14 @@ function initTwoFactorAuthenticationGUI() {
},
}, checkTwoFactorAuth);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created two factor auth GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created two factor auth GUI`);
}
// ===========================================================================
function showTwoFactorAuthGUI() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing two-factor authentication window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing two-factor authentication window`);
setChatWindowEnabled(false);
mexui.setInput(true);
twoFactorAuth.window.shown = true;
@@ -113,7 +112,7 @@ function showTwoFactorAuthGUI() {
// ===========================================================================
function twoFactorAuthFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports two-factor authentication failed. Reason: ${errorMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports two-factor authentication failed. Reason: ${errorMessage}`);
twoFactorAuth.messageLabel.text = errorMessage;
twoFactorAuth.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
twoFactorAuth.codeInput.text = "";
@@ -122,15 +121,15 @@ function twoFactorAuthFailed(errorMessage) {
// ===========================================================================
function twoFactorAuthSuccess() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports two-factor authentication was successful`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports two-factor authentication was successful`);
closeAllWindows();
}
// ===========================================================================
function checkTwoFactorAuth() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking two-factor authentication with server ...`);
sendNetworkEventToServer("agrp.2fa", twoFactorAuth.codeInput.lines[0]);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking two-factor authentication with server ...`);
sendNetworkEventToServer("v.rp.2fa", twoFactorAuth.codeInput.lines[0]);
}
// ===========================================================================

View File

@@ -1,9 +1,84 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: bizmgr.js
// DESC: Provides business manager GUI
// TYPE: Client (JavaScript)
// ===========================================================================
/*
class BusinessManagerData {
constructor(businessIndex, name, locked, entranceFee, buyPrice, rentPrice, floorItems, storageItems) {
this.businessIndex = businessIndex;
this.name = name;
this.locked = locked;
this.entranceFee = entranceFee;
this.buyPrice = buyPrice;
this.rentPrice = rentPrice;
this.till = till;
this.ownerName = ownerName;
this.floorItems = floorItems;
this.storageItems = storageItems;
}
}
// ===========================================================================
let businessManager = {
window: null,
generalTabButton: null,
floorItemsTab: null,
storageItemsTab: null,
orderItemsTab: null,
data: null,
// General Tab
businessName: null,
businessOwnerName: null,
businessEntranceFee: null,
businessBuyPrice: null,
businessRentPrice: null,
};
// ===========================================================================
function initBusinessManagerGUI() {
}
// ===========================================================================
function showBusinessManagerGUI() {
}
// ===========================================================================
function hideBusinessManagerGUI() {
}
// ===========================================================================
function updateBusinessManagerGUIStrings() {
}
// ===========================================================================
function receiveBusinessManagerData(businessIndex, name, locked, entranceFee, buyPrice, rentPrice, floorItems, storageItems) {
let businessManagerData = new BusinessManagerData(businessIndex, name, locked, entranceFee, buyPrice, rentPrice, floorItems, storageItems);
businessManager.data = businessManagerData;
updateBusinessManagerGUIStrings();
}
// ===========================================================================
function saveBusinessData() {
sendNetworkEventToServer("v.rp.businessManagerSave", businessManager.data.businessIndex);
}
*/
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: changepass.js
// DESC: Provides change password GUI
@@ -20,7 +19,7 @@ let passwordChange = {
// ===========================================================================
function initChangePasswordGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password change GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating password change GUI ...`);
passwordChange.window = mexui.window(game.width / 2 - 130, game.height / 2 - 125, 300, 250, 'Change Password', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -111,13 +110,13 @@ function initChangePasswordGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkChangePassword);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created change password GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created change password GUI`);
}
// ===========================================================================
function passwordChangeFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports change password failed. Reason: ${errorMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports change password failed. Reason: ${errorMessage}`);
passwordChange.messageLabel.text = errorMessage;
passwordChange.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
passwordChange.passwordInput.text = "";
@@ -128,14 +127,14 @@ function passwordChangeFailed(errorMessage) {
// ===========================================================================
function checkChangePassword() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password change with server ...`);
sendNetworkEventToServer("agrp.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking password change with server ...`);
sendNetworkEventToServer("v.rp.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]);
}
// ===========================================================================
function showChangePasswordGUI(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing change password window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing change password window`);
closeAllWindows();
setChatWindowEnabled(false);
mexui.setInput(true);
@@ -150,7 +149,7 @@ function showChangePasswordGUI(errorMessage) {
// ===========================================================================
function passwordChangeSuccess() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password change was successful`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports password change was successful`);
guiSubmitKey = false;
closeAllWindows();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: charselect.js
// DESC: Provides character select GUI
@@ -24,7 +23,7 @@ let characterSelect = {
// ===========================================================================
function initCharacterSelectGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating character select GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating character select GUI ...`);
characterSelect.window = mexui.window(game.width / 2 - 215, game.height / 2 - 83, 430, 190, 'SELECT CHARACTER', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -151,18 +150,18 @@ function initCharacterSelectGUI() {
borderColour: toColour(0, 0, 0, 0),
}
});
logToConsole(LOG_DEBUG, `[VRR.GUI] Created character select GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created character select GUI`);
}
// ===========================================================================
function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, skinId) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing character selection window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing character selection window`);
setChatWindowEnabled(false);
mexui.setInput(true);
characterSelect.nameText.text = `${firstName} ${lastName}`;
characterSelect.cashText.text = `Money: $${cash}`;
characterSelect.cashText.text = `Money: ${getCurrencyString(cash)}`;
characterSelect.clanText.text = `Clan: ${clan}`;
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
@@ -179,46 +178,46 @@ function showCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, ski
function showNewCharacter() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing new character dialog window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing new character dialog window`);
showNewCharacterGUI();
}
// ===========================================================================
function selectNextCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting next character info from server for character select window`);
sendNetworkEventToServer("agrp.nextCharacter");
logToConsole(LOG_DEBUG, `[AGRP.GUI] Requesting next character info from server for character select window`);
sendNetworkEventToServer("v.rp.nextCharacter");
}
// ===========================================================================
function selectPreviousCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Requesting previous character info from server for character select window`);
sendNetworkEventToServer("agrp.previousCharacter");
logToConsole(LOG_DEBUG, `[AGRP.GUI] Requesting previous character info from server for character select window`);
sendNetworkEventToServer("v.rp.previousCharacter");
}
// ===========================================================================
function selectThisCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Tell server the current shown character was selected in character select window`);
sendNetworkEventToServer("agrp.selectCharacter");
logToConsole(LOG_DEBUG, `[AGRP.GUI] Tell server the current shown character was selected in character select window`);
sendNetworkEventToServer("v.rp.selectCharacter");
}
// ===========================================================================
function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, skinId) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Updating character info with data from server`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Updating character info with data from server`);
setChatWindowEnabled(false);
characterSelect.window.shown = false;
characterSelect.nameText.text = `${firstName} ${lastName}`;
characterSelect.cashText.text = `Money: $${cash}`;
characterSelect.cashText.text = `Money: ${getCurrencyString(cash)}`;
characterSelect.clanText.text = `Clan: ${clan}`;
characterSelect.lastPlayedText.text = `Last Played: ${lastPlayed}`;
if (characterSelect.skinImage != null) {
characterSelect.skinImage.remove();
}
characterSelect.skinImage = (getGame() == AGRP_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.skinImage = (getGame() == V_GAME_GTA_III) ? characterSelect.window.image(310, 32, 100, 90, `files/images/skins/gta3/${getSkinImage(skinId)}.png`) : characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.window.shown = true;
@@ -230,7 +229,7 @@ function switchCharacterSelectGUI(firstName, lastName, cash, clan, lastPlayed, s
// ===========================================================================
function characterSelectSuccess() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports character selection was successful`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports character selection was successful`);
closeAllWindows();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: clanmgr.js
// DESC: Provides clan manager GUI
@@ -10,12 +9,16 @@
let clanManager = {
window: null,
generalTab: null,
ranksTab: null,
membersTab: null,
vehiclesTab: null,
businessesTab: null,
housesTab: null,
generalTabButton: null,
ranksTabButton: null,
membersTabButton: null,
vehiclesTabButton: null,
businessesTabButton: null,
housesTabButton: null,
};
// ===========================================================================
// ===========================================================================
function initClanManagerGUI() {
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: error.js
// DESC: Provides error box GUI
@@ -17,7 +16,7 @@ let errorDialog = {
// ===========================================================================
function initErrorDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating error GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating error GUI ...`);
errorDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'ERROR', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -59,14 +58,14 @@ function initErrorDialogGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
},
}, closeErrorDialog);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created error GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created error GUI ...`);
}
// ===========================================================================
function showErrorGUI(errorMessage, errorTitle, buttonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
setChatWindowEnabled(false);
mexui.setInput(true);
errorDialog.messageLabel.text = errorMessage;
@@ -78,7 +77,7 @@ function showErrorGUI(errorMessage, errorTitle, buttonText) {
// ===========================================================================
function closeErrorDialog() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing error dialog`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing error dialog`);
errorDialog.window.shown = false;
mexui.setInput(false);
}

View File

@@ -0,0 +1,39 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: 5cardpoker.js
// DESC: Provides 5-card poker games GUI
// TYPE: Client (JavaScript)
// ===========================================================================
let fiveCardPokerGUI = {
window: null,
}
function initFiveCardPokerGUI() {
// Render a five card poker game in MexUI
//logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating five-card poker GUI ...`);
fiveCardPokerGUI.window = mexui.window(game.width / 2 - 200, game.height - 150, 400, 400, 'Five Card Poker', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
},
title: {
textSize: 11.0,
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], windowTitleAlpha),
},
icon: {
textSize: 0.0,
textColour: toColour(0, 0, 0, 0),
backgroundColour: toColour(0, 0, 0, 0),
},
});
fiveCardPokerGUI.window.titleBarShown = false;
fiveCardPokerGUI.window.shown = false;
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created five card poker GUI`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: betting.js
// DESC: Provides betting GUI (used for multiple casino games)

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: blackjack.js
// DESC: Provides blackjack game GUI
@@ -23,7 +22,7 @@ let dealerCards = [];
function initBlackJackGUI() {
// Render a blackjack game in MexUI
//logToConsole(LOG_DEBUG, `[VRR.GUI] Creating blackjack GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating blackjack GUI ...`);
blackJackGUI.window = mexui.window(game.width / 2 - 200, game.height - 150, 400, 400, 'Blackjack', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
@@ -43,7 +42,7 @@ function initBlackJackGUI() {
blackJackGUI.window.shown = false;
//logToConsole(LOG_DEBUG, `[VRR.GUI] Created blackjack GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created blackjack GUI`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: housemgr.js
// DESC: Provides house manager GUI

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: info.js
// DESC: Provides info dialog box GUI
@@ -17,7 +16,7 @@ let infoDialog = {
// ===========================================================================
function initInfoDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating info dialog GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating info dialog GUI ...`);
infoDialog.window = mexui.window(getScreenWidth() / 2 - 200, getScreenHeight() / 2 - 70, 400, 140, 'Information', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -58,13 +57,13 @@ function initInfoDialogGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
},
}, closeInfoDialog);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created info dialog GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created info dialog GUI`);
}
// ===========================================================================
function closeInfoDialog() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing info dialog`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing info dialog`);
infoDialog.window.shown = false;
mexui.setInput(false);
}
@@ -73,7 +72,7 @@ function closeInfoDialog() {
function showInfoGUI(infoMessage, infoTitle, buttonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
mexui.setInput(true);
infoDialog.messageLabel.text = infoMessage;
infoDialog.okayButton.text = buttonText;

View File

@@ -0,0 +1,44 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: inventory.js
// DESC: Provides inventory dialog box GUI
// TYPE: Client (JavaScript)
// ===========================================================================
let inventoryGUI = [
{
window: null,
},
{
window: null,
},
];
// ===========================================================================
function initInventoryGUI() {
}
// ===========================================================================
function closeAllInventoryGUI() {
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing all inventory GUI`);
for (let i in inventoryGUI) {
inventoryGUI[i].window.shown = false;
}
mexui.setInput(false);
}
// ===========================================================================
function showInventoryGUI(inventoryIndex, items) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing inventory window. Index: ${inventoryIndex}`);
inventoryGUI[inventoryIndex].window.shown = true;
mexui.setInput(true);
}
// ===========================================================================

View File

@@ -0,0 +1,44 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: inventorybulk.js
// DESC: Provides bulk inventory box GUI
// TYPE: Client (JavaScript)
// ===========================================================================
let inventoryBulkGUI = [
{
window: null,
},
{
window: null,
},
];
// ===========================================================================
function initInventoryBulkGUI() {
}
// ===========================================================================
function closeAllInventoryBulkGUI() {
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing all bulk inventory GUI`);
for (let i in inventoryBulkGUI) {
inventoryBulkGUI[i].window.shown = false;
}
mexui.setInput(false);
}
// ===========================================================================
function showInventoryBulkGUI(inventoryIndex, items) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing bulk inventory window. Index: ${inventoryIndex}`);
inventoryBulkGUI[inventoryIndex].window.shown = true;
mexui.setInput(true);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: list.js
// DESC: Provides simple list GUI
@@ -12,12 +11,14 @@ let listDialog = {
window: null,
messageLabel: null,
listGrid: null,
listRows: [],
};
// ===========================================================================
function initListGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating list dialog GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating list dialog GUI ...`);
listDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 500, 'List', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -71,14 +72,14 @@ function initListGUI() {
}
}
});
logToConsole(LOG_DEBUG, `[VRR.GUI] Created list dialog GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created list dialog GUI`);
}
// ===========================================================================
function showListGUI() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing login window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing list window`);
setChatWindowEnabled(false);
mexui.setInput(true);
listDialog.window.shown = true;
@@ -90,19 +91,56 @@ function showListGUI() {
// ===========================================================================
function checkListDialogSelection() {
if (!listDialog.listGrid.activeRow) {
return false;
}
sendNetworkEventToServer("v.rp.list.select", listDialog.listGrid.activeRow.getEntryIndex());
}
// ===========================================================================
function selectPreviousListItem() {
if (!listDialog.listGrid.activeRow) {
return false;
}
let activeRowId = listDialog.listGrid.activeRow.getEntryIndex();
if (activeRowId <= 1) {
listDialog.listGrid.activeRow = 0;
} else {
listDialog.listGrid.activeRow = listDialog.listRows[activeRowId - 1];
}
//sendNetworkEventToServer("v.rp.list.next", listDialog.listGrid.activeRow.getEntryIndex());
}
// ===========================================================================
function selectNextListItem() {
let activeRowId = listDialog.listGrid.activeRow.getEntryIndex();
if (activeRowId >= listDialog.listRows.length - 1) {
listDialog.listGrid.activeRow = 0;
} else {
listDialog.listGrid.activeRow = listDialog.listRows[activeRowId + 1];
}
//sendNetworkEventToServer("v.rp.list.next", listDialog.listGrid.activeRow.getEntryIndex());
}
// ===========================================================================
function clearListGUI() {
listDialog.listGrid.removeAllEntries();
}
// ===========================================================================
function populateListGUI(listItems) {
for (let i in listItems) {
let row = listDialog.listGrid.row(listItems[i]);
listDialog.listRows.push(row);
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: localechooser.js
// DESC: Provides locale chooser GUI
@@ -20,7 +19,7 @@ let flagImageGap = toVector2(5, 5);
// ===========================================================================
function initLocaleChooserGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating locale chooser GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating locale chooser GUI ...`);
localeChooser.window = mexui.window(game.width / 2 - 200, game.height - 150, 60, 60, 'Choose a language', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], 0),
@@ -40,15 +39,13 @@ function initLocaleChooserGUI() {
localeChooser.window.shown = false;
loadLocaleConfig();
logToConsole(LOG_DEBUG, `[VRR.GUI] Created locale chooser GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created locale chooser GUI`);
}
// ===========================================================================
function closeLocaleChooserGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Closing locale chooser window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Closing locale chooser window`);
localeChooser.window.shown = false;
for (let i in localeChooser.flagImages) {
localeChooser.flagImages[i].shown = false;
@@ -59,9 +56,6 @@ function closeLocaleChooserGUI() {
// ===========================================================================
function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) {
// Disabled for now until image loading crash can be fixed
return false;
if (position.x != 0.0 && position.y != 0.0) {
localeChooser.window.position = position;
} else {
@@ -69,7 +63,7 @@ function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) {
}
//closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing locale chooser window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing locale chooser window`);
mexui.setInput(true);
localeChooser.window.shown = true;
@@ -81,7 +75,7 @@ function showLocaleChooserGUI(position = toVector2(0.0, 0.0)) {
// ===========================================================================
function toggleLocaleChooserGUI() {
if (localeChooser.window.shown) {
if (localeChooser.window.shown == true) {
closeLocaleChooserGUI();
} else {
showLocaleChooserGUI();
@@ -91,14 +85,14 @@ function toggleLocaleChooserGUI() {
// ===========================================================================
function localeChooserSetLocale(localeId) {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Asking server to change locale to ${localeId}`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.GUI] Asking server to change locale to ${localeId}`);
sendLocaleSelectToServer(localeId);
}
// ===========================================================================
function resetLocaleChooserOptions() {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Resetting locale chooser options`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.GUI] Resetting locale chooser options`);
// let tempLocaleOptions = getServerData().localeOptions; // getAvailableLocaleOptions();
let tempLocaleOptions = getAvailableLocaleOptions();
@@ -122,7 +116,7 @@ function resetLocaleChooserOptions() {
localeChooser.flagImages[i].shown = false;
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Created locale chooser option ${tempLocaleOptions[i].englishName} with image ${imagePath}`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.GUI] Created locale chooser option ${tempLocaleOptions[i].englishName} with image ${imagePath}`);
//localeChooser.activeRingImages.push(activeRingImage);
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: login.js
// DESC: Provides login GUI
@@ -43,7 +42,7 @@ let loginHTML =
// ===========================================================================
function initLoginGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating login GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating login GUI ...`);
login.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'LOGIN', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -109,7 +108,7 @@ function initLoginGUI() {
login.loginButton = login.window.button(20, 205, 260, 30, 'LOGIN', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(0, 0, 0, 255),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
textSize: 12.0,
textFont: mainFont,
textAlign: 0.5,
@@ -122,7 +121,7 @@ function initLoginGUI() {
login.forgotPasswordButton = login.window.button(180, 240, 100, 15, 'RESET PASS', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(0, 0, 0, 255),
textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255),
textSize: 8.0,
textFont: mainFont,
textAlign: 0.5,
@@ -144,14 +143,14 @@ function initLoginGUI() {
},
});
logToConsole(LOG_DEBUG, `[VRR.GUI] Created login GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created login GUI`);
}
// ===========================================================================
function showLoginGUI() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing login window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing login window`);
setChatWindowEnabled(false);
mexui.setInput(true);
login.window.shown = true;
@@ -165,14 +164,14 @@ function showLoginGUI() {
// ===========================================================================
function checkLogin() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking login with server ...`);
sendNetworkEventToServer("agrp.checkLogin", login.passwordInput.lines[0]);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking login with server ...`);
sendNetworkEventToServer("v.rp.checkLogin", login.passwordInput.lines[0]);
}
// ===========================================================================
function loginFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports login failed`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports login failed`);
login.messageLabel.text = errorMessage;
login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
login.passwordInput.text = "";
@@ -181,7 +180,7 @@ function loginFailed(errorMessage) {
// ===========================================================================
function loginSuccess() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports login was successful`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports login was successful`);
guiSubmitKey = false;
closeAllWindows();
}
@@ -190,9 +189,9 @@ function loginSuccess() {
function switchToPasswordResetGUI() {
//closeAllWindows();
//logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset dialog window`);
//logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing password reset dialog window`);
//showResetPasswordGUI();
sendNetworkEventToServer("agrp.checkResetPassword", "");
sendNetworkEventToServer("v.rp.checkResetPassword", "");
return false;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: newchar.js
// DESC: Provides new character creation GUI
@@ -20,7 +19,7 @@ let newCharacter = {
// ===========================================================================
function initNewCharacterGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating new character GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating new character GUI ...`);
newCharacter.window = mexui.window(getScreenWidth() / 2 - 130, getScreenHeight() / 2 - 115, 300, 230, 'NEW CHARACTER', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -111,13 +110,13 @@ function initNewCharacterGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkNewCharacter);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created new character GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created new character GUI`);
}
// ===========================================================================
function newCharacterFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports new character creation failed. Reason: ${errorMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports new character creation failed. Reason: ${errorMessage}`);
newCharacter.messageLabel.text = errorMessage;
newCharacter.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
newCharacter.firstNameInput.text = "";
@@ -135,7 +134,7 @@ function newCharacterFailed(errorMessage) {
// ===========================================================================
function checkNewCharacter() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking new character with server ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking new character with server ...`);
if (newCharacter.firstNameInput.lines[0].length < 2) {
return false;
}
@@ -144,7 +143,7 @@ function checkNewCharacter() {
return false;
}
sendNetworkEventToServer("agrp.checkNewCharacter",
sendNetworkEventToServer("v.rp.checkNewCharacter",
newCharacter.firstNameInput.lines[0],
newCharacter.lastNameInput.lines[0],
);
@@ -153,7 +152,7 @@ function checkNewCharacter() {
// ===========================================================================
function showNewCharacterGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing new character window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing new character window`);
closeAllWindows();
setChatWindowEnabled(false);
mexui.setInput(true);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: register.js
// DESC: Provides account registration GUI
@@ -21,7 +20,7 @@ let register = {
// ===========================================================================
function initRegisterGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating register GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating register GUI ...`);
register.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 150, 300, 300, 'Register', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -131,13 +130,13 @@ function initRegisterGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkRegistration);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created register GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created register GUI`);
}
// ===========================================================================
function registrationFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports registration failed. Reason: ${errorMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports registration failed. Reason: ${errorMessage}`);
register.messageLabel.text = errorMessage;
register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
register.passwordInput.text = "";
@@ -148,14 +147,14 @@ function registrationFailed(errorMessage) {
// ===========================================================================
function checkRegistration() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking registration with server ...`);
sendNetworkEventToServer("agrp.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking registration with server ...`);
sendNetworkEventToServer("v.rp.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
}
// ===========================================================================
function showRegistrationGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing registration window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing registration window`);
closeAllWindows();
setChatWindowEnabled(false);
mexui.setInput(true);
@@ -171,7 +170,7 @@ function showRegistrationGUI() {
// ===========================================================================
function registrationSuccess() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports registration was successful`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports registration was successful`);
guiSubmitKey = false;
closeAllWindows();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: resetpass.js
// DESC: Provides password reset GUI
@@ -21,7 +20,7 @@ let passwordReset = {
// ===========================================================================
function initResetPasswordGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Creating password reset GUI ...`);
passwordReset.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'RESET PASSWORD', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -121,14 +120,14 @@ function initResetPasswordGUI() {
},
});
logToConsole(LOG_DEBUG, `[VRR.GUI] Created password reset GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created password reset GUI`);
}
// ===========================================================================
function showResetPasswordGUI() {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing password reset window`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing password reset window`);
setChatWindowEnabled(false);
mexui.setInput(true);
passwordReset.window.shown = true;
@@ -142,14 +141,14 @@ function showResetPasswordGUI() {
// ===========================================================================
function checkResetPassword() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`);
sendNetworkEventToServer("agrp.checkResetPassword", passwordReset.emailInput.lines[0]);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`);
sendNetworkEventToServer("v.rp.checkResetPassword", passwordReset.emailInput.lines[0]);
}
// ===========================================================================
function resetPasswordFailed(errorMessage) {
logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password reset failed`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Server reports password reset failed`);
passwordReset.messageLabel.text = errorMessage;
passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
passwordReset.emailInput.text = "";
@@ -158,7 +157,7 @@ function resetPasswordFailed(errorMessage) {
// ===========================================================================
function resetPasswordCodeInputGUI() {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.GUI] Server reports password reset email confirmation was successful. Asking for code ...`);
closeAllWindows();
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel");
@@ -173,7 +172,7 @@ function resetPasswordCodeInputGUI() {
// ===========================================================================
function resetPasswordEmailInputGUI() {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.GUI] Server reports password reset request was approved. Asking for email ...`);
closeAllWindows();
passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordConfirmEmailLabel");

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: yesno.js
// DESC: Provides yes/no prompt dialog GUI
@@ -19,7 +18,7 @@ let yesNoDialog = {
// ===========================================================================
function initYesNoDialogGUI() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI ...`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created prompt GUI ...`);
yesNoDialog.window = mexui.window(game.width / 2 - 200, game.height / 2 - 70, 400, 140, 'Question', {
main: {
backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha),
@@ -74,14 +73,14 @@ function initYesNoDialogGUI() {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
},
}, yesNoDialogAnswerNo);
logToConsole(LOG_DEBUG, `[VRR.GUI] Created prompt GUI`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Created prompt GUI`);
}
// ===========================================================================
function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonText) {
closeAllWindows();
logToConsole(LOG_DEBUG, `[VRR.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
logToConsole(LOG_DEBUG, `[AGRP.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
mexui.setInput(true);
yesNoDialog.messageLabel.text = "";
@@ -100,16 +99,16 @@ function showYesNoPromptGUI(promptMessage, promptTitle, yesButtonText, noButtonT
// ===========================================================================
function yesNoDialogAnswerNo() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer NO to server prompt`);
sendNetworkEventToServer("agrp.promptAnswerNo");
logToConsole(LOG_DEBUG, `[AGRP.GUI] Responding with answer NO to server prompt`);
sendNetworkEventToServer("v.rp.promptAnswerNo");
closeAllWindows();
}
// ===========================================================================
function yesNoDialogAnswerYes() {
logToConsole(LOG_DEBUG, `[VRR.GUI] Responding with answer YES to server prompt`);
sendNetworkEventToServer("agrp.promptAnswerYes");
logToConsole(LOG_DEBUG, `[AGRP.GUI] Responding with answer YES to server prompt`);
sendNetworkEventToServer("v.rp.promptAnswerYes");
closeAllWindows();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: house.js
// DESC: Provides house functions and usage
@@ -17,16 +16,19 @@ class HouseData {
this.blipModel = blipModel;
this.pickupModel = pickupModel;
this.hasInterior = hasInterior;
this.rentPrice = 0;
this.buyPrice = 0;
this.blipId = -1;
this.locked = false;
}
}
// ===========================================================================
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior) {
logToConsole(LOG_DEBUG, `[VRR.House] Received house ${houseId} (${name}) from server`);
function receiveHouseFromServer(houseId, description, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked) {
logToConsole(LOG_DEBUG, `[AGRP.House] Received house ${houseId} (${name}) from server`);
if (!areServerElementsSupported()) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
if (getHouseData(houseId) != false) {
let houseData = getHouseData(houseId);
houseData.description = description;
@@ -34,24 +36,37 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
houseData.blipModel = blipModel;
houseData.pickupModel = pickupModel;
houseData.hasInterior = hasInterior;
houseData.buyPrice = buyPrice;
houseData.rentPrice = rentPrice;
houseData.locked = locked;
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} already exists. Checking blip ...`);
if (houseData.buyPrice > 0) {
houseData.labelInfoType = V_PROPLABEL_INFO_BUYHOUSE;
} else {
if (houseData.rentPrice > 0) {
houseData.labelInfoType = V_PROPLABEL_INFO_RENTHOUSE;
} else {
houseData.labelInfoType = V_PROPLABEL_INFO_ENTER;
}
}
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} already exists. Checking blip ...`);
if (blipModel == -1) {
if (houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been removed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getHouseData(houseId).blipId);
} else {
destroyElement(getElementFromId(blipId));
}
houseData.blipId = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip is unchanged`);
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip is unchanged`);
}
} else {
if (houseData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been changed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.setBlipCoordinates(houseData.blipId, houseData.entrancePosition);
natives.changeBlipSprite(houseData.blipId, houseData.blipModel);
natives.setBlipMarkerLongDistance(houseData.blipId, false);
@@ -63,20 +78,20 @@ function receiveHouseFromServer(houseId, description, entrancePosition, blipMode
if (blipId != -1) {
houseData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} doesn't exist. Adding ...`);
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} doesn't exist. Adding ...`);
let tempHouseData = new HouseData(houseId, description, entrancePosition, blipModel, pickupModel, hasInterior);
if (blipModel != -1) {
let blipId = createGameBlip(tempHouseData.blipModel, tempHouseData.entrancePosition, "House");
if (blipId != -1) {
tempHouseData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.House] House ${houseId} has no blip.`);
logToConsole(LOG_DEBUG, `[AGRP.House] House ${houseId} has no blip.`);
}
getServerData().houses.push(tempHouseData);
setAllHouseDataIndexes();

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: item.js
// DESC: Provides item action and hotbar functions
@@ -17,8 +16,8 @@ let itemActionDelaySize = toVector2(200, 5);
// ===========================================================================
function initItemScript() {
logToConsole(LOG_DEBUG, "[VRR.Item]: Initializing item script ...");
logToConsole(LOG_DEBUG, "[VRR.Item]: Item script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Item]: Initializing item script ...");
logToConsole(LOG_DEBUG, "[AGRP.Item]: Item script initialized!");
}
// ===========================================================================
@@ -48,7 +47,7 @@ function processItemActionRendering() {
// ===========================================================================
function updatePlayerHotBar(activeSlot, itemsArray) {
logToConsole(LOG_DEBUG, `[VRR.Main] Updating hotbar`);
logToConsole(LOG_DEBUG, `[AGRP.Main] Updating hotbar`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: job.js
// DESC: Provides job functions and usage
@@ -36,31 +35,31 @@ class JobData {
// ===========================================================================
function initJobScript() {
logToConsole(LOG_DEBUG, "[VRR.Job]: Initializing job script ...");
logToConsole(LOG_DEBUG, "[VRR.Job]: Job script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Job]: Initializing job script ...");
logToConsole(LOG_DEBUG, "[AGRP.Job]: Job script initialized!");
}
// ===========================================================================
function setLocalPlayerJobType(tempJobType) {
logToConsole(LOG_DEBUG, `[VRR.Job] Set local player job type to ${tempJobType}`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Set local player job type to ${tempJobType}`);
localPlayerJobType = tempJobType;
}
// ===========================================================================
function setLocalPlayerWorkingState(tempWorking) {
logToConsole(LOG_DEBUG, `[VRR.Job] Setting working state to ${tempWorking}`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Setting working state to ${tempWorking}`);
localPlayerWorking = tempWorking;
}
// ===========================================================================
function showJobRouteLocation(position, colour) {
logToConsole(LOG_DEBUG, `[VRR.Job] Showing job route location at ${position.x}, ${position.y}, ${position.z}`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Showing job route location at ${position.x}, ${position.y}, ${position.z}`);
hideJobRouteLocation();
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
if (getGame() == AGRP_GAME_GTA_SA) {
if (getMultiplayerMod() == V_MPMOD_GTAC) {
if (getGame() == V_GAME_GTA_SA) {
// Server-side spheres don't show in GTA SA for some reason.
jobRouteLocationSphere = game.createPickup(1318, position, 1);
} else {
@@ -81,7 +80,7 @@ function showJobRouteLocation(position, colour) {
// ===========================================================================
function enteredJobRouteSphere() {
logToConsole(LOG_DEBUG, `[VRR.Job] Entered job route sphere`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Entered job route sphere`);
hideJobRouteLocation();
tellServerPlayerArrivedAtJobRouteLocation();
}
@@ -115,7 +114,7 @@ function blinkJobRouteLocationBlip(times, position, colour) {
// ===========================================================================
function hideJobRouteLocation() {
logToConsole(LOG_DEBUG, `[VRR.Job] Hiding job route location`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Hiding job route location`);
if (jobRouteLocationBlip != null) {
destroyElement(jobRouteLocationBlip);
@@ -138,9 +137,9 @@ function hideJobRouteLocation() {
// ===========================================================================
function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, pickupModel) {
logToConsole(LOG_DEBUG, `[VRR.Job] Received job ${jobId} (${name}) from server`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Received job ${jobId} (${name}) from server`);
if (getGame() == AGRP_GAME_GTA_IV) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
if (getJobData(jobId) != false) {
let jobData = getJobData(jobId);
jobData.jobLocationId = jobLocationId;
@@ -149,23 +148,23 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
jobData.blipModel = blipModel;
jobData.pickupModel = pickupModel;
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} already exists. Checking blip ...`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId} already exists. Checking blip ...`);
if (blipModel == -1) {
if (jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been removed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId}'s blip has been removed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.removeBlipAndClearIndex(getJobData(jobId).blipId);
} else {
destroyElement(getElementFromId(blipId));
}
jobData.blipId = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip is unchanged`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId}'s blip is unchanged`);
}
} else {
if (jobData.blipId != -1) {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been changed by the server`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId}'s blip has been changed by the server`);
if (getGame() == V_GAME_GTA_IV) {
natives.setBlipCoordinates(jobData.blipId, jobData.position);
natives.changeBlipSprite(jobData.blipId, jobData.blipModel);
natives.setBlipMarkerLongDistance(jobData.blipId, false);
@@ -177,20 +176,20 @@ function receiveJobFromServer(jobId, jobLocationId, name, position, blipModel, p
if (blipId != -1) {
jobData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
}
}
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} doesn't exist. Adding ...`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId} doesn't exist. Adding ...`);
let tempJobData = new JobData(jobId, jobLocationId, name, position, blipModel, pickupModel);
if (blipModel != -1) {
let blipId = createGameBlip(blipModel, tempJobData.position, tempJobData.name);
if (blipId != -1) {
tempJobData.blipId = blipId;
}
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId}'s blip has been added by the server (Model ${blipModel}, ID ${blipId})`);
} else {
logToConsole(LOG_DEBUG, `[VRR.Job] Job ${jobId} has no blip.`);
logToConsole(LOG_DEBUG, `[AGRP.Job] Job ${jobId} has no blip.`);
}
getServerData().jobs.push(tempJobData);
setAllJobDataIndexes();

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: keybind.js
// DESC: Provides keybind features
@@ -17,14 +16,14 @@ let keyBindLongHoldDuration = 1500;
// ===========================================================================
function initKeyBindScript() {
logToConsole(LOG_DEBUG, "[VRR.KeyBind]: Initializing key bind script ...");
logToConsole(LOG_DEBUG, "[VRR.KeyBind]: Key bind script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.KeyBind]: Initializing key bind script ...");
logToConsole(LOG_DEBUG, "[AGRP.KeyBind]: Key bind script initialized!");
}
// ===========================================================================
function bindAccountKey(key, keyState) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
logToConsole(LOG_DEBUG, `[AGRP.KeyBind]: Binded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
keyBinds.push(toInteger(key));
bindKey(toInteger(key), keyState, function (event) {
if (isAnyGUIActive()) {
@@ -33,14 +32,14 @@ function bindAccountKey(key, keyState) {
if (hasKeyBindDelayElapsed()) {
if (canLocalPlayerUseKeyBinds()) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
logToConsole(LOG_DEBUG, `[AGRP.KeyBind]: Using keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
lastKeyBindUse = sdl.ticks;
tellServerPlayerUsedKeyBind(key);
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not allowed to use keybinds!`);
logToConsole(LOG_DEBUG, `[AGRP.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not allowed to use keybinds!`);
}
} else {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not enough time has passed since last keybind use!`);
logToConsole(LOG_DEBUG, `[AGRP.KeyBind]: Failed to use keybind for key ${toUpperCase(getKeyNameFromId(key))} (${key}) - Not enough time has passed since last keybind use!`);
}
});
}
@@ -48,7 +47,7 @@ function bindAccountKey(key, keyState) {
// ===========================================================================
function unBindAccountKey(key) {
logToConsole(LOG_DEBUG, `[VRR.KeyBind]: Unbinded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
logToConsole(LOG_DEBUG, `[AGRP.KeyBind]: Unbinded key ${toUpperCase(getKeyNameFromId(key))} (${key})`);
unbindKey(key);
keyBinds.splice(keyBinds.indexOf(key), 1);
return true;

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: labels.js
// DESC: Provides functionality for world labels (3D labels)
@@ -14,7 +13,12 @@ let jobLabels = [];
let propertyLabelNameFont = null;
let propertyLabelLockedFont = null;
let propertyLabelHeight = 1.0;
let propertyLabelHeight = (getGame() == V_GAME_MAFIA_ONE) ? 2.0 : 1.0;
let propertyPickupRenderDistance = 75.0;
let propertyLabelRenderDistance = 5.0;
let propertyLabelLockedOffset = 16;
let propertyLabelNameOffset = 20;
let propertyLabelPriceOffset = 16;
let jobNameLabelFont = null;
let jobHelpLabelFont = null;
@@ -23,21 +27,15 @@ let unlockedColour = toColour(50, 205, 50, 255);
let lockedColour = toColour(205, 92, 92, 255);
let jobHelpColour = toColour(234, 198, 126, 255);
let renderLabelDistance = 7.5;
let propertyLabelLockedOffset = 16;
let propertyLabelNameOffset = 18;
let propertyLabelPriceOffset = 16;
// ===========================================================================
function initLabelScript() {
logToConsole(LOG_DEBUG, "[VRR.Label]: Initializing label script ...");
logToConsole(LOG_DEBUG, "[AGRP.Label]: Initializing label script ...");
propertyLabelNameFont = initLabelPropertyNameFont();
propertyLabelLockedFont = initLabelPropertyLockedFont();
jobNameLabelFont = initLabelJobNameFont();
jobHelpLabelFont = initLabelJobHelpFont();
logToConsole(LOG_DEBUG, "[VRR.Label]: Label script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Label]: Label script initialized!");
}
// ===========================================================================
@@ -66,7 +64,7 @@ function initLabelJobHelpFont() {
// ===========================================================================
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType) {
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price, rentPrice, labelInfoType, fee) {
if (localPlayer == null) {
return false;
}
@@ -79,34 +77,35 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport does not exist!");
return false;
}
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport is not active!");
return false;
}
}
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
position = getPosAbovePos(position, propertyLabelHeight);
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
if (getGame() == V_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(position, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
screenPosition = getScreenFromWorldPosition(position);
}
logToConsole(LOG_VERBOSE, `[AGRP.Label] World [${position.x}, ${position.y}, ${position.z}] to screen [${screenPosition.x}, ${screenPosition.y}, ${screenPosition.z}]`);
if (screenPosition.x < 0 || screenPosition.x > game.width) {
return false;
}
let text = "";
if (price > "0") {
text = getLocaleString("PropertyForSaleLabel", price);
if (toInteger(price) > 0) {
text = getLocaleString("PropertyForSaleLabel", getCurrencyString(price));
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
@@ -114,8 +113,17 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
}
text = "";
if (rentPrice != "0") {
text = getLocaleString("PropertyForRentLabel", rentPrice);
if (toInteger(rentPrice) > 0) {
text = getLocaleString("PropertyForRentLabel", getCurrencyString(rentPrice));
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
screenPosition.y -= propertyLabelPriceOffset;
}
text = "";
if (toInteger(fee) > 0) {
text = getLocaleString("PropertyEntranceFeeLabel", getCurrencyString(fee));
let size = propertyLabelLockedFont.measure(text, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(200, 200, 200, 255), false, true, false, true);
@@ -128,10 +136,10 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
text = (locked) ? toUpperCase(getLocaleString("Locked")) : toUpperCase(getLocaleString("Unlocked"));
}
if (!locked && labelInfoType != AGRP_PROPLABEL_INFO_NONE) {
if (!locked && labelInfoType != V_PROPLABEL_INFO_NONE) {
let infoText = "";
switch (labelInfoType) {
case AGRP_PROPLABEL_INFO_ENTER: {
case V_PROPLABEL_INFO_ENTER: {
if (enterPropertyKey) {
infoText = getLocaleString("PropertyEnterKeyPressLabel", toUpperCase(getKeyNameFromId(enterPropertyKey)));
} else {
@@ -140,27 +148,27 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break;
}
case AGRP_PROPLABEL_INFO_BUY: {
case V_PROPLABEL_INFO_BUY: {
infoText = getLocaleString("BusinessBuyItemsLabel", "/buy");
break;
}
case AGRP_PROPLABEL_INFO_BUYBIZ: {
case V_PROPLABEL_INFO_BUYBIZ: {
infoText = getLocaleString("BuyBusinessLabel", "/bizbuy");
break;
}
case AGRP_PROPLABEL_INFO_BUYHOUSE: {
case V_PROPLABEL_INFO_BUYHOUSE: {
infoText = getLocaleString("BuyHouseLabel", "/housebuy");
break;
}
case AGRP_PROPLABEL_INFO_RENTHOUSE: {
case V_PROPLABEL_INFO_RENTHOUSE: {
infoText = getLocaleString("RentHouseLabel", "/houserent");
break;
}
case AGRP_PROPLABEL_INFO_ENTERVEHICLE: {
case V_PROPLABEL_INFO_ENTERVEHICLE: {
infoText = getLocaleString("VehicleDealershipLabel");
break;
}
@@ -174,7 +182,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
break;
}
}
if (getDistance(localPlayer.position, position) <= renderLabelDistance - 2) {
if (getDistance(localPlayer.position, position) <= propertyLabelRenderDistance - 2) {
let size = propertyLabelLockedFont.measure(infoText, game.width, 0.0, 0.0, propertyLabelLockedFont.size, true, true);
propertyLabelLockedFont.render(infoText, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelLockedFont.size, toColour(234, 198, 126, 255), false, true, false, true);
screenPosition.y -= propertyLabelLockedOffset;
@@ -210,14 +218,14 @@ function renderPropertyExitLabel(position) {
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport does not exist!");
return false;
}
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport is not active!");
return false;
}
}
@@ -225,7 +233,7 @@ function renderPropertyExitLabel(position) {
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -255,14 +263,14 @@ function renderJobLabel(name, position, jobType) {
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
if (!natives.doesViewportExist(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport does not exist!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport does not exist!");
return false;
}
if (!natives.isViewportActive(natives.getGameViewportId())) {
logToConsole(LOG_INFO, "[VRR.Label]: Game viewport is not active!");
logToConsole(LOG_INFO, "[AGRP.Label]: Game viewport is not active!");
return false;
}
}
@@ -270,7 +278,7 @@ function renderJobLabel(name, position, jobType) {
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = new Vec3(0.0, 0.0, 0.0);
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
screenPosition = natives.getViewportPositionOfCoord(tempPosition, natives.getGameViewportId());
} else {
screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -309,26 +317,41 @@ function renderJobLabel(name, position, jobType) {
function processLabelRendering() {
if (renderLabels) {
if (!areServerElementsSupported()) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE) {
if (localPlayer != null) {
getServerData().businesses.forEach((business) => {
if (getDistance(localPlayer.position, business.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
//renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, makeLargeNumberReadable(business.price), makeLargeNumberReadable(business.rentPrice), business.labelInfoType);
if (getDistance(localPlayer.position, business.entrancePosition) <= propertyPickupRenderDistance) {
if (getGame() == V_GAME_GTA_IV || getGame() == V_GAME_GTA_IV_EFLC) {
natives.drawColouredCylinder(getPosBelowPos(business.entrancePosition, 1.0), 0.0, 0.0, 0, 153, 255, 255);
}
if (getDistance(localPlayer.position, business.entrancePosition) <= propertyLabelRenderDistance) {
renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType, business.entranceFee);
}
}
});
getServerData().houses.forEach((house) => {
if (getDistance(localPlayer.position, house.entrancePosition) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
//renderPropertyEntranceLabel("House", house.entrancePosition, house.locked, true, makeLargeNumberReadable(house.price), makeLargeNumberReadable(house.rentPrice), 0);
if (getDistance(localPlayer.position, house.entrancePosition) <= propertyPickupRenderDistance) {
if (getGame() == V_GAME_GTA_IV || getGame() == V_GAME_GTA_IV_EFLC) {
natives.drawColouredCylinder(getPosBelowPos(house.entrancePosition, 1.0), 0.0, 0.0, 0, 200, 0, 255);
}
if (getDistance(localPlayer.position, house.entrancePosition) <= propertyLabelRenderDistance) {
renderPropertyEntranceLabel(house.description, house.entrancePosition, house.locked, true, house.buyPrice, house.rentPrice, house.labelInfoType);
}
}
});
getServerData().jobs.forEach((job) => {
if (getDistance(localPlayer.position, job.position) <= 75.0) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
//renderJobLabel(job.name, job.position, job.jobType);
if (getDistance(localPlayer.position, job.position) <= propertyPickupRenderDistance) {
if (getGame() == V_GAME_GTA_IV || getGame() == V_GAME_GTA_IV_EFLC) {
natives.drawColouredCylinder(getPosBelowPos(job.position, 1.0), 0.0, 0.0, 255, 255, 0, 255);
}
}
if (getDistance(localPlayer.position, job.position) <= 5.0) {
renderJobLabel(job.name, job.position, job.jobType);
}
});
}
@@ -338,41 +361,47 @@ function processLabelRendering() {
if (localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for (let i in pickups) {
if (pickups[i].getData("agrp.label.type") != null) {
if (getDistance(localPlayer.position, pickups[i].position) <= renderLabelDistance) {
if (pickups[i].getData("v.rp.label.type") != null) {
if (getDistance(localPlayer.position, pickups[i].position) <= propertyLabelRenderDistance) {
if (!pickups[i].isOnScreen) {
let price = "0";
let rentPrice = "0";
let labelInfoType = AGRP_PROPLABEL_INFO_NONE;
if (pickups[i].getData("agrp.label.price") != null) {
price = makeLargeNumberReadable(pickups[i].getData("agrp.label.price"));
let fee = "0";
let labelInfoType = V_PROPLABEL_INFO_NONE;
if (pickups[i].getData("v.rp.label.price") != null) {
price = pickups[i].getData("v.rp.label.price");
}
if (pickups[i].getData("agrp.label.rentprice") != null) {
rentPrice = makeLargeNumberReadable(pickups[i].getData("agrp.label.rentprice"));
if (pickups[i].getData("v.rp.label.rentprice") != null) {
rentPrice = pickups[i].getData("v.rp.label.rentprice");
}
if (pickups[i].getData("agrp.label.help") != null) {
labelInfoType = pickups[i].getData("agrp.label.help");
if (pickups[i].getData("v.rp.label.help") != null) {
labelInfoType = pickups[i].getData("v.rp.label.help");
}
switch (pickups[i].getData("agrp.label.type")) {
case AGRP_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType);
if (pickups[i].getData("v.rp.label.fee") != null) {
fee = pickups[i].getData("v.rp.label.fee");
}
switch (pickups[i].getData("v.rp.label.type")) {
case V_LABEL_BUSINESS: {
renderPropertyEntranceLabel(pickups[i].getData("v.rp.label.name"), pickups[i].position, pickups[i].getData("v.rp.label.locked"), true, price, rentPrice, labelInfoType, fee);
break;
}
case AGRP_LABEL_HOUSE: {
renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), false, price, rentPrice, labelInfoType);
case V_LABEL_HOUSE: {
renderPropertyEntranceLabel(pickups[i].getData("v.rp.label.name"), pickups[i].position, pickups[i].getData("v.rp.label.locked"), false, price, rentPrice, labelInfoType);
break;
}
case AGRP_LABEL_JOB: {
renderJobLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.jobType"));
case V_LABEL_JOB: {
renderJobLabel(pickups[i].getData("v.rp.label.name"), pickups[i].position, pickups[i].getData("v.rp.label.jobType"));
break;
}
case AGRP_LABEL_EXIT: {
case V_LABEL_EXIT: {
renderPropertyExitLabel(pickups[i].position);
break;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: locale.js
// DESC: Provides locale functions and usage
@@ -38,7 +37,7 @@ function loadLocaleConfig() {
let configFile = loadTextFile("config/client/locale.json");
getServerData().localeOptions = JSON.parse(configFile);
resetLocaleChooserOptions();
//resetLocaleChooserOptions();
loadAllLocaleStrings();
}
@@ -47,11 +46,12 @@ function loadLocaleConfig() {
function loadAllLocaleStrings() {
let localeOptions = getServerData().localeOptions;
for (let i in localeOptions) {
logToConsole(LOG_INFO, `[VRR.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`);
let localeFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`);
let localeData = JSON.parse(localeFile);
logToConsole(LOG_INFO, `[AGRP.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`);
let localeStringFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`);
let localeStringData = JSON.parse(localeStringFile);
getServerData().localeStrings[i] = localeData;
let localeId = localeOptions[i].id;
getServerData().localeStrings[localeId] = localeStringData;
}
resetGUIStrings();
@@ -60,7 +60,7 @@ function loadAllLocaleStrings() {
// ===========================================================================
function setLocale(tempLocaleId) {
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${getServerData().localeOptions[tempLocaleId].englishName})`);
logToConsole(LOG_DEBUG, `[AGRP.Locale] Setting locale to ${tempLocaleId} (${getServerData().localeOptions[tempLocaleId].englishName})`);
localLocaleId = tempLocaleId;
resetGUIStrings();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: logo.js
// DESC: Provides logo rendering functions
@@ -15,14 +14,18 @@ let logoSize = toVector2(128, 128);
// ===========================================================================
function initLogoScript() {
logToConsole(LOG_DEBUG, "[VRR.Logo]: Initializing logo script ...");
logToConsole(LOG_DEBUG, "[AGRP.Logo]: Initializing logo script ...");
//logoImage = loadLogoImage();
logToConsole(LOG_DEBUG, "[VRR.Logo]: Logo script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Logo]: Logo script initialized!");
}
// ===========================================================================
function loadLogoImage() {
//if (getGame() == V_GAME_MAFIA_ONE) {
// return false;
//}
let logoStream = openFile(mainLogoPath);
let tempLogoImage = null;
if (logoStream != null) {
@@ -36,6 +39,10 @@ function loadLogoImage() {
// ===========================================================================
function processLogoRendering() {
if (getGame() == V_GAME_MAFIA_ONE) {
return false;
}
if (renderLogo) {
if (logoImage != null) {
graphics.drawRectangle(logoImage, logoPos, logoSize);
@@ -46,7 +53,7 @@ function processLogoRendering() {
// ===========================================================================
function setServerLogoRenderState(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
logToConsole(LOG_DEBUG, `[AGRP.Main] Server logo ${(state) ? "enabled" : "disabled"}`);
renderLogo = state;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: messaging.js
// DESC: Provides messaging/textdraw functions and usage
@@ -23,10 +22,10 @@ let smallGameMessageTimer = null;
// ===========================================================================
function initMessagingScript() {
logToConsole(LOG_DEBUG, "[VRR.Messaging]: Initializing messaging script ...");
logToConsole(LOG_DEBUG, "[AGRP.Messaging]: Initializing messaging script ...");
smallGameMessageFonts = loadSmallGameMessageFonts();
bigGameMessageFonts = loadSmallGameMessageFonts();
logToConsole(LOG_DEBUG, "[VRR.Messaging]: Messaging script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Messaging]: Messaging script initialized!");
}
// ===========================================================================
@@ -39,6 +38,12 @@ function loadSmallGameMessageFonts() {
fontStream.close();
}
fontStream = openFile("files/fonts/aurora-bold-condensed.ttf");
if (fontStream != null) {
tempSmallGameMessageFonts["AuroraBdCnBT"] = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
tempSmallGameMessageFonts["Roboto"] = lucasFont.createDefaultFont(20.0, "Roboto");
tempSmallGameMessageFonts["RobotoLight"] = lucasFont.createDefaultFont(20.0, "Roboto", "Light");
@@ -55,6 +60,12 @@ function loadBigGameMessageFont() {
fontStream.close();
}
fontStream = openFile("files/fonts/aurora-bold-condensed.ttf");
if (fontStream != null) {
tempBigGameMessageFonts["AuroraBdCnBT"] = lucasFont.createFont(fontStream, 20.0);
fontStream.close();
}
tempBigGameMessageFonts["Roboto"] = lucasFont.createDefaultFont(28.0, "Roboto");
tempBigGameMessageFonts["RobotoLight"] = lucasFont.createDefaultFont(28.0, "Roboto", "Light");
@@ -64,10 +75,10 @@ function loadBigGameMessageFont() {
// ===========================================================================
function processSmallGameMessageRendering() {
logToConsole(LOG_VERBOSE, "[VRR.Messaging]: Processing small game message rendering ...");
logToConsole(LOG_VERBOSE, "[AGRP.Messaging]: Processing small game message rendering ...");
if (renderSmallGameMessage) {
if (smallGameMessageText != "") {
logToConsole(LOG_VERBOSE, `[VRR.Messaging]: Rendering small game message: ${smallGameMessageText}`);
logToConsole(LOG_VERBOSE, `[AGRP.Messaging]: Rendering small game message: ${smallGameMessageText}`);
if (smallGameMessageFonts[smallGameMessageFontName] != null) {
smallGameMessageFonts[smallGameMessageFontName].render(smallGameMessageText, [0, game.height - 90], game.width, 0.5, 0.0, smallGameMessageFonts[smallGameMessageFontName].size, smallGameMessageColour, true, true, false, true);
}
@@ -78,7 +89,7 @@ function processSmallGameMessageRendering() {
// ===========================================================================
function showSmallGameMessage(text, colour, duration, fontName) {
logToConsole(LOG_DEBUG, `[VRR.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`);
logToConsole(LOG_DEBUG, `[AGRP.Messaging] Showing small game message '${text}' using font ${fontName} for ${duration}ms`);
if (smallGameMessageText != "") {
clearTimeout(smallGameMessageTimer);
}

View File

@@ -12,34 +12,29 @@
// CREDITS TO LUCASC190 FOR MAKING THE MOUSE CAMERA
// WALKING CODE ADDED BY VORTREX
function SetStandardControlsEnabled(bEnabled)
{
if(typeof gta == "undefined") {
function SetStandardControlsEnabled(bEnabled) {
if (typeof gta == "undefined") {
return false;
}
if (game.standardControls === undefined)
{
if (game.standardControls === undefined) {
logToConsole(LOG_WARN, "game.standardControls not implemented");
return;
}
game.standardControls = bEnabled;
}
function GetCurrentPlayerIndex()
{
function GetCurrentPlayerIndex() {
return 0;
}
function GetPlayerPed(uiIndex)
{
function GetPlayerPed(uiIndex) {
if (uiIndex >= 1)
throw new Error("player index out of range");
return localPlayer;
}
function GetPedVehicle(pPed)
{
function GetPedVehicle(pPed) {
return pPed.vehicle;
}
@@ -49,8 +44,7 @@ let ENTITYTYPE_PED = 3;
let ENTITYTYPE_OBJECT = 4;
let ENTITYTYPE_DUMMY = 5;
function GetEntityType(Entity)
{
function GetEntityType(Entity) {
if (Entity.isType(ELEMENT_BUILDING))
return ENTITYTYPE_BUILDING;
if (Entity.isType(ELEMENT_VEHICLE))
@@ -64,79 +58,66 @@ function GetEntityType(Entity)
return undefined;
}
function GetPlaceableMatrix(pPlaceable)
{
function GetPlaceableMatrix(pPlaceable) {
if (pPlaceable == GetCamera())
return game.cameraMatrix;
return pPlaceable.matrix;
}
function GetEntityModel(pEntity)
{
function GetEntityModel(pEntity) {
return pEntity;
}
function GetModelBoundingSphere(usModel)
{
function GetModelBoundingSphere(usModel) {
return [usModel.boundingRadius, usModel.boundingCentre.x, usModel.boundingCentre.y, usModel.boundingCentre.z];
}
function GetMouseSpeed()
{
function GetMouseSpeed() {
if (gui.cursorEnabled)
return [0,0];
return [0, 0];
let MouseSpeed = game.getMouseSpeed();
return [MouseSpeed.x,-MouseSpeed.y];
return [MouseSpeed.x, -MouseSpeed.y];
}
function GetMouseSensitivity()
{
if (game.getMouseSensitivity === undefined)
{
function GetMouseSensitivity() {
if (game.getMouseSensitivity === undefined) {
//logToConsole(LOG_ERROR, "game.getMouseSensitivity not implemented");
return [0.0025,0.003];
return [0.0025, 0.003];
}
let MouseSensitivity = game.getMouseSensitivity();
return [MouseSensitivity.x,MouseSensitivity.y];
return [MouseSensitivity.x, MouseSensitivity.y];
}
let GetCamera;
{
const Camera = Symbol();
GetCamera = function()
{
GetCamera = function () {
return Camera;
}
}
function AreEntityCollisionsEnabled(pEntity)
{
function AreEntityCollisionsEnabled(pEntity) {
return pEntity.collisionsEnabled;
}
function SetEntityCollisionsEnabled(pEntity, bCollisionsEnabled)
{
function SetEntityCollisionsEnabled(pEntity, bCollisionsEnabled) {
pEntity.collisionsEnabled = bCollisionsEnabled;
}
function ProcessLineOfSight(vecStartX, vecStartY, vecStartZ, vecEndX, vecEndY, vecEndZ, bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera)
{
if (game.processLineOfSight === undefined)
{
function ProcessLineOfSight(vecStartX, vecStartY, vecStartZ, vecEndX, vecEndY, vecEndZ, bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera) {
if (game.processLineOfSight === undefined) {
logToConsole(LOG_WARN, "game.processLineOfSight not implemented");
return [null];
}
let Result = game.processLineOfSight([vecStartX, vecStartY, vecStartZ], [vecEndX, vecEndY, vecEndZ], bCheckBuildings, bCheckVehicles, bCheckPeds, bCheckObjects, bCheckDummies, bCheckSeeThroughStuff, bIgnoreSomeObjectsForCamera);
if (Result == null)
return [null];
return [Result.position.x, Result.position.y ,Result.position.z, Result.normal.x, Result.normal.y ,Result.normal.z, Result.entity];
return [Result.position.x, Result.position.y, Result.position.z, Result.normal.x, Result.normal.y, Result.normal.z, Result.entity];
}
function SetPlaceableMatrix(pPlaceable, mat)
{
if (pPlaceable == GetCamera())
{
function SetPlaceableMatrix(pPlaceable, mat) {
if (pPlaceable == GetCamera()) {
game.setCameraMatrix(mat);
return;
}
@@ -149,20 +130,17 @@ let GetTickCount;
{
let FrameCount = 0;
setInterval(() =>
{
setInterval(() => {
++FrameCount;
}, 0);
let GTAFrameCount = 0;
addEventHandler("OnProcess", (event, deltaTime) =>
{
addEventHandler("OnProcess", (event, deltaTime) => {
++GTAFrameCount;
});
GetTickCount = function(bGTA, bFrames)
{
GetTickCount = function (bGTA, bFrames) {
if (bFrames)
return bGTA ? GTAFrameCount : FrameCount;
else
@@ -170,16 +148,16 @@ let GetTickCount;
}
}
function easingSinusoidalInOut(t,b,c,d)//TODO: Move this to MathUtil.js
function easingSinusoidalInOut(t, b, c, d)//TODO: Move this to MathUtil.js
{
return -c/2 * (Math.cos((Math.PI)*t/d) - 1) + b;
return -c / 2 * (Math.cos((Math.PI) * t / d) - 1) + b;
}
//TODO: extract
function applyMultiplierTimeStep(m,t)//TODO: Move this to MathUtil.js
function applyMultiplierTimeStep(m, t)//TODO: Move this to MathUtil.js
{
return Math.max(Math.min(1.0-(1.0-m)*(t),1),0);
return Math.max(Math.min(1.0 - (1.0 - m) * (t), 1), 0);
}
//TODO: getOffset
@@ -192,8 +170,7 @@ function applyMultiplierTimeStep(m,t)//TODO: Move this to MathUtil.js
//TODO: confirm
const identityMatrix = new Matrix4x4();
if (identityMatrix.setIdentity === undefined)
{
if (identityMatrix.setIdentity === undefined) {
identityMatrix.m11 = 1;
identityMatrix.m12 = 0;
identityMatrix.m13 = 0;
@@ -230,72 +207,62 @@ cameraIdentityMatrix.m42 = 0;
cameraIdentityMatrix.m43 = 0;
cameraIdentityMatrix.m44 = 1;
function createMultipliedMatrix()
{
function createMultipliedMatrix() {
let matrix = new Matrix4x4();
matrix.setMultiply.apply(matrix, arguments);
return matrix;
}
function createXRotationMatrix(x)
{
function createXRotationMatrix(x) {
let matrix = new Matrix4x4();
matrix.setRotateX(x);
return matrix;
}
function createYRotationMatrix(x)
{
function createYRotationMatrix(x) {
let matrix = new Matrix4x4();
matrix.setRotateY(x);
return matrix;
}
function createZRotationMatrix(z)
{
function createZRotationMatrix(z) {
let matrix = new Matrix4x4();
matrix.setRotateZ(z);
return matrix;
}
function createTranslationMatrix(x,y,z)
{
function createTranslationMatrix(x, y, z) {
let matrix = new Matrix4x4();
matrix.setTranslate([x,y,z]);
matrix.setTranslate([x, y, z]);
return matrix;
}
//TODO: createScaleMatrix
function getDotProduct(x,y,z,x2,y2,z2)
{
return x*x2 + y*y2 + z*z2;
function getDotProduct(x, y, z, x2, y2, z2) {
return x * x2 + y * y2 + z * z2;
}
function getCrossProduct(x,y,z,x2,y2,z2)
{
return [y*z2-z*y2, z*x2-x*z2, x*y2-y*x2];
function getCrossProduct(x, y, z, x2, y2, z2) {
return [y * z2 - z * y2, z * x2 - x * z2, x * y2 - y * x2];
}
function getLength(x,y,z)
{
return Math.sqrt(getDotProduct(x,y,z,x,y,z));
function getLength(x, y, z) {
return Math.sqrt(getDotProduct(x, y, z, x, y, z));
}
function normalise(x,y,z)
{
let length = getLength(x,y,z);
function normalise(x, y, z) {
let length = getLength(x, y, z);
if (length == 0)
throw new Error("an attempt was made to normalise a three dimensional vector with a length of zero");
return [x/length, y/length, z/length];
return [x / length, y / length, z / length];
}
function createLookAtLHMatrix(eyeX, eyeY, eyeZ, atX, atY, atZ, upX,upY,upZ)
{
function createLookAtLHMatrix(eyeX, eyeY, eyeZ, atX, atY, atZ, upX, upY, upZ) {
let matrix = new Matrix4x4();
let [lookX, lookY, lookZ] = normalise(atX-eyeX,atY-eyeY,atZ-eyeZ);
let [rightX, rightY, rightZ] = normalise.apply(null,getCrossProduct(upX,upY,upZ,lookX, lookY, lookZ));
[upX,upY,upZ] = getCrossProduct(lookX, lookY, lookZ,rightX, rightY, rightZ);
let [lookX, lookY, lookZ] = normalise(atX - eyeX, atY - eyeY, atZ - eyeZ);
let [rightX, rightY, rightZ] = normalise.apply(null, getCrossProduct(upX, upY, upZ, lookX, lookY, lookZ));
[upX, upY, upZ] = getCrossProduct(lookX, lookY, lookZ, rightX, rightY, rightZ);
matrix.m11 = rightX;
matrix.m12 = rightY;
matrix.m13 = rightZ;
@@ -323,10 +290,9 @@ function createLookAtLHMatrix(eyeX, eyeY, eyeZ, atX, atY, atZ, upX,upY,upZ)
return matrix;
}
function getDifferenceBetweenAngles(current,target)
{
let f = (((target-current)+Math.PI)/(Math.PI*2));
return ((f-Math.floor(f))*(Math.PI*2))-Math.PI;
function getDifferenceBetweenAngles(current, target) {
let f = (((target - current) + Math.PI) / (Math.PI * 2));
return ((f - Math.floor(f)) * (Math.PI * 2)) - Math.PI;
}
let easeCamera = false;
@@ -336,46 +302,41 @@ let easeStartPosX, easeStartPosY, easeStartPosZ;
let easeStartLookX, easeStartLookY, easeStartLookZ;
let easeStartUpX, easeStartUpY, easeStartUpZ;
function getCameraPositionInfo(matrix)
{
function getCameraPositionInfo(matrix) {
return [matrix.m41, matrix.m42, matrix.m43, matrix.m21, matrix.m22, matrix.m23, matrix.m31, matrix.m32, matrix.m33];
}
function startCameraEase()
{
function startCameraEase() {
easeCamera = true;
easeStartTicks = GetTickCount(true,false);
easeStartTicks = GetTickCount(true, false);
easeDuration = 1000;
let matrix = GetPlaceableMatrix(GetCamera());
[easeStartPosX, easeStartPosY, easeStartPosZ, easeStartLookX, easeStartLookY, easeStartLookZ, easeStartUpX, easeStartUpY, easeStartUpZ] = getCameraPositionInfo(matrix);
}
function applyCameraEase(matrix)
{
function applyCameraEase(matrix) {
if (!easeCamera)
return matrix;
let ease = (GetTickCount(true,false)-easeStartTicks)/easeDuration;
if (ease < 1)
{
ease = easingSinusoidalInOut(ease,0,1,1);
let ease = (GetTickCount(true, false) - easeStartTicks) / easeDuration;
if (ease < 1) {
ease = easingSinusoidalInOut(ease, 0, 1, 1);
let [newPosX, newPosY, newPosZ, newLookX, newLookY, newLookZ, newUpX, newUpY, newUpZ] = getCameraPositionInfo(matrix);
let easePosX = easeStartPosX+(newPosX-easeStartPosX)*ease;
let easePosY = easeStartPosY+(newPosY-easeStartPosY)*ease;
let easePosZ = easeStartPosZ+(newPosZ-easeStartPosZ)*ease;
let easeLookX = easeStartLookX+(newLookX-easeStartLookX)*ease;
let easeLookY = easeStartLookY+(newLookY-easeStartLookY)*ease;
let easeLookZ = easeStartLookZ+(newLookZ-easeStartLookZ)*ease;
let easeUpX = easeStartUpX+(newUpX-easeStartUpX)*ease;
let easeUpY = easeStartUpY+(newUpY-easeStartUpY)*ease;
let easeUpZ = easeStartUpZ+(newUpZ-easeStartUpZ)*ease;
return createLookAtLHMatrix(easePosX,easePosY,easePosZ,easePosX+easeLookX,easePosY+easeLookY,easePosZ+easeLookZ,easeUpX,easeUpY,easeUpZ);
let easePosX = easeStartPosX + (newPosX - easeStartPosX) * ease;
let easePosY = easeStartPosY + (newPosY - easeStartPosY) * ease;
let easePosZ = easeStartPosZ + (newPosZ - easeStartPosZ) * ease;
let easeLookX = easeStartLookX + (newLookX - easeStartLookX) * ease;
let easeLookY = easeStartLookY + (newLookY - easeStartLookY) * ease;
let easeLookZ = easeStartLookZ + (newLookZ - easeStartLookZ) * ease;
let easeUpX = easeStartUpX + (newUpX - easeStartUpX) * ease;
let easeUpY = easeStartUpY + (newUpY - easeStartUpY) * ease;
let easeUpZ = easeStartUpZ + (newUpZ - easeStartUpZ) * ease;
return createLookAtLHMatrix(easePosX, easePosY, easePosZ, easePosX + easeLookX, easePosY + easeLookY, easePosZ + easeLookZ, easeUpX, easeUpY, easeUpZ);
}
return matrix;
}
function isCameraEasing()
{
return easeCamera && GetTickCount(true,false) < (easeStartTicks+easeDuration);
function isCameraEasing() {
return easeCamera && GetTickCount(true, false) < (easeStartTicks + easeDuration);
}
let oldCameraTarget = null;
@@ -383,14 +344,12 @@ let OldPosition = null;//2019 Lucas was here!
let cameraRotZ;
let cameraRotY;
function getCameraTarget()
{
function getCameraTarget() {
let playerPed = GetPlayerPed(GetCurrentPlayerIndex());
let vehicle = GetPedVehicle(playerPed);
if (vehicle != null)
return vehicle;
if (playerPed != null)
{
if (playerPed != null) {
//if (playerPed.health <= 1)//Breaks because of fade//2019 Lucas was here!
// return null;
return playerPed;
@@ -398,59 +357,52 @@ function getCameraTarget()
return null;
}
function isRelativeToTarget(target)
{
function isRelativeToTarget(target) {
if (GetEntityType(target) == ENTITYTYPE_PED)
return false;
return false
}
function isClipped(target)
{
function isClipped(target) {
if (GetEntityType(target) == ENTITYTYPE_PED)
return true;
return true;
}
//2019 Lucas was here!
function ShouldReturnToRestRotation(Target)
{
function ShouldReturnToRestRotation(Target) {
if (GetEntityType(Target) == ENTITYTYPE_PED)
return false;
return true;
}
function getCameraRestRotation(target)
{
function getCameraRestRotation(target) {
let targetMatrix = GetPlaceableMatrix(target);
let rotZ;
if (isRelativeToTarget(target))
rotZ = 0;
else
rotZ = -Math.atan2(targetMatrix.m21,targetMatrix.m22);
rotZ = -Math.atan2(targetMatrix.m21, targetMatrix.m22);
let rotY = -0.2;
return [rotZ, rotY];
}
function resetCameraRotation()
{
function resetCameraRotation() {
[cameraRotZ, cameraRotY] = getCameraRestRotation(getCameraTarget());
}
//2019 Lucas was here!
let DeltaTime = 0;
addEventHandler("OnProcess", (event, deltaTime) =>
{
addEventHandler("OnProcess", (event, deltaTime) => {
DeltaTime = deltaTime;
if(!localPlayer) {
if (!localPlayer) {
return false;
}
});
let IdleTime = 0;//2019 Lucas was here!
function processReturnToRestRotation()
{
function processReturnToRestRotation() {
//resetCameraRotation();//2019 Lucas was here!
//2019 Lucas was here!
@@ -458,37 +410,32 @@ function processReturnToRestRotation()
if (!ShouldReturnToRestRotation(Target))
return;
IdleTime += DeltaTime;
if (IdleTime > 1.5)
{
if (IdleTime > 1.5) {
let Velocity = Target.velocity;
let Matrix = Target.matrix;
let Speed = getDotProduct(Velocity.x,Velocity.y,Velocity.z,Matrix.getElement(1*4+0),Matrix.getElement(1*4+1),Matrix.getElement(1*4+2));
let Speed = getDotProduct(Velocity.x, Velocity.y, Velocity.z, Matrix.getElement(1 * 4 + 0), Matrix.getElement(1 * 4 + 1), Matrix.getElement(1 * 4 + 2));
let AbsSpeed = Math.abs(Speed);
let Multiplier = Math.min(AbsSpeed/0.75, 1);
if (Multiplier != 0)
{
let Multiplier = Math.min(AbsSpeed / 0.75, 1);
if (Multiplier != 0) {
let [TargetCameraRotZ2, TargetCameraRotY2] = getCameraRestRotation(Target);
if (Speed < 0)
TargetCameraRotZ2 += Math.PI;
let TimeStep = game.timeStep/50*60;
cameraRotZ += getDifferenceBetweenAngles(cameraRotZ,TargetCameraRotZ2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier;
cameraRotY += getDifferenceBetweenAngles(cameraRotY,TargetCameraRotY2)*applyMultiplierTimeStep(1/20,TimeStep)*Multiplier;
let TimeStep = game.timeStep / 50 * 60;
cameraRotZ += getDifferenceBetweenAngles(cameraRotZ, TargetCameraRotZ2) * applyMultiplierTimeStep(1 / 20, TimeStep) * Multiplier;
cameraRotY += getDifferenceBetweenAngles(cameraRotY, TargetCameraRotY2) * applyMultiplierTimeStep(1 / 20, TimeStep) * Multiplier;
}
}
}
function cancelReturnToRestRotation()
{
function cancelReturnToRestRotation() {
IdleTime = 0;//2019 Lucas was here!
}
let distance;
let zIncrease;
function getCameraOffsetInfo(target)
{
if (GetEntityType(target) == ENTITYTYPE_PED)
{
function getCameraOffsetInfo(target) {
if (GetEntityType(target) == ENTITYTYPE_PED) {
let distance = 4;
let zIncrease = 0.8;
let offsetX = 0;
@@ -507,8 +454,7 @@ function getCameraOffsetInfo(target)
let offsetX;
let offsetY;
let offsetZ;
if (radius <= 3.0535011291504)
{
if (radius <= 3.0535011291504) {
minDistance = 4;
maxDistance = 8;
minZIncrease = 0.5;
@@ -516,8 +462,7 @@ function getCameraOffsetInfo(target)
minRadius = 2;
maxRadius = 3.0535011291504;
}
else
{
else {
minDistance = 8;
maxDistance = 16;
minZIncrease = 1;
@@ -528,66 +473,59 @@ function getCameraOffsetInfo(target)
offsetX = 0;
offsetY = 0;
offsetZ = 0;
distance = minDistance+(radius-minRadius)/(maxRadius-minRadius)*(maxDistance-minDistance);
zIncrease = minZIncrease+(radius-minRadius)/(maxRadius-minRadius)*(maxZIncrease-minZIncrease);
distance = minDistance + (radius - minRadius) / (maxRadius - minRadius) * (maxDistance - minDistance);
zIncrease = minZIncrease + (radius - minRadius) / (maxRadius - minRadius) * (maxZIncrease - minZIncrease);
return [distance, zIncrease, offsetX, offsetY, offsetZ];
}
function update()
{
function update() {
let target = getCameraTarget();
if (target != null)
{
if (oldCameraTarget != target)
{
if (target != null) {
if (oldCameraTarget != target) {
//if (oldCameraTarget != null)//2019 Lucas was here!
let Position = target.position;
if (OldPosition == null || getLength(Position.x-OldPosition.x,Position.y-OldPosition.y,Position.z-OldPosition.z) < 10)
if (OldPosition == null || getLength(Position.x - OldPosition.x, Position.y - OldPosition.y, Position.z - OldPosition.z) < 10)
startCameraEase()
resetCameraRotation()
}
let [mouseSpeedX, mouseSpeedY] = GetMouseSpeed();
let [mouseSensitivityX, mouseSensitivityY] = GetMouseSensitivity();
mouseSpeedX = mouseSpeedX*mouseSensitivityX*2;
mouseSpeedY = mouseSpeedY*mouseSensitivityY*2;
if (mouseSpeedX == 0 && mouseSpeedY == 0)
{
mouseSpeedX = mouseSpeedX * mouseSensitivityX * 2;
mouseSpeedY = mouseSpeedY * mouseSensitivityY * 2;
if (mouseSpeedX == 0 && mouseSpeedY == 0) {
processReturnToRestRotation();
}
else
{
cameraRotZ = cameraRotZ-mouseSpeedX;
cameraRotY = cameraRotY-mouseSpeedY;
else {
cameraRotZ = cameraRotZ - mouseSpeedX;
cameraRotY = cameraRotY - mouseSpeedY;
cancelReturnToRestRotation();
}
cameraRotY = Math.max(cameraRotY,-Math.PI/2+0.01);
cameraRotY = Math.max(cameraRotY, -Math.PI / 2 + 0.01);
if (GetEntityType(target) != ENTITYTYPE_PED)
cameraRotY = Math.min(cameraRotY,Math.PI/8.5);//2019 Lucas was here!
cameraRotY = Math.min(cameraRotY, Math.PI / 8.5);//2019 Lucas was here!
else
cameraRotY = Math.min(cameraRotY,Math.PI/4);
cameraRotY = Math.min(cameraRotY, Math.PI / 4);
let camera = GetCamera();
let targetMatrix = GetPlaceableMatrix(target);
let [distance, zIncrease, offsetX, offsetY, offsetZ] = getCameraOffsetInfo(target);
let offsetTranslationMatrix = createTranslationMatrix(offsetX, offsetY, offsetZ);
targetMatrix = createMultipliedMatrix(offsetTranslationMatrix,targetMatrix);
targetMatrix = createMultipliedMatrix(offsetTranslationMatrix, targetMatrix);
let targetPosX, targetPosY, targetPosZ;
if (isRelativeToTarget(target))
[targetPosX, targetPosY, targetPosZ] = [0,0,0];
[targetPosX, targetPosY, targetPosZ] = [0, 0, 0];
else
[targetPosX, targetPosY, targetPosZ] = [targetMatrix.m41,targetMatrix.m42,targetMatrix.m43];
let distanceTranslationMatrix = createTranslationMatrix(0,-distance,0);
targetPosZ = targetPosZ+zIncrease;
[targetPosX, targetPosY, targetPosZ] = [targetMatrix.m41, targetMatrix.m42, targetMatrix.m43];
let distanceTranslationMatrix = createTranslationMatrix(0, -distance, 0);
targetPosZ = targetPosZ + zIncrease;
let targetTranslationMatrix = createTranslationMatrix(targetPosX, targetPosY, targetPosZ);
let offsetRotationX = createXRotationMatrix(cameraRotY);
let offsetRotationZ = createZRotationMatrix(cameraRotZ);
let cameraMatrix = createMultipliedMatrix(cameraIdentityMatrix,distanceTranslationMatrix,offsetRotationX,offsetRotationZ,targetTranslationMatrix);
if (isRelativeToTarget(target))
{
cameraMatrix = createMultipliedMatrix(cameraMatrix,targetMatrix);
targetTranslationMatrix = createMultipliedMatrix(targetTranslationMatrix,targetMatrix);
let cameraMatrix = createMultipliedMatrix(cameraIdentityMatrix, distanceTranslationMatrix, offsetRotationX, offsetRotationZ, targetTranslationMatrix);
if (isRelativeToTarget(target)) {
cameraMatrix = createMultipliedMatrix(cameraMatrix, targetMatrix);
targetTranslationMatrix = createMultipliedMatrix(targetTranslationMatrix, targetMatrix);
}
if (isClipped(target))
{
if (isClipped(target)) {
let startX = targetTranslationMatrix.m41;
let startY = targetTranslationMatrix.m42;
let startZ = targetTranslationMatrix.m43;
@@ -603,17 +541,16 @@ function update()
let ignoreSomeObjectsForCamera = true;
let collisionsEnabled = AreEntityCollisionsEnabled(target);
if (collisionsEnabled)
SetEntityCollisionsEnabled(target,false);
let [positionX,positionY,positionZ,normalX,normalY,normalZ,targetEntity] = ProcessLineOfSight(startX,startY,startZ,endX,endY,endZ,checkBuildings,checkVehicles,checkPeds,checkObjects,checkDummies,checkSeeThroughStuff,ignoreSomeObjectsForCamera);
SetEntityCollisionsEnabled(target, false);
let [positionX, positionY, positionZ, normalX, normalY, normalZ, targetEntity] = ProcessLineOfSight(startX, startY, startZ, endX, endY, endZ, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, checkSeeThroughStuff, ignoreSomeObjectsForCamera);
if (collisionsEnabled)
SetEntityCollisionsEnabled(target,true);
if (positionX != null)
{
SetEntityCollisionsEnabled(target, true);
if (positionX != null) {
//2019 Lucas was here!
let Distance = 0.3;
positionX += normalX*Distance;
positionY += normalY*Distance;
positionZ += normalZ*Distance;
positionX += normalX * Distance;
positionY += normalY * Distance;
positionZ += normalZ * Distance;
cameraMatrix.m41 = positionX;
cameraMatrix.m42 = positionY;
@@ -622,7 +559,7 @@ function update()
}
if (isCameraEasing())
cameraMatrix = applyCameraEase(cameraMatrix);
SetPlaceableMatrix(camera,cameraMatrix);
SetPlaceableMatrix(camera, cameraMatrix);
UpdateCamera(camera);
}
oldCameraTarget = target;
@@ -630,9 +567,8 @@ function update()
return target != null;
}
addEventHandler("OnCameraProcess", (event) =>
{
if(mouseCameraEnabled) {
addEventHandler("OnCameraProcess", (event) => {
if (mouseCameraEnabled) {
update();
event.preventDefault();
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: nametags.js
// DESC: Provides nametag rendering
@@ -23,10 +22,10 @@ let playerPing = {};
// ===========================================================================
function initNameTagScript() {
logToConsole(LOG_DEBUG, "[VRR.NameTag]: Initializing nametag script ...");
logToConsole(LOG_DEBUG, "[AGRP.NameTag]: Initializing nametag script ...");
nametagFont = loadNameTagFont();
afkStatusFont = loadPausedStatusFont();
logToConsole(LOG_DEBUG, "[VRR.NameTag]: Nametag script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.NameTag]: Nametag script initialized!");
}
// ===========================================================================
@@ -53,7 +52,7 @@ function updatePlayerNameTag(clientName, characterName, colour, paused, ping) {
playerPaused[clientName] = paused;
playerPing[clientName] = ping;
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
let client = getPlayerFromParams(clientName);
if (client != false) {
if (getPlayerPed(client) != null) {
@@ -85,8 +84,8 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
// -------------------------------------------
// Health Bar
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
if (getGame() == AGRP_GAME_GTA_III) {
if (getMultiplayerMod() == V_MPMOD_GTAC) {
if (getGame() == V_GAME_GTA_III) {
// Mickey Hamfists is ridiculously tall. Raise the nametag for him a bit
if (skin == 109) {
y -= 20;

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: connected.js
// DESC: Provides wrapped natives for GTA Connected and Mafia Connected mods
@@ -38,7 +37,7 @@ function getPlayerPosition() {
// ===========================================================================
function setPlayerPosition(position) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
natives.setCharCoordinates(localPlayer, position);
} else {
localPlayer.position = position;
@@ -188,7 +187,7 @@ function getVehiclesInRange(position, range) {
// ===========================================================================
function createGameBlip(blipModel, position, name = "") {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
let blipId = natives.addBlipForCoord(position);
if (blipId) {
natives.changeBlipSprite(blipId, blipModel);
@@ -213,6 +212,7 @@ function setEntityData(entity, dataName, dataValue, syncToClients = true) {
// ===========================================================================
function setVehicleEngine(vehicleId, state) {
//getElementFromId(vehicleId).netFlags.sendSync = state;
getElementFromId(vehicleId).engine = state;
}
@@ -231,50 +231,50 @@ function repairVehicle(syncId) {
// ===========================================================================
function syncVehicleProperties(vehicle) {
if (doesEntityDataExist(vehicle, "agrp.lights")) {
let lightStatus = getEntityData(vehicle, "agrp.lights");
if (doesEntityDataExist(vehicle, "v.rp.lights")) {
let lightStatus = getEntityData(vehicle, "v.rp.lights");
vehicle.lights = lightStatus;
}
if (doesEntityDataExist(vehicle, "agrp.invincible")) {
let invincible = getEntityData(vehicle, "agrp.invincible");
if (doesEntityDataExist(vehicle, "v.rp.invincible")) {
let invincible = getEntityData(vehicle, "v.rp.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible);
}
if (doesEntityDataExist(vehicle, "agrp.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "agrp.panelStatus");
if (doesEntityDataExist(vehicle, "v.rp.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "v.rp.panelStatus");
for (let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "agrp.wheelStatus");
if (doesEntityDataExist(vehicle, "v.rp.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "v.rp.wheelStatus");
for (let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.lightStatus")) {
let lightStatus = getEntityData(vehicle, "agrp.lightStatus");
if (doesEntityDataExist(vehicle, "v.rp.lightStatus")) {
let lightStatus = getEntityData(vehicle, "v.rp.lightStatus");
for (let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "agrp.suspensionHeight");
if (doesEntityDataExist(vehicle, "v.rp.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "v.rp.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (getGame() == V_GAME_GTA_SA) {
let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
for (let i in allUpgrades) {
vehicle.removeUpgrade(i);
}
if (doesEntityDataExist(vehicle, "agrp.upgrades")) {
let upgrades = getEntityData(vehicle, "agrp.upgrades");
if (doesEntityDataExist(vehicle, "v.rp.upgrades")) {
let upgrades = getEntityData(vehicle, "v.rp.upgrades");
for (let i in upgrades) {
if (upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]);
@@ -283,12 +283,12 @@ function syncVehicleProperties(vehicle) {
}
}
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "agrp.livery")) {
let livery = getEntityData(vehicle, "agrp.livery");
if (getGame() == AGRP_GAME_GTA_SA) {
if (getGame() == V_GAME_GTA_SA || getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "v.rp.livery")) {
let livery = getEntityData(vehicle, "v.rp.livery");
if (getGame() == V_GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if (getGame() == AGRP_GAME_GTA_IV) {
} else if (getGame() == V_GAME_GTA_IV) {
vehicle.livery = livery;
}
}
@@ -316,9 +316,9 @@ function doesEntityDataExist(entity, dataName) {
// ===========================================================================
function syncCivilianProperties(civilian) {
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.scale")) {
let scaleFactor = getEntityData(civilian, "agrp.scale");
if (getGame() == V_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "v.rp.scale")) {
let scaleFactor = getEntityData(civilian, "v.rp.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
@@ -328,79 +328,79 @@ function syncCivilianProperties(civilian) {
}
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "agrp.fightStyle")) {
let fightStyle = getEntityData(civilian, "agrp.fightStyle");
if (getGame() == V_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "v.rp.fightStyle")) {
let fightStyle = getEntityData(civilian, "v.rp.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.walkStyle")) {
let walkStyle = getEntityData(civilian, "agrp.walkStyle");
if (getGame() == V_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "v.rp.walkStyle")) {
let walkStyle = getEntityData(civilian, "v.rp.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "v.rp.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "v.rp.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "agrp.bodyPropHead");
if (doesEntityDataExist(civilian, "v.rp.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "v.rp.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "agrp.bodyPropEyes");
if (doesEntityDataExist(civilian, "v.rp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "v.rp.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "agrp.bodyPropLeftHand");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "v.rp.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "agrp.bodyPropRightHand");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "v.rp.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "agrp.bodyPropLeftWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "v.rp.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "v.rp.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "v.rp.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "agrp.bodyPropHip");
if (doesEntityDataExist(civilian, "v.rp.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "v.rp.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "agrp.bodyPropLeftFoot");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "v.rp.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "agrp.bodyPropRightFoot");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "v.rp.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if (doesEntityDataExist(civilian, "agrp.anim")) {
let animData = getEntityData(vehicle, "agrp.anim");
if (doesEntityDataExist(civilian, "v.rp.anim")) {
let animData = getEntityData(vehicle, "v.rp.anim");
civilian.addAnimation(animData[0], animData[1]);
}
}
@@ -414,9 +414,9 @@ function preventDefaultEventAction(event) {
// ===========================================================================
function syncPlayerProperties(player) {
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(player, "agrp.scale")) {
let scaleFactor = getEntityData(player, "agrp.scale");
if (getGame() == V_GAME_GTA_III) {
if (doesEntityDataExist(player, "v.rp.scale")) {
let scaleFactor = getEntityData(player, "v.rp.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
@@ -426,95 +426,95 @@ function syncPlayerProperties(player) {
}
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (doesEntityDataExist(player, "agrp.fightStyle")) {
let fightStyle = getEntityData(player, "agrp.fightStyle");
if (getGame() == V_GAME_GTA_SA) {
if (doesEntityDataExist(player, "v.rp.fightStyle")) {
let fightStyle = getEntityData(player, "v.rp.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
//if(getGame() == AGRP_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "agrp.walkStyle")) {
// let walkStyle = getEntityData(player, "agrp.walkStyle");
//if(getGame() == V_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "v.rp.walkStyle")) {
// let walkStyle = getEntityData(player, "v.rp.walkStyle");
// player.walkStyle = walkStyle;
// }
//}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(player, "v.rp.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "v.rp.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHead");
if (doesEntityDataExist(player, "v.rp.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "v.rp.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "agrp.bodyPartUpper");
if (doesEntityDataExist(player, "v.rp.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "v.rp.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "agrp.bodyPartLower");
if (doesEntityDataExist(player, "v.rp.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "v.rp.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(player, "v.rp.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "v.rp.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "agrp.bodyPropHead");
if (doesEntityDataExist(player, "v.rp.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "v.rp.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "agrp.bodyPropEyes");
if (doesEntityDataExist(player, "v.rp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "v.rp.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "agrp.bodyPropLeftHand");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "v.rp.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "agrp.bodyPropRightHand");
if (doesEntityDataExist(player, "v.rp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "v.rp.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "agrp.bodyPropLeftWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "v.rp.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "v.rp.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "v.rp.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "agrp.bodyPropHip");
if (doesEntityDataExist(player, "v.rp.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "v.rp.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "agrp.bodyPropLeftFoot");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "v.rp.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "agrp.bodyPropRightFoot");
if (doesEntityDataExist(player, "v.rp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "v.rp.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
@@ -523,9 +523,9 @@ function syncPlayerProperties(player) {
// ===========================================================================
function syncObjectProperties(object) {
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
if (doesEntityDataExist(object, "agrp.scale")) {
let scaleFactor = getEntityData(object, "agrp.scale");
if (getGame() == V_GAME_GTA_III || getGame() == V_GAME_GTA_VC) {
if (doesEntityDataExist(object, "v.rp.scale")) {
let scaleFactor = getEntityData(object, "v.rp.scale");
let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
@@ -575,9 +575,9 @@ function getPlayerId(client) {
// ===========================================================================
function syncElementProperties(element) {
if (doesEntityDataExist(element, "agrp.interior")) {
if (doesEntityDataExist(element, "v.rp.interior")) {
if (typeof element.interior != "undefined") {
element.interior = getEntityData(element, "agrp.interior");
element.interior = getEntityData(element, "v.rp.interior");
}
}
@@ -627,21 +627,21 @@ function getScreenHeight() {
function openAllGarages() {
switch (getGame()) {
case AGRP_GAME_GTA_III:
case V_GAME_GTA_III:
for (let i = 0; i <= 26; i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case AGRP_GAME_GTA_VC:
case V_GAME_GTA_VC:
for (let i = 0; i <= 32; i++) {
openGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case AGRP_GAME_GTA_SA:
case V_GAME_GTA_SA:
for (let i = 0; i <= 44; i++) {
openGarage(i);
}
@@ -656,21 +656,21 @@ function openAllGarages() {
function closeAllGarages() {
switch (getGame()) {
case AGRP_GAME_GTA_III:
case V_GAME_GTA_III:
for (let i = 0; i <= 26; i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case AGRP_GAME_GTA_VC:
case V_GAME_GTA_VC:
for (let i = 0; i <= 32; i++) {
closeGarage(i);
game.NO_SPECIAL_CAMERA_FOR_THIS_GARAGE(i);
}
break;
case AGRP_GAME_GTA_SA:
case V_GAME_GTA_SA:
for (let i = 0; i <= 44; i++) {
closeGarage(i);
}
@@ -690,7 +690,7 @@ function setPedInvincible(ped, state) {
// ===========================================================================
function setPedLookAt(ped, position) {
if (getGame() == AGRP_GAME_GTA_SA) {
if (getGame() == V_GAME_GTA_SA) {
ped.lookAt(position, 10000);
return true;
} else {
@@ -710,4 +710,24 @@ function deleteLocalPlayerPed() {
destroyElement(localPlayer);
}
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if (getElementFromId(elementId) == null) {
return false;
}
getElementFromId(elementId).collisionsEnabled = state;
}
// ===========================================================================
function getElementCollisionsEnabled(elementId, state) {
if (getElementFromId(elementId) == null) {
return false;
}
return getElementFromId(elementId).collisionsEnabled;
}
// ===========================================================================

View File

@@ -1,190 +1,197 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: netevents.js
// DESC: Provides server communication and cross-endpoint network events
// TYPE: Client (JavaScript)
// ===========================================================================
function initServerScript() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Initializing server script ...");
addAllNetworkHandlers();
logToConsole(LOG_DEBUG, "[VRR.Server]: Server script initialized!");
function initNetworkEventsScript() {
logToConsole(LOG_DEBUG, "[AGRP.NetEvents]: Initializing server script ...");
logToConsole(LOG_DEBUG, "[AGRP.NetEvents]: Server script initialized!");
}
// ===========================================================================
function addAllNetworkHandlers() {
logToConsole(LOG_DEBUG, "[VRR.Server]: Adding network handlers ...");
logToConsole(LOG_DEBUG, "[AGRP.Server]: Adding network handlers ...");
// Chat Box
addNetworkEventHandler("m", receiveChatBoxMessageFromServer); // Not prefixed with VRR to make it as small as possible
addNetworkEventHandler("agrp.chatScrollLines", setChatScrollLines);
addNetworkEventHandler("agrp.chatAutoHideDelay", setChatAutoHideDelay);
addNetworkEventHandler("agrp.chatTimeStamps", setChatTimeStampsState);
addNetworkEventHandler("agrp.chatEmoji", setChatEmojiState);
addNetworkEventHandler("v.rp.chatScrollLines", setChatScrollLines);
addNetworkEventHandler("v.rp.chatAutoHideDelay", setChatAutoHideDelay);
addNetworkEventHandler("v.rp.chatTimeStamps", setChatTimeStampsState);
addNetworkEventHandler("v.rp.chatEmoji", setChatEmojiState);
// Messaging (like textdraws and stuff)
addNetworkEventHandler("agrp.smallGameMessage", showSmallGameMessage);
addNetworkEventHandler("v.rp.smallGameMessage", showSmallGameMessage);
// Job
addNetworkEventHandler("agrp.job", receiveJobFromServer);
addNetworkEventHandler("agrp.working", setLocalPlayerWorkingState);
addNetworkEventHandler("agrp.jobType", setLocalPlayerJobType);
addNetworkEventHandler("agrp.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("agrp.hideJobRouteLocation", hideJobRouteLocation);
addNetworkEventHandler("v.rp.job", receiveJobFromServer);
addNetworkEventHandler("v.rp.working", setLocalPlayerWorkingState);
addNetworkEventHandler("v.rp.jobType", setLocalPlayerJobType);
addNetworkEventHandler("v.rp.showJobRouteLocation", showJobRouteLocation);
addNetworkEventHandler("v.rp.hideJobRouteLocation", hideJobRouteLocation);
// Local player states and values
addNetworkEventHandler("agrp.restoreCamera", restoreLocalCamera);
addNetworkEventHandler("agrp.cameraLookAt", setLocalCameraLookAt);
addNetworkEventHandler("agrp.freeze", setLocalPlayerFrozenState);
addNetworkEventHandler("agrp.control", setLocalPlayerControlState);
addNetworkEventHandler("agrp.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("agrp.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("agrp.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("agrp.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("agrp.position", setLocalPlayerPosition);
addNetworkEventHandler("agrp.heading", setLocalPlayerHeading);
addNetworkEventHandler("agrp.interior", setLocalPlayerInterior);
addNetworkEventHandler("agrp.spawned", onServerSpawnedLocalPlayer);
addNetworkEventHandler("agrp.money", setLocalPlayerCash);
addNetworkEventHandler("agrp.armour", setLocalPlayerArmour);
addNetworkEventHandler("agrp.localPlayerSkin", setLocalPlayerSkin);
addNetworkEventHandler("agrp.pedSpeak", makeLocalPlayerPedSpeak);
addNetworkEventHandler("agrp.infiniteRun", setLocalPlayerInfiniteRun);
addNetworkEventHandler("agrp.playerCop", setLocalPlayerAsCopState);
addNetworkEventHandler("agrp.health", setLocalPlayerHealth);
addNetworkEventHandler("agrp.wantedLevel", setLocalPlayerWantedLevel);
addNetworkEventHandler("agrp.playerPedId", sendLocalPlayerNetworkIdToServer);
addNetworkEventHandler("agrp.ped", setLocalPlayerPedPartsAndProps);
addNetworkEventHandler("agrp.spawn", serverRequestedLocalPlayerSpawn);
addNetworkEventHandler("agrp.clearPedState", clearLocalPedState);
addNetworkEventHandler("agrp.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkEventHandler("agrp.deleteLocalPlayerPed", deleteLocalPlayerPed);
addNetworkEventHandler("v.rp.restoreCamera", restoreLocalCamera);
addNetworkEventHandler("v.rp.cameraLookAt", setLocalCameraLookAt);
addNetworkEventHandler("v.rp.freeze", setLocalPlayerFrozenState);
addNetworkEventHandler("v.rp.control", setLocalPlayerControlState);
addNetworkEventHandler("v.rp.fadeCamera", fadeLocalCamera);
addNetworkEventHandler("v.rp.removeFromVehicle", removeLocalPlayerFromVehicle);
addNetworkEventHandler("v.rp.clearWeapons", clearLocalPlayerWeapons);
addNetworkEventHandler("v.rp.giveWeapon", giveLocalPlayerWeapon);
addNetworkEventHandler("v.rp.position", setLocalPlayerPosition);
addNetworkEventHandler("v.rp.heading", setLocalPlayerHeading);
addNetworkEventHandler("v.rp.interior", setLocalPlayerInterior);
addNetworkEventHandler("v.rp.spawned", onServerSpawnedLocalPlayer);
addNetworkEventHandler("v.rp.money", setLocalPlayerMoney);
addNetworkEventHandler("v.rp.armour", setLocalPlayerArmour);
addNetworkEventHandler("v.rp.localPlayerSkin", setLocalPlayerSkin);
addNetworkEventHandler("v.rp.pedSpeak", makeLocalPlayerPedSpeak);
addNetworkEventHandler("v.rp.infiniteRun", setLocalPlayerInfiniteRun);
addNetworkEventHandler("v.rp.playerCop", setLocalPlayerAsCopState);
addNetworkEventHandler("v.rp.health", setLocalPlayerHealth);
addNetworkEventHandler("v.rp.wantedLevel", setLocalPlayerWantedLevel);
addNetworkEventHandler("v.rp.playerPedId", sendLocalPlayerNetworkIdToServer);
addNetworkEventHandler("v.rp.ped", setLocalPlayerPedPartsAndProps);
addNetworkEventHandler("v.rp.spawn", serverRequestedLocalPlayerSpawn);
addNetworkEventHandler("v.rp.clearPedState", clearLocalPedState);
addNetworkEventHandler("v.rp.drunkEffect", setLocalPlayerDrunkEffect);
addNetworkEventHandler("v.rp.deleteLocalPlayerPed", deleteLocalPlayerPed);
// Vehicle
addNetworkEventHandler("agrp.vehicle", receiveVehicleFromServer);
addNetworkEventHandler("agrp.veh.lights", setVehicleLights);
addNetworkEventHandler("agrp.veh.engine", setVehicleEngine);
addNetworkEventHandler("agrp.veh.repair", repairVehicle);
addNetworkEventHandler("agrp.cruiseControl", toggleVehicleCruiseControl);
addNetworkEventHandler("v.rp.vehicle", receiveVehicleFromServer);
addNetworkEventHandler("v.rp.veh.lights", setVehicleLights);
addNetworkEventHandler("v.rp.veh.engine", setVehicleEngine);
addNetworkEventHandler("v.rp.veh.repair", repairVehicle);
addNetworkEventHandler("v.rp.cruiseControl", toggleLocalVehicleCruiseControl);
addNetworkEventHandler("v.rp.passenger", enterVehicleAsPassenger);
addNetworkEventHandler("v.rp.vehBuyState", setVehiclePurchaseState);
// Radio
addNetworkEventHandler("agrp.radioStream", playStreamingRadio);
addNetworkEventHandler("agrp.audioFileStream", playAudioFile);
addNetworkEventHandler("agrp.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("agrp.radioVolume", setStreamingRadioVolume);
addNetworkEventHandler("v.rp.radioStream", playStreamingRadio);
addNetworkEventHandler("v.rp.audioFileStream", playAudioFile);
addNetworkEventHandler("v.rp.stopRadioStream", stopStreamingRadio);
addNetworkEventHandler("v.rp.radioVolume", setStreamingRadioVolume);
// Key Bindings
addNetworkEventHandler("agrp.delKeyBind", unBindAccountKey);
addNetworkEventHandler("agrp.addKeyBind", bindAccountKey);
addNetworkEventHandler("agrp.clearKeyBinds", clearKeyBinds);
addNetworkEventHandler("v.rp.delKeyBind", unBindAccountKey);
addNetworkEventHandler("v.rp.addKeyBind", bindAccountKey);
addNetworkEventHandler("v.rp.clearKeyBinds", clearKeyBinds);
// Weapon Damage
addNetworkEventHandler("agrp.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("agrp.weaponDamageEvent", setPlayerWeaponDamageEvent);
addNetworkEventHandler("v.rp.weaponDamageEnabled", setPlayerWeaponDamageEnabled);
addNetworkEventHandler("v.rp.weaponDamageEvent", setPlayerWeaponDamageEvent);
// GUI
addNetworkEventHandler("agrp.showRegistration", showRegistrationGUI);
addNetworkEventHandler("agrp.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("agrp.showLogin", showLoginGUI);
addNetworkEventHandler("agrp.2fa", showTwoFactorAuthGUI);
addNetworkEventHandler("agrp.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
addNetworkEventHandler("agrp.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
addNetworkEventHandler("agrp.showChangePassword", showChangePasswordGUI);
addNetworkEventHandler("agrp.showCharacterSelect", showCharacterSelectGUI);
addNetworkEventHandler("agrp.switchCharacterSelect", switchCharacterSelectGUI);
addNetworkEventHandler("agrp.showError", showErrorGUI);
addNetworkEventHandler("agrp.showInfo", showInfoGUI);
addNetworkEventHandler("agrp.showPrompt", showYesNoPromptGUI);
addNetworkEventHandler("agrp.loginSuccess", loginSuccess);
addNetworkEventHandler("agrp.characterSelectSuccess", characterSelectSuccess);
addNetworkEventHandler("agrp.loginFailed", loginFailed);
addNetworkEventHandler("agrp.registrationSuccess", registrationSuccess);
addNetworkEventHandler("agrp.registrationFailed", registrationFailed);
addNetworkEventHandler("agrp.newCharacterFailed", newCharacterFailed);
addNetworkEventHandler("agrp.changePassword", showChangePasswordGUI);
addNetworkEventHandler("agrp.showLocaleChooser", showLocaleChooserGUI);
addNetworkEventHandler("agrp.guiColour", setGUIColours);
addNetworkEventHandler("v.rp.showRegistration", showRegistrationGUI);
addNetworkEventHandler("v.rp.showNewCharacter", showNewCharacterGUI);
addNetworkEventHandler("v.rp.showLogin", showLoginGUI);
addNetworkEventHandler("v.rp.2fa", showTwoFactorAuthGUI);
addNetworkEventHandler("v.rp.showResetPasswordCodeInput", resetPasswordCodeInputGUI);
addNetworkEventHandler("v.rp.showResetPasswordEmailInput", resetPasswordEmailInputGUI);
addNetworkEventHandler("v.rp.showChangePassword", showChangePasswordGUI);
addNetworkEventHandler("v.rp.showCharacterSelect", showCharacterSelectGUI);
addNetworkEventHandler("v.rp.switchCharacterSelect", switchCharacterSelectGUI);
addNetworkEventHandler("v.rp.showError", showErrorGUI);
addNetworkEventHandler("v.rp.showInfo", showInfoGUI);
addNetworkEventHandler("v.rp.showPrompt", showYesNoPromptGUI);
addNetworkEventHandler("v.rp.loginSuccess", loginSuccess);
addNetworkEventHandler("v.rp.characterSelectSuccess", characterSelectSuccess);
addNetworkEventHandler("v.rp.loginFailed", loginFailed);
addNetworkEventHandler("v.rp.registrationSuccess", registrationSuccess);
addNetworkEventHandler("v.rp.registrationFailed", registrationFailed);
addNetworkEventHandler("v.rp.newCharacterFailed", newCharacterFailed);
addNetworkEventHandler("v.rp.changePassword", showChangePasswordGUI);
addNetworkEventHandler("v.rp.showLocaleChooser", showLocaleChooserGUI);
addNetworkEventHandler("v.rp.guiColour", setGUIColours);
addNetworkEventHandler("v.rp.mapChangeWarning", setMapChangeWarningState);
// 2D Rendering
addNetworkEventHandler("v.rp.set2DRendering", set2DRendering);
addNetworkEventHandler("v.rp.logo", setServerLogoRenderState);
addNetworkEventHandler("v.rp.showItemActionDelay", showItemActionDelay);
// Business
addNetworkEventHandler("agrp.business", receiveBusinessFromServer);
addNetworkEventHandler("v.rp.business", receiveBusinessFromServer);
// House
addNetworkEventHandler("agrp.house", receiveHouseFromServer);
addNetworkEventHandler("v.rp.house", receiveHouseFromServer);
// GPS
addNetworkEventHandler("agrp.showGPSBlip", showGPSLocation);
addNetworkEventHandler("v.rp.showGPSBlip", showGPSLocation);
// Locale
addNetworkEventHandler("agrp.locale", setLocale);
addNetworkEventHandler("agrp.localeChooser", toggleLocaleChooserGUI);
addNetworkEventHandler("v.rp.locale", setLocale);
addNetworkEventHandler("v.rp.localeChooser", toggleLocaleChooserGUI);
// Animation
addNetworkEventHandler("v.rp.anim", makePedPlayAnimation);
addNetworkEventHandler("v.rp.stopAnim", makePedStopAnimation);
addNetworkEventHandler("v.rp.forceAnim", forcePedAnimation);
// Nametags
addNetworkEventHandler("v.rp.nametag", updatePlayerNameTag);
addNetworkEventHandler("v.rp.nametagDistance", setNameTagDistance);
// Misc
addNetworkEventHandler("agrp.mouseCursor", toggleMouseCursor);
addNetworkEventHandler("agrp.mouseCamera", toggleMouseCamera);
addNetworkEventHandler("agrp.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkEventHandler("agrp.clearPickups", clearLocalPlayerOwnedPickups);
addNetworkEventHandler("agrp.passenger", enterVehicleAsPassenger);
addNetworkEventHandler("agrp.logo", setServerLogoRenderState);
addNetworkEventHandler("agrp.ambience", setCityAmbienceState);
addNetworkEventHandler("agrp.runCode", runClientCode);
addNetworkEventHandler("agrp.minuteDuration", setMinuteDuration);
addNetworkEventHandler("agrp.snow", setSnowState);
addNetworkEventHandler("agrp.enterPropertyKey", setEnterPropertyKey);
addNetworkEventHandler("agrp.skinSelect", toggleSkinSelect);
addNetworkEventHandler("agrp.hotbar", updatePlayerHotBar);
addNetworkEventHandler("agrp.showItemActionDelay", showItemActionDelay);
addNetworkEventHandler("agrp.set2DRendering", set2DRendering);
addNetworkEventHandler("agrp.mouseCameraForce", setMouseCameraState);
addNetworkEventHandler("agrp.logLevel", setLogLevel);
addNetworkEventHandler("agrp.hideAllGUI", hideAllGUI);
addNetworkEventHandler("agrp.nametag", updatePlayerNameTag);
addNetworkEventHandler("agrp.nametagDistance", setNameTagDistance);
addNetworkEventHandler("agrp.ping", updatePlayerPing);
addNetworkEventHandler("agrp.anim", makePedPlayAnimation);
addNetworkEventHandler("agrp.stopAnim", makePedStopAnimation);
addNetworkEventHandler("agrp.forceAnim", forcePedAnimation);
addNetworkEventHandler("agrp.clientInfo", serverRequestedClientInfo);
addNetworkEventHandler("agrp.interiorLights", updateInteriorLightsState);
addNetworkEventHandler("agrp.cutsceneInterior", setCutsceneInterior);
addNetworkEventHandler("agrp.syncElement", forceSyncElementProperties);
addNetworkEventHandler("agrp.elementPosition", setElementPosition);
addNetworkEventHandler("agrp.elementCollisions", setElementCollisionsEnabled);
addNetworkEventHandler("agrp.vehBuyState", setVehiclePurchaseState);
addNetworkEventHandler("agrp.holdObject", makePedHoldObject);
addNetworkEventHandler("agrp.profanityFilter", setProfanityFilterState);
addNetworkEventHandler("v.rp.mouseCursor", toggleMouseCursor);
addNetworkEventHandler("v.rp.mouseCamera", toggleMouseCamera);
addNetworkEventHandler("v.rp.mouseCameraForce", setMouseCameraState);
addNetworkEventHandler("v.rp.clearPeds", clearLocalPlayerOwnedPeds);
addNetworkEventHandler("v.rp.clearPickups", clearLocalPlayerOwnedPickups);
addNetworkEventHandler("v.rp.ambience", setCityAmbienceState);
addNetworkEventHandler("v.rp.runCode", runClientCode);
addNetworkEventHandler("v.rp.minuteDuration", setMinuteDuration);
addNetworkEventHandler("v.rp.snow", setSnowState);
addNetworkEventHandler("v.rp.enterPropertyKey", setEnterPropertyKey);
addNetworkEventHandler("v.rp.skinSelect", toggleSkinSelect);
addNetworkEventHandler("v.rp.hotbar", updatePlayerHotBar);
addNetworkEventHandler("v.rp.logLevel", setLogLevel);
addNetworkEventHandler("v.rp.hideAllGUI", hideAllGUI);
addNetworkEventHandler("v.rp.ping", updatePlayerPing);
addNetworkEventHandler("v.rp.clientInfo", serverRequestedClientInfo);
addNetworkEventHandler("v.rp.interiorLights", updateInteriorLightsState);
addNetworkEventHandler("v.rp.scene", changeScene);
addNetworkEventHandler("v.rp.syncElement", forceSyncElementProperties);
addNetworkEventHandler("v.rp.elementPosition", setElementPosition);
addNetworkEventHandler("v.rp.elementCollisions", setElementCollisionsEnabled);
addNetworkEventHandler("v.rp.holdObject", makePedHoldObject);
addNetworkEventHandler("v.rp.profanityFilter", setProfanityFilterState);
addNetworkEventHandler("v.rp.currencyString", receiveCurrencyStringFromServer);
addNetworkEventHandler("v.rp.token", serverRequestedToken);
}
// ===========================================================================
function sendResourceReadySignalToServer() {
sendNetworkEventToServer("agrp.clientReady");
sendNetworkEventToServer("v.rp.clientReady");
}
// ===========================================================================
function sendResourceStartedSignalToServer() {
sendNetworkEventToServer("agrp.clientStarted");
sendNetworkEventToServer("v.rp.clientStarted");
}
// ===========================================================================
function sendResourceStoppedSignalToServer() {
if (isConnected) {
sendNetworkEventToServer("agrp.clientStopped");
sendNetworkEventToServer("v.rp.clientStopped");
}
}
// ===========================================================================
function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
logToConsole(LOG_DEBUG, `[AGRP.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`);
renderHUD = hudState;
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
natives.displayCash(hudState);
natives.displayAmmo(hudState);
natives.displayHud(hudState);
@@ -206,7 +213,7 @@ function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardS
// ===========================================================================
function onServerSpawnedLocalPlayer(state) {
logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`);
logToConsole(LOG_DEBUG, `[AGRP.Main] Setting spawned state to ${state}`);
isSpawned = state;
setUpInitialGame();
if (state) {
@@ -231,19 +238,19 @@ function onServerSpawnedLocalPlayer(state) {
// ===========================================================================
function tellServerPlayerUsedKeyBind(key) {
sendNetworkEventToServer("agrp.useKeyBind", key);
sendNetworkEventToServer("v.rp.useKeyBind", key);
}
// ===========================================================================
function tellServerPlayerArrivedAtJobRouteLocation() {
sendNetworkEventToServer("agrp.arrivedAtJobRouteLocation");
sendNetworkEventToServer("v.rp.arrivedAtJobRouteLocation");
}
// ===========================================================================
function tellServerItemActionDelayComplete() {
sendNetworkEventToServer("agrp.itemActionDelayComplete");
sendNetworkEventToServer("v.rp.itemActionDelayComplete");
}
// ===========================================================================
@@ -253,13 +260,13 @@ function sendServerClientInfo() {
if (typeof CLIENT_VERSION_MAJOR != "undefined") {
clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`;
}
sendNetworkEventToServer("agrp.clientInfo", clientVersion, game.width, game.height);
sendNetworkEventToServer("v.rp.clientInfo", clientVersion, game.width, game.height);
}
// ===========================================================================
function sendServerNewAFKStatus(state) {
sendNetworkEventToServer("agrp.afk", state);
sendNetworkEventToServer("v.rp.afk", state);
}
// ===========================================================================
@@ -298,16 +305,6 @@ function forceSyncElementProperties(elementId) {
// ===========================================================================
function setElementCollisionsEnabled(elementId, state) {
if (getElementFromId(elementId) == null) {
return false;
}
getElementFromId(elementId).collisionsEnabled = state;
}
// ===========================================================================
function setLocalPlayerArmour(armour) {
if (typeof localPlayer.armour != "undefined") {
localPlayer.armour = armour;
@@ -330,7 +327,7 @@ function setLogLevel(level) {
function setLocalPlayerInfiniteRun(state) {
if (localPlayer != null) {
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
if (getGame() == V_GAME_GTA_III || getGame() == V_GAME_GTA_VC) {
game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state));
}
}
@@ -339,8 +336,8 @@ function setLocalPlayerInfiniteRun(state) {
// ===========================================================================
function setLocalPlayerSkin(skinId) {
logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`);
if (getGame() == AGRP_GAME_GTA_IV) {
logToConsole(LOG_INFO, `[AGRP.Server] Setting locale player skin to ${skinId}`);
if (getGame() == V_GAME_GTA_IV) {
if (natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);
natives.loadAllObjectsNow();
@@ -356,7 +353,7 @@ function setLocalPlayerSkin(skinId) {
// ===========================================================================
function makePedHoldObject(pedId, modelIndex) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1])
}
}
@@ -364,13 +361,15 @@ function makePedHoldObject(pedId, modelIndex) {
// ===========================================================================
function sendLocalPlayerNetworkIdToServer() {
sendNetworkEventToServer("agrp.playerPedId", natives.getNetworkIdFromPed(localPlayer));
if (getGame() == V_GAME_GTA_IV || getGame() == V_GAME_GTA_IV_EFLC) {
sendNetworkEventToServer("v.rp.playerPedId", natives.getNetworkIdFromPed(localPlayer));
}
}
// ===========================================================================
function setCutsceneInterior(cutsceneName) {
if (getGame() == AGRP_GAME_GTA_IV) {
function changeScene(sceneName) {
if (getGame() == V_GAME_GTA_IV) {
if (cutsceneName == "") {
natives.clearCutscene();
} else {
@@ -379,13 +378,15 @@ function setCutsceneInterior(cutsceneName) {
}
natives.initCutscene(cutsceneName);
}
} else if (getGame() == V_GAME_MAFIA_ONE) {
game.changeMap(sceneName);
}
}
// ===========================================================================
function makeLocalPlayerPedSpeak(speechName) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
// if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo)
// Only speeches with _MEGAPHONE will have the bullhorn effect
// Afaik it only works on police voices anyway
@@ -394,7 +395,7 @@ function makeLocalPlayerPedSpeak(speechName) {
} else {
natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1);
}
} else if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
} else if (getGame() == V_GAME_GTA_III || getGame() == V_GAME_GTA_VC) {
// Don't have a way to get the ped ref ID and can't use ped in arg
//game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int);
}
@@ -403,7 +404,7 @@ function makeLocalPlayerPedSpeak(speechName) {
// ===========================================================================
function setLocalPlayerAsCopState(state) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
natives.setPlayerAsCop(natives.getPlayerId(), state);
natives.setPoliceIgnorePlayer(natives.getPlayerId(), state);
}
@@ -412,7 +413,7 @@ function setLocalPlayerAsCopState(state) {
// ===========================================================================
function serverRequestedLocalPlayerSpawn(skinId, position) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
natives.createPlayer(skinId, position);
//if(isCustomCameraSupported()) {
// game.restoreCamera(true);
@@ -423,7 +424,7 @@ function serverRequestedLocalPlayerSpawn(skinId, position) {
// ===========================================================================
function sendLocaleSelectToServer(localeId) {
sendNetworkEventToServer("agrp.localeSelect", localeId);
sendNetworkEventToServer("v.rp.localeSelect", localeId);
}
// ===========================================================================
@@ -435,4 +436,35 @@ function clearLocalPlayerOwnedPickups() {
}
}
// ===========================================================================
function receiveCurrencyStringFromServer(newCurrencyString) {
currencyString = newCurrencyString;
}
// ===========================================================================
function setMapChangeWarningState(state) {
mapChangeWarning = state;
}
// ===========================================================================
function updatePlayerPing(playerName, ping) {
playerPing[playerName] = ping;
}
// ===========================================================================
function receiveClientVariablesFromServer(clientVariablesString) {
serverData.cvars = JSON.parse(clientVariablesString);
}
// ===========================================================================
function serverRequestedToken() {
let token = loadToken();
sendNetworkEventToServer("v.rp.token", token);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: npc.js
// DESC: Provides NPC functions and processing
@@ -10,7 +9,7 @@
function processNPCMovement(npc) {
//if(npc.isSyncer == true) {
if (getEntityData(npc, "agrp.lookAtClosestPlayer") == true) {
if (getEntityData(npc, "v.rp.lookAtClosestPlayer") == true) {
let closestPlayer = getClosestPlayer(getElementPosition(npc.id));
setPedLookAt(npc, getElementPosition(closestPlayer.id));
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: object.js
// DESC: Provides object functions and processing
@@ -20,7 +19,7 @@ function startMovingObject(object) {
function stopMovingObject(object, save = true) {
if (save) {
sendNetworkEventToServer("agrp.objectSave", object.id, object.position, object.rotation);
sendNetworkEventToServer("v.rp.objectSave", object.id, object.position, object.rotation);
}
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: radio.js
// DESC: Provides internet streaming radio functions and usage
@@ -44,4 +43,8 @@ function playAudioFile(audioName, loop, volume) {
findResourceByName("connectedrp-extra").exports.playCustomAudio(audioName, volume / 100, loop);
}
// ===========================================================================
// ===========================================================================
function getStreamingRadioVolumeForPosition(position1, position2) {
return false;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: scoreboard.js
// DESC: Provides scoreboard features and rendering
@@ -18,10 +17,10 @@ let scoreboardKey = SDLK_TAB;
// ===========================================================================
function initScoreBoardScript() {
logToConsole(LOG_DEBUG, "[VRR.ScoreBoard]: Initializing scoreboard script ...");
logToConsole(LOG_DEBUG, "[AGRP.ScoreBoard]: Initializing scoreboard script ...");
scoreBoardTitleFont = initScoreBoardTitleFont();
scoreBoardListFont = initScoreBoardListFont();
logToConsole(LOG_DEBUG, "[VRR.ScoreBoard]: Scoreboard script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.ScoreBoard]: Scoreboard script initialized!");
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: skin-select.js
// DESC: Provides skin-selector functions and usage
@@ -11,7 +10,7 @@
let skinSelectMessageFontTop = null;
let skinSelectMessageFontBottom = null;
let skinSelectMessageTextTop = "Skin Name";
let skinSelectMessageTextBottom = "Choose a skin using PAGEUP and PAGEDOWN keys. Use ENTER to finish or BACKSPACE to cancel.";
let skinSelectMessageTextBottom = "Choose a skin using LEFT and RIGHT arrow keys. Use ENTER to finish or BACKSPACE to cancel.";
let skinSelectMessageColourTop = COLOUR_YELLOW;
let skinSelectMessageColourBottom = COLOUR_WHITE;
@@ -24,10 +23,10 @@ let skinSelectHeading = null;
// ===========================================================================
function initSkinSelectScript() {
logToConsole(LOG_DEBUG, "[VRR.SkinSelect]: Initializing skin selector script ...");
logToConsole(LOG_DEBUG, "[AGRP.SkinSelect]: Initializing skin selector script ...");
skinSelectMessageFontTop = loadSkinSelectMessageFontTop();
skinSelectMessageFontBottom = loadSkinSelectMessageFontBottom();
logToConsole(LOG_DEBUG, "[VRR.SkinSelect]: Skin selector script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.SkinSelect]: Skin selector script initialized!");
}
// ===========================================================================
@@ -46,7 +45,7 @@ function loadSkinSelectMessageFontBottom() {
function processSkinSelectKeyPress(keyCode) {
if (usingSkinSelector) {
if (keyCode == SDLK_LEFT || keyCode == SDLK_A) {
if (keyCode == getKeyIdFromParams("left") || keyCode == getKeyIdFromParams("a")) {
if (skinSelectorIndex >= allowedSkins.length - 1) {
skinSelectorIndex = 1;
} else {
@@ -55,7 +54,7 @@ function processSkinSelectKeyPress(keyCode) {
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]);
} else if (keyCode == SDLK_RIGHT || keyCode == SDLK_D) {
} else if (keyCode == getKeyIdFromParams("right") || keyCode == getKeyIdFromParams("d")) {
if (skinSelectorIndex <= 0) {
skinSelectorIndex = allowedSkins.length - 1;
} else {
@@ -64,16 +63,19 @@ function processSkinSelectKeyPress(keyCode) {
logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`);
skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1];
setLocalPlayerSkin(allowedSkins[skinSelectorIndex][0]);
} else if (keyCode == SDLK_RETURN) {
sendNetworkEventToServer("agrp.skinSelected", skinSelectorIndex);
} else if (keyCode == getKeyIdFromParams("enter")) {
sendNetworkEventToServer("v.rp.skinSelected", skinSelectorIndex);
toggleSkinSelect(false);
return true;
} else if (keyCode == SDLK_BACKSPACE) {
sendNetworkEventToServer("agrp.skinSelected", -1);
} else if (keyCode == getKeyIdFromParams("backspace")) {
sendNetworkEventToServer("v.rp.skinSelected", -1);
toggleSkinSelect(false);
return true;
}
localPlayer.heading = skinSelectHeading;
if (getGame() <= V_GAME_GTA_SA) {
localPlayer.heading = skinSelectHeading;
}
}
}
@@ -104,13 +106,21 @@ function toggleSkinSelect(state) {
skinSelectHeading = localPlayer.heading;
if (isCustomCameraSupported()) {
let tempPosition = localPlayer.position;
tempPosition.z += 0.5;
let frontCameraPosition = getPosInFrontOfPos(tempPosition, localPlayer.heading, 3);
game.setCameraLookAt(frontCameraPosition, localPlayer.position, true);
let cameraPosition = localPlayer.position;
let playerPosition = localPlayer.position;
if (getGame() == V_GAME_MAFIA_ONE) {
cameraPosition.y += 1.5;
playerPosition.y += 1.5;
distance = 3;
} else {
cameraPosition.z += 0.5;
distance = 3;
}
let frontCameraPosition = getPosInFrontOfPos(cameraPosition, localPlayer.heading, distance);
game.setCameraLookAt(frontCameraPosition, playerPosition, true);
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
let skinId = allowedSkins[skinSelectorIndex][0];
if (natives.isModelInCdimage(skinId)) {
natives.requestModel(skinId);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: startup.js
// DESC: Provides startup/shutdown procedures
@@ -13,7 +12,7 @@ function initClientScripts() {
initNameTagScript();
initScoreBoardScript();
initMessagingScript();
initServerScript();
initNetworkEventsScript();
initLogoScript();
initLabelScript();
initChatBoxScript();
@@ -21,12 +20,15 @@ function initClientScripts() {
initKeyBindScript();
initEventScript();
initSkinSelectScript();
initCursorScript();
addAllNetworkHandlers();
}
// ===========================================================================
function setUpInitialGame() {
if (getGame() == AGRP_GAME_GTA_III) {
if (getGame() == V_GAME_GTA_III) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA III ...");
// Turn off unlimited sprint
@@ -45,7 +47,7 @@ function setUpInitialGame() {
// Provided by mouse camera script (mousecam.js)
SetStandardControlsEnabled(true);
} else if (getGame() == AGRP_GAME_GTA_VC) {
} else if (getGame() == V_GAME_GTA_VC) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA Vice City ...");
// Turn off unlimited sprint
@@ -88,7 +90,7 @@ function setUpInitialGame() {
// Provided by mouse camera script (mousecam.js)
SetStandardControlsEnabled(true);
} else if (getGame() == AGRP_GAME_GTA_SA) {
} else if (getGame() == V_GAME_GTA_SA) {
logToConsole(LOG_DEBUG | LOG_WARN, "Setting up initial game stuff for GTA San Andreas ...");
// Turn weapon skills down a bit
game.setGameStat(STAT_WEAPONTYPE_PISTOL_SKILL, 400);
@@ -125,7 +127,7 @@ function setUpInitialGame() {
// Disables taxi/vigilante/etc and other start mission triggers
game.onMission = true;
} else if (getGame() == AGRP_GAME_GTA_IV) {
} else if (getGame() == V_GAME_GTA_IV) {
natives.allowEmergencyServices(false);
natives.setCreateRandomCops(true);
natives.setMaxWantedLevel(0);
@@ -187,7 +189,7 @@ function setUpInitialGame() {
// Some last steps
//natives.loadAllObjectsNow();
} else if (getGame() == AGRP_GAME_MAFIA_ONE) {
} else if (getGame() == V_GAME_MAFIA_ONE) {
game.mapEnabled = false;
game.setTrafficEnabled(false);
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: sync.js
// DESC: Provides some elements and data sync
@@ -11,12 +10,12 @@
function processSync(event, deltaTime) {
if (localPlayer != null) {
if (!areServerElementsSupported()) {
sendNetworkEventToServer("agrp.plr.pos", (localPlayer.vehicle != null) ? localPlayer.vehicle.position : localPlayer.position);
sendNetworkEventToServer("agrp.plr.rot", (localPlayer.vehicle != null) ? localPlayer.vehicle.heading : localPlayer.heading);
sendNetworkEventToServer("v.rp.plr.pos", (localPlayer.vehicle != null) ? localPlayer.vehicle.position : localPlayer.position);
sendNetworkEventToServer("v.rp.plr.rot", (localPlayer.vehicle != null) ? localPlayer.vehicle.heading : localPlayer.heading);
//if(localPlayer.vehicle != null) {
// sendNetworkEventToServer("agrp.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position);
// sendNetworkEventToServer("agrp.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading);
// sendNetworkEventToServer("v.rp.veh.pos", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.position);
// sendNetworkEventToServer("v.rp.veh.rot", getVehicleForNetworkEvent(localPlayer.vehicle), localPlayer.vehicle.heading);
//}
}
@@ -25,7 +24,7 @@ function processSync(event, deltaTime) {
logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons();
calledDeathEvent = true;
sendNetworkEventToServer("agrp.playerDeath");
sendNetworkEventToServer("v.rp.playerDeath");
}
}
}
@@ -35,12 +34,11 @@ function processSync(event, deltaTime) {
logToConsole(LOG_DEBUG, `Local player died`);
localPlayer.clearWeapons();
calledDeathEvent = true;
sendNetworkEventToServer("agrp.playerDeath");
sendNetworkEventToServer("v.rp.playerDeath");
}
}
if (streamingRadioElement) {
streamingRadio.position = getElementPosition(streamingRadioElement.id);
//streamingRadio.volume = getStreamingRadioVolumeForPosition(streamingRadio.position);
}
}
@@ -48,25 +46,15 @@ function processSync(event, deltaTime) {
// ===========================================================================
function setVehicleLights(vehicleId, state) {
if (getGame() != AGRP_GAME_MAFIA_ONE) {
if (!state) {
getElementFromId(vehicleId).lightStatus = 2;
} else {
getElementFromId(vehicleId).lightStatus = 1;
}
} else if (getGame() == AGRP_GAME_GTA_IV) {
if (!state) {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
} else {
natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
}
} else {
if (!state) {
getElementFromId(vehicleId).lights = false;
} else {
getElementFromId(vehicleId).lights = true;
}
}
//if (getGame() == V_GAME_GTA_IV) {
// if (!state) {
// natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 0));
// } else {
// natives.forceCarLights(natives.getVehicleFromNetworkId(vehicleId, 1));
// }
//} else {
getElementFromId(vehicleId).lights = state;
//}
}
// ===========================================================================
@@ -82,54 +70,55 @@ function syncVehicleProperties(vehicle) {
return false;
}
if (doesEntityDataExist(vehicle, "agrp.lights")) {
let lightStatus = getEntityData(vehicle, "agrp.lights");
if (!lightStatus) {
vehicle.lightStatus = 2;
} else {
vehicle.lightStatus = 1;
}
if (doesEntityDataExist(vehicle, "v.rp.lights")) {
let lightStatus = getEntityData(vehicle, "v.rp.lights");
vehicle.lights = lightStatus;
}
if (doesEntityDataExist(vehicle, "agrp.invincible")) {
let invincible = getEntityData(vehicle, "agrp.invincible");
if (doesEntityDataExist(vehicle, "v.rp.locked")) {
let lockStatus = getEntityData(vehicle, "v.rp.locked");
vehicle.locked = lockStatus;
}
if (doesEntityDataExist(vehicle, "v.rp.invincible")) {
let invincible = getEntityData(vehicle, "v.rp.invincible");
element.setProofs(invincible, invincible, invincible, invincible, invincible);
}
if (doesEntityDataExist(vehicle, "agrp.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "agrp.panelStatus");
if (doesEntityDataExist(vehicle, "v.rp.panelStatus")) {
let panelsStatus = getEntityData(vehicle, "v.rp.panelStatus");
for (let i in panelsStatus) {
vehicle.setPanelStatus(i, panelsStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "agrp.wheelStatus");
if (doesEntityDataExist(vehicle, "v.rp.wheelStatus")) {
let wheelsStatus = getEntityData(vehicle, "v.rp.wheelStatus");
for (let i in wheelsStatus) {
vehicle.setWheelStatus(i, wheelsStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.lightStatus")) {
let lightStatus = getEntityData(vehicle, "agrp.lightStatus");
if (doesEntityDataExist(vehicle, "v.rp.lightStatus")) {
let lightStatus = getEntityData(vehicle, "v.rp.lightStatus");
for (let i in lightStatus) {
vehicle.setLightStatus(i, lightStatus[i]);
}
}
if (doesEntityDataExist(vehicle, "agrp.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "agrp.suspensionHeight");
if (doesEntityDataExist(vehicle, "v.rp.suspensionHeight")) {
let suspensionHeight = getEntityData(vehicle, "v.rp.suspensionHeight");
vehicle.setSuspensionHeight(suspensionHeight);
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (isGameFeatureSupported("vehicleUpgrades")) {
//let allUpgrades = getGameConfig().vehicleUpgrades[getGame()];
//for(let i in allUpgrades) {
// vehicle.removeUpgrade(i);
//}
if (doesEntityDataExist(vehicle, "agrp.upgrades")) {
let upgrades = getEntityData(vehicle, "agrp.upgrades");
if (doesEntityDataExist(vehicle, "v.rp.upgrades")) {
let upgrades = getEntityData(vehicle, "v.rp.upgrades");
for (let i in upgrades) {
if (upgrades[i] != 0) {
vehicle.addUpgrade(upgrades[i]);
@@ -138,12 +127,12 @@ function syncVehicleProperties(vehicle) {
}
}
if (getGame() == AGRP_GAME_GTA_SA || getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "agrp.livery")) {
let livery = getEntityData(vehicle, "agrp.livery");
if (getGame() == AGRP_GAME_GTA_SA) {
if (getGame() == V_GAME_GTA_SA || getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(vehicle, "v.rp.livery")) {
let livery = getEntityData(vehicle, "v.rp.livery");
if (getGame() == V_GAME_GTA_SA) {
vehicle.setPaintJob(livery);
} else if (getGame() == AGRP_GAME_GTA_IV) {
} else if (getGame() == V_GAME_GTA_IV) {
vehicle.livery = livery;
}
}
@@ -157,9 +146,9 @@ function syncCivilianProperties(civilian) {
return false;
}
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.scale")) {
let scaleFactor = getEntityData(civilian, "agrp.scale");
if (isGameFeatureSupported("pedScale")) {
if (doesEntityDataExist(civilian, "v.rp.scale")) {
let scaleFactor = getEntityData(civilian, "v.rp.scale");
let tempMatrix = civilian.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = civilian.position;
@@ -169,79 +158,79 @@ function syncCivilianProperties(civilian) {
}
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "agrp.fightStyle")) {
let fightStyle = getEntityData(civilian, "agrp.fightStyle");
if (getGame() == V_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "v.rp.fightStyle")) {
let fightStyle = getEntityData(civilian, "v.rp.fightStyle");
civilian.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(civilian, "agrp.walkStyle")) {
let walkStyle = getEntityData(civilian, "agrp.walkStyle");
if (getGame() == V_GAME_GTA_SA) {
if (doesEntityDataExist(civilian, "v.rp.walkStyle")) {
let walkStyle = getEntityData(civilian, "v.rp.walkStyle");
civilian.walkStyle = walkStyle;
}
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "agrp.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "agrp.bodyPropHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(civilian, "v.rp.bodyPropHair")) {
let bodyPropHair = getEntityData(civilian, "v.rp.bodyPropHair");
civilian.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "agrp.bodyPropHead");
if (doesEntityDataExist(civilian, "v.rp.bodyPropHead")) {
let bodyPropHead = getEntityData(civilian, "v.rp.bodyPropHead");
civilian.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "agrp.bodyPropEyes");
if (doesEntityDataExist(civilian, "v.rp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(civilian, "v.rp.bodyPropEyes");
civilian.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "agrp.bodyPropLeftHand");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(civilian, "v.rp.bodyPropLeftHand");
civilian.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "agrp.bodyPropRightHand");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(civilian, "v.rp.bodyPropRightHand");
civilian.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "agrp.bodyPropLeftWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(civilian, "v.rp.bodyPropLeftWrist");
civilian.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "v.rp.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(civilian, "v.rp.bodyPropRightWrist");
civilian.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "agrp.bodyPropHip");
if (doesEntityDataExist(civilian, "v.rp.bodyPropHip")) {
let bodyPropHip = getEntityData(civilian, "v.rp.bodyPropHip");
civilian.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "agrp.bodyPropLeftFoot");
if (doesEntityDataExist(civilian, "v.rp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(civilian, "v.rp.bodyPropLeftFoot");
civilian.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if (doesEntityDataExist(civilian, "agrp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "agrp.bodyPropRightFoot");
if (doesEntityDataExist(civilian, "v.rp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(civilian, "v.rp.bodyPropRightFoot");
civilian.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
if (doesEntityDataExist(civilian, "agrp.anim")) {
let animationSlot = getEntityData(civilian, "agrp.anim");
if (doesEntityDataExist(civilian, "v.rp.anim")) {
let animationSlot = getEntityData(civilian, "v.rp.anim");
let animationData = getAnimationData(animationSlot);
civilian.addAnimation(animationData.groupId, animationData.animId);
}
@@ -249,14 +238,34 @@ function syncCivilianProperties(civilian) {
// ===========================================================================
function syncObjectProperties(object) {
if (!areServerElementsSupported()) {
return false;
}
if (isGameFeatureSupported("objectScale")) {
if (doesEntityDataExist(object, "v.rp.scale")) {
let scaleFactor = getEntityData(object, "v.rp.scale");
let tempMatrix = object.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = object.position;
object.matrix = tempMatrix;
tempPosition.z += scaleFactor.z;
object.position = tempPosition;
}
}
}
// ===========================================================================
function syncPlayerProperties(player) {
if (!areServerElementsSupported()) {
return false;
}
if (getGame() == AGRP_GAME_GTA_III) {
if (doesEntityDataExist(player, "agrp.scale")) {
let scaleFactor = getEntityData(player, "agrp.scale");
if (isGameFeatureSupported("pedScale")) {
if (doesEntityDataExist(player, "v.rp.scale")) {
let scaleFactor = getEntityData(player, "v.rp.scale");
let tempMatrix = player.matrix;
tempMatrix.setScale(toVector3(scaleFactor.x, scaleFactor.y, scaleFactor.z));
let tempPosition = player.position;
@@ -266,95 +275,95 @@ function syncPlayerProperties(player) {
}
}
if (getGame() == AGRP_GAME_GTA_SA) {
if (doesEntityDataExist(player, "agrp.fightStyle")) {
let fightStyle = getEntityData(player, "agrp.fightStyle");
if (getGame() == V_GAME_GTA_SA) {
if (doesEntityDataExist(player, "v.rp.fightStyle")) {
let fightStyle = getEntityData(player, "v.rp.fightStyle");
player.setFightStyle(fightStyle[0], fightStyle[1]);
}
}
//if(getGame() == AGRP_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "agrp.walkStyle")) {
// let walkStyle = getEntityData(player, "agrp.walkStyle");
//if(getGame() == V_GAME_GTA_SA) {
// if(doesEntityDataExist(player, "v.rp.walkStyle")) {
// let walkStyle = getEntityData(player, "v.rp.walkStyle");
// player.walkStyle = walkStyle;
// }
//}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(player, "v.rp.bodyPartHair")) {
let bodyPartHead = getEntityData(player, "v.rp.bodyPartHair");
player.changeBodyPart(0, bodyPartHead[0], bodyPartHair[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "agrp.bodyPartHead");
if (doesEntityDataExist(player, "v.rp.bodyPartHead")) {
let bodyPartHead = getEntityData(player, "v.rp.bodyPartHead");
player.changeBodyPart(1, bodyPartHead[0], bodyPartHead[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "agrp.bodyPartUpper");
if (doesEntityDataExist(player, "v.rp.bodyPartUpper")) {
let bodyPartUpper = getEntityData(player, "v.rp.bodyPartUpper");
player.changeBodyPart(1, bodyPartUpper[0], bodyPartUpper[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "agrp.bodyPartLower");
if (doesEntityDataExist(player, "v.rp.bodyPartLower")) {
let bodyPartLower = getEntityData(player, "v.rp.bodyPartLower");
player.changeBodyPart(1, bodyPartLower[0], bodyPartLower[1]);
}
}
if (getGame() == AGRP_GAME_GTA_IV) {
if (doesEntityDataExist(player, "agrp.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "agrp.bodyPropHair");
if (getGame() == V_GAME_GTA_IV) {
if (doesEntityDataExist(player, "v.rp.bodyPropHair")) {
let bodyPropHair = getEntityData(player, "v.rp.bodyPropHair");
player.changeBodyProp(0, bodyPropHair[0], bodyPropHair[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "agrp.bodyPropHead");
if (doesEntityDataExist(player, "v.rp.bodyPropHead")) {
let bodyPropHead = getEntityData(player, "v.rp.bodyPropHead");
player.changeBodyProp(1, bodyPropHead[0], bodyPropHead[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "agrp.bodyPropEyes");
if (doesEntityDataExist(player, "v.rp.bodyPropEyes")) {
let bodyPropEyes = getEntityData(player, "v.rp.bodyPropEyes");
player.changeBodyProp(1, bodyPropEyes[0], bodyPropEyes[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "agrp.bodyPropLeftHand");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftHand")) {
let bodyPropLeftHand = getEntityData(player, "v.rp.bodyPropLeftHand");
player.changeBodyProp(1, bodyPropLeftHand[0], bodyPropLeftHand[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "agrp.bodyPropRightHand");
if (doesEntityDataExist(player, "v.rp.bodyPropRightHand")) {
let bodyPropRightHand = getEntityData(player, "v.rp.bodyPropRightHand");
player.changeBodyProp(1, bodyPropRightHand[0], bodyPropRightHand[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "agrp.bodyPropLeftWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftWrist")) {
let bodyPropLeftWrist = getEntityData(player, "v.rp.bodyPropLeftWrist");
player.changeBodyProp(1, bodyPropLeftWrist[0], bodyPropLeftWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "v.rp.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "agrp.bodyPropRightWrist");
if (doesEntityDataExist(player, "v.rp.bodyPropRightWrist")) {
let bodyPropRightWrist = getEntityData(player, "v.rp.bodyPropRightWrist");
player.changeBodyProp(1, bodyPropRightWrist[0], bodyPropRightWrist[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "agrp.bodyPropHip");
if (doesEntityDataExist(player, "v.rp.bodyPropHip")) {
let bodyPropHip = getEntityData(player, "v.rp.bodyPropHip");
player.changeBodyProp(1, bodyPropHip[0], bodyPropHip[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "agrp.bodyPropLeftFoot");
if (doesEntityDataExist(player, "v.rp.bodyPropLeftFoot")) {
let bodyPropLeftFoot = getEntityData(player, "v.rp.bodyPropLeftFoot");
player.changeBodyProp(1, bodyPropLeftFoot[0], bodyPropLeftFoot[1]);
}
if (doesEntityDataExist(player, "agrp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "agrp.bodyPropRightFoot");
if (doesEntityDataExist(player, "v.rp.bodyPropRightFoot")) {
let bodyPropRightFoot = getEntityData(player, "v.rp.bodyPropRightFoot");
player.changeBodyProp(1, bodyPropRightFoot[0], bodyPropRightFoot[1]);
}
}
@@ -367,13 +376,21 @@ function syncElementProperties(element) {
return false;
}
if (doesEntityDataExist(element, "agrp.interior")) {
if (typeof element.interior != "undefined") {
element.interior = getEntityData(element, "agrp.interior");
if (isGameFeatureSupported("interior")) {
if (doesEntityDataExist(element, "v.rp.interior")) {
if (typeof element.interior != "undefined") {
element.interior = getEntityData(element, "v.rp.interior");
}
}
}
if (getGame() == AGRP_GAME_MAFIA_ONE) {
if (isGameFeatureSupported("toggleCollision")) {
if (doesEntityDataExist(element, "v.rp.collisions")) {
element.collisionsEnabled = getEntityData(element, "v.rp.collisions");
}
}
if (getGame() == V_GAME_MAFIA_ONE) {
switch (element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
@@ -404,6 +421,10 @@ function syncElementProperties(element) {
syncPlayerProperties(element);
break;
case ELEMENT_OBJECT:
syncObjectProperties(element);
break;
default:
break;
}
@@ -414,7 +435,7 @@ function syncElementProperties(element) {
// ===========================================================================
function receiveHouseFromServer(houseId, entrancePosition, blipModel, pickupModel, hasInterior) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
}
}

View File

@@ -1,8 +0,0 @@
function getCurrentUnixTimeStampSquirrel() {
return time();
}
function getTimeStampOutput(timeStamp) {
local dateObj = date(timeStamp);
return dateObj.hour + ":" + dateObj.minute + ":" + dateObj.second;
}

20
scripts/client/token.js Normal file
View File

@@ -0,0 +1,20 @@
// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: token.js
// DESC: Provides "remember me" auto-login token system and functions
// TYPE: Client (JavaScript)
// ===========================================================================
function saveToken(token) {
saveDataToFile("config/client/token.js", token);
}
// ===========================================================================
function loadToken() {
return loadDataFromFile("config/client/token.js");
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: utilities.js
// DESC: Provides util functions and arrays with data
@@ -9,18 +8,19 @@
// ===========================================================================
function setLocalPlayerFrozenState(state) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting frozen state to ${state}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting frozen state to ${state}`);
gui.showCursor(state, !state);
}
// ===========================================================================
function setLocalPlayerControlState(controlState, cursorState = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
controlsEnabled = controlState;
if (getGame() == AGRP_GAME_GTA_III || getGame() == AGRP_GAME_GTA_VC) {
game.setPlayerControl(controlState);
if (getGame() == V_GAME_GTA_III || getGame() == V_GAME_GTA_VC) {
game.SET_PLAYER_CONTROL(game.GET_PLAYER_ID(), boolToInt(controlState));
} else if (getGame() != AGRP_GAME_GTA_IV) {
} else if (getGame() <= V_GAME_GTA_IV) {
setElementCollisionsEnabled(localPlayer, controlState);
setPedInvincible(localPlayer, true);
}
@@ -28,14 +28,15 @@ function setLocalPlayerControlState(controlState, cursorState = false) {
// ===========================================================================
function fadeLocalCamera(state, time) {
if (isFadeCameraSupported()) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Fading camera ${(state) ? "in" : "out"} for ${time} seconds`);
function fadeLocalCamera(state, duration, colour) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Fading camera ${(state) ? "in" : "out"} for ${time}ms`);
if (isFadeCameraSupported()) {
game.fadeCamera(state, time);
}
}
cameraFadeDuration = duration;
cameraFadeStart = sdl.ticks;
cameraFadeEnabled = true;
cameraFadeIn = state;
cameraFadeColour = colour;
cameraFadeAlpha = (state) ? 255 : 0;
}
// ===========================================================================
@@ -47,7 +48,7 @@ function removeLocalPlayerFromVehicle() {
// ===========================================================================
function restoreLocalCamera() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Camera restored`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Camera restored`);
if (isGameFeatureSupported("customCamera")) {
game.restoreCamera(true);
}
@@ -55,16 +56,8 @@ function restoreLocalCamera() {
// ===========================================================================
function clearLocalPlayerOwnedPeds() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[VRR.Utilities] All self-owned peds cleared`);
};
// ===========================================================================
function setLocalCameraLookAt(cameraPosition, cameraLookAt) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Set camera to look at [${cameraLookAt.x}, ${cameraLookAt.y}, ${cameraLookAt.z}] from [${cameraPosition.x}, ${cameraPosition.y}, ${cameraPosition.z}]`);
if (isCustomCameraSupported()) {
game.setCameraLookAt(cameraPosition, cameraLookAt, true);
}
@@ -72,13 +65,21 @@ function setLocalCameraLookAt(cameraPosition, cameraLookAt) {
// ===========================================================================
function clearLocalPlayerOwnedPeds() {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Clearing all self-owned peds ...`);
clearSelfOwnedPeds();
logToConsole(LOG_DEBUG, `[AGRP.Utilities] All self-owned peds cleared`);
};
// ===========================================================================
function setCityAmbienceState(state, clearElements = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Ambient civilians and traffic ${(state) ? "enabled" : "disabled"}`);
game.setTrafficEnabled(state);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
if (getMultiplayerMod() == V_MPMOD_GTAC) {
game.setGenerateCarsAroundCamera(state);
if (getGame() != AGRP_GAME_GTA_SA) {
if (getGame() != V_GAME_GTA_SA) {
game.setCiviliansEnabled(state);
}
@@ -96,7 +97,7 @@ function runClientCode(code, returnTo) {
try {
returnValue = eval("(" + code + ")");
} catch (error) {
sendNetworkEventToServer("agrp.runCodeFail", returnTo, error.toString());
sendNetworkEventToServer("v.rp.runCodeFail", returnTo, error.toString());
return false;
}
let returnValueString = returnValue;
@@ -105,7 +106,7 @@ function runClientCode(code, returnTo) {
} else {
returnValueString = "null/undefined";
}
sendNetworkEventToServer("agrp.runCodeSuccess", returnTo, returnValueString);
sendNetworkEventToServer("v.rp.runCodeSuccess", returnTo, returnValueString);
}
// ===========================================================================
@@ -113,7 +114,7 @@ function runClientCode(code, returnTo) {
function enterVehicleAsPassenger() {
if (localPlayer.vehicle == null) {
let tempVehicle = getClosestVehicle(localPlayer.position);
if (getGame() != AGRP_GAME_GTA_IV) {
if (getGame() != V_GAME_GTA_IV) {
if (tempVehicle != null) {
localPlayer.enterVehicle(tempVehicle, false);
}
@@ -133,15 +134,15 @@ function enterVehicleAsPassenger() {
// ===========================================================================
function giveLocalPlayerWeapon(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Giving weapon ${weaponId} with ${ammo} ammo`);
forceWeapon = weaponId;
if (getGame() == AGRP_GAME_MAFIA_ONE) {
if (getGame() == V_GAME_MAFIA_ONE) {
localPlayer.giveWeapon(weaponId, 0, ammo);
forceWeaponAmmo = 0;
forceWeaponClipAmmo = ammo;
} else {
localPlayer.giveWeapon(weaponId, ammo, active);
if (getGame() < AGRP_GAME_GTA_IV) {
if (getGame() < V_GAME_GTA_IV) {
forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(weaponId));
forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(weaponId));
} else {
@@ -154,7 +155,7 @@ function giveLocalPlayerWeapon(weaponId, ammo, active) {
// ===========================================================================
function clearLocalPlayerWeapons(clearData) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing weapons`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Clearing weapons`);
localPlayer.clearWeapons();
if (clearData == true) {
forceWeapon = 0;
@@ -172,7 +173,7 @@ function getClosestVehicle(pos) {
// ===========================================================================
function setLocalPlayerPosition(position) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting position to ${position.x}, ${position.y}, ${position.z}`);
if (typeof localPlayer.velocity != "undefined") {
localPlayer.velocity = toVector3(0.0, 0.0, 0.0);
}
@@ -185,7 +186,7 @@ function setLocalPlayerPosition(position) {
// ===========================================================================
function setLocalPlayerHeading(heading) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting heading to ${heading}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting heading to ${heading}`);
if (typeof localPlayer.heading != "undefined") {
localPlayer.heading = heading;
}
@@ -194,8 +195,8 @@ function setLocalPlayerHeading(heading) {
// ===========================================================================
function setLocalPlayerInterior(interior) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting interior to ${interior}`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting interior to ${interior}`);
if (getMultiplayerMod() == V_MPMOD_GTAC) {
if (!isGTAIV()) {
localPlayer.interior = interior;
game.cameraInterior = interior;
@@ -213,8 +214,8 @@ function setLocalPlayerInterior(interior) {
if (areServerElementsSupported() && isGameFeatureSupported("interior")) {
let vehicles = getElementsByType(ELEMENT_VEHICLE);
for (let i in vehicles) {
if (getEntityData(vehicles[i], "agrp.interior")) {
vehicles[i].interior = getEntityData(vehicles[i], "agrp.interior");
if (getEntityData(vehicles[i], "v.rp.interior")) {
vehicles[i].interior = getEntityData(vehicles[i], "v.rp.interior");
}
}
}
@@ -222,13 +223,16 @@ function setLocalPlayerInterior(interior) {
// ===========================================================================
function setSnowState(falling, ground) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting falling snow to ${falling} and ground snow to ${ground}`);
function setSnowState(falling, ground, forceGround) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting falling snow to ${falling} and ground snow to ${ground}`);
snowing = falling;
if (ground) {
forceSnowing(false);
forceSnowing(ground);
}
//snow.force = ground;
//if (forceGround == true) {
// forceSnowing(forceGround);
// groundSnow.flush();
//} else {
// snow.enabled = ground;
//}
}
// ===========================================================================
@@ -240,8 +244,8 @@ function setLocalPlayerHealth(health) {
// ===========================================================================
function playPedSpeech(pedName, speechId) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Making ${pedName}'s ped talk (${speechId})`);
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Making ${pedName}'s ped talk (${speechId})`);
if (getMultiplayerMod() == V_MPMOD_GTAC) {
game.SET_CHAR_SAY(int, int);
}
}
@@ -249,7 +253,7 @@ function playPedSpeech(pedName, speechId) {
// ===========================================================================
function clearLocalPedState() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Clearing local ped state`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Clearing local ped state`);
localPlayer.clearObjective();
}
@@ -262,8 +266,8 @@ function getWeaponSlot(weaponId) {
// ===========================================================================
function setLocalPlayerDrunkEffect(amount, duration) {
if (getMultiplayerMod() == AGRP_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Drunk effect set to ${amount} for ${duration} ms`);
if (getMultiplayerMod() == V_MPMOD_GTAC) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Drunk effect set to ${amount} for ${duration} ms`);
drunkEffectAmount = 0;
drunkEffectDurationTimer = setInterval(function () {
drunkEffectAmount = drunkEffectAmount;
@@ -313,7 +317,7 @@ function clearSelfOwnedVehicles() {
// ===========================================================================
function setMouseCameraState(state) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state) ? "Enabled" : "Disabled"} mouse camera`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] ${(state) ? "Enabled" : "Disabled"} mouse camera`);
mouseCameraEnabled = state;
SetStandardControlsEnabled(!mouseCameraEnabled);
}
@@ -321,50 +325,33 @@ function setMouseCameraState(state) {
// ===========================================================================
function toggleMouseCursor() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`);
gui.showCursor(!gui.cursorEnabled, gui.cursorEnabled);
}
// ===========================================================================
function toggleMouseCursor() {
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] ${(!gui.cursorEnabled) ? "Enabled" : "Disabled"} mouse cursor`);
setMouseCameraState(!mouseCameraEnabled);
}
// ===========================================================================
function setPlayerWeaponDamageEvent(clientName, eventType) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Set ${clientName} damage event type to ${eventType}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Set ${clientName} damage event type to ${eventType}`);
weaponDamageEvent[clientName] = eventType;
}
// ===========================================================================
function setPlayerWeaponDamageEnabled(clientName, state) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] ${(state) ? "Enabled" : "Disabled"} damage from ${clientName}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] ${(state) ? "Enabled" : "Disabled"} damage from ${clientName}`);
weaponDamageEnabled[clientName] = state;
}
// ===========================================================================
function setLocalPlayerCash(amount) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting local player money`);
if (localPlayer == null) {
return false;
}
if (typeof localPlayer.money != "undefined") {
localPlayer.money = toInteger(amount);
}
if (getGame() == AGRP_GAME_GTA_IV) {
natives.setMultiplayerHudCash(amount);
}
}
// ===========================================================================
function destroyAutoCreatedPickups() {
if (typeof ELEMENT_PICKUP != "undefined") {
getElementsByType(ELEMENT_PICKUP).forEach(function (pickup) {
@@ -411,21 +398,24 @@ function processWantedLevelReset() {
function processLocalPlayerVehicleControlState() {
if (areServerElementsSupported()) {
if (inVehicle && localPlayer.vehicle != null) {
if (doesEntityDataExist(localPlayer.vehicle, "agrp.engine")) {
if (getEntityData(localPlayer.vehicle, "agrp.engine") == false) {
if (localPlayer.vehicle != null) {
if (doesEntityDataExist(localPlayer.vehicle, "v.rp.engine")) {
if (getEntityData(localPlayer.vehicle, "v.rp.engine") == false) {
localPlayer.vehicle.engine = false;
//localPlayer.vehicle.netFlags.sendSync = false;
if (!localPlayer.vehicle.engine) {
if (typeof localPlayer.vehicle.velocity != "undefined") {
localPlayer.vehicle.velocity = toVector3(0.0, 0.0, 0.0);
localPlayer.vehicle.turnVelocity = toVector3(0.0, 0.0, 0.0);
}
//if(parkedVehiclePosition) {
//if (parkedVehiclePosition) {
// localPlayer.vehicle.position = parkedVehiclePosition;
// localPlayer.vehicle.heading = parkedVehicleHeading;
//}
}
} else {
//localPlayer.vehicle.netFlags.sendSync = true;
}
}
}
@@ -439,12 +429,12 @@ function forceLocalPlayerEquippedWeaponItem() {
if (forceWeapon != 0) {
if (localPlayer.weapon != forceWeapon) {
localPlayer.weapon = forceWeapon;
if (getGame() < AGRP_GAME_GTA_IV) {
if (getGame() < V_GAME_GTA_IV) {
localPlayer.setWeaponClipAmmunition(getWeaponSlot(forceWeapon), forceWeaponClipAmmo);
localPlayer.setWeaponAmmunition(getWeaponSlot(forceWeapon), forceWeaponAmmo);
}
} else {
//if(getGame() < AGRP_GAME_GTA_IV) {
//if(getGame() < V_GAME_GTA_IV) {
// forceWeaponClipAmmo = localPlayer.getWeaponClipAmmunition(getWeaponSlot(forceWeapon));
// forceWeaponAmmo = localPlayer.getWeaponAmmunition(getWeaponSlot(forceWeapon));
//}
@@ -471,7 +461,7 @@ function getLocalPlayerPosition() {
// ===========================================================================
function getVehicleForNetworkEvent(vehicle) {
if (getGame() == AGRP_GAME_GTA_IV) {
if (getGame() == V_GAME_GTA_IV) {
return natives.getNetworkIdFromVehicle(vehicle);
}
return vehicle.id;
@@ -480,7 +470,7 @@ function getVehicleForNetworkEvent(vehicle) {
// ===========================================================================
function setMinuteDuration(minuteDuration) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting minute duration to ${minuteDuration}ms`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting minute duration to ${minuteDuration}ms`);
if (isTimeSupported()) {
game.time.minuteDuration = minuteDuration;
@@ -543,7 +533,7 @@ function processNearbyPickups() {
//if(pickups[i].interior == localPlayer.interior && pickups[i].dimension == localPlayer.dimension) {
if (currentPickup != pickups[i]) {
currentPickup = pickups[i];
sendNetworkEventToServer("agrp.pickup", pickups[i].id);
sendNetworkEventToServer("v.rp.pickup", pickups[i].id);
}
//}
}
@@ -554,7 +544,7 @@ function processNearbyPickups() {
// ===========================================================================
function processGameSpecifics() {
if (getGame() < AGRP_GAME_GTA_IV) {
if (getGame() < V_GAME_GTA_IV) {
game.clearMessages();
}
@@ -574,4 +564,56 @@ function setProfanityFilterState(state) {
updateChatBox();
}
// ===========================================================================
function processVehicleCruiseControl() {
if (localPlayer.vehicle == null) {
return false;
}
if (!localPlayer.vehicle.isSyncer) {
return false;
}
if (getLocalPlayerVehicleSeat() != 0) {
return false;
}
if (cruiseControlEnabled) {
setVehicleSpeed(cruiseControlSpeed);
}
}
// ===========================================================================
function getCurrencyString(amount) {
let tempString = currencyString;
tempString = tempString.replace("{AMOUNT}", toString(makeLargeNumberReadable(amount)));
return tempString;
}
// ===========================================================================
function updateLocalPlayerMoney() {
if (localPlayer == null) {
return false;
}
if (typeof localPlayer.money != "undefined") {
localPlayer.money = toInteger(localPlayerMoney);
}
if (getGame() == V_GAME_GTA_IV) {
natives.setMultiplayerHudCash(localPlayerMoney);
}
}
// ===========================================================================
function setLocalPlayerMoney(amount) {
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Setting local player money`);
localPlayerMoney = amount;
updateLocalPlayerMoney();
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: vehicle.js
// DESC: Provides vehicle functions and arrays with data
@@ -31,9 +30,9 @@ class VehicleData {
// ===========================================================================
function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2, colour3 = 0, colour4 = 0, locked = false, lights = false, engine = false, licensePlate = "") {
logToConsole(LOG_DEBUG, `[VRR.Vehicle] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`);
logToConsole(LOG_DEBUG, `[AGRP.Vehicle] Received vehicle ${vehicleId} (${getVehicleNameFromModel(model, getGame())}) from server`);
if (getGame() != AGRP_GAME_GTA_IV) {
if (getGame() != V_GAME_GTA_IV) {
return false;
}
@@ -53,7 +52,7 @@ function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2,
let vehicle = natives.getVehicleFromNetworkId(vehicleId.ivNetworkId);
} else {
//logToConsole(LOG_DEBUG, `[VRR.Vehicle] Vehicle ${vehicleId} doesn't exist. Adding ...`);
//logToConsole(LOG_DEBUG, `[AGRP.Vehicle] Vehicle ${vehicleId} doesn't exist. Adding ...`);
//let tempVehicleData = new VehicleData(vehicleId, name, position, blipModel, pickupModel);
//vehicles.push(tempVehicleData);
@@ -64,20 +63,20 @@ function receiveVehicleFromServer(vehicleId, position, model, colour1, colour2,
// ===========================================================================
function processVehiclePurchasing() {
if (vehiclePurchaseState == AGRP_VEHBUYSTATE_TESTDRIVE) {
if (vehiclePurchaseState == V_VEHBUYSTATE_TESTDRIVE) {
if (getLocalPlayerVehicle() == false) {
vehiclePurchaseState = AGRP_VEHBUYSTATE_EXITVEH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_EXITVEH);
vehiclePurchaseState = V_VEHBUYSTATE_EXITVEH;
sendNetworkEventToServer("v.rp.vehBuyState", V_VEHBUYSTATE_EXITVEH);
return false;
} else {
if (vehiclePurchasing == getLocalPlayerVehicle()) {
if (getDistance(getLocalPlayerVehicle().position, vehiclePurchasePosition) >= 25) {
vehiclePurchaseState = AGRP_VEHBUYSTATE_FARENOUGH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_FARENOUGH);
vehiclePurchaseState = V_VEHBUYSTATE_FARENOUGH;
sendNetworkEventToServer("v.rp.vehBuyState", V_VEHBUYSTATE_FARENOUGH);
}
} else {
vehiclePurchaseState = AGRP_VEHBUYSTATE_WRONGVEH;
sendNetworkEventToServer("agrp.vehBuyState", AGRP_VEHBUYSTATE_WRONGVEH);
vehiclePurchaseState = V_VEHBUYSTATE_WRONGVEH;
sendNetworkEventToServer("v.rp.vehBuyState", V_VEHBUYSTATE_WRONGVEH);
}
}
}
@@ -131,14 +130,13 @@ function setAllVehicleDataIndexes() {
// ===========================================================================
function toggleVehicleCruiseControl(vehicle) {
if (!vehicle.isSyncer) {
function toggleLocalVehicleCruiseControl() {
if (!localPlayer.vehicle.isSyncer) {
return false;
}
cruiseControl = !cruiseControl;
cruiseControlEnabled = !cruiseControlEnabled;
cruiseControlSpeed = getVehicleSpeed(vehicle);
}
// ===========================================================================
@@ -155,7 +153,7 @@ function getVehicleSpeed(vehicle) {
speed = getLength(vecMoveSpeed[0], vecMoveSpeed[1], vecMoveSpeed[2]);
}
if (getGame() == AGRP_GAME_GTA_IV || getGame() == AGRP_GAME_GTA_IV_EFLC) {
if (getGame() == V_GAME_GTA_IV || getGame() == V_GAME_GTA_IV_EFLC) {
speed /= 40.0;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: accent.js
// DESC: Provides accent functions and usage

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: account.js
// DESC: Provides account functions and usage
@@ -9,35 +8,35 @@
// ===========================================================================
// Account Contact Types
const AGRP_CONTACT_NONE = 0;
const AGRP_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
const AGRP_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
const AGRP_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
const V_CONTACT_NONE = 0;
const V_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
const V_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
const V_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
// ===========================================================================
// Account Authentication Methods
const AGRP_ACCT_AUTHMETHOD_NONE = 0; // None
const AGRP_ACCT_AUTHMETHOD_EMAIL = 1; // Email
const AGRP_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
const AGRP_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
const AGRP_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
const AGRP_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
const V_ACCT_AUTHMETHOD_NONE = 0; // None
const V_ACCT_AUTHMETHOD_EMAIL = 1; // Email
const V_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
const V_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
const V_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
const V_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
// ===========================================================================
// Two-Factor Authentication States
const AGRP_2FA_STATE_NONE = 0; // None
const AGRP_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
const AGRP_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
const AGRP_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
const V_2FA_STATE_NONE = 0; // None
const V_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
const V_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
const V_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
// ===========================================================================
// Reset Password States
const AGRP_RESETPASS_STATE_NONE = 0; // None
const AGRP_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
const AGRP_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
const V_RESETPASS_STATE_NONE = 0; // None
const V_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
const V_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
// ===========================================================================
@@ -58,6 +57,7 @@ class AccountData {
this.ircAccount = "";
this.discordAccount = 0;
this.settings = 0;
this.seenActionTips = 0;
this.emailAddress = "";
this.ipAddress = 0;
@@ -87,6 +87,7 @@ class AccountData {
this.ircAccount = toInteger(dbAssoc["acct_irc"]);
this.discordAccount = toInteger(dbAssoc["acct_discord"]);
this.settings = toInteger(dbAssoc["acct_svr_settings"]);
this.seenActionTips = toInteger(dbAssoc["acct_svr_seen_action_tips"]);
this.emailAddress = toString(dbAssoc["acct_email"]);
this.ipAddress = toString(dbAssoc["acct_ip"]);
@@ -193,8 +194,8 @@ class AccountStaffNoteData {
// ===========================================================================
function initAccountScript() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Initializing account script ...");
logToConsole(LOG_DEBUG, "[VRR.Account]: Account script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Account]: Initializing account script ...");
logToConsole(LOG_DEBUG, "[AGRP.Account]: Account script initialized!");
}
// ===========================================================================
@@ -283,31 +284,31 @@ function toggleAccountGUICommand(command, params, client) {
if (doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softRed}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account OFF.`);
} else {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, getLocaleString(client, "GUIAccountSettingToggle", `{softGreen}${toUpperCase(getLocaleString(client, "On"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled GUI for their account ON.`);
}
if (!isPlayerLoggedIn(client)) {
if (getPlayerData().accountData.databaseId != 0) {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else {
hideAllPlayerGUI(client);
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "{ALTCOLOUR}/login{MAINCOLOUR}"));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
}
} else {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
hideAllPlayerGUI(client);
messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "{ALTCOLOUR}/register{MAINCOLOUR}"));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
}
}
@@ -322,11 +323,11 @@ function toggleAccountLoginAttemptNotificationsCommand(command, params, client)
if (doesPlayerHaveLoginAlertsEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You turned ${getBoolRedGreenInlineColour(false)}OFF{MAINCOLOUR} notification by email when somebody tries to login to your account`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerNormal(client, `⚙️ You turned ${getBoolRedGreenInlineColour(true)}ON{MAINCOLOUR} notification by email when somebody tries to login to your account`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled the login attempt email notifications OFF for their account`);
}
return true;
@@ -340,14 +341,14 @@ function toggleAccountServerLogoCommand(command, params, client) {
if (!doesPlayerHaveLogoEnabled(client)) {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "AccountServerLogoSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo ON for their account`);
if (getServerConfig().showLogo) {
updatePlayerShowLogoState(client, true);
}
} else {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "AccountServerLogoSet", `${getBoolRedGreenInlineColour(false)}${getLocaleString(client, "Off")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled the server logo OFF for their account`);
updatePlayerShowLogoState(client, false);
}
@@ -376,11 +377,11 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
if (!doesPlayerHaveTwoFactorAuthEnabled(client)) {
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "TwoFactorAuthSet", `${getBoolRedGreenInlineColour(true)}${getLocaleString(client, "On")}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication ON for their account`);
} else {
getPlayerData(client).accountData.settings = removeBitFlag(getPlayerData(client).accountData.settings, flagValue);
messagePlayerSuccess(client, getLocaleString(client, "TwoFactorAuthSet", `${getBoolRedGreenInlineColour(false)}${toUpperCase(getLocaleString(client, "Off"))}{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has toggled two-factor authentication OFF for their account`);
}
return true;
}
@@ -495,7 +496,7 @@ function changeAccountPasswordCommand(command, params, client) {
}
getPlayerData(client).accountData.password = hashAccountPassword(getPlayerData(client).accountData.name, params);
messagePlayerSuccess(client, `Your password has been changed!`);
messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged"));
}
// ===========================================================================
@@ -591,7 +592,7 @@ function verifyAccountEmailCommand(command, params, client) {
let verificationCode = getParam(params, " ", 1);
if (isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, `You already verified your email!`);
messagePlayerError(client, getLocaleString(client, "AccountEmailAlreadyVerified"));
return false;
}
@@ -644,7 +645,7 @@ function resetAccountPasswordCommand(command, params, client) {
// ===========================================================================
function setAccountDiscordCommand(command, params, client) {
messagePlayerError(client, `This command is not yet finished and will be available soon!`);
messagePlayerError(client, getLocaleString(client, "CommandDisabled"));
return false;
if (areParamsEmpty(params)) {
@@ -715,26 +716,23 @@ function isAccountPasswordCorrect(accountData, password) {
function loadAccountFromName(accountName, fullLoad = false) {
let dbConnection = connectToDatabase();
let dbAssoc = [];
if (dbConnection) {
accountName = escapeDatabaseString(dbConnection, accountName);
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_name = '${accountName}' LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if (dbQuery) {
if (dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempAccountData = new AccountData(dbAssoc);
if (fullLoad) {
tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId);
tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId);
}
freeDatabaseQuery(dbQuery);
return tempAccountData;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
let tempAccountData = new AccountData(dbAssoc[0]);
if (fullLoad) {
tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId);
tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
tempAccountData.contacts = loadAccountContactsFromDatabase(tempAccountData.databaseId);
}
return tempAccountData;
}
disconnectFromDatabase(dbConnection);
}
return false;
}
@@ -742,13 +740,13 @@ function loadAccountFromName(accountName, fullLoad = false) {
function loadAccountFromId(accountId, fullLoad = false) {
let dbConnection = connectToDatabase();
let dbAssoc = [];
if (dbConnection) {
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_id = ${accountId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString);
if (dbQuery) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempAccountData = new AccountData(dbAssoc);
freeDatabaseQuery(dbQuery);
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
let tempAccountData = new AccountData(dbAssoc[0]);
if (fullLoad) {
tempAccountData.messages = loadAccountMessagesFromDatabase(tempAccountData.databaseId);
tempAccountData.notes = loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
@@ -804,7 +802,7 @@ function getAccountHashingFunction() {
// ===========================================================================
function isNameRegistered(name) {
async function isNameRegistered(name) {
let accountData = loadAccountFromName(name, true);
if (accountData.databaseId > 0) {
return true;
@@ -830,7 +828,7 @@ function saltAccountInfo(name, password) {
// ===========================================================================
function loginSuccess(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} successfully logged in.`);
getPlayerData(client).loggedIn = true;
if (getPlayerData(client).loginTimeout != null) {
@@ -841,23 +839,23 @@ function loginSuccess(client) {
updateConnectionLogOnAuth(client, getPlayerData(client).accountData.databaseId);
if (doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
logToConsole(LOG_WARN, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
setPlayerNativeAdminState(client, true);
}
if (doesServerHaveTesterOnlyEnabled()) {
if (!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
setTimeout(function () {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
getPlayerData(client).customDisconnectReason = "NotATester";
disconnectPlayer(client);
}, 3500);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`);
showPlayerErrorGUI(client, getLocaleString(client, "NotATester"), getLocaleString(client, "AccessDenied"));
return false;
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
@@ -867,11 +865,11 @@ function loginSuccess(client) {
if (getPlayerData(client).subAccounts.length == 0) {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
getPlayerData(client).promptType = V_PROMPT_CREATEFIRSTCHAR;
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters message (GUI disabled)`);
}
} else {
showCharacterSelectToClient(client);
@@ -921,6 +919,7 @@ function saveAccountToDatabase(accountData) {
let data2 = [
["acct_svr_settings", (accountData.settings != NaN) ? toInteger(accountData.settings) : 0],
["acct_svr_seen_action_tips", (accountData.seenActionTips != NaN) ? toInteger(accountData.seenActionTips) : 0],
["acct_svr_staff_title", toString(safeStaffTitle)],
["acct_svr_staff_flags", (accountData.flags.admin != NaN) ? toInteger(accountData.flags.admin) : 0],
["acct_svr_mod_flags", (accountData.flags.moderation != NaN) ? toInteger(accountData.flags.moderation) : 0],
@@ -1034,7 +1033,7 @@ function saveAccountContactsToDatabase(accountContactData) {
// ===========================================================================
function createAccount(name, password, email = "") {
async function createAccount(name, password, email = "") {
let dbConnection = connectToDatabase();
if (dbConnection) {
@@ -1064,41 +1063,41 @@ function createAccount(name, password, email = "") {
function checkLogin(client, password) {
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1;
if (getPlayerData(client).loginAttemptsRemaining <= 0) {
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
getPlayerData(client).customDisconnectReason = "FailedToLogin";
disconnectPlayer(client);
}
if (isPlayerLoggedIn(client)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
logToConsole(LOG_WARN, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginSuccessGUI(client);
} else {
messagePlayerError(client, "You are already logged in!");
messagePlayerError(client, getLocaleString(client, "AlreadyLoggedIn"));
}
return false;
}
if (!isPlayerRegistered(client)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
logToConsole(LOG_WARN, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
messagePlayerError(client, "Your name is not registered! Use /register to make an account.");
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
return false;
}
if (areParamsEmpty(password)) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
logToConsole(LOG_WARN, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
showPlayerLoginFailedGUI(client, getLocaleString(client, "LoginFailedInvalidPassword", getPlayerData(client).loginAttemptsRemaining));
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else {
messagePlayerError(client, `You must enter a password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
messagePlayerError(client, getLocaleString(client, "LoginFailedNoPassword", getPlayerData(client).loginAttemptsRemaining));
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
@@ -1109,13 +1108,13 @@ function checkLogin(client, password) {
}
if (!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), password))) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
logToConsole(LOG_WARN, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
showPlayerLoginFailedGUI(client, getLocaleString(client, "LoginFailedInvalidPassword", getPlayerData(client).loginAttemptsRemaining));
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else {
messagePlayerError(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
messagePlayerError(client, getLocaleString(client, "LoginFailedInvalidPassword", getPlayerData(client).loginAttemptsRemaining));
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
// Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it.
@@ -1148,7 +1147,7 @@ function checkLogin(client, password) {
// ===========================================================================
function checkRegistration(client, password, confirmPassword = "", emailAddress = "") {
logToConsole(LOG_DEBUG, `[VRR.Account]: Checking registration for ${getPlayerName(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Checking registration for ${getPlayerName(client)}`);
if (isPlayerRegistered(client)) {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
@@ -1175,7 +1174,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPassword"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password is blank)`);
} else {
messagePlayerError(client, "The password cannot be blank!");
messagePlayerError(client, getLocaleString(client, "RegistrationFailedNoPassword"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password is blank)`);
}
return false;
@@ -1211,7 +1210,20 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
showPlayerRegistrationFailedGUI(client, getLocaleString(client, "RegistrationFailedNoPasswordWeak"));
logToConsole(LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to create an account (password doesn't meet requirements)`);
} else {
messagePlayerError(client, "Password doesn't meet requirements!");
messagePlayerError(client, getLocaleString(client, "PasswordNotGoodEnough"));
let passwordRequirements = []
if (getGlobalConfig().passwordRequiredCapitals > 0) {
passwordRequirements.push(getLocaleString(client, "PasswordNeedsCapitals", getGlobalConfig().passwordRequiredCapitals))
}
if (getGlobalConfig().passwordRequiredNumbers > 0) {
passwordRequirements.push(getLocaleString(client, "PasswordNeedsNumbers", getGlobalConfig().passwordRequiredNumbers))
}
if (getGlobalConfig().passwordRequiredSymbols > 0) {
passwordRequirements.push(getLocaleString(client, "PasswordNeedsSymbols", getGlobalConfig().passwordRequiredSymbols))
}
messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", passwordRequirements.join(", ")));
}
return false;
}
@@ -1231,7 +1243,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
messagePlayerAlert(client, getLocaleString(client, "RegistrationFailedCreateError"));
}
messagePlayerAlert(client, `${getServerName()} staff have been notified of the problem and will fix it shortly.`);
messagePlayerAlert(client, getLocaleString(client, "DevelopersNotified"));
return false;
}
@@ -1251,16 +1263,16 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if (doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
setTimeout(function () {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
getPlayerData(client).customDisconnectReason = "NotATester";
disconnectPlayer(client);
}, 5000);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the error GUI (not a tester).`);
showPlayerErrorGUI(client, getLocaleString(client, "NotATester"), getLocaleString(client, "AccessDenied"));
return false;
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the "not a tester" error message (GUI disabled).`);
messagePlayerError(client, getLocaleString(client, "NotATester"));
return false;
}
@@ -1270,9 +1282,9 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
showPlayerRegistrationSuccessGUI(client);
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
getPlayerData(client).promptType = V_PROMPT_CREATEFIRSTCHAR;
} else {
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage"), `{ALTCOLOUR}/newchar{MAINCOLOUR}`);
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
}
}
};
@@ -1285,7 +1297,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
}
switch (getPlayerData(client).passwordResetState) {
case AGRP_RESETPASS_STATE_EMAILCONFIRM: {
case V_RESETPASS_STATE_EMAILCONFIRM: {
if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton"));
@@ -1293,7 +1305,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
}
let passwordResetCode = toUpperCase(generateEmailVerificationCode());
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_CODEINPUT;
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_CODEINPUT;
getPlayerData(client).passwordResetCode = passwordResetCode;
showPlayerResetPasswordCodeInputGUI(client);
sendPasswordResetEmail(client, passwordResetCode);
@@ -1301,11 +1313,11 @@ function checkAccountResetPasswordRequest(client, inputText) {
break;
}
case AGRP_RESETPASS_STATE_CODEINPUT: {
case V_RESETPASS_STATE_CODEINPUT: {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`);
if (inputText != "") {
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_SETPASS;
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_SETPASS;
showPlayerChangePasswordGUI(client);
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
} else {
@@ -1313,7 +1325,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, ${getPlayerData(client).passwordResetAttemptsRemaining} attempts remaining)`);
if (getPlayerData(client).passwordResetAttemptsRemaining <= 0) {
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, no more attempts remaining, kicking ...)`);
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
getPlayerData(client).customDisconnectReason = "FailedToLogin";
disconnectPlayer(client);
return false;
}
@@ -1322,10 +1334,10 @@ function checkAccountResetPasswordRequest(client, inputText) {
break;
}
case AGRP_RESETPASS_STATE_NONE: {
case V_RESETPASS_STATE_NONE: {
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} requested a password reset. Awaiting email input ...`);
showPlayerResetPasswordEmailInputGUI(client);
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_EMAILCONFIRM;
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_EMAILCONFIRM;
break;
}
}
@@ -1337,8 +1349,8 @@ function checkAccountResetPasswordRequest(client, inputText) {
function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
if (!isPlayerLoggedIn(client)) {
if (getPlayerData(client).passwordResetState != AGRP_RESETPASS_STATE_SETPASS) {
//getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
if (getPlayerData(client).passwordResetState != V_RESETPASS_STATE_SETPASS) {
//getPlayerData(client).passwordResetState = V_RESETPASS_STATE_NONE;
//disconnectPlayer(client);
logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
return false;
@@ -1352,9 +1364,9 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
if (!doesPasswordMeetRequirements(newPassword)) {
let passwordRequirementsString = `${needsCapitals}, ${needsNumbers}, ${needsSymbols}`;
let needsCapitals = getLocaleString(client, "PasswordNeedsCapitals", "1");
let needsNumbers = getLocaleString(client, "PasswordNeedsNumbers", "1");
let needsSymbols = getLocaleString(client, "PasswordNeedsSymbols", "1");
let needsCapitals = getLocaleString(client, "PasswordNeedsCapitals", getGlobalConfig().passwordRequiredCapitals);
let needsNumbers = getLocaleString(client, "PasswordNeedsNumbers", getGlobalConfig().passwordRequiredNumbers);
let needsSymbols = getLocaleString(client, "PasswordNeedsSymbols", getGlobalConfig().passwordRequiredSymbols);
messagePlayerError(client, getLocaleString(client, "AccountPasswordNeedsImproved"));
messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", passwordRequirementsString));
@@ -1374,8 +1386,8 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
saveAccountToDatabase(getPlayerData(client).accountData);
if (getPlayerData(client).passwordResetState == AGRP_RESETPASS_STATE_SETPASS) {
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
if (getPlayerData(client).passwordResetState == V_RESETPASS_STATE_SETPASS) {
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_NONE;
}
messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged"));
@@ -1391,11 +1403,11 @@ function isValidEmailAddress(emailAddress) {
// ===========================================================================
function saveAllPlayersToDatabase() {
logToConsole(LOG_DEBUG, "[VRR.Account]: Saving all clients to database ...");
logToConsole(LOG_DEBUG, "[AGRP.Account]: Saving all clients to database ...");
getClients().forEach(function (client) {
savePlayerToDatabase(client);
});
logToConsole(LOG_DEBUG, "[VRR.Account]: All clients saved to database successfully!");
logToConsole(LOG_DEBUG, "[AGRP.Account]: All clients saved to database successfully!");
}
// ===========================================================================
@@ -1409,14 +1421,14 @@ function savePlayerToDatabase(client) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Account]: Saving client ${getPlayerName(client)} to database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Saving client ${getPlayerName(client)} to database ...`);
saveAccountToDatabase(getPlayerData(client).accountData);
if (getPlayerData(client).currentSubAccount != -1) {
//let subAccountData = getPlayerCurrentSubAccount(client);
if (getPlayerPed(client) != null) {
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != AGRP_RETURNTO_TYPE_ADMINGET) {
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != V_RETURNTO_TYPE_ADMINGET) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
@@ -1431,100 +1443,12 @@ function savePlayerToDatabase(client) {
saveSubAccountToDatabase(getPlayerCurrentSubAccount(client));
}
logToConsole(LOG_DEBUG, `[VRR.Account]: Saved client ${getPlayerDisplayForConsole(client)} to database successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Saved client ${getPlayerDisplayForConsole(client)} to database successfully!`);
return true;
}
// ===========================================================================
function initClient(client) {
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`);
if (isConsole(client)) {
logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`);
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`);
if (playerInitialized[client.index] == true) {
logToConsole(LOG_DEBUG | LOG_ERROR, `[VRR.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`);
return false;
}
playerInitialized[client.index] = true;
//setEntityData(client, "agrp.isInitialized", true, false);
logToConsole(LOG_DEBUG, `[VRR.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
updatePlayerSnowState(client);
//logToConsole(LOG_DEBUG, `[VRR.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
//showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
logToConsole(LOG_DEBUG, `[VRR.Account] Waiting for 2.5 seconds to prevent race attack ...`);
setTimeout(function () {
if (client != null) {
clearChatBox(client);
logToConsole(LOG_DEBUG, `[VRR.Account] Loading account for ${getPlayerDisplayForConsole(client)}`);
let tempAccountData = loadAccountFromName(getPlayerName(client), true);
logToConsole(LOG_DEBUG, `[VRR.Account] Loading subaccounts for ${getPlayerDisplayForConsole(client)}`);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts);
getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client);
getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp();
requestClientInfo(client);
if (tempAccountData != false) {
sendPlayerLocaleId(client, getPlayerData(client).accountData.locale);
if (isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} else {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
showPlayerLoginGUI(client);
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen"));
//if(checkForGeoIPModule()) {
// let iso = module.geoip.getCountryISO(getPlayerIP(client));
// let localeId = getLocaleFromCountryISO(iso);
//}
//showSmallGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
}
startLoginTimeoutForPlayer(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
} else {
sendPlayerLocaleId(client, 0);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
showPlayerRegistrationGUI(client);
} else {
logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "/register"), getColourByName("softGreen"));
}
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
sendAccountKeyBindsToClient(client);
}
}, 2500);
}
// ===========================================================================
function saveConnectionToDatabase(client) {
let dbConnection = connectToDatabase();
if (dbConnection) {
@@ -1548,12 +1472,11 @@ function createDefaultAccountServerData(accountDatabaseId) {
// ===========================================================================
function loadAccountKeybindsFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[VRR.Account]: Loading account keybinds for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Loading account keybinds for account ${accountDatabaseID} from database ...`);
let tempAccountKeybinds = [];
let dbConnection = connectToDatabase();
let dbQuery = null;
let dbAssoc;
let dbAssoc = [];
for (let i in getGlobalConfig().keyBind.defaultKeyBinds) {
let tempKeyBindData = new KeyBindData(false);
@@ -1566,109 +1489,98 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) {
if (accountDatabaseID != 0 && typeof accountDatabaseId != "undefined") {
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`);
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountKeyBindData = new KeyBindData(dbAssoc);
tempAccountKeybinds.push(tempAccountKeyBindData);
logToConsole(LOG_DEBUG, `[VRR.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${toUpperCase(getKeyNameFromId(tempAccountKeyBindData.key))}') loaded from database successfully!`);
}
let dbQueryString = `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempAccountKeyBindData = new KeyBindData(dbAssoc[i]);
tempAccountKeybinds.push(tempAccountKeyBindData);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${toUpperCase(getKeyNameFromId(tempAccountKeyBindData.key))}') loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
}
logToConsole(LOG_DEBUG, `[VRR.Account]: ${tempAccountKeybinds.length} account keybinds for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: ${tempAccountKeybinds.length} account keybinds for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountKeybinds;
}
// ===========================================================================
function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[VRR.Account]: Loading account staff notes for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Loading account staff notes for account ${accountDatabaseID} from database ...`);
let tempAccountStaffNotes = [];
let dbConnection = connectToDatabase();
let dbQuery = null;
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID));
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc);
tempAccountStaffNotes.push(tempAccountStaffNoteData);
logToConsole(LOG_DEBUG, `[VRR.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
}
let dbQueryString = "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID);
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc[i]);
tempAccountStaffNotes.push(tempAccountStaffNoteData);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[VRR.Account]: ${tempAccountStaffNotes.length} account staff notes for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: ${tempAccountStaffNotes.length} account staff notes for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountStaffNotes;
}
// ===========================================================================
function loadAccountContactsFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[VRR.Account]: Loading account contacts for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Loading account contacts for account ${accountDatabaseID} from database ...`);
let tempAccountContacts = [];
let dbConnection = connectToDatabase();
let dbQuery = null;
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID));
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountContactData = new AccountContactData(dbAssoc);
tempAccountContacts.push(tempAccountContactData);
logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
}
let dbQueryString = "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID);
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempAccountContactData = new AccountContactData(dbAssoc[i]);
tempAccountContacts.push(tempAccountContactData);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[VRR.Account]: ${tempAccountContacts.length} account contacts for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: ${tempAccountContacts.length} account contacts for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountContacts;
}
// ===========================================================================
function loadAccountMessagesFromDatabase(accountDatabaseID) {
logToConsole(LOG_DEBUG, `[VRR.Account]: Loading account messages for account ${accountDatabaseID} from database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Loading account messages for account ${accountDatabaseID} from database ...`);
let tempAccountMessages = [];
let dbConnection = connectToDatabase();
let dbQuery = null;
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_msg` WHERE `acct_msg_deleted` = 0 AND `acct_msg_acct` = " + toString(accountDatabaseID));
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempAccountMessageData = new AccountContactData(dbAssoc);
tempAccountMessages.push(tempAccountMessageData);
logToConsole(LOG_DEBUG, `[VRR.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
}
let dbQueryString = "SELECT * FROM`acct_msg` WHERE `acct_msg_deleted` = 0 AND`acct_msg_acct` = " + toString(accountDatabaseID);
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempAccountMessageData = new AccountContactData(dbAssoc[i]);
tempAccountMessages.push(tempAccountMessageData);
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_DEBUG, `[VRR.Account]: ${tempAccountMessages.length} account messages for account ${accountDatabaseID} loaded from database successfully!`);
logToConsole(LOG_DEBUG, `[AGRP.Account]: ${tempAccountMessages.length} account messages for account ${accountDatabaseID} loaded from database successfully!`);
return tempAccountMessages;
}
@@ -1747,34 +1659,34 @@ function generateEmailVerificationCode() {
// ===========================================================================
function sendEmailVerificationEmail(client, emailVerificationCode) {
async function sendEmailVerificationEmail(client, emailVerificationCode) {
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
}
// ===========================================================================
function sendPasswordResetEmail(client, verificationCode) {
async function sendPasswordResetEmail(client, verificationCode) {
let emailBodyText = getEmailConfig().bodyContent.confirmPasswordReset;
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", verificationCode);
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerName()}`, emailBodyText);
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerName()}`, emailBodyText);
}
// ===========================================================================
function verifyAccountEmail(accountData, verificationCode) {
async function verifyAccountEmail(accountData, verificationCode) {
let emailVerificationCode = generateRandomString(10);
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
getPlayerData(client).accountData.emailAddress = emailAddress;
getPlayerData(client).accountData.emailVerificationCode = module.hashing.sha512(emailVerificationCode);
@@ -1782,7 +1694,7 @@ function verifyAccountEmail(accountData, verificationCode) {
// ===========================================================================
function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
async function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
@@ -1794,13 +1706,13 @@ function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGa
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US'));
sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText);
await sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText);
return true;
}
// ===========================================================================
function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
async function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
@@ -1812,7 +1724,7 @@ function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getG
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US'));
sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText);
await sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText);
return true;
}
@@ -1845,7 +1757,7 @@ function checkPlayerTwoFactorAuthentication(client, authCode) {
}
}
getPlayerData(client).customDisconnectReason = "Kicked - Failed to login";
getPlayerData(client).customDisconnectReason = "FailedToLogin";
disconnectPlayer(client);
return false;
}
@@ -1858,13 +1770,13 @@ function isPlayerATester(client) {
// ===========================================================================
function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
async function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
let emailBodyText = getEmailConfig().bodyContent.twoFactorAuthentication;
emailBodyText = emailBodyText.replace("{2FACODE}", twoFactorAuthCode);
emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(getGame()));
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText);
await sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText);
return true;
}
@@ -1873,7 +1785,7 @@ function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
function startLoginTimeoutForPlayer(client) {
getPlayerData(client).loginTimeout = setTimeout(function () {
if (isPlayerLoggedIn(client) == false) {
getPlayerData(client).customDisconnectReason = "Kicked - Login timeout";
getPlayerData(client).customDisconnectReason = "FailedToLogin";
disconnectPlayer(client);
}
}, getGlobalConfig().loginTimeout);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: animation.js
// DESC: Provides animation functions and usage
@@ -9,8 +8,8 @@
// ===========================================================================
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!");
}
// ===========================================================================
@@ -35,8 +34,8 @@ function playPlayerAnimationCommand(command, params, client) {
return false;
}
if (getAnimationData(animationSlot)[3] == AGRP_ANIMTYPE_SURRENDER) {
getPlayerData(client).pedState = AGRP_PEDSTATE_HANDSUP;
if (getAnimationData(animationSlot)[3] == V_ANIMTYPE_SURRENDER) {
getPlayerData(client).pedState = V_PEDSTATE_HANDSUP;
}
if (isPlayerHandCuffed(client) || isPlayerTazed(client) || isPlayerInForcedAnimation(client)) {
@@ -44,7 +43,11 @@ function playPlayerAnimationCommand(command, params, client) {
return false;
}
messagePlayerTip(client, getLocaleString(client, "AnimationStopCommandTip", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
if (getAnimationData(animationSlot).loop == true) {
if (hasPlayerSeenActionTip(client, "AnimationStop")) {
messagePlayerTip(client, getGroupedLocaleString(client, "ActionTips", "AnimationStop", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
}
}
makePlayerPlayAnimation(client, animationSlot, animationPositionOffset);
}
@@ -66,6 +69,8 @@ function stopPlayerAnimationCommand(command, params, client) {
getPlayerData(client).animationForced = false;
//setPlayerMouseCameraState(client, false);
markPlayerActionTipSeen(client, "AnimationStop");
}
// ===========================================================================
@@ -91,16 +96,18 @@ function isPlayerInForcedAnimation(client) {
// ===========================================================================
function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
if (getAnimationData(animationSlot).loop == true) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
}
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
setEntityData(getPlayerPed(client), "agrp.anim", animationSlot, true);
//if(getAnimationData(animationSlot)[9] != AGRP_ANIMMOVE_NONE) {
// if(getGame() < AGRP_GAME_GTA_SA) {
//setEntityData(getPlayerPed(client), "v.rp.anim", animationSlot, true);
//if(getAnimationData(animationSlot)[9] != V_ANIMMOVE_NONE) {
// if(getGame() < V_GAME_GTA_SA) {
// setPlayerMouseCameraState(client, true);
// }
//}
@@ -109,11 +116,13 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
// ===========================================================================
function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
if (getAnimationData(animationSlot).loop == true) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
}
setPlayerControlState(client, false);
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: anticheat.js
// DESC: Provides anticheat functions and usage
@@ -9,17 +8,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 != AGRP_PEDSTATE_READY) {
if (getPlayerData(client).pedState == AGRP_PEDSTATE_ENTERINGVEHICLE) {
if (getPlayerData(client).pedState != V_PEDSTATE_READY) {
if (getPlayerData(client).pedState == V_PEDSTATE_ENTERINGVEHICLE) {
sendPlayerClearPedState(client);
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
getPlayerData(client).pedState = V_PEDSTATE_READY;
} else {
return false;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: bans.js
// DESC: Provides ban functions and usage
@@ -9,18 +8,18 @@
// ===========================================================================
// 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;
const V_BANTYPE_NONE = 0;
const V_BANTYPE_ACCOUNT = 1;
const V_BANTYPE_SUBACCOUNT = 2;
const V_BANTYPE_IPADDRESS = 3;
const V_BANTYPE_SUBNET = 4;
// ===========================================================================
class BanData {
constructor(dbAssoc = false) {
this.databaseId = 0;
this.type = AGRP_BANTYPE_NONE;
this.type = V_BANTYPE_NONE;
this.detail = "";
this.ipAddress = "";
this.name = "";
@@ -39,8 +38,8 @@ class BanData {
// ===========================================================================
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!");
}
// ===========================================================================
@@ -62,16 +61,16 @@ function accountBanCommand(command, params, client) {
// Prevent banning admins with really high permissions
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
messagePlayerError(client, getLocaleString(client, "CantBanClient"));
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(targetClient)}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`;
getPlayerData(targetClient).customDisconnectReason = "Banned";
disconnectPlayer(targetClient);
}
@@ -94,16 +93,16 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
messagePlayerError(client, getLocaleString(client, "CantBanClient"));
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(targetClient)}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `Banned - ${reason}`;
getPlayerData(targetClient).customDisconnectReason = "Banned";
disconnectPlayer(targetClient);
}
@@ -126,14 +125,14 @@ function ipBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
messagePlayerError(client, getLocaleString(client, "CantBanClient"));
return false;
}
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
getPlayerData(targetClient).customDisconnectReason = `IP Banned - ${reason}`;
getPlayerData(targetClient).customDisconnectReason = "Banned";
serverBanIP(getPlayerIP(targetClient));
disconnectPlayer(targetClient);
}
@@ -158,14 +157,14 @@ function subNetBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions
if (doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
messagePlayerError(client, getLocaleString(client, "CantBanClient"));
return false;
}
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
getPlayerData(client).customDisconnectReason = `IP Subnet Banned - ${reason}`;
getPlayerData(client).customDisconnectReason = "Banned";
serverBanIP(getPlayerIP(targetClient));
}
@@ -175,7 +174,7 @@ function banAccount(accountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -190,7 +189,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -205,7 +204,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_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 (${V_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -220,7 +219,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let safeReason = dbConnection.escapetoString(reason);
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${AGRP_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 (${V_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -234,7 +233,7 @@ 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=${AGRP_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -248,7 +247,7 @@ 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=${AGRP_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -262,7 +261,7 @@ 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=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -276,7 +275,7 @@ 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=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
freeDatabaseQuery(dbQuery);
dbConnection.close();
return true;
@@ -288,7 +287,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
// ===========================================================================
function isAccountBanned(accountId) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId);
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_ACCOUNT && ban.detail === accountId);
if (bans.length > 0) {
return true;
}
@@ -299,7 +298,7 @@ function isAccountBanned(accountId) {
// ===========================================================================
function isSubAccountBanned(subAccountId) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
if (bans.length > 0) {
return true;
}
@@ -310,7 +309,7 @@ function isSubAccountBanned(subAccountId) {
// ===========================================================================
function isIpAddressBanned(ipAddress) {
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress);
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_IPADDRESS && ban.detail === ipAddress);
if (bans.length > 0) {
return true;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: bank.js
// DESC: Provides banking functions and usage
@@ -9,13 +8,13 @@
// ===========================================================================
// 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.
const V_BANK_ACCT_OWNER_NONE = 0; // Not owned
const V_BANK_ACCT_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const V_BANK_ACCT_OWNER_JOB = 2; // Owned by a job
const V_BANK_ACCT_OWNER_CLAN = 3; // Owned by a clan
const V_BANK_ACCT_OWNER_FACTION = 4; // Owned by a faction
const V_BANK_ACCT_OWNER_BIZ = 4; // Owned by a faction
const V_BANK_ACCT_OWNER_PUBLIC = 5; // Is a public bank account. Technically not owned. This probably won't be used.
// ===========================================================================
@@ -26,7 +25,7 @@ function isPlayerAtBank(client) {
let businessId = getPlayerBusiness(client);
if (getBusinessData(client) != false) {
if (getBusinessData(businessId).type == AGRP_BIZ_TYPE_BANK) {
if (getBusinessData(businessId).type == V_BIZ_TYPE_BANK) {
return true;
}
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage
@@ -16,7 +15,7 @@ let serverBitFlags = {
accountSettingsFlags: {},
subAccountSettingsFlags: {},
accountFlags: {},
seenHelpTipsFlags: {},
seenActionTipsFlags: {},
npcTriggerTypeFlags: {},
npcTriggerConditionTypesFlags: {},
npcTriggerResponseTypeFlags: {},
@@ -240,12 +239,28 @@ 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",
@@ -265,7 +280,7 @@ let serverBitFlagKeys = {
// ===========================================================================
function initBitFlagScript() {
logToConsole(LOG_DEBUG, "[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);
@@ -277,9 +292,9 @@ function initBitFlagScript() {
serverBitFlags.npcTriggerTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerTypeKeys);
serverBitFlags.npcTriggerConditionTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerConditionTypeKeys);
serverBitFlags.npcTriggerResponseTypes = createBitFlagTable(serverBitFlagKeys.npcTriggerResponseTypeKeys);
serverBitFlags.seenHelpTips = createBitFlagTable(serverBitFlagKeys.seenHelpTipsKeys);
serverBitFlags.seenActionTips = createBitFlagTable(serverBitFlagKeys.seenActionTipsKeys);
serverBitFlags.jobRankFlags = createBitFlagTable(serverBitFlagKeys.jobRankKeys);
logToConsole(LOG_INFO, "[VRR.BitFlag]: Bit flag script initialized successfully!");
logToConsole(LOG_INFO, "[AGRP.BitFlag]: Bit flag script initialized successfully!");
return true;
}
@@ -313,7 +328,7 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
// ===========================================================================
function doesPlayerHaveClanPermission(client, requiredFlags) {
function doesPlayerHaveClanPermission(client, requiredFlags, exemptAdminFlag = false) {
if (isConsole(client)) {
return true;
}
@@ -322,8 +337,10 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
return true;
}
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
return true;
if (exemptAdminFlag == false) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
return true;
}
}
let clanFlags = 0;
@@ -343,7 +360,7 @@ function doesPlayerHaveClanPermission(client, requiredFlags) {
// ===========================================================================
function doesPlayerHaveJobPermission(client, requiredFlags) {
function doesPlayerHaveJobPermission(client, requiredFlags, exemptAdminFlag = false) {
if (isConsole(client)) {
return true;
}
@@ -352,8 +369,10 @@ function doesPlayerHaveJobPermission(client, requiredFlags) {
return true;
}
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
return true;
if (exemptAdminFlag == false) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
return true;
}
}
let jobFlags = 0;
@@ -443,6 +462,20 @@ function getClanDiscordWebhookValue(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)) {
return false;

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,27 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// 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 V_CASINO_GAME_NONE = 0;
const V_CASINO_GAME_BLACKJACK = 1;
const V_CASINO_GAME_POKER = 2;
const V_CASINO_GAME_BACCARAT = 3;
const V_CASINO_GAME_ROULETTE = 4;
const V_CASINO_GAME_CRAPS = 5;
const V_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;
const V_CASINO_DECK_SUIT_NONE = 1;
const V_CASINO_DECK_SUIT_CLUBS = 1;
const V_CASINO_DECK_SUIT_DIAMONDS = 2;
const V_CASINO_DECK_SUIT_HEARTS = 3;
const V_CASINO_DECK_SUIT_SPADES = 4;
// ===========================================================================
@@ -37,45 +36,45 @@ class DeckCard {
// ===========================================================================
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"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 1, "deckCardClubAce"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 2, "deckCardClubTwo"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 3, "deckCardClubThree"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 4, "deckCardClubFour"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 5, "deckCardClubFive"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 6, "deckCardClubSix"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 7, "deckCardClubSeven"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 8, "deckCardClubEight"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 9, "deckCardClubNine"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 10, "deckCardClubTen"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 11, "deckCardClubJack"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 12, "deckCardClubQueen"),
new DeckCard(V_CASINO_DECK_SUIT_CLUBS, 13, "deckCardClubKing"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 1, "deckCardDiamondAce"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 2, "deckCardDiamondTwo"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 3, "deckCardDiamondThree"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 4, "deckCardDiamondFour"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 5, "deckCardDiamondFive"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 6, "deckCardDiamondSix"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 7, "deckCardDiamondSeven"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 8, "deckCardDiamondEight"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 9, "deckCardDiamondNine"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 10, "deckCardDiamondTen"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 11, "deckCardDiamondJack"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 12, "deckCardDiamondQueen"),
new DeckCard(V_CASINO_DECK_SUIT_DIAMONDS, 13, "deckCardDiamondKing"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 1, "deckCardHeartAce"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 2, "deckCardHeartTwo"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 3, "deckCardHeartThree"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 4, "deckCardHeartFour"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 5, "deckCardHeartFive"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 6, "deckCardHeartSix"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 7, "deckCardHeartSeven"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 8, "deckCardHeartEight"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 9, "deckCardHeartNine"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 10, "deckCardHeartTen"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 11, "deckCardHeartJack"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 12, "deckCardHeartQueen"),
new DeckCard(V_CASINO_DECK_SUIT_HEARTS, 13, "deckCardHeartKing"),
];
// ===========================================================================
@@ -118,20 +117,7 @@ function blackJackHitCommand(command, params, client) {
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;
}
}
let tempHandValue = getValueOfBlackJackHand(hand);
if (handValue > 21) {
playerBustBlackJack(client);
@@ -155,14 +141,6 @@ function blackJackStandCommand(command, params, client) {
// ===========================================================================
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++) {
@@ -174,4 +152,23 @@ function dealPlayerBlackJackHand(deck, players) {
}
}
// ===========================================================================
function calculateValueOfBlackJackHand(hand) {
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;
}
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: chat.js
// DESC: Provides chat functions and usage
@@ -9,8 +8,8 @@
// ===========================================================================
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;
}
@@ -174,7 +173,14 @@ function adminChatCommand(command, params, client) {
return false;
}
messageAdmins(`{jobYellow}[Admin Chat] {ALTCOLOUR}${getPlayerName(client)}: ${params}`);
let clients = getClients();
for (let i in clients) {
if (doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("BasicModeration"))) {
messagePlayerAdminChat(clients[i], client, params);
}
}
messageDiscordAdminChannel(`${getPlayerData(client).accountData.staffTitle} ${getPlayerData(client).accountData.name}: ${messageText}`);
}
// ===========================================================================
@@ -217,7 +223,10 @@ function privateMessageCommand(command, params, client) {
getPlayerData(targetClient).privateMessageReplyTo = client;
messagePlayerPrivateMessage(targetClient, client, messageText);
messagePlayerTip(client, getLocaleString(client, "PrivateMessageReplyCommandTip", "{ALTCOLOUR}/reply{MAINCOLOUR}"))
if (!hasPlayerSeenActionTip(targetClient, "ReplyToDirectMessage")) {
messagePlayerTip(targetClient, getGroupedLocaleString(targetClient, "ActionTips", "ReplyToDirectMessage", "{ALTCOLOUR}/reply{MAINCOLOUR}"));
}
}
// ===========================================================================
@@ -240,6 +249,8 @@ function replyToLastPrivateMessageCommand(command, params, client) {
getPlayerData(targetClient).privateMessageReplyTo = client;
messagePlayerPrivateMessage(targetClient, client, messageText);
markPlayerActionTipSeen(client, "ReplyToDirectMessage");
}
// ===========================================================================
@@ -390,7 +401,7 @@ function clanChat(client, messageText) {
// ===========================================================================
function canPlayerUseMegaphone(client) {
if (getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_MEGAPHONE) != -1) {
if (getPlayerFirstItemSlotByUseType(client, V_ITEM_USE_TYPE_MEGAPHONE) != -1) {
if (isPlayerActiveItemEnabled(client)) {
return true;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: clan.js
// DESC: Provides clan functions and usage
@@ -110,94 +109,88 @@ class ClanMemberData {
// ===========================================================================
function initClanScript() {
logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ...");
logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!");
logToConsole(LOG_INFO, "[AGRP.Clan]: Initializing clans script ...");
logToConsole(LOG_INFO, "[AGRP.Clan]: Clan script initialized successfully!");
return true;
}
// ===========================================================================
function loadClansFromDatabase() {
logToConsole(LOG_INFO, "[VRR.Clan]: Loading clans from database ...");
logToConsole(LOG_INFO, "[AGRP.Clan]: Loading clans from database ...");
let tempClans = [];
let dbConnection = connectToDatabase();
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempClanData = new ClanData(dbAssoc);
//tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
logToConsole(LOG_DEBUG, `[VRR.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
let dbQueryString = `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempClanData = new ClanData(dbAssoc[i]);
//tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
tempClans.push(tempClanData);
logToConsole(LOG_DEBUG, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[VRR.Clan]: ${tempClans.length} clans loaded from database successfully!`);
logToConsole(LOG_INFO, `[AGRP.Clan]: ${tempClans.length} clans loaded from database successfully!`);
return tempClans;
}
// ===========================================================================
function loadClanMembersFromDatabase() {
logToConsole(LOG_INFO, "[VRR.Clan]: Loading clans from database ...");
logToConsole(LOG_INFO, "[AGRP.Clan]: Loading clans from database ...");
let tempClans = [];
let dbConnection = connectToDatabase();
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempClanData = new ClanData(dbAssoc);
tempClans.push(tempClanData);
logToConsole(LOG_VERBOSE, `[VRR.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
let dbQueryString = `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempClanData = new ClanData(dbAssoc[i]);
tempClans.push(tempClanData);
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[VRR.Clan]: ${tempClans.length} clans loaded from database successfully!`);
logToConsole(LOG_INFO, `[AGRP.Clan]: ${tempClans.length} clans loaded from database successfully!`);
return tempClans;
}
// ===========================================================================
function loadClanRanksFromDatabase(clanDatabaseId) {
logToConsole(LOG_INFO, `[VRR.Clan]: Loading ranks for clan ${clanDatabaseId} from database ...`);
logToConsole(LOG_INFO, `[AGRP.Clan]: Loading ranks for clan ${clanDatabaseId} from database ...`);
let dbConnection = connectToDatabase();
let dbAssoc;
let dbAssoc = [];
let tempClanRanks = [];
if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_rank WHERE clan_rank_clan = ${clanDatabaseId}`);
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempClanRankData = new ClanRankData(dbAssoc);
tempClanRanks.push(tempClanRankData);
logToConsole(LOG_VERBOSE, `[VRR.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`);
}
let dbQueryString = `SELECT * FROM clan_rank WHERE clan_rank_clan = ${clanDatabaseId}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempClanRankData = new ClanRankData(dbAssoc[i]);
tempClanRanks.push(tempClanRankData);
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[VRR.Clan]: Loaded ranks for clan ${clanDatabaseId} from database successfully!`);
logToConsole(LOG_INFO, `[AGRP.Clan]: Loaded ranks for clan ${clanDatabaseId} from database successfully!`);
return tempClanRanks;
}
@@ -1292,10 +1285,10 @@ function setClanRankTitle(clanId, rankId, title) {
// ===========================================================================
function saveAllClansToDatabase() {
logToConsole(LOG_DEBUG, `[VRR.Clan]: Saving all server clans to database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Clan]: Saving all server clans to database ...`);
if (getServerConfig().devServer) {
logToConsole(LOG_DEBUG, `[VRR.Clan]: Aborting save all clans to database, dev server is enabled.`);
logToConsole(LOG_DEBUG, `[AGRP.Clan]: Aborting save all clans to database, dev server is enabled.`);
return false;
}
@@ -1303,7 +1296,7 @@ function saveAllClansToDatabase() {
saveClanToDatabase(i);
}
logToConsole(LOG_INFO, `[VRR.Clan]: Saved all server clans to database`);
logToConsole(LOG_INFO, `[AGRP.Clan]: Saved all server clans to database`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: client.js
// DESC: Provides client communication and cross-endpoint operations
@@ -9,21 +8,20 @@
// ===========================================================================
// Return-To types (for when a player is teleported)
const AGRP_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid
const AGRP_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting
const AGRP_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select
const V_RETURNTO_TYPE_NONE = 0; // "Return to" data is invalid
const V_RETURNTO_TYPE_ADMINGET = 1; // "Return to" data is from admin teleporting
const V_RETURNTO_TYPE_SKINSELECT = 2; // "Return to" data is from skin select
// ===========================================================================
/**
* @class Representing extra data for a client
* @property {AccountData} accountData
* @property {Array.<SubAccountData>} subAccounts
*/
class ClientData {
constructor(client, accountData, subAccounts) {
/** @member {AccountData} accountData */
this.accountData = accountData;
/** @member {Array.<SubAccountData>} subAccounts */
this.subAccounts = subAccounts; // Characters
// General Info
@@ -38,9 +36,9 @@ class ClientData {
this.sessionId = 0;
// Security
this.passwordResetState = AGRP_RESETPASS_STATE_NONE;
this.passwordResetState = V_RESETPASS_STATE_NONE;
this.passwordResetCode = "";
this.twoFactorAuthenticationState = AGRP_2FA_STATE_NONE;
this.twoFactorAuthenticationState = V_2FA_STATE_NONE;
this.twoFactorAuthenticationCode = 0;
this.loginTimeout = null;
this.loginAttemptsRemaining = 3;
@@ -66,11 +64,11 @@ class ClientData {
// Items
this.tempLockerCache = new Array(9).fill(-1);
this.tempLockerType = AGRP_TEMP_LOCKER_TYPE_NONE;
this.tempLockerType = V_TEMP_LOCKER_TYPE_NONE;
this.hotBarItems = new Array(9).fill(-1);
this.activeHotBarSlot = -1;
this.toggleUseItem = false;
this.itemActionState = AGRP_ITEM_ACTION_NONE;
this.itemActionState = V_ITEM_ACTION_NONE;
this.itemActionItem = -1;
this.paintBallItemCache = [];
@@ -105,7 +103,7 @@ class ClientData {
this.returnToDimension = null;
this.returnToHouse = null;
this.returnToBusiness = null;
this.returnToType = AGRP_RETURNTO_TYPE_NONE;
this.returnToType = V_RETURNTO_TYPE_NONE;
// Animation
this.currentAnimation = -1;
@@ -116,22 +114,24 @@ class ClientData {
// Misc
this.changingCharacterName = false;
this.currentPickup = false;
this.currentPickup = null;
this.usingSkinSelect = false;
this.keyBinds = [];
this.incomingDamageMultiplier = 1;
this.weaponDamageEvent = AGRP_WEAPON_DAMAGE_EVENT_NORMAL;
this.weaponDamageEvent = V_WEAPON_DAMAGE_EVENT_NORMAL;
this.lastJobVehicle = null;
this.health = 100;
this.locale = 0;
this.enteringVehicle = null;
this.customDisconnectReason = "";
this.interiorCutscene = -1;
this.scene = "";
this.playerBlip = null;
this.alcoholLevel = 0;
this.pedState = AGRP_PEDSTATE_NONE;
this.promptType = AGRP_PROMPT_NONE;
this.pedState = V_PEDSTATE_NONE;
this.promptType = V_PROMPT_NONE;
this.privateMessageReplyTo = null;
this.enteringExitingProperty = null;
this.inProperty = null;
// Paintball
this.inPaintBall = false;
@@ -143,26 +143,26 @@ class ClientData {
this.jobRouteEditNextLocationDelay = 0;
this.jobRouteEditNextLocationArriveMessage = "";
this.jobRouteEditNextLocationGotoMessage = "";
this.jobRouteEditNextLocationType = AGRP_JOB_ROUTE_LOCATION_TYPE_NONE;
this.jobRouteEditNextLocationType = V_JOB_ROUTE_LOC_TYPE_NONE;
// Casino Stuff
this.casinoChips = 0; // This might become an item with a useId of a business (for chips belonging to specific casinos)
this.casinoCardHand = [];
this.casinoPlayingGame = AGRP_CASINO_GAME_NONE;
this.casinoPlayingGame = V_CASINO_GAME_NONE;
}
};
// ===========================================================================
function initClientScript() {
logToConsole(LOG_DEBUG, "[VRR.Client]: Initializing client script ...");
logToConsole(LOG_DEBUG, "[VRR.Client]: Client script initialized!");
logToConsole(LOG_DEBUG, "[AGRP.Client]: Initializing client script ...");
logToConsole(LOG_DEBUG, "[AGRP.Client]: Client script initialized!");
}
// ===========================================================================
function resetClientStuff(client) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
if (!getPlayerData(client)) {
return false;
@@ -172,24 +172,128 @@ function resetClientStuff(client) {
stopJobRoute(client, false, false);
}
if (isPlayerWorking(client)) {
stopWorking(client);
}
if (getPlayerData(client).rentingVehicle) {
stopRentingVehicle(client);
}
if (isPlayerInPaintBall(client)) {
stopPaintBall(client);
}
//if (isPlayerFishing(client)) {
// stopFishing(client);
//}
deleteJobItems(client);
deletePaintBallItems(client);
//deletePlayerTemporaryLockerItems(client);
getPlayerData(client).lastVehicle = null;
//getPlayerData(client).lastVehicle = null;
}
// ===========================================================================
function kickAllClients() {
getClients().forEach((client) => {
getPlayerData(client).customDisconnectReason = `Kicked - All clients are being disconnected`;
getPlayerData(client).customDisconnectReason = "ServerRestarting";
disconnectPlayer(client);
})
}
// ===========================================================================
function initClient(client) {
logToConsole(LOG_DEBUG, `[AGRP.Account] Initializing client ${getPlayerDisplayForConsole(client)} ...`);
if (isConsole(client)) {
logToConsole(LOG_DEBUG | LOG_ERROR, `[AGRP.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (is console client)`);
return false;
}
if (playerInitialized[client.index] == true) {
logToConsole(LOG_DEBUG | LOG_ERROR, `[AGRP.Account] Client initialization failed for ${getPlayerDisplayForConsole(client)}! (already initialized)`);
return false;
}
playerInitialized[client.index] = true;
//setEntityData(client, "v.rp.isInitialized", true, false);
logToConsole(LOG_DEBUG, `[AGRP.Account] Initializing GUI for ${getPlayerDisplayForConsole(client)} ...`);
sendPlayerCurrencyString(client);
sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
updatePlayerSnowState(client, getServerConfig().groundSnow);
//logToConsole(LOG_DEBUG, `[AGRP.Account] Showing connect camera to ${getPlayerDisplayForConsole(client)} ...`);
//showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
logToConsole(LOG_DEBUG, `[AGRP.Account] Waiting for 2.5 seconds to prevent race attack ...`);
setTimeout(function () {
if (client != null) {
clearChatBox(client);
logToConsole(LOG_DEBUG, `[AGRP.Account] Loading account for ${getPlayerDisplayForConsole(client)}`);
let tempAccountData = loadAccountFromName(getPlayerName(client), true);
logToConsole(LOG_DEBUG, `[AGRP.Account] Loading subaccounts for ${getPlayerDisplayForConsole(client)}`);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts);
getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client);
getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp();
requestClientInfo(client);
if (tempAccountData != false) {
sendPlayerLocaleId(client, getPlayerData(client).accountData.locale);
if (isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIP(client)) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} else {
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
showPlayerLoginGUI(client);
} else {
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"), getColourByName("softGreen"));
if (checkForGeoIPModule()) {
let iso = module.geoip.getCountryISO(getGlobalConfig().geoIPCountryDatabaseFilePath, getPlayerIP(client));
let localeId = getLocaleFromCountryISO(iso);
if (localeId != 0) {
if (getLocaleData(localeId).enabled) {
messagePlayerTip(client, getLanguageLocaleString(localeId, "LocaleOffer", `/lang ${getLocaleData(localeId).isoCode}`), getColourByName("white"), 10000, "Roboto");
}
}
}
}
startLoginTimeoutForPlayer(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
} else {
sendPlayerLocaleId(client, 0);
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
showPlayerRegistrationGUI(client);
} else {
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`);
messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client), "/register"), getColourByName("softGreen"));
}
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
}
getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
sendAccountKeyBindsToClient(client);
}
}, 2500);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: command.js
// DESC: Provides command data, functions and usage
@@ -44,8 +43,8 @@ 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!");
}
// ===========================================================================
@@ -81,6 +80,8 @@ function loadCommands() {
new CommandData("chatfilter", toggleAccountProfanityFilterCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off profanity filter"),
new CommandData("chatemoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
new CommandData("emoji", toggleAccountReplaceEmojiCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off automatic emoji"),
//new CommandData("resetkeybinds", resetKeyBindsCommand, "", getStaffFlagValue("None"), true, false, "Resets all your keybinds to default"),
//new CommandData("copykeybinds", copyKeyBindsToServerCommand, "<server id>", getStaffFlagValue("None"), true, false, "Copies all your current keybinds to another server"),
//new CommandData("noblood", toggleAccountHideBloodCommand, "", getStaffFlagValue("None"), true, false, "Turns on/off blood in-game"),
],
ammunation: [],
@@ -353,6 +354,7 @@ function loadCommands() {
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("itemtypedropmodel", setItemTypeDropModelCommand, "<item type> <object name/id>", getStaffFlagValue("ManageItems"), true, false, "Sets the drop model for the object of an item type when dropped"),
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"),
@@ -360,7 +362,7 @@ function loadCommands() {
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("itemtypecapacity", setItemTypeCapacityCommand, "<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"),
@@ -592,6 +594,7 @@ function loadCommands() {
new CommandData("biz", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("business", getPlayerCurrentBusinessCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which business a player is at/in"),
new CommandData("house", getPlayerCurrentHouseCommand, "<player name/id>", getStaffFlagValue("BasicModeration"), true, true, "Gets which house a player is at/in"),
//new CommandData("clearchat", clearChatCommand, "", getStaffFlagValue("None"), true, true, "Clears the chat"),
],
startup: [],
subAccount: [
@@ -634,7 +637,7 @@ function loadCommands() {
new CommandData("vehowner", setVehicleOwnerCommand, "<player id/name>", getStaffFlagValue("ManageVehicles"), true, true),
new CommandData("vehpublic", setVehiclePublicCommand, "", getStaffFlagValue("ManageVehicles"), true, true),
new CommandData("vehclan", setVehicleClanCommand, "<clan id/name>", getStaffFlagValue(""), true, true),
new CommandData("vehbiz", setVehicleToBusinessCommand, "", getStaffFlagValue(""), true, true),
new CommandData("vehbiz", setVehicleBusinessCommand, "", getStaffFlagValue(""), true, true),
new CommandData("vehjob", setVehicleJobCommand, "[job id/name]", getStaffFlagValue("ManageVehicles"), true, true),
new CommandData("vehdelowner", removeVehicleOwnerCommand, "", getStaffFlagValue("ManageVehicles"), true, true),
new CommandData("vehrank", setVehicleRankCommand, "<rank id/name>", getStaffFlagValue("None"), true, true),
@@ -704,7 +707,7 @@ function addAllCommandHandlers() {
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}`);
logToConsole(LOG_VERBOSE, `[AGRP.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
addCommandHandler(commands[i][j].command, processPlayerCommand);
commandCount++;
}
@@ -713,11 +716,14 @@ function addAllCommandHandlers() {
removeCommandHandler("help");
addCommandHandler("help", helpCommand);
logToConsole(LOG_INFO, `[VRR.Command] ${commandCount} command handlers added!`);
logToConsole(LOG_INFO, `[AGRP.Command] ${commandCount} command handlers added!`);
}
// ===========================================================================
/**
* @return {CommandData} command
*/
function getCommand(command) {
let commandGroups = getCommands()
for (let i in commandGroups) {
@@ -734,6 +740,9 @@ function getCommand(command) {
// ===========================================================================
/**
* @return {CommandData} command
*/
function getCommandData(command) {
return getCommand(command);
}
@@ -785,12 +794,12 @@ function disableCommand(command, params, client) {
params = toLowerCase(params);
if (!getCommand(params)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
messagePlayerError(client, `The command {ALTCOLOUR}/${params}{MAINCOLOUR} does not exist!`);
return false;
}
getCommand(params).enabled = false;
messagePlayerSuccess(client, `Command {ALTCOLOUR}/${params} {MAINCOLOUR}has been disabled!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} disabled the {ALTCOLOUR}${params}{MAINCOLOUR} command!`, true);
return true;
}
@@ -805,12 +814,12 @@ function enableCommand(command, params, client) {
params = toLowerCase(params);
if (!getCommand(params)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${params} {MAINCOLOUR} does not exist!`);
messagePlayerError(client, `The command {ALTCOLOUR}/${params}{MAINCOLOUR} does not exist!`);
return false;
}
getCommand(params).enabled = true;
messagePlayerSuccess(client, `Command {ALTCOLOUR}/${params} {MAINCOLOUR}has been enabled!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} enabled the {ALTCOLOUR}${params}{MAINCOLOUR} command!`, true);
return true;
}
@@ -825,7 +834,7 @@ function disableAllCommandsByType(command, params, client) {
params = toLowerCase(params);
if (isNull(getServerData().commands[params])) {
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
messagePlayerError(client, `Command type {ALTCOLOUR}${params}{MAINCOLOUR} does not exist!`);
return false;
}
@@ -833,7 +842,7 @@ function disableAllCommandsByType(command, params, client) {
getServerData().commands[params][i].enabled = false;
}
messagePlayerSuccess(client, `{clanOrange}All {ALTCOLOUR}${params} {MAINCOLOUR}commands have been disabled!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} disabled all {ALTCOLOUR}${params}{MAINCOLOUR} commands!`, true);
return true;
}
@@ -848,7 +857,7 @@ function enableAllCommandsByType(command, params, client) {
params = toLowerCase(params);
if (isNull(getServerData().commands[params])) {
messagePlayerError(client, `Command type {ALTCOLOUR}${params} {MAINCOLOUR}does not exist!`);
messagePlayerError(client, `Command type {ALTCOLOUR}${params}{MAINCOLOUR} does not exist!`);
return false;
}
@@ -856,7 +865,7 @@ function enableAllCommandsByType(command, params, client) {
getServerData().commands[params][i].enabled = true;
}
messagePlayerSuccess(client, `{clanOrange}All {ALTCOLOUR}${params} {MAINCOLOUR}commands have been enabled!`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} enabled all {ALTCOLOUR}${params}{MAINCOLOUR} commands!`, true);
return true;
}
@@ -881,7 +890,7 @@ function processPlayerCommand(command, params, client) {
}
if (!doesCommandExist(toLowerCase(command))) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
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)))) {
@@ -893,7 +902,7 @@ function processPlayerCommand(command, params, client) {
}
if (!commandData.enabled) {
logToConsole(LOG_WARN, `[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (command is disabled): /${command} ${paramsDisplay}`);
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;
@@ -901,7 +910,7 @@ function processPlayerCommand(command, params, client) {
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}`);
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;
}
@@ -909,7 +918,7 @@ function processPlayerCommand(command, params, client) {
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}`);
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;
}
@@ -917,13 +926,13 @@ function processPlayerCommand(command, params, client) {
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}`);
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);
}
@@ -1028,10 +1037,10 @@ function cacheAllCommandsAliases() {
// ===========================================================================
function getCommandAliasesNames(command) {
function getCommandAliasesNames(commandData) {
let commandAliases = [];
for (let i in command.aliases) {
commandAliases.push(command.aliases[i].name);
for (let i in commandData.aliases) {
commandAliases.push(commandData.aliases[i].name);
}
return commandAliases;

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: config.js
// DESC: Provides server configuration
@@ -91,10 +90,10 @@ class ServerConfigData {
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"],
spawnHeading: toFloat(dbAssoc["svr_newchar_rot_z"]),
money: toInteger(dbAssoc["svr_newchar_money"]),
bank: toInteger(dbAssoc["svr_newchar_bank"]),
skin: toInteger(dbAssoc["svr_newchar_skin"]),
};
this.connectCameraPosition = toVector3(dbAssoc["svr_connectcam_pos_x"], dbAssoc["svr_connectcam_pos_y"], dbAssoc["svr_connectcam_pos_z"]);
@@ -126,8 +125,8 @@ class ServerConfigData {
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.useRealTime = intToBool(toInteger(dbAssoc["svr_real_time_enabled"]));
this.realTimeZone = dbAssoc["svr_real_time_timezone"];
this.discord = {
sendEvents: intToBool(dbAssoc["svr_discord_send_events"]),
@@ -194,22 +193,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: [
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,
V_ITEM_USE_TYPE_WEAPON,
V_ITEM_USE_TYPE_TAZER,
V_ITEM_USE_TYPE_EXTINGUISHER,
V_ITEM_USE_TYPE_SPRAYPAINT,
V_ITEM_USE_TYPE_PEPPERSPRAY,
],
onFootOnlyItems: [
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,
V_ITEM_USE_TYPE_VEHREPAIR,
V_ITEM_USE_TYPE_VEHCOLOUR,
V_ITEM_USE_TYPE_VEHUPGRADE_PART,
V_ITEM_USE_TYPE_VEHLIVERY,
V_ITEM_USE_TYPE_VEHTIRE,
],
vehicleInactiveRespawnDelay: 1800000, // 20 minutes
chatSectionHeaderLength: 96,
@@ -246,85 +245,88 @@ let globalConfig = {
fishingCastMaxStrength: 100,
fishingCastMinStrength: 30,
jobRouteLocationSphereRadius: 3,
monthlyChanceOfSnow: [90, 50, 10, 0, 0, 0, 0, 0, 0, 0, 50, 90],
defaultEnabledAccountSettings: [
"ChatBoxTimestamps",
"ChatEmoji",
],
};
// ===========================================================================
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}`);
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}`);
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}`);
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}`);
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}`);
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}`);
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}`);
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();
let dbAssoc = [];
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) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
return tempServerConfigData;
}
disconnectFromDatabase(dbConnection);
}
@@ -335,16 +337,14 @@ function loadServerConfigFromGameAndPort(gameId, port) {
function loadServerConfigFromGame(gameId) {
let dbConnection = connectToDatabase();
let dbAssoc = [];
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);
return tempServerConfigData;
}
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
return tempServerConfigData;
}
disconnectFromDatabase(dbConnection);
}
@@ -355,36 +355,37 @@ function loadServerConfigFromGame(gameId) {
function loadServerConfigFromId(tempServerId) {
let dbConnection = connectToDatabase();
let dbAssoc = [];
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) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
return tempServerConfigData;
}
disconnectFromDatabase(dbConnection);
}
return false;
}
// ===========================================================================
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 (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, `[VRR.Config]: Setting weather to ${tempServerConfig.weather}`);
game.forceWeather(tempServerConfig.weather);
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
game.forceWeather(getWeatherData(tempServerConfig.weather).weatherId);
}
updateServerRules();
@@ -393,7 +394,7 @@ function applyConfigToServer(tempServerConfig) {
// ===========================================================================
function saveServerConfigToDatabase() {
logToConsole(LOG_DEBUG, `[VRR.Config]: Saving server ${getServerConfig().databaseId} configuration to database ...`);
logToConsole(LOG_DEBUG, `[AGRP.Config]: Saving server ${getServerConfig().databaseId} configuration to database ...`);
if (getServerConfig().needsSaved) {
let dbConnection = connectToDatabase();
if (dbConnection) {
@@ -457,7 +458,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!`);
}
// ===========================================================================
@@ -580,19 +581,19 @@ function setWeatherCommand(command, params, client) {
return false;
}
let weatherId = getWeatherFromParams(getParam(params, " ", 1));
let weatherIndex = getWeatherFromParams(getParam(params, " ", 1));
if (!weatherId) {
if (!getWeatherData(weatherIndex)) {
messagePlayerError(client, `That weather ID or name is invalid!`);
return false;
}
game.forceWeather(toInteger(weatherId));
getServerConfig().weather = weatherId;
game.forceWeather(getWeatherData(weatherIndex).weatherId);
getServerConfig().weather = weatherIndex;
getServerConfig().needsSaved = true;
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getGame()][toInteger(weatherId)]);
announceAdminAction("ServerWeatherSet", getPlayerName(client), getWeatherData(weatherIndex).name);
updateServerRules();
return true;
}
@@ -891,7 +892,7 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
* @return {bool} Whether or not the command was successful
*
*/
function reloadServerConfigurationCommand(command, params, client) {
async function reloadServerConfigurationCommand(command, params, client) {
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port);
applyConfigToServer(serverConfig);
updateServerRules();
@@ -931,7 +932,7 @@ function reloadEmailConfigurationCommand(command, params, client) {
*/
function reloadDatabaseConfigurationCommand(command, params, client) {
if (getDatabaseConfig().usePersistentConnection && isDatabaseConnected(persistentDatabaseConnection)) {
logToConsole(LOG_WARN, `[VRR.Database] Closing persistent database connection`);
logToConsole(LOG_WARN, `[AGRP.Database] Closing persistent database connection`);
persistentDatabaseConnection.close();
persistentDatabaseConnection = null;
}
@@ -979,7 +980,7 @@ 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) {
return localeConfig;
@@ -989,7 +990,7 @@ 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) {
return economyConfig;
@@ -999,7 +1000,7 @@ 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) {
return accentConfig;
@@ -1009,7 +1010,7 @@ 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) {
return discordConfig;
@@ -1020,7 +1021,7 @@ 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) {
return databaseConfig;
@@ -1031,7 +1032,7 @@ 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) {
return keyBindConfig;
@@ -1042,7 +1043,7 @@ 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) {
return emailConfig;
@@ -1125,20 +1126,25 @@ function getDatabaseConfig() {
// ===========================================================================
function loadServerConfig() {
logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration");
try {
if (toInteger(server.getCVar("agrp_devserver")) == 1) {
serverConfig = loadServerConfigFromGame(getGame());
} else {
serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort());
}
logToConsole(LOG_DEBUG, "[AGRP.Config] Loading server configuration");
} catch (error) {
logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`);
thisResource.stop();
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());
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}`);
//logToConsole(LOG_DEBUG | LOG_WARN, `Server ID: ${serverConfig.databaseId}`);
}
// ===========================================================================

View File

@@ -1,16 +1,15 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: core.js
// DESC: Provides core data structures, function, and operations
// TYPE: Server (JavaScript)
// ===========================================================================
let scriptVersion = "1.2";
let scriptVersion = "1.3";
let serverStartTime = 0;
let logLevel = LOG_INFO | LOG_DEBUG | LOG_VERBOSE; // LOG_ERROR|LOG_WARN;
let logLevel = LOG_INFO | LOG_ERROR | LOG_WARN | LOG_DEBUG | LOG_VERBOSE;
let playerResourceReady = new Array(server.maxClients).fill(false);
let playerResourceStarted = new Array(server.maxClients).fill(false);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: crime.js
// DESC: Provides crime data structures, functions, and operations

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: database.js
// DESC: Provides database handling, functions and usage
@@ -15,8 +14,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!");
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage
@@ -9,7 +8,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);
@@ -18,7 +17,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;
}
@@ -152,7 +151,7 @@ function addLogLevelCommand(command, params, client) {
}
sendPlayerLogLevel(null, logLevel);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR} enabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -219,7 +218,7 @@ function removeLogLevelCommand(command, params, client) {
}
sendPlayerLogLevel(null, logLevel);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} {MAINCOLOUR}disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
messageAdmins(`{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR} disabled log level {ALTCOLOUR}${toLowerCase(params)}`);
return true;
}
@@ -254,7 +253,7 @@ function simulateCommandForPlayerCommand(command, params, client) {
}
if (!getCommand(tempCommand)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} does not exist! Use /help for commands and information.`);
return false;
}
@@ -288,7 +287,7 @@ function simulateCommandForAllPlayersCommand(command, params, client) {
let tempParams = splitParams.slice(1).join(" ");
if (!getCommand(tempCommand)) {
messagePlayerError(client, `The command {ALTCOLOUR}/${command} {MAINCOLOUR}does not exist! Use /help for commands and information.`);
messagePlayerError(client, `The command {ALTCOLOUR}/${command}{MAINCOLOUR} does not exist! Use /help for commands and information.`);
return false;
}
@@ -441,22 +440,16 @@ function testErrorGUICommand(command, params, client) {
// ===========================================================================
function saveServerDataCommand(command, params, client) {
messageAdmins(`{adminOrange}Vortrex{MAINCOLOUR} has forced a manual save of all data. Initiating ...`);
messageAdmins(`{adminOrange}Vortrex{MAINCOLOUR} has forced a manual save of all data. Initiating ...`, true);
saveServerDataToDatabase();
messageAdmins(`{MAINCOLOUR}All server data saved to database successfully!`);
messageAdmins(`{MAINCOLOUR}All server data saved to database successfully!`, true);
return true;
}
// ===========================================================================
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;
}
@@ -555,40 +548,38 @@ function isDevelopmentServer() {
// ===========================================================================
function migrateSubAccountsToPerServerData() {
async function migrateSubAccountsToPerServerData() {
let dbConnection = connectToDatabase();
let dbQuery = false;
let dbAssoc = false;
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
if (dbQuery) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
createDefaultSubAccountServerData(dbAssoc["sacct_id"]);
let dbAssoc = [];
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) {
freeDatabaseQuery(dbQuery2);
}
if (dbConnection) {
let dbQueryString = `SELECT * FROM sacct_main`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
createDefaultSubAccountServerData(dbAssoc[0]["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) {
freeDatabaseQuery(dbQuery2);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase();
}
}
// ===========================================================================
function resetAllAccountsHotkeysToDefault() {
async function resetAllAccountsHotkeysToDefault() {
let dbConnection = connectToDatabase();
let dbQuery = false;
let dbAssoc = false;
let dbAssoc = [];
if (dbConnection) {
dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`);
if (dbQuery) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
createDefaultKeybindsForAccount(dbAssoc["acct_id"]);
}
freeDatabaseQuery(dbQuery);
let dbQueryString = `SELECT acct_id FROM acct_main`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
createDefaultKeybindsForAccount(dbAssoc[0]["acct_id"]);
}
disconnectFromDatabase();
}
}
@@ -655,6 +646,8 @@ function fixAllServerBlipsCommand(command, params, client) {
createAllJobBlips();
createAllBusinessBlips();
createAllHouseBlips();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server blips`);
}
// ===========================================================================
@@ -668,6 +661,8 @@ function fixAllServerPickupsCommand(command, params, client) {
createAllJobPickups();
createAllBusinessPickups();
createAllHousePickups();
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} reset all server pickups`);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage
@@ -9,15 +8,15 @@
// ===========================================================================
// Discord Webhook Types
const AGRP_DISCORD_WEBHOOK_NONE = 0;
const AGRP_DISCORD_WEBHOOK_LOG = 1;
const AGRP_DISCORD_WEBHOOK_ADMIN = 2;
const V_DISCORD_WEBHOOK_NONE = 0;
const V_DISCORD_WEBHOOK_LOG = 1;
const V_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!");
}
// ===========================================================================
@@ -111,7 +110,7 @@ function messageDiscordChatChannel(messageString) {
messageString = removeColoursInMessage(messageString);
messageString = replaceProfanityInMessage(messageString);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
triggerDiscordWebHook(messageString, getServerId(), V_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
@@ -131,7 +130,7 @@ function messageDiscordEventChannel(messageString) {
messageString = removeColoursInMessage(messageString);
messageString = replaceProfanityInMessage(messageString);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
triggerDiscordWebHook(messageString, getServerId(), V_DISCORD_WEBHOOK_LOG);
}
// ===========================================================================
@@ -150,7 +149,7 @@ function messageDiscordAdminChannel(messageString) {
}
messageString = removeColoursInMessage(messageString);
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_ADMIN);
triggerDiscordWebHook(messageString, getServerId(), V_DISCORD_WEBHOOK_ADMIN);
}
// ===========================================================================
@@ -178,13 +177,13 @@ function messageDiscordClanWebhook(clanIndex, requiredFlagValue, messageString)
// ===========================================================================
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = AGRP_DISCORD_WEBHOOK_LOG) {
function triggerDiscordWebHook(messageString, serverId = getServerId(), type = V_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("{0}", encodeURIComponent(messageString));
tempURL = tempURL.replace("{1}", serverId);
tempURL = tempURL.replace("{2}", type);
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);
@@ -211,7 +210,7 @@ function triggerClanDiscordWebHook(clanIndex, messageString) {
let webhookURL = getClanData(clanIndex).discordWebhookURL;
let tempURL = getGlobalConfig().discord.webhook.webhookBaseURL;
tempURL = tempURL.replace("{0}", encodeURI(messageString));
tempURL = tempURL.replace("{0}", encodeURIComponent(messageString));
tempURL = tempURL.replace("{1}", serverId);
tempURL = tempURL.replace("{2}", type);
tempURL = tempURL.replace("{3}", getGlobalConfig().discord.webhook.pass);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: economy.js
// DESC: Provides economy/financial utils, functions and usage
@@ -9,8 +8,8 @@
// ===========================================================================
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!");
}
// ===========================================================================
@@ -47,15 +46,15 @@ function playerPayDay(client) {
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}`);
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) {
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 {
@@ -141,14 +140,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}`));
}
// ===========================================================================
@@ -188,19 +187,19 @@ function repossessFirstAsset(client) {
// ===========================================================================
function getAllVehiclesOwnedByPlayer(client) {
return getServerData().vehicles.filter((v) => v.ownerType == AGRP_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
return getServerData().vehicles.filter((v) => v.ownerType == V_VEHOWNER_PLAYER && v.ownerId == getPlayerCurrentSubAccount(client).databaseId);
}
// ===========================================================================
function getAllBusinessesOwnedByPlayer(client) {
return getServerData().businesses.filter((b) => b.ownerType == AGRP_BIZ_OWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
return getServerData().businesses.filter((b) => b.ownerType == V_BIZ_OWNER_PLAYER && b.ownerId == getPlayerCurrentSubAccount(client).databaseId);
}
// ===========================================================================
function getAllHousesOwnedByPlayer(client) {
return getServerData().houses.filter((h) => h.ownerType == AGRP_HOUSE_OWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
return getServerData().houses.filter((h) => h.ownerType == V_HOUSE_OWNER_PLAYER && h.ownerId == getPlayerCurrentSubAccount(client).databaseId);
}
// ===========================================================================
@@ -213,4 +212,12 @@ function isDoubleBonusActive() {
return false;
}
// ===========================================================================
function getCurrencyString(amount) {
let tempString = getGlobalConfig().economy.currencyString;
tempString = tempString.replace("{AMOUNT}", toString(makeLargeNumberReadable(amount)));
return tempString;
}
// ===========================================================================

View File

@@ -1,40 +1,74 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: email.js
// DESC: Provides email handling, functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
// Email Methods
const V_EMAIL_METHOD_NONE = 0; // None
const V_EMAIL_METHOD_SMTP_MODULE = "smtp"; // Use SMTP module
const V_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!");
}
// ===========================================================================
async function sendEmail(toEmail, toName, subject, body) {
if (!checkForSMTPModule()) {
return false;
switch (getEmailConfig().method) {
case V_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 V_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;
}
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
);
});
return true;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -9,9 +8,9 @@
// ===========================================================================
function initEventScript() {
logToConsole(LOG_INFO, "[VRR.Event]: Initializing event script ...");
logToConsole(LOG_INFO, "[AGRP.Event]: Initializing event script ...");
addAllEventHandlers();
logToConsole(LOG_INFO, "[VRR.Event]: Event script initialized!");
logToConsole(LOG_INFO, "[AGRP.Event]: Event script initialized!");
}
// ===========================================================================
@@ -28,17 +27,21 @@ function addAllEventHandlers() {
addEventHandler("onElementStreamIn", onElementStreamIn);
addEventHandler("onElementStreamOut", onElementStreamOut);
addEventHandler("onPedSpawn", onPedSpawn);
addEventHandler("OnPickupPickedUp", onPedPickupPickedUp);
addEventHandler("onPedEnteredVehicleEx", onPedEnteredVehicle);
addEventHandler("onPedExitedVehicleEx", onPedExitedVehicle);
addEventHandler("onPedEnteredSphereEx", onPedEnteredSphere);
addEventHandler("onPedExitedSphereEx", onPedExitedSphere);
addEventHandler("OnPickupPickedUp", onPedPickupPickedUp);
if (getGame() == V_GAME_MAFIA_ONE) {
addEventHandler("onPedFall", onPedFall);
}
}
// ===========================================================================
function onPlayerConnect(event, ipAddress, port) {
logToConsole(LOG_INFO, `[VRR.Event] Client connecting (IP: ${ipAddress})`);
logToConsole(LOG_INFO, `[AGRP.Event] onPlayerConnect - Client connecting (IP: ${ipAddress})`);
//if(isIpAddressBanned(ipAddress)) {
// messagePlayerError(client, "You are banned from this server!");
// return false;
@@ -48,15 +51,14 @@ function onPlayerConnect(event, ipAddress, port) {
// ===========================================================================
function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
logToConsole(LOG_INFO, `[AGRP.Event] onPlayerJoin - Client ${getPlayerDisplayForConsole(client)} joining from ${getPlayerIP(client)}`);
//if (isFadeCameraSupported()) {
// fadeCamera(client, true, 1.0);
//}
playerResourceReady[getPlayerId(client)] = false;
playerResourceStarted[getPlayerId(client)] = false;
playerInitialized[getPlayerId(client)] = false;
playerGUIReady[getPlayerId(client)] = false;
//if(isCustomCameraSupported()) {
// showConnectCameraToPlayer(client);
//}
getServerData().clients[getPlayerId(client)] = null;
let messageText = `👋 ${getPlayerName(client)} is connecting to the server ...`;
messageDiscordEventChannel(messageText);
@@ -65,13 +67,12 @@ function onPlayerJoin(event, client) {
for (let i in clients) {
messagePlayerNormal(clients[i], getLocaleString(clients[i], "PlayerConnecting", getPlayerName(client)));
}
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
}
// ===========================================================================
function onPlayerJoined(event, client) {
logToConsole(LOG_INFO, `[AGRP.Event] onPlayerJoined - Client ${getPlayerDisplayForConsole(client)} joined from ${getPlayerIP(client)}`);
//initClient(client);
}
@@ -99,37 +100,23 @@ function onElementStreamOut(event, element, client) {
// ===========================================================================
function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
updateConnectionLogOnQuit(client, quitReasonId);
let disconnectName = disconnectReasons[quitReasonId];
let reasonTextEnglish = getLanguageGroupedLocaleString(englishLocale, "DisconnectReasons", disconnectName);
let clientName = getPlayerName(client);
let reasonText = disconnectReasons[quitReasonId];
if (getPlayerData(client) != false) {
if (getPlayerData(client).customDisconnectReason != "") {
reasonText = getPlayerData(client).customDisconnectReason;
disconnectName = getPlayerData(client).customDisconnectReason;
}
}
//messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
updateConnectionLogOnQuit(client, disconnectName);
//if (isPlayerFishing(client)) {
// stopFishing(client);
//}
if (isPlayerInPaintBall(client)) {
stopPaintBall(client);
}
if (isPlayerOnJobRoute(client)) {
stopJobRoute(client);
}
if (isPlayerWorking(client)) {
stopWorking(client);
}
resetClientStuff(client);
if (isPlayerLoggedIn(client)) {
savePlayerToDatabase(client);
resetClientStuff(client);
}
if (getPlayerData(client).loginTimeout != null) {
@@ -141,13 +128,15 @@ function onPlayerQuit(event, client, quitReasonId) {
playerInitialized[client.index] = false;
playerGUIReady[client.index] = false;
messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
getClients().forEach(forClient => {
let reasonText = getGroupedLocaleString(forClient, "DisconnectReasons", quitReasonId);
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", getPlayerName(client), reasonText));
});
getServerData().clients[getPlayerId(client)] = null;
logToConsole(LOG_INFO, `👋 Client ${getPlayerDisplayForConsole(client)} disconnected (quitReasonId - ${reasonTextEnglish})`);
//messageDiscordEventChannel(`👋 ${clientName} has left the server (${reasonTextEnglish})`);
messageDiscordEventChannel(`👋 ${getLanguageLocaleString(englishLocale, "PlayerLeftServer", clientName, reasonTextEnglish)}`);
getClients().filter(c => c != client).forEach(forClient => {
messagePlayerNormal(forClient, getLocaleString(forClient, "PlayerLeftServer", clientName, getGroupedLocaleString(forClient, "DisconnectReasons", disconnectName)));
});
}
// ===========================================================================
@@ -178,7 +167,7 @@ function onEntityProcess(event, entity) {
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AGRP_PEDSTATE_ENTERINGVEHICLE;
getPlayerData(client).pedState = V_PEDSTATE_ENTERINGVEHICLE;
if (!getVehicleData(vehicle)) {
return false;
@@ -213,30 +202,25 @@ function onPedExitingVehicle(event, ped, vehicle) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
getPlayerData(client).pedState = AGRP_PEDSTATE_EXITINGVEHICLE;
}
if (!getVehicleData(vehicle).spawnLocked) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
getPlayerData(client).pedState = V_PEDSTATE_EXITINGVEHICLE;
}
}
// ===========================================================================
function onResourceStart(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] Resource ${resource.name} started!`);
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Resource ${resource.name} started!`);
//if(resource != thisResource) {
// messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} started!`);
//}
if (resource == thisResource) {
//messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} started!`);
messageDiscordEventChannel(`✅ Server is starting up!`);
}
}
// ===========================================================================
function onResourceStop(event, resource) {
logToConsole(LOG_WARN, `[VRR.Event] Resource ${resource.name} stopped!`);
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Resource ${resource.name} stopped!`);
//if(resource != thisResource) {
// messageAdmins(`{MAINCOLOUR}Resource {ALTCOLOUR}${resource.name}{MAINCOLOUR} stopped!`);
@@ -247,27 +231,47 @@ function onResourceStop(event, resource) {
saveServerDataToDatabase();
disconnectFromDatabase(persistentDatabaseConnection, true);
collectAllGarbage();
messageDiscordEventChannel(`⛔ Server is shutting down!`);
}
}
// ===========================================================================
function onPedEnteredSphere(event, ped, sphere) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
// Handled client-side since server spheres aren't showing on GTAC atm (bug)
//if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
// playerArrivedAtJobRouteLocation(client);
// }
//}
if (ped == null) {
return false;
}
if (sphere == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} entered sphere ${sphere.id}!`);
//if (ped.isType(ELEMENT_PLAYER)) {
// let client = getClientFromPlayerElement(ped);
// Handled client-side since server spheres aren't showing on GTAC atm (bug)
//if (isPlayerOnJobRoute(client)) {
// if (sphere == getJobRouteLocationData(getPlayerJob(client), getPlayerJobRoute(client), getPlayerJobRouteLocation(client)).marker) {
// playerArrivedAtJobRouteLocation(client);
// }
//}
//}
}
// ===========================================================================
function onPedExitedSphere(event, ped, sphere) {
if (ped == null) {
return false;
}
if (sphere == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} exited sphere ${sphere.id}!`);
//if (ped.isType(ELEMENT_PLAYER)) {
// let client = getClientFromPlayerElement(ped);
//}
@@ -276,6 +280,16 @@ function onPedExitedSphere(event, ped, sphere) {
// ===========================================================================
function onPedPickupPickedUp(event, ped, pickup) {
if (ped == null) {
return false;
}
if (pickup == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} picked up pickup ${pickup.id}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
@@ -289,7 +303,10 @@ function onPedPickupPickedUp(event, ped, pickup) {
// ===========================================================================
/*
function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} wasted by ped ${killerPed.id}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let killerClient = null;
if (killerPed != null && killerPed.type == ELEMENT_PLAYER) {
@@ -298,12 +315,15 @@ function onPedWasted(event, ped, killerPed, weapon, pedPiece) {
onPlayerWasted(getClientFromPlayerElement(ped), killerClient, weapon, pedPiece);
}
}
*/
// ===========================================================================
function onPlayerDeath(client, killer, weapon, pedPiece) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Player ${getPlayerDisplayForConsole(client)} died!`);
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} died.`);
getPlayerData(client).pedState = AGRP_PEDSTATE_DEAD;
getPlayerData(client).pedState = V_PEDSTATE_DEAD;
updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false);
setTimeout(function () {
@@ -393,172 +413,185 @@ function onPlayerDeath(client, killer, weapon, pedPiece) {
// ===========================================================================
function onPedSpawn(ped) {
if (ped.type == ELEMENT_PLAYER) {
//setTimeout(onPlayerSpawn, 250, ped);
onPlayerSpawn();
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} spawned!`);
//if (ped.type == ELEMENT_PLAYER) {
// if (getGame() != V_GAME_MAFIA_ONE) {
// //setTimeout(onPlayerSpawn, 250, getClientFromPlayerElement(ped));
// //onPlayerSpawn(getClientFromPlayerElement(ped));
// }
//}
}
// ===========================================================================
async function onPlayerSpawn(client) {
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Player ${getPlayerDisplayForConsole(client)} spawned!`);
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
//if(getPlayerPed(client) == null) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player element not set yet. Rechecking ...`);
// setTimeout(onPlayerSpawn, 500, client);
// return false;
//}
//logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
//logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
if (areServerElementsSupported()) {
await waitUntil(() => client != null && getPlayerPed(client) != null);
}
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
stopRadioStreamForPlayer(client);
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if (!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Spawn bug. Data invalid.`;
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client);
return false;
}
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if (!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without logging in.`;
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client);
return false;
}
//logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
//logToConsole(LOG_DEBUG, `[AGRP.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if (getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = `Kicked - Tried to force spawn without selecting a character.`;
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
getPlayerData(targetClient).customDisconnectReason = "Desync";
disconnectPlayer(client);
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s player data is valid. Continuing spawn processing ...`);
if (isGameFeatureSupported("pedScale")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(getPlayerPed(client), "agrp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped scale (${getPlayerCurrentSubAccount(client).pedScale})`);
setEntityData(getPlayerPed(client), "v.rp.scale", getPlayerCurrentSubAccount(client).pedScale, true);
}
//if (isPlayerSwitchingCharacter(client) || isPlayerCreatingCharacter(client)) {
// logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
// logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)}'s ped is being used for character selection/creation. No further spawn processing needed'`);
// return false;
//}
if (isCustomCameraSupported() && getGame() != AGRP_GAME_GTA_IV && getGame() != AGRP_GAME_GTA_IV_EFLC) {
logToConsole(LOG_DEBUG, `[VRR.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
if (isCustomCameraSupported()) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Restoring ${getPlayerDisplayForConsole(client)}'s camera`);
restorePlayerCamera(client);
}
if (areServerElementsSupported()) {
logToConsole(LOG_DEBUG, `[VRR.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
logToConsole(LOG_DEBUG, `[AGRP.Event] Storing ${getPlayerDisplayForConsole(client)} ped in client data `);
getPlayerData(client).ped = getPlayerPed(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending ${getPlayerDisplayForConsole(client)} the 'now playing as' message`);
messagePlayerAlert(client, `You are now playing as: {businessBlue}${getCharacterFullName(client)}`, getColourByName("white"));
//messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
//messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
// Tried this. Doesn't work for some reason.
// Mafia Connected needs fixed to set position on spawn.
//if (getGame() == AGRP_GAME_MAFIA_ONE) {
//if (getGame() == V_GAME_MAFIA_ONE) {
// setPlayerPosition(client, getPlayerCurrentSubAccount(client).spawnPosition);
// setPlayerHeading(client, getPlayerCurrentSubAccount(client).spawnHeading);
// setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
//}
if (isGameFeatureSupported("interior")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player interior for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).interior}`);
setPlayerInterior(client, getPlayerCurrentSubAccount(client).interior);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player dimension for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).dimension}`);
setPlayerDimension(client, getPlayerCurrentSubAccount(client).dimension);
//if(getPlayerCurrentSubAccount(client).interior != 0 || getPlayerCurrentSubAccount(client).dimension != 0) {
// updateAllInteriorVehiclesForPlayer(client, getPlayerCurrentSubAccount(client).interior, getPlayerCurrentSubAccount(client).dimension);
//}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player health for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).health}`);
setPlayerHealth(client, getPlayerCurrentSubAccount(client).health);
if (isGameFeatureSupported("pedArmour")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player armour for ${getPlayerDisplayForConsole(client)} to ${getPlayerCurrentSubAccount(client).armour}`);
setPlayerArmour(client, getPlayerCurrentSubAccount(client).armour);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending ${getPlayerDisplayForConsole(client)}'s job type to their client (${getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client))})`);
sendPlayerJobType(client, getPlayerCurrentSubAccount(client).job);
if (isGameFeatureSupported("rendering2D")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Enabling all rendering states for ${getPlayerDisplayForConsole(client)}`);
setPlayer2DRendering(client, true, true, true, true, true, true);
}
if (isGameFeatureSupported("snow")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
updatePlayerSnowState(client);
}
//if (isGameFeatureSupported("snow")) {
// logToConsole(LOG_DEBUG, `[AGRP.Event] Sending snow states to ${getPlayerDisplayForConsole(client)}`);
// updatePlayerSnowState(client, true);
//}
if (areServerElementsSupported() && isGameFeatureSupported("walkStyle")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "agrp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player walking style for ${getPlayerDisplayForConsole(client)}`);
setEntityData(getPlayerPed(client), "v.rp.walkStyle", getPlayerCurrentSubAccount(client).walkStyle, true);
}
if (isGameFeatureSupported("fightStyle")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Setting player fighting style for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting player fighting style for ${getPlayerDisplayForConsole(client)}`);
setPlayerFightStyle(client, getPlayerCurrentSubAccount(client).fightStyle);
}
if (isGameFeatureSupported("rendering2D")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Updating logo state for ${getPlayerDisplayForConsole(client)}`);
updatePlayerShowLogoState(client, (getServerConfig().showLogo && doesPlayerHaveLogoEnabled(client)));
}
logToConsole(LOG_DEBUG, `[VRR.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Caching ${getPlayerDisplayForConsole(client)}'s hotbar items`);
cachePlayerHotBarItems(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Syncing ${getPlayerDisplayForConsole(client)}'s hotbar`);
updatePlayerHotBar(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting ${getPlayerDisplayForConsole(client)}'s switchchar state to false`);
getPlayerData(client).switchingCharacter = false;
if (!doesPlayerHaveKeyBindsDisabled(client) && doesPlayerHaveKeyBindForCommand(client, "enter")) {
let keyId = getPlayerKeyBindForCommand(client, "enter");
logToConsole(LOG_DEBUG, `[VRR.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending custom enter property key ID (${keyId.key}, ${toUpperCase(getKeyNameFromId(keyId.key))}) to ${getPlayerDisplayForConsole(client)}`);
sendPlayerEnterPropertyKey(client, keyId.key);
}
sendPlayerChatBoxTimeStampsState(client, isPlayerAccountSettingEnabled(client, "ChatBoxTimestamps"));
sendPlayerChatEmojiState(client, isPlayerAccountSettingEnabled(client, "ChatEmoji"));
sendPlayerProfanityFilterState(client, isPlayerAccountSettingEnabled(client, "ProfanityFilter"));
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
//sendPlayerGlobalKeyBindsState(client, !isPlayerAccountSettingEnabled(client, "NoKeyBinds"));
//if(isGTAIV()) {
// setEntityData(getPlayerPed(client), "agrp.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(getPlayerPed(client), "agrp.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartHair", getPlayerCurrentSubAccount(client).bodyParts.hair, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyParts.head, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartUpper", getPlayerCurrentSubAccount(client).bodyParts.upper, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartLower", getPlayerCurrentSubAccount(client).bodyParts.lower, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPropHair", getPlayerCurrentSubAccount(client).bodyProps.hair, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPropEyes", getPlayerCurrentSubAccount(client).bodyProps.eyes, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartHead", getPlayerCurrentSubAccount(client).bodyProps.head, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartLeftHand", getPlayerCurrentSubAccount(client).bodyProps.leftHand, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartRightHand", getPlayerCurrentSubAccount(client).bodyProps.rightHand, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartLeftWrist", getPlayerCurrentSubAccount(client).bodyProps.leftWrist, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartRightWrist", getPlayerCurrentSubAccount(client).bodyProps.rightWrist, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartHip", getPlayerCurrentSubAccount(client).bodyProps.hip, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartLeftFoot", getPlayerCurrentSubAccount(client).bodyProps.leftFoot, true);
// setEntityData(getPlayerPed(client), "v.rp.bodyPartRightFoot", getPlayerCurrentSubAccount(client).bodyProps.rightFoot, true);
//}
if (isGTAIV()) {
//sendPlayerPedPartsAndProps(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
logToConsole(LOG_DEBUG, `[AGRP.Event] Setting ${getPlayerDisplayForConsole(client)}'s ped state to ready`);
getPlayerData(client).pedState = V_PEDSTATE_READY;
if (areServerElementsSupported()) {
syncPlayerProperties(client);
@@ -567,23 +600,29 @@ async function onPlayerSpawn(client) {
//}, 1000);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Syncing ${getPlayerDisplayForConsole(client)}'s cash ${getPlayerCurrentSubAccount(client).cash}`);
updatePlayerCash(client);
if (isGameFeatureSupported("customNametag")) {
logToConsole(LOG_DEBUG, `[VRR.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending player nametag distance to ${getPlayerDisplayForConsole(client)}`);
sendNameTagDistanceToClient(client, getServerConfig().nameTagDistance);
}
if (!areServerElementsSupported()) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
logToConsole(LOG_DEBUG, `[AGRP.Event] Sending properties, jobs, and vehicles to ${getPlayerDisplayForConsole(client)} (no server elements)`);
sendAllBusinessesToPlayer(client);
sendAllHousesToPlayer(client);
//sendAllJobsToPlayer(client);
//sendAllVehiclesToPlayer(client);
if (getGame() != V_GAME_GTA_IV) {
sendAllJobsToPlayer(client);
}
requestPlayerPedNetworkId(client);
}
logToConsole(LOG_DEBUG, `[VRR.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
if (!areServerElementsSupported()) {
sendAllVehiclesToPlayer(client);
}
logToConsole(LOG_DEBUG, `[AGRP.Event] Updating spawned state for ${getPlayerDisplayForConsole(client)} to true`);
updatePlayerSpawnedState(client, true);
getPlayerData(client).payDayTickStart = sdl.ticks;
@@ -591,14 +630,29 @@ async function onPlayerSpawn(client) {
// Locales are handled via resource files now. No need to send anymore, but kept in case revert is needed.
//sendPlayerLocaleStrings(client);
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
logToConsole(LOG_DEBUG, `[AGRP.Event] Updating all player name tags`);
updateAllPlayerNameTags();
setPlayerWeaponDamageEvent(client, AGRP_WEAPON_DAMAGE_EVENT_NORMAL);
setPlayerWeaponDamageEvent(client, V_WEAPON_DAMAGE_EVENT_NORMAL);
if (doesPlayerHaveGUIEnabled(client) && getServerConfig().useGUI == true) {
if (checkForGeoIPModule()) {
let iso = getPlayerCountryISOCode(client);
let localeId = getLocaleFromCountryISO(iso);
if (localeId != 0) {
if (getLocaleData(localeId).enabled) {
messagePlayerTip(client, getLanguageLocaleString(localeId, "LocaleOffer", `/lang ${getLocaleData(localeId).isoCode}`), getColourByName("white"), 10000, "Roboto");
}
}
}
}
if (areServerElementsSupported()) {
if (getGlobalConfig().playerStreamInDistance == -1 || getGlobalConfig().playerStreamOutDistance == -1) {
getPlayerPed(client).netFlags.distanceStreaming = false;
//getPlayerPed(client).netFlags.distanceStreaming = false;
setElementStreamInDistance(getPlayerPed(client), 99999);
setElementStreamOutDistance(getPlayerPed(client), 99999);
} else {
setElementStreamInDistance(getPlayerPed(client), getServerConfig().playerStreamInDistance);
setElementStreamOutDistance(getPlayerPed(client), getServerConfig().playerStreamOutDistance);
@@ -607,9 +661,11 @@ async function onPlayerSpawn(client) {
resetPlayerBlip(client);
}
updateJobBlipsForPlayer(client);
// Radio stuff must be last thing sent to client because it hangs the client for a second, which blocks processing of other incoming packets
// Start playing business/house radio if in one
if (getPlayerCurrentSubAccount(client).interior != getGameConfig().mainWorldInterior[getGame()] || getPlayerCurrentSubAccount(client).dimension != getGameConfig().mainWorldDimension[getGame()]) {
if (getPlayerDimension(client) != getGameConfig().mainWorldDimension[getGame()]) {
let businessId = getPlayerBusiness(client);
let houseId = getPlayerHouse(client);
if (businessId != -1) {
@@ -623,8 +679,6 @@ async function onPlayerSpawn(client) {
} else {
stopRadioStreamForPlayer(client);
}
} else {
stopRadioStreamForPlayer(client);
}
messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
@@ -633,6 +687,8 @@ async function onPlayerSpawn(client) {
// ===========================================================================
function onPlayerCommand(event, client, command, params) {
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Player used command ${command}!`);
if (!doesCommandExist(command)) {
processPlayerCommand(command, params, client);
}
@@ -641,10 +697,30 @@ function onPlayerCommand(event, client, command, params) {
// ===========================================================================
function onPedExitedVehicle(event, ped, vehicle, seat) {
if (ped == null) {
return false;
}
if (vehicle == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} exited vehicle ${vehicle.id} from seat ${seat}!`);
if (getVehicleData(vehicle) == false) {
return false;
}
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
getPlayerData(client).pedState = V_PEDSTATE_READY;
if (getVehicleData(vehicle).spawnLocked == false && canPlayerManageVehicle(client, vehicle) == true) {
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
getVehicleData(vehicle).needsSaved = true;
}
stopRadioStreamForPlayer(client);
@@ -662,7 +738,7 @@ function onPedExitedVehicle(event, ped, vehicle, seat) {
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} exited a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("v.rp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
}
}
}
@@ -670,6 +746,16 @@ function onPedExitedVehicle(event, ped, vehicle, seat) {
// ===========================================================================
function onPedEnteredVehicle(event, ped, vehicle, seat) {
if (ped == null) {
return false;
}
if (vehicle == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} entered vehicle ${vehicle.id} in seat ${seat}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
@@ -677,55 +763,53 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
return false;
}
if (getGame() == AGRP_GAME_GTA_IV) {
vehicle = getVehicleFromIVNetworkId(clientVehicle);
}
if (!getVehicleData(vehicle)) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("agrp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
logToConsole(LOG_DEBUG, `[AGRP.Event] ${getPlayerDisplayForConsole(client)} entered a ${getVehicleName(vehicle)} (ID: ${vehicle.getData("v.rp.dataSlot")}, Database ID: ${getVehicleData(vehicle).databaseId})`);
getPlayerData(client).lastVehicle = vehicle;
getVehicleData(vehicle).lastActiveTime = getCurrentUnixTimestamp();
if (getPlayerVehicleSeat(client) == AGRP_VEHSEAT_DRIVER) {
if (seat == V_VEHSEAT_DRIVER) {
vehicle.engine = getVehicleData(vehicle).engine;
setEntityData(vehicle, "v.rp.engine", getVehicleData(vehicle).engine, true);
//vehicle.netFlags.sendSync = getVehicleData(vehicle).engine;
if (getVehicleData(vehicle).buyPrice > 0) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
messagePlayerAlert(client, getLocaleString(client, "VehicleForSale", getVehicleName(vehicle), `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).buyPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehbuy{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else if (getVehicleData(vehicle).rentPrice > 0) {
if (getVehicleData(vehicle).rentedBy != client) {
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
messagePlayerAlert(client, getLocaleString(client, "VehicleForRent", getVehicleName(vehicle), `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).rentPrice)}{MAINCOLOUR}`, `{ALTCOLOUR}/vehrent{MAINCOLOUR}`));
resetVehiclePosition(vehicle);
} else {
messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}$${makeLargeNumberReadable(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`));
messagePlayerAlert(client, getLocaleString(client, "CurrentlyRentingThisVehicle", `{vehiclePurple}${getVehicleName(vehicle)}{MAINCOLOUR}`, `{ALTCOLOUR}${getCurrencyString(getVehicleData(vehicle).rentPrice)}`, `{ALTCOLOUR}/stoprent{MAINCOLOUR}`));
}
} else {
let ownerName = "Nobody";
let ownerType = getLocaleString(client, "NotOwned");
ownerType = toLowerCase(getVehicleOwnerTypeText(getVehicleData(vehicle).ownerType));
switch (getVehicleData(vehicle).ownerType) {
case AGRP_VEHOWNER_CLAN:
case V_VEHOWNER_CLAN:
ownerName = getClanData(getClanIndexFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = getLocaleString(client, "Clan");
break;
case AGRP_VEHOWNER_JOB:
case V_VEHOWNER_JOB:
ownerName = getJobData(getJobIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = getLocaleString(client, "Job");
break;
case AGRP_VEHOWNER_PLAYER:
case V_VEHOWNER_PLAYER:
let subAccountData = loadSubAccountFromId(getVehicleData(vehicle).ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName}`;
ownerType = getLocaleString(client, "Player");
break;
case AGRP_VEHOWNER_BIZ:
ownerName = getBusinessData(getVehicleData(vehicle).ownerId).name;
case V_VEHOWNER_BIZ:
ownerName = getBusinessData(getBusinessIdFromDatabaseId(getVehicleData(vehicle).ownerId)).name;
ownerType = getLocaleString(client, "Business");
break;
@@ -754,10 +838,12 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
let currentSubAccount = getPlayerCurrentSubAccount(client);
if (isPlayerWorking(client)) {
if (getVehicleData(vehicle).ownerType == AGRP_VEHOWNER_JOB) {
if (getVehicleData(vehicle).ownerType == V_VEHOWNER_JOB) {
if (getVehicleData(vehicle).ownerId == getPlayerCurrentSubAccount(client).job) {
getPlayerCurrentSubAccount(client).lastJobVehicle = vehicle;
messagePlayerInfo(client, `Use /startroute to start working in this vehicle`);
if (!hasPlayerSeenActionTip(client, "JobRouteStart")) {
messagePlayerInfo(client, getGroupedLocaleString(client, "ActionTips", "JobRouteStart", `{ALTCOLOUR}/startroute{MAINCOLOUR}`));
}
}
}
}
@@ -784,10 +870,23 @@ function onPedEnteredVehicle(event, ped, vehicle, seat) {
// ===========================================================================
function onPedEnteringVehicle(event, ped, vehicle, seat) {
if (ped == null) {
return false;
}
if (vehicle == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} is entering vehicle ${vehicle.id} in seat ${seat}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
if (seat == V_VEHSEAT_DRIVER) {
//vehicle.netFlags.sendSync = getVehicleData(vehicle).engine;
}
onPlayerEnteringVehicle(client, vehicle, seat);
}
}
}
@@ -795,12 +894,48 @@ function onPedEnteringVehicle(event, ped, vehicle, seat) {
// ===========================================================================
function onPedExitingVehicle(event, ped, vehicle, seat) {
if (ped == null) {
return false;
}
if (vehicle == null) {
return false;
}
logToConsole(LOG_WARN | LOG_DEBUG, `[AGRP.Event] Ped ${ped.id} is exiting vehicle ${vehicle.id} in seat ${seat}!`);
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
if (seat == V_VEHSEAT_DRIVER) {
//vehicle.netFlags.sendSync = getVehicleData(vehicle).engine;
}
onPlayerExitingVehicle(client, vehicle, seat);
}
}
}
// ===========================================================================
function onPlayerEnteringVehicle(client, vehicle, seat) {
}
// ===========================================================================
function onPlayerExitingVehicle(client, vehicle, seat) {
}
// ===========================================================================
function onPedFall(ped) {
if (ped.isType(ELEMENT_PLAYER)) {
let client = getClientFromPlayerElement(ped);
if (client != null) {
processPlayerDeath(client);
}
}
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: fishing.js
// DESC: Provides fishing functions and commands
@@ -9,59 +8,59 @@
// ===========================================================================
// 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;
const V_FISHING_CATCH_TYPE_NONE = 0;
const V_FISHING_CATCH_TYPE_FISH = 1;
const V_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;
const V_FISHING_LINE_STATE_NONE = 0;
const V_FISHING_LINE_STATE_READY = 1;
const V_FISHING_LINE_STATE_CASTING = 2;
const V_FISHING_LINE_STATE_CASTED = 3;
const V_FISHING_LINE_STATE_REELING = 4;
const V_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],
["Salmon", V_FISHING_CATCH_TYPE_FISH],
["Tuna", V_FISHING_CATCH_TYPE_FISH],
["Crab", V_FISHING_CATCH_TYPE_FISH],
["Trout", V_FISHING_CATCH_TYPE_FISH],
["Sea Bass", V_FISHING_CATCH_TYPE_FISH],
["Shark", V_FISHING_CATCH_TYPE_FISH],
["Turtle", V_FISHING_CATCH_TYPE_FISH],
["Manta Ray", V_FISHING_CATCH_TYPE_FISH],
["Cat Fish", V_FISHING_CATCH_TYPE_FISH],
["Blue Marlin", V_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],
["Rusty Can", V_FISHING_CATCH_TYPE_JUNK],
["Old Pants", V_FISHING_CATCH_TYPE_JUNK],
["Old Shoes", V_FISHING_CATCH_TYPE_JUNK],
["Garbage", V_FISHING_CATCH_TYPE_JUNK],
["Baby Diaper", V_FISHING_CATCH_TYPE_JUNK],
["Old Tire", V_FISHING_CATCH_TYPE_JUNK],
["Old Car Battery", V_FISHING_CATCH_TYPE_JUNK],
["Horse Hoove", V_FISHING_CATCH_TYPE_JUNK],
["Soggy Log", V_FISHING_CATCH_TYPE_JUNK],
["Soggy Dildo", V_FISHING_CATCH_TYPE_JUNK],
["Clump of Seaweed", V_FISHING_CATCH_TYPE_JUNK],
];
// ===========================================================================
let fishingAnimations = {
[AGRP_GAME_GTA_III]: {
[V_GAME_GTA_III]: {
"fishingLineCasting": "bathit1",
"fishingLineReeling": "aimdown",
},
[AGRP_GAME_GTA_VC]: {
[V_GAME_GTA_VC]: {
"fishingLineCasting": "frontpunch",
"fishingLineReeling": "aimdown",
},
[AGRP_GAME_GTA_SA]: {
[V_GAME_GTA_SA]: {
"fishingLineCasting": "none",
"fishingLineReeling": "none",
}
@@ -70,7 +69,7 @@ let fishingAnimations = {
// ===========================================================================
let fishingParticleEffects = {
[AGRP_GAME_GTA_III]: {
[V_GAME_GTA_III]: {
"fishingLineCast": [
"MediumSprayingWater",
0.2,
@@ -87,8 +86,8 @@ let fishingParticleEffects = {
// ===========================================================================
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!");
}
// ===========================================================================
@@ -99,7 +98,7 @@ function castFishingLineCommand(command, params, client) {
return false;
}
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
if (doesPlayerHaveItemOfUseTypeEquipped(client, V_ITEM_USE_TYPE_FISHINGROD)) {
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
return false;
}
@@ -132,7 +131,7 @@ function resetFishingLineCommand(client) {
return false;
}
if (doesPlayerHaveItemOfUseTypeEquipped(client, AGRP_ITEM_USE_TYPE_FISHINGROD)) {
if (doesPlayerHaveItemOfUseTypeEquipped(client, V_ITEM_USE_TYPE_FISHINGROD)) {
messagePlayerError(client, getLocaleString(client, "NeedFishingRod"));
return false;
}
@@ -151,7 +150,7 @@ function resetFishingLineCommand(client) {
showSmallGameMessage(client, messageText);
getPlayerData(client).fishingLineState = AGRP_FISHING_LINE_STATE_NONE;
getPlayerData(client).fishingLineState = V_FISHING_LINE_STATE_NONE;
getPlayerData(client).fishingLineCastStart = 0;
}
@@ -173,7 +172,7 @@ function castPlayerFishingLine(client, strength) {
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;
getPlayerData(client).fishingLineState = V_FISHING_LINE_STATE_CASTED;
}, strength * 10);
}
@@ -197,13 +196,13 @@ function isPlayerInFishingSpot(client) {
// ===========================================================================
function isPlayerFishing(client) {
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
return (getPlayerData(client).fishingLineState != V_FISHING_LINE_STATE_NONE);
}
// ===========================================================================
function isPlayerFishing(client) {
return (getPlayerData(client).fishingLineState != AGRP_FISHING_LINE_STATE_NONE);
return (getPlayerData(client).fishingLineState != V_FISHING_LINE_STATE_NONE);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: forensics.js
// DESC: Provides forensics functions and commands (bullet casings, blood, etc)
@@ -9,13 +8,13 @@
// ===========================================================================
// 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)
const V_FORENSICS_NONE = 0;
const V_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
const V_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit and outfit worn when somebody is shot
const V_FORENSICS_BODY = 3; // Body. A dead body lol
const V_FORENSICS_HAIR = 4; // Hair.
const V_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
const V_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank and unfinished food items when eaten
const V_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: gate.js
// DESC: Provides gate functions and commands
@@ -9,14 +8,14 @@
// ===========================================================================
// 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.
const V_GATEOWNER_NONE = 0; // Not owned
const V_GATEOWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const V_GATEOWNER_JOB = 2; // Owned by a job
const V_GATEOWNER_CLAN = 3; // Owned by a clan
const V_GATEOWNER_FACTION = 4; // Owned by a faction
const V_GATEOWNER_PUBLIC = 5; // Public gate. Technically not owned. This probably won't be used.
const V_GATEOWNER_BUSINESS = 6; // Owned by a business. Back lots, unloading areas, and other stuff like that
const V_GATEOWNER_HOUSE = 7; // Owned by a house. Like for mansions with closed private areas.
// ===========================================================================
@@ -28,7 +27,7 @@ class GateData {
this.enabled = false;
this.position = toVector3(0.0, 0.0, 0.0);
this.locked = true;
this.ownerType = AGRP_GATEOWNER_NONE;
this.ownerType = V_GATEOWNER_NONE;
this.ownerId = 0;
if (dbAssoc) {
@@ -46,8 +45,8 @@ class GateData {
// ===========================================================================
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!`);
}
// ===========================================================================
@@ -55,17 +54,17 @@ function initGateScript() {
function doesPlayerHaveGateKeys(client, vehicle) {
let gateData = getGateData(vehicle);
if (gateData.ownerType == AGRP_GATEOWNER_PUBLIC) {
if (gateData.ownerType == V_GATEOWNER_PUBLIC) {
return true;
}
if (gateData.ownerType == AGRP_GATEOWNER_PLAYER) {
if (gateData.ownerType == V_GATEOWNER_PLAYER) {
if (gateData.ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true;
}
}
if (gateData.ownerType == AGRP_GATEOWNER_CLAN) {
if (gateData.ownerType == V_GATEOWNER_CLAN) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageClans"))) {
return true;
}
@@ -77,7 +76,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if (gateData.ownerType == AGRP_GATEOWNER_FACTION) {
if (gateData.ownerType == V_GATEOWNER_FACTION) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageFactions"))) {
return true;
}
@@ -89,7 +88,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if (gateData.ownerType == AGRP_GATEOWNER_JOB) {
if (gateData.ownerType == V_GATEOWNER_JOB) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageJobs"))) {
return true;
}
@@ -99,7 +98,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if (gateData.ownerType == AGRP_GATEOWNER_BUSINESS) {
if (gateData.ownerType == V_GATEOWNER_BUSINESS) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageBusinesses"))) {
return true;
}
@@ -109,7 +108,7 @@ function doesPlayerHaveGateKeys(client, vehicle) {
}
}
if (gateData.ownerType == AGRP_GATEOWNER_HOUSE) {
if (gateData.ownerType == V_GATEOWNER_HOUSE) {
if (doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
return true;
}
@@ -194,7 +193,7 @@ function saveGateToDatabase(gateId) {
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) {
let safeGateName = escapeDatabaseString(tempGateData.name);
@@ -228,7 +227,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;
}
@@ -236,28 +235,26 @@ 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;
let dbAssoc = [];
if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`);
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!`);
}
let dbQueryString = `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempGateData = new GateData(dbAssoc[i]);
tempGates.push(tempGateData);
logToConsole(LOG_DEBUG, `[AGRP.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
}
freeDatabaseQuery(dbQuery);
}
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;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: gps.js
// DESC: Provides GPS functions and commands
@@ -9,36 +8,36 @@
// ===========================================================================
// 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
const V_GPS_TYPE_NONE = 0; // None (invalid)
const V_GPS_TYPE_BUSINESS = 1; // Business
const V_GPS_TYPE_POLICE = 2; // Police Station
const V_GPS_TYPE_HOSPITAL = 3; // Hospital
const V_GPS_TYPE_JOB = 4; // Job
const V_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 locationType = V_GPS_TYPE_NONE;
let useType = V_ITEM_USE_TYPE_NONE;
let blipColour = "white";
switch (toLowerCase(params)) {
case "police":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_POLICE;
locationType = V_GPS_TYPE_POLICE;
break;
case "hospital":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_HOSPITAL;
locationType = V_GPS_TYPE_HOSPITAL;
break;
case "job":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_JOB;
locationType = V_GPS_TYPE_JOB;
break;
case "skin":
@@ -46,8 +45,8 @@ function gpsCommand(command, params, client) {
case "clothes":
case "player":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_SKIN;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_SKIN;
break;
case "gun":
@@ -57,29 +56,29 @@ function gpsCommand(command, params, client) {
case "wep":
case "weps":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_WEAPON;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_WEAPON;
break;
case "food":
case "eat":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_FOOD;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_FOOD;
break;
case "drink":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_DRINK;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_DRINK;
break;
case "alcohol":
case "booze":
case "bar":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_ALCOHOL;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_ALCOHOL;
break;
case "repair":
@@ -88,8 +87,8 @@ function gpsCommand(command, params, client) {
case "spray":
case "fix":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_VEHREPAIR;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_VEHREPAIR;
break;
case "vehiclecolour":
@@ -97,14 +96,14 @@ function gpsCommand(command, params, client) {
case "carcolour":
case "colour":
blipColour = "businessBlue"
locationType = AGRP_GPS_TYPE_BUSINESS;
useType = AGRP_ITEM_USE_TYPE_VEHCOLOUR;
locationType = V_GPS_TYPE_BUSINESS;
useType = V_ITEM_USE_TYPE_VEHCOLOUR;
break;
default: {
let itemTypeId = getItemTypeFromParams(params);
if (getItemTypeData(itemTypeId) != false) {
locationType = AGRP_GPS_TYPE_BUSINESS;
locationType = V_GPS_TYPE_BUSINESS;
blipColour = "businessBlue";
useType = getItemTypeData(itemTypeId).useType;
} else {
@@ -116,12 +115,12 @@ function gpsCommand(command, params, client) {
}
}
if (locationType == AGRP_GPS_TYPE_NONE) {
if (locationType == V_GPS_TYPE_NONE) {
messagePlayerError(client, getLocaleString(client, "InvalidGPSLocation"));
return false;
}
if (locationType == AGRP_GPS_TYPE_BUSINESS) {
if (locationType == V_GPS_TYPE_BUSINESS) {
let businessId = getClosestBusinessWithBuyableItemOfUseType(useType);
if (!businessId) {
messagePlayerError(client, getLocaleString(client, "NoBusinessWithItemType"));
@@ -138,7 +137,7 @@ function gpsCommand(command, params, client) {
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");
}
if (locationType == AGRP_GPS_TYPE_GAMELOC) {
if (locationType == V_GPS_TYPE_GAMELOC) {
hideAllBlipsForPlayerGPS(client);
blinkGenericGPSBlipForPlayer(client, position, 0, getColourByType(blipColour), 10);
messagePlayerSuccess(client, "Look for the blinking icon on your mini map");

View File

@@ -1,287 +1,27 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// 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 == AGRP_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered NO to their prompt (${getPlayerData(client).promptType})`);
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");
getPlayerData(targetClient).customDisconnectReason = `Kicked - Didn't create a character`;
setTimeout(function () { disconnectPlayer(client); }, 5000);
break;
case AGRP_PROMPT_BIZORDER:
if (getPlayerData(client).businessOrderAmount > 0) {
if (canPlayerUseGUI(client)) {
showPlayerErrorGUI(client, "You canceled the order.", "Business Order Canceled");
} else {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} canceled the order of ${getPlayerData(client).businessOrderAmount} ${getPlayerData(client).businessOrderItem} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness)}`);
messagePlayerError(client, "You canceled the order!");
}
} else {
showPlayerErrorGUI(client, "You aren't ordering anything for a business!", "Business Order Canceled");
}
break;
default:
break;
}
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
}
// ===========================================================================
function playerPromptAnswerYes(client) {
if (getPlayerData(client).promptType == AGRP_PROMPT_NONE) {
return false;
}
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} answered YES to their prompt (${getPlayerData(client).promptType})`);
switch (getPlayerData(client).promptType) {
case AGRP_PROMPT_CREATEFIRSTCHAR: {
showPlayerNewCharacterGUI(client);
break;
}
case AGRP_PROMPT_BIZORDER: {
if (getPlayerData(client).businessOrderAmount > 0) {
if (getBusinessData(getPlayerData(client).businessOrderBusiness).till < getPlayerData(client).businessOrderCost) {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} failed to order ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name} (Reason: Not enough money in business till)`);
showPlayerErrorGUI(client, "This business doesn't have enough money! Deposit some using /bizdeposit", "Business Order Canceled");
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
} else {
logToConsole(LOG_DEBUG, `[VRR.GUI] ${getPlayerDisplayForConsole(client)} successfully ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} at ${getPlayerData(client).businessOrderCost / getPlayerData(client).businessOrderAmount} each for business ${getBusinessData(getPlayerData(client).businessOrderBusiness).name}`);
showPlayerInfoGUI(client, `You ordered ${getPlayerData(client).businessOrderAmount} ${getItemTypeData(getPlayerData(client).businessOrderItem).name} (${getItemValueDisplay(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue)}) for ${getPlayerData(client).businessOrderCost}!`, "Business Order Successful");
createItem(getPlayerData(client).businessOrderItem, getPlayerData(client).businessOrderValue, 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);
getPlayerData(client).businessOrderAmount = 0;
getPlayerData(client).businessOrderBusiness = false;
getPlayerData(client).businessOrderItem = -1;
getPlayerData(client).businessOrderValue = -1;
}
} else {
showPlayerErrorGUI(client, ``, `Business Order Canceled`);
}
break;
}
case AGRP_PROMPT_GIVEVEHTOCLAN: {
if (!isPlayerInAnyVehicle(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicle"));
return false;
}
if (!getVehicleData(getPlayerVehicle(client))) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if (getVehicleData(getPlayerVehicle(client)).ownerType != AGRP_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
if (getVehicleData(getPlayerVehicle(client)).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnVehicle"));
return false;
}
getVehicleData(getPlayerVehicle(client)).ownerType = 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 AGRP_PROMPT_GIVEHOUSETOCLAN: {
let houseId = getPlayerHouse(client);
if (!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
if (getHouseData(houseId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
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 AGRP_PROMPT_GIVEBIZTOCLAN: {
let businessId = getPlayerBusiness(client);
if (!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
if (getBusinessData(businessId).ownerType != AGRP_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false;
}
if (getBusinessData(businessId).ownerId != getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "MustOwnBusiness"));
return false;
}
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 AGRP_PROMPT_BUYHOUSE: {
let houseId = getPlayerHouse(client);
if (!houseId) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
if (getHouseData(houseId).buyPrice <= 0) {
messagePlayerError(client, getLocaleString(client, "HouseNotForSale"));
return false;
}
if (getPlayerCurrentSubAccount(client).cash < getHouseData(houseId).buyPrice) {
messagePlayerError(client, getLocaleString(client, "HousePurchaseNotEnoughMoney"));
return false;
}
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getHouseData(houseId).buyPrice = 0;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messageDiscordEventChannel(`🏘️ ${getCharacterFullName(client)} is now the owner of *${getHouseData(houseId).description}*!`);
messagePlayerSuccess(client, `🏘️ You are now the owner of {houseGreen}${getHouseData(houseId).description}`);
break;
}
case AGRP_PROMPT_BUYBIZ: {
let businessId = getPlayerBusiness(client);
if (!businessId) {
messagePlayerError(client, getLocaleString(client, "InvalidBusiness"));
return false;
}
if (getBusinessData(businessId).buyPrice <= 0) {
messagePlayerError(client, getLocaleString(client, "BusinessNotForSale"));
return false;
}
if (getPlayerCurrentSubAccount(client).cash < getBusinessData(businessId).buyPrice) {
messagePlayerError(client, getLocaleString(client, "BusinessPurchaseNotEnoughMoney"));
return false;
}
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}`);
break;
}
case AGRP_PROMPT_RESETKEYBINDS: {
break;
}
case AGRP_PROMPT_COPYKEYBINDSTOSERVER: {
break;
}
default: {
submitBugReport(client, `[AUTOMATED REPORT] Unknown prompt type: ${getPlayerData(client).promptType}`);
break;
}
}
getPlayerData(client).promptType = AGRP_PROMPT_NONE;
}
// ===========================================================================
function canPlayerUseGUI(client) {
function doesPlayerUseGUI(client) {
return (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client));
}
// ===========================================================================
function playerPromptAnswerYesCommand(command, params, client) {
playerPromptAnswerYes(client);
}
// ===========================================================================
function playerPromptAnswerNoCommand(command, params, client) {
playerPromptAnswerNo(client);
}
// ===========================================================================
function playerToggledGUI(client) {
toggleAccountGUICommand("gui", "", client);
}
// ===========================================================================
function showPlayerTwoFactorAuthenticationGUI(client) {
sendNetworkEventToPlayer("agrp.2fa", client);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: help.js
// DESC: Provides update info, help commands, and documentation
@@ -9,8 +8,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!`);
}
// ===========================================================================
@@ -204,9 +203,9 @@ function showAccountHelpMessage(client) {
function showVehicleHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0, `{ALTCOLOUR}/info dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 1, `{ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 0));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 1, `{ALTCOLOUR}/info dealership{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 2, `{ALTCOLOUR}/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleHelp", 3, `{ALTCOLOUR}/info mechanic{MAINCOLOUR}`));
}
@@ -216,8 +215,8 @@ function showVehicleDealershipHelpMessage(client) {
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehicleDealershipHelp")));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 0, `{ALTCOLOUR}/gps{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 1, `{ALTCOLOUR}/buyveh{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 2));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 2, `{ALTCOLOUR}/buyveh{MAINCOLOUR}`));
messagePlayerHelpContent(client, getGroupedLocaleString(client, "VehicleDealershipHelp", 3));
}
// ===========================================================================
@@ -348,22 +347,23 @@ function showCommandHelpMessage(client, commandName) {
commandName = commandName.slice(1);
}
let command = getCommandData(commandName);
let aliases = getCommandAliasesNames(command);
let commandData = getCommandData(commandName);
let aliases = getCommandAliasesNames(commandData);
messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderCommandInfo", commandName)));
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${command.helpDescription}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Description: ${commandData.helpDescription}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usage: /${commandData.command} ${commandData.syntaxString}`);
if (aliases.length > 0) {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.join(", ")}`);
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: ${aliases.map(alias => `/${alias.command}`).join(", ")}`);
} else {
messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Aliases: (None)`);
}
//messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
//messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(commandData.allowOnDiscord)}`);
//if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("BasicModeration"))) {
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(command.allowOnDiscord)}`);
// messagePlayerNormal(client, `{clanOrange}• {MAINCOLOUR}Usable on Discord: ${getYesNoFromBool(commandData.allowOnDiscord)}`);
//}
}
@@ -398,4 +398,24 @@ function helpGetSkinCommand(command, params, client) {
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);
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: house.js
// DESC: Provides house commands, functions, and usage
@@ -9,19 +8,19 @@
// ===========================================================================
// House Location Types
const AGRP_HOUSE_LOC_NONE = 0; // None
const AGRP_HOUSE_LOC_GATE = 1; // Center of any moveable gate that belongs to the house
const AGRP_HOUSE_LOC_GARAGE = 2; // Location for garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
const V_HOUSE_LOC_NONE = 0; // None
const V_HOUSE_LOC_GATE = 1; // Center of any moveable gate that belongs to the house
const V_HOUSE_LOC_GARAGE = 2; // Location for garage (pos1 = outside, pos2 = inside). Use pos to teleport or spawn veh/ped
// ===========================================================================
// House Owner Types
const AGRP_HOUSE_OWNER_NONE = 0; // Not owned
const AGRP_HOUSE_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const AGRP_HOUSE_OWNER_JOB = 2; // Owned by a job
const AGRP_HOUSE_OWNER_CLAN = 3; // Owned by a clan
const AGRP_HOUSE_OWNER_FACTION = 4; // Owned by a faction
const AGRP_HOUSE_OWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
const V_HOUSE_OWNER_NONE = 0; // Not owned
const V_HOUSE_OWNER_PLAYER = 1; // Owner is a player (character/subaccount)
const V_HOUSE_OWNER_JOB = 2; // Owned by a job
const V_HOUSE_OWNER_CLAN = 3; // Owned by a clan
const V_HOUSE_OWNER_FACTION = 4; // Owned by a faction
const V_HOUSE_OWNER_PUBLIC = 5; // Is a public house. Technically not owned. This probably won't be used.
// ===========================================================================
@@ -32,7 +31,7 @@ class HouseData {
constructor(dbAssoc = false) {
this.databaseId = 0
this.description = "";
this.ownerType = AGRP_HOUSE_OWNER_NONE;
this.ownerType = V_HOUSE_OWNER_NONE;
this.ownerId = 0;
this.buyPrice = 0;
this.rentPrice = 0;
@@ -42,6 +41,7 @@ class HouseData {
this.index = -1;
this.needsSaved = false;
this.interiorLights = true;
this.propertyType = V_PROPERTY_TYPE_HOUSE;
this.itemCache = [];
this.locations = [];
@@ -55,6 +55,7 @@ class HouseData {
this.entranceBlipModel = -1;
this.entrancePickup = null;
this.entranceBlip = null;
this.entranceScene = "";
this.exitPosition = false;
this.exitRotation = 0.0;
@@ -64,6 +65,7 @@ class HouseData {
this.exitBlipModel = -1;
this.exitPickup = null;
this.exitBlip = null;
this.exitScene = "";
this.streamingRadioStation = 0;
this.streamingRadioStationIndex = -1;
@@ -86,6 +88,7 @@ class HouseData {
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.entranceScene = toString(dbAssoc["house_entrance_scene"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
@@ -93,6 +96,7 @@ class HouseData {
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
this.exitScene = toString(dbAssoc["house_exit_scene"]);
}
}
};
@@ -163,34 +167,32 @@ class HouseGameScriptData {
// ===========================================================================
function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!");
logToConsole(LOG_INFO, "[AGRP.House]: Initializing house script ...");
logToConsole(LOG_INFO, "[AGRP.House]: House script initialized successfully!");
return true;
}
// ===========================================================================
function loadHousesFromDatabase() {
logToConsole(LOG_INFO, "[VRR.House]: Loading houses from database ...");
logToConsole(LOG_INFO, "[AGRP.House]: Loading houses from database ...");
let tempHouses = [];
let dbConnection = connectToDatabase();
let dbAssoc;
let dbAssoc = [];
if (dbConnection) {
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`);
if (dbQuery) {
if (dbQuery.numRows > 0) {
while (dbAssoc = fetchQueryAssoc(dbQuery)) {
let tempHouseData = new HouseData(dbAssoc);
tempHouses.push(tempHouseData);
logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
}
let dbQueryString = `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`;
dbAssoc = fetchQueryAssoc(dbConnection, dbQueryString);
if (dbAssoc.length > 0) {
for (let i in dbAssoc) {
let tempHouseData = new HouseData(dbAssoc[i]);
tempHouses.push(tempHouseData);
logToConsole(LOG_VERBOSE, `[AGRP.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
}
freeDatabaseQuery(dbQuery);
}
disconnectFromDatabase(dbConnection);
}
logToConsole(LOG_INFO, `[VRR.House]: ${tempHouses.length} houses loaded from database successfully!`);
logToConsole(LOG_INFO, `[AGRP.House]: ${tempHouses.length} houses loaded from database successfully!`);
return tempHouses;
}
@@ -211,8 +213,8 @@ function createHouseCommand(command, params, client) {
return false;
}
createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].House, -1, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created house: {houseGreen}${params}`);
createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].House, -1, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorScene);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created house: {houseGreen}${params}`, true);
}
// ===========================================================================
@@ -266,11 +268,11 @@ function setHouseDescriptionCommand(command, params, client) {
let oldDescription = getHouseData(houseId).description;
getHouseData(houseId).description = newHouseDescription;
setEntityData(getHouseData(houseId).entrancePickup, "agrp.label.name", getHouseData(houseId).description, true);
setEntityData(getHouseData(houseId).entrancePickup, "v.rp.label.name", getHouseData(houseId).description, true);
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed house {houseGreen}${oldDescription}{MAINCOLOUR} to {houseGreen}${getHouseData(houseId).description}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} renamed house {houseGreen}${oldDescription}{MAINCOLOUR} to {houseGreen}${getHouseData(houseId).description}`, true);
}
// ===========================================================================
@@ -299,17 +301,18 @@ function setHouseOwnerCommand(command, params, client) {
}
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
getHouseData(houseId).ownerType = V_HOUSE_OWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(newHouseOwner).databaseId;
getHouseData(houseId).needsSaved = true;
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_PLAYER;
getHouseData(houseId).ownerId = getPlayerCurrentSubAccount(newHouseOwner).databaseId;
messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to {ALTCOLOUR}${newHouseOwner.name}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(newHouseOwner)}`);
}
/**
@@ -330,17 +333,17 @@ function removeHouseOwnerCommand(command, params, client) {
}
if (!doesPlayerHaveStaffPermission(client, getStaffFlagValue("ManageHouses"))) {
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
}
getHouseData(houseId).ownerType = AGRP_HOUSE_OWNER_NONE;
getHouseData(houseId).ownerType = V_HOUSE_OWNER_NONE;
getHouseData(houseId).ownerId = -1;
getHouseData(houseId).needsSaved = true;
messagePlayerSuccess(client, `{MAINCOLOUR}You removed house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} owner`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} owner`);
}
// ===========================================================================
@@ -369,7 +372,7 @@ function setHouseClanCommand(command, params, client) {
return false;
}
if (getHouseData(houseId).ownerType != AGRP_VEHOWNER_PLAYER) {
if (getHouseData(houseId).ownerType != V_VEHOWNER_PLAYER) {
messagePlayerError(client, getLocaleString(client, "MustOwnHouse"));
return false;
}
@@ -380,7 +383,7 @@ function setHouseClanCommand(command, params, client) {
}
showPlayerPrompt(client, getLocaleString(client, "SetHouseClanConfirmMessage"), getLocaleString(client, "SetHouseClanConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_HOUSEGIVETOCLAN;
getPlayerData(client).promptType = V_PROMPT_GIVEHOUSETOCLAN;
//messagePlayerSuccess(`{MAINCOLOUR}You gave house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} to the {clanOrange}${getClanData(clanId).name} {MAINCOLOUR}clan!`);
}
@@ -463,7 +466,7 @@ function setHousePickupCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} pickup display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} pickup to {ALTCOLOUR}${toLowerCase(typeParam)}`, true);
}
// ===========================================================================
@@ -499,7 +502,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
tempHouseLocation.exitInterior = -1;
getHouseData(houseId).exitPickupModel = -1;
getHouseData(houseId).hasInterior = false;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior`, true);
return false;
}
@@ -529,7 +532,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior type to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior type to {ALTCOLOUR}${typeParam}`, true);
}
// ===========================================================================
@@ -580,7 +583,7 @@ function setHouseBlipCommand(command, params, client) {
resetHouseBlips(houseId);
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} blip display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} blip to {ALTCOLOUR}${toLowerCase(typeParam)}`, true);
}
// ===========================================================================
@@ -616,7 +619,7 @@ function moveHouseEntranceCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} entrance to their position`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} entrance to their position`, true);
}
// ===========================================================================
@@ -656,7 +659,7 @@ function moveHouseExitCommand(command, params, client) {
getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} exit to their position`);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} moved house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} exit to their position`, true);
}
// ===========================================================================
@@ -692,8 +695,13 @@ function deleteHouseCommand(command, params, client) {
* @return {bool} Whether or not the house was successfully deleted
*
*/
function deleteHouse(houseId, whoDeleted = 0) {
let tempHouseData = getServerData().houses[houseId];
function deleteHouse(houseIndex, whoDeleted = 0) {
if (!getHouseData(houseIndex)) {
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
return false;
}
let tempHouseData = getServerData().houses[houseIndex];
let dbConnection = connectToDatabase();
let dbQuery = null;
@@ -706,15 +714,15 @@ function deleteHouse(houseId, whoDeleted = 0) {
disconnectFromDatabase(dbConnection);
}
deleteHouseEntrancePickup(houseId);
deleteHouseExitPickup(houseId);
deleteHouseEntrancePickup(houseIndex);
deleteHouseExitPickup(houseIndex);
deleteHouseEntranceBlip(houseId);
deleteHouseExitBlip(houseId);
deleteHouseEntranceBlip(houseIndex);
deleteHouseExitBlip(houseIndex);
removePlayersFromHouse(houseId);
removePlayersFromHouse(houseIndex);
getServerData().houses.splice(houseId, 1);
getServerData().houses.splice(houseIndex, 1);
}
// ===========================================================================
@@ -739,11 +747,13 @@ function removePlayerFromHouse(client) {
* @return {Boolean} Whether or not the players were forced to exit
*
*/
function removePlayersFromHouse(houseId) {
function removePlayersFromHouse(houseIndex) {
getClients().forEach(function (client) {
if (doesHouseHaveInterior(houseId)) {
if (getPlayerHouse(client) == houseId) {
exitHouse(client);
if (doesHouseHaveInterior(houseIndex)) {
if (getPlayerHouse(client) == houseIndex) {
if (getPlayerInterior(client) == getHouseData(houseIndex).exitInterior && getPlayerDimension(client) == getHouseData(houseIndex).exitDimension) {
exitHouse(client);
}
}
}
});
@@ -761,7 +771,7 @@ function removePlayersFromHouse(houseId) {
* @return {bool} Whether or not the player was successfully removed from the house
*
*/
function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceCutscene = -1) {
function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceScene = -1) {
let tempHouseData = new HouseData(false);
tempHouseData.description = description;
@@ -771,7 +781,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
tempHouseData.entranceBlipModel = entranceBlipModel;
tempHouseData.entranceInterior = entranceInterior;
tempHouseData.entranceDimension = entranceDimension;
tempHouseData.entranceCutscene = entranceCutscene;
tempHouseData.entranceScene = entranceScene;
tempHouseData.exitPosition = exitPosition;
tempHouseData.exitRotation = 0.0;
@@ -779,7 +789,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
tempHouseData.exitBlipModel = -1;
tempHouseData.exitInterior = 0;
tempHouseData.exitDimension = 0;
tempHouseData.exitCutscene = -1;
tempHouseData.exitScene = -1;
tempHouseData.needsSaved = true;
@@ -867,9 +877,9 @@ function getPlayerHouse(client) {
// ===========================================================================
function saveAllHousesToDatabase() {
logToConsole(LOG_DEBUG, `[VRR.House]: Saving all server houses to database ...`);
logToConsole(LOG_DEBUG, `[AGRP.House]: Saving all server houses to database ...`);
if (getServerConfig().devServer) {
logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.House]: Aborting save all houses to database, dev server is enabled.`);
logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.House]: Aborting save all houses to database, dev server is enabled.`);
return false;
}
@@ -878,7 +888,7 @@ function saveAllHousesToDatabase() {
saveHouseToDatabase(i);
}
}
logToConsole(LOG_INFO, `[VRR.House]: Saved all server houses to database`);
logToConsole(LOG_INFO, `[AGRP.House]: Saved all server houses to database`);
}
// ===========================================================================
@@ -890,7 +900,7 @@ function saveHouseToDatabase(houseId) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.description}' to database ...`);
logToConsole(LOG_VERBOSE, `[AGRP.House]: Saving house '${tempHouseData.description}' to database ...`);
let dbConnection = connectToDatabase();
if (dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
@@ -910,7 +920,7 @@ function saveHouseToDatabase(houseId) {
["house_entrance_vw", tempHouseData.entranceDimension],
["house_entrance_pickup", tempHouseData.entrancePickupModel],
["house_entrance_blip", tempHouseData.entranceBlipModel],
//["house_entrance_cutscene", tempHouseData.entranceCutscene],
["house_entrance_scene", tempHouseData.entranceScene],
["house_exit_pos_x", tempHouseData.exitPosition.x],
["house_exit_pos_y", tempHouseData.exitPosition.y],
["house_exit_pos_z", tempHouseData.exitPosition.z],
@@ -919,13 +929,13 @@ function saveHouseToDatabase(houseId) {
["house_exit_vw", tempHouseData.exitDimension],
["house_exit_pickup", tempHouseData.exitPickupModel],
["house_exit_blip", tempHouseData.exitBlipModel],
//["house_exit_cutscene", tempHouseData.exitCutscene],
["house_exit_scene", tempHouseData.exitScene],
["house_buy_price", tempHouseData.buyPrice],
["house_rent_price", tempHouseData.rentPrice],
["house_has_interior", boolToInt(tempHouseData.hasInterior)],
["house_interior_lights", boolToInt(tempHouseData.interiorLights)],
["house_custom_interior", boolToInt(tempHouseData.customInterior)],
["house_radio_station", boolToInt(tempHouseData.streamingRadioStation)],
["house_radio_station", (getRadioStationData(tempHouseData.streamingRadioStationIndex) != false) ? getRadioStationData(tempHouseData.streamingRadioStationIndex).databaseId : -1],
];
let dbQuery = null;
@@ -944,7 +954,7 @@ function saveHouseToDatabase(houseId) {
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saved house '${tempHouseData.description}' to database!`);
logToConsole(LOG_VERBOSE, `[AGRP.House]: Saved house '${tempHouseData.description}' to database!`);
return false;
}
@@ -958,7 +968,7 @@ function saveHouseLocationToDatabase(houseId, locationId) {
return false;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location ${locationId} for house ${houseId} to database ...`);
logToConsole(LOG_VERBOSE, `[AGRP.House]: Saving house location ${locationId} for house ${houseId} to database ...`);
let dbConnection = connectToDatabase();
if (dbConnection) {
let data = [
@@ -999,7 +1009,7 @@ function saveHouseLocationToDatabase(houseId, locationId) {
disconnectFromDatabase(dbConnection);
return true;
}
logToConsole(LOG_VERBOSE, `[VRR.House]: Saved location ${locationId} for house ${houseId} to database`);
logToConsole(LOG_VERBOSE, `[AGRP.House]: Saved location ${locationId} for house ${houseId} to database`);
return false;
}
@@ -1029,10 +1039,6 @@ function createHouseEntrancePickup(houseId) {
return false;
}
if (!isGameFeatureSupported("pickup")) {
return false;
}
if (!getHouseData(houseId)) {
return false;
}
@@ -1047,14 +1053,20 @@ function createHouseEntrancePickup(houseId) {
return false;
}
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
if (areServerElementsSupported() && getGame() != V_GAME_MAFIA_ONE && getGame() != V_GAME_GTA_IV) {
let entrancePickup = null;
if (isGameFeatureSupported("pickup")) {
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
if (getServerData().houses[houseId].entrancePickupModel != 0) {
pickupModelId = getHouseData(houseId).entrancePickupModel;
}
if (getServerData().houses[houseId].entrancePickupModel != 0) {
pickupModelId = getHouseData(houseId).entrancePickupModel;
}
entrancePickup = createGamePickup(pickupModelId, houseData.entrancePosition, getGameConfig().pickupTypes[getGame()].house);
} else if (isGameFeatureSupported("dummyElement")) {
entrancePickup = createGameDummyElement(houseData.exitPosition);
}
if (areServerElementsSupported()) {
let entrancePickup = createGamePickup(pickupModelId, getHouseData(houseId).entrancePosition, getGameConfig().pickupTypes[getGame()].house);
if (entrancePickup != null) {
setElementOnAllDimensions(entrancePickup, false);
setElementDimension(entrancePickup, getHouseData(houseId).entranceDimension);
@@ -1065,13 +1077,6 @@ function createHouseEntrancePickup(houseId) {
getHouseData(houseId).entrancePickup = entrancePickup;
updateHousePickupLabelData(houseId);
}
} else {
let pickupModelId = getGameConfig().pickupModels[getGame()].House;
if (houseData.entrancePickupModel != 0) {
pickupModelId = houseData.entrancePickupModel;
}
sendHouseToPlayer(null, houseId, houseId.description, houseId.entrancePosition, blipModelId, pickupModelId, houseId.hasInterior);
}
}
@@ -1125,8 +1130,8 @@ function createHouseEntranceBlip(houseId) {
setElementStreamOutDistance(entranceBlip, getGlobalConfig().houseBlipStreamOutDistance);
}
setEntityData(entranceBlip, "agrp.owner.type", AGRP_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "agrp.owner.id", houseId, false);
setEntityData(entranceBlip, "v.rp.owner.type", V_BLIP_HOUSE_ENTRANCE, false);
setEntityData(entranceBlip, "v.rp.owner.id", houseId, false);
houseData.entranceBlip = entranceBlip;
}
@@ -1143,10 +1148,6 @@ function createHouseExitPickup(houseId) {
return false;
}
if (!isGameFeatureSupported("pickup")) {
return false;
}
if (!getHouseData(houseId)) {
return false;
}
@@ -1161,13 +1162,19 @@ function createHouseExitPickup(houseId) {
return false;
}
let pickupModelId = getGameConfig().pickupModels[getGame()].Exit;
let exitPickup = null;
if (isGameFeatureSupported("pickup")) {
let pickupModelId = getGameConfig().pickupModels[getGame()].Exit;
if (getServerData().houses[houseId].exitPickupModel != 0) {
pickupModelId = houseData.exitPickupModel;
if (getServerData().houses[houseId].exitPickupModel != 0) {
pickupModelId = houseData.exitPickupModel;
}
exitPickup = createGamePickup(pickupModelId, houseData.exitPosition, getGameConfig().pickupTypes[getGame()].house);
} else if (isGameFeatureSupported("dummyElement")) {
//exitPickup = createGameDummyElement(houseData.exitPosition);
}
let exitPickup = createGamePickup(pickupModelId, houseData.exitPosition, getGameConfig().pickupTypes[getGame()].house);
if (exitPickup != null) {
setElementDimension(exitPickup, houseData.exitDimension);
setElementOnAllDimensions(exitPickup, false);
@@ -1231,8 +1238,8 @@ function createHouseExitBlip(houseId) {
setElementStreamOutDistance(exitBlip, getGlobalConfig().houseBlipStreamOutDistance);
}
setElementTransient(exitBlip, false);
setEntityData(exitBlip, "agrp.owner.type", AGRP_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "agrp.owner.id", houseId, false);
setEntityData(exitBlip, "v.rp.owner.type", V_BLIP_HOUSE_EXIT, false);
setEntityData(exitBlip, "v.rp.owner.id", houseId, false);
getHouseData(houseId).exitBlip = exitBlip;
}
}
@@ -1241,22 +1248,22 @@ function createHouseExitBlip(houseId) {
function getHouseOwnerTypeText(ownerType) {
switch (ownerType) {
case AGRP_HOUSE_OWNER_CLAN:
case V_HOUSE_OWNER_CLAN:
return "clan";
case AGRP_HOUSE_OWNER_PLAYER:
case V_HOUSE_OWNER_PLAYER:
return "player";
case AGRP_HOUSE_OWNER_NONE:
case V_HOUSE_OWNER_NONE:
return "not owned";
case AGRP_HOUSE_OWNER_PUBLIC:
case V_HOUSE_OWNER_PUBLIC:
return "not owned";
case AGRP_HOUSE_OWNER_JOB:
case V_HOUSE_OWNER_JOB:
return "job";
case AGRP_HOUSE_OWNER_BIZ:
case V_HOUSE_OWNER_BIZ:
return "business";
default:
@@ -1291,28 +1298,28 @@ function getHouseInfoCommand(command, params, client) {
let ownerName = "Unknown";
switch (getHouseData(houseId).ownerType) {
case AGRP_HOUSE_OWNER_CLAN:
case V_HOUSE_OWNER_CLAN:
ownerName = getClanData(houseData).name;
break;
case AGRP_HOUSE_OWNER_PLAYER:
case V_HOUSE_OWNER_PLAYER:
let subAccountData = loadSubAccountFromId(houseData.ownerId);
ownerName = `${subAccountData.firstName} ${subAccountData.lastName} [${subAccountData.databaseId}]`;
break;
case AGRP_HOUSE_OWNER_NONE:
case V_HOUSE_OWNER_NONE:
ownerName = "None";
break;
case AGRP_HOUSE_OWNER_PUBLIC:
case V_HOUSE_OWNER_PUBLIC:
ownerName = "Public";
break;
case AGRP_HOUSE_OWNER_BIZ:
case V_HOUSE_OWNER_BIZ:
ownerName = getBusinessDataFromDatabaseId(houseData.ownerId).name;
break;
case AGRP_HOUSE_OWNER_JOB:
case V_HOUSE_OWNER_JOB:
ownerName = getJobData(houseData.ownerId).name;
break;
}
@@ -1377,7 +1384,7 @@ function setHouseBuyPriceCommand(command, params, client) {
getHouseData(houseId).buyPrice = amount;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}${getCurrencyString(amount)}`);
}
// ===========================================================================
@@ -1415,7 +1422,7 @@ function setHouseRentPriceCommand(command, params, client) {
getHouseData(houseId).rentPrice = amount;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}${getCurrencyString(amount)}`);
}
// ===========================================================================
@@ -1447,8 +1454,8 @@ function buyHouseCommand(command, params, client) {
return false;
}
getPlayerData(client).promptType = V_PROMPT_BUYHOUSE;
showPlayerPrompt(client, getLocaleString(client, "BuyHouseConfirmMessage"), getLocaleString(client, "BuyHouseConfirmTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
getPlayerData(client).promptType = AGRP_PROMPT_HOUSEBUY;
}
// ===========================================================================
@@ -1606,7 +1613,7 @@ function cacheHouseItems(houseId) {
getHouseData(houseId).itemCache = [];
for (let i in getServerData().items) {
if (getItemData(i).ownerType == AGRP_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) {
if (getItemData(i).ownerType == V_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) {
getHouseData(houseId).itemCache.push(i);
}
}
@@ -1635,7 +1642,7 @@ function getHouseIdFromDatabaseId(databaseId) {
//function clearPlayerHouseGameScripts(client, houseId) {
// for(let i in getHouseData(houseId).gameScripts) {
// sendPlayerGameScriptState(client, AGRP_GAMESCRIPT_DENY);
// sendPlayerGameScriptState(client, V_GAMESCRIPT_DENY);
// }
//}
@@ -1657,11 +1664,11 @@ function canPlayerSetHouseInteriorLights(client, houseId) {
return true;
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true;
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true;
}
@@ -1677,11 +1684,11 @@ function canPlayerLockUnlockHouse(client, houseId) {
return true;
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_PLAYER && getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true;
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_CLAN && getHouseData(houseId).ownerId == getClanData(getPlayerClan(client)).databaseId) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true;
}
@@ -1731,13 +1738,13 @@ function canPlayerManageHouse(client, houseId) {
return true;
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_PLAYER) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_PLAYER) {
if (getHouseData(houseId).ownerId == getPlayerCurrentSubAccount(client).databaseId) {
return true;
}
}
if (getHouseData(houseId).ownerType == AGRP_HOUSE_OWNER_CLAN) {
if (getHouseData(houseId).ownerType == V_HOUSE_OWNER_CLAN) {
if (getHouseData(houseId).ownerId == getPlayerClan(client)) {
if (doesPlayerHaveClanPermission(client, getClanFlagValue("ManageHouses"))) {
return true;
@@ -1771,33 +1778,34 @@ function getHouseFromParams(params) {
// ===========================================================================
function updateHousePickupLabelData(houseId) {
if (!areServerElementsSupported()) {
if (!areServerElementsSupported() || getGame() == V_GAME_MAFIA_ONE || getGame() == V_GAME_GTA_IV) {
sendHouseToPlayer(null, houseId, getHouseData(houseId).description, getHouseData(houseId).entrancePosition, getHouseEntranceBlipModelForNetworkEvent(houseId), getHouseEntrancePickupModelForNetworkEvent(houseId), getHouseData(houseId).buyPrice, getHouseData(houseId).rentPrice, getHouseData(houseId).hasInterior, getHouseData(houseId).locked);
return false;
}
let houseData = getHouseData(houseId);
if (houseData.entrancePickup != null) {
setEntityData(houseData.entrancePickup, "agrp.owner.type", AGRP_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "agrp.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "agrp.label.type", AGRP_LABEL_HOUSE, true);
setEntityData(houseData.entrancePickup, "agrp.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "agrp.label.locked", houseData.locked, true);
setEntityData(houseData.entrancePickup, "v.rp.owner.type", V_PICKUP_HOUSE_ENTRANCE, false);
setEntityData(houseData.entrancePickup, "v.rp.owner.id", houseId, false);
setEntityData(houseData.entrancePickup, "v.rp.label.type", V_LABEL_HOUSE, true);
setEntityData(houseData.entrancePickup, "v.rp.label.name", houseData.description, true);
setEntityData(houseData.entrancePickup, "v.rp.label.locked", houseData.locked, true);
setEntityData(houseData.entrancePickup, "v.rp.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "v.rp.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "v.rp.label.help", V_PROPLABEL_INFO_ENTER, true);
if (houseData.buyPrice > 0) {
setEntityData(houseData.entrancePickup, "agrp.label.price", houseData.buyPrice, true);
setEntityData(houseData.entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_BUYHOUSE, true);
} else {
if (houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "agrp.label.rentprice", houseData.rentPrice, true);
setEntityData(houseData.entrancePickup, "agrp.label.help", AGRP_PROPLABEL_INFO_RENTHOUSE, true);
}
setEntityData(houseData.entrancePickup, "v.rp.label.help", V_PROPLABEL_INFO_BUYHOUSE, true);
} else if (houseData.rentPrice > 0) {
setEntityData(houseData.entrancePickup, "v.rp.label.help", V_PROPLABEL_INFO_RENTHOUSE, true);
}
}
if (houseData.exitPickup != null) {
setEntityData(houseData.exitPickup, "agrp.owner.type", AGRP_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "agrp.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "agrp.label.type", AGRP_LABEL_EXIT, true);
setEntityData(houseData.exitPickup, "v.rp.owner.type", V_PICKUP_HOUSE_EXIT, false);
setEntityData(houseData.exitPickup, "v.rp.owner.id", houseId, false);
setEntityData(houseData.exitPickup, "v.rp.label.type", V_LABEL_EXIT, true);
}
}
@@ -1852,4 +1860,34 @@ function isPlayerInAnyHouse(client) {
return false;
}
// ===========================================================================
function getHouseEntranceBlipModelForNetworkEvent(houseIndex) {
let blipModelId = -1;
if (isGameFeatureSupported("blip")) {
blipModelId = getGameConfig().blipSprites[getGame()].House;
if (getHouseData(houseIndex).entranceBlipModel != 0) {
blipModelId = getHouseData(houseIndex).entranceBlipModel;
}
}
return blipModelId;
}
// ===========================================================================
function getHouseEntrancePickupModelForNetworkEvent(houseIndex) {
let pickupModelId = -1;
if (isGameFeatureSupported("pickup")) {
pickupModelId = getGameConfig().pickupModels[getGame()].House;
if (getHouseData(houseIndex).entrancePickupModel != 0) {
pickupModelId = getHouseData(houseIndex).entrancePickupModel;
}
}
return pickupModelId;
}
// ===========================================================================

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: insurance.js
// DESC: Provides insurance commands, functions, and usage
@@ -9,33 +8,33 @@
// ===========================================================================
// 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
const V_INS_ACCT_OWNER_NONE = 0; // None
const V_INS_ACCT_OWNER_PLAYER = 1; // Player owns insurance company
const V_INS_ACCT_OWNER_BIZ = 2; // Business owns insurance company
const V_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
const V_INS_ACCT_ENTITY_NONE = 0; // None
const V_INS_ACCT_ENTITY_PLAYER_HEALTH = 1; // Health Insurance
const V_INS_ACCT_ENTITY_PLAYER_LIFE = 2; // Life Insurance
const V_INS_ACCT_ENTITY_VEH = 3; // Vehicle Insurance
const V_INS_ACCT_ENTITY_BIZ = 4; // Business Insurance
const V_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
const V_INS_ACCT_HISTORY_NONE = 0; // None
const V_INS_ACCT_HISTORY_PLAYER_MEDICAL = 1; // Medical insurance was used (player disease/injury)
const V_INS_ACCT_HISTORY_PLAYER_DEATH = 2; // Life insurance was used (player death)
const V_INS_ACCT_HISTORY_VEH_DAMAGE = 3; // Vehicle was damaged, but not destroyed
const V_INS_ACCT_HISTORY_VEH_WRECKED = 4; // Vehicle was completely destroyed
const V_INS_ACCT_HISTORY_VEH_THEFT = 5; // Vehicle was stolen
const V_INS_ACCT_HISTORY_BIZ_DAMAGE = 6; // Business was damaged (broken items/window/door)
const V_INS_ACCT_HISTORY_BIZ_THEFT = 7; // Business was stolen from
const V_INS_ACCT_HISTORY_HOUSE_DAMAGE = 8; // House was damaged
const V_INS_ACCT_HISTORY_HOUSE_THEFT = 9; // House was stolen from
// ===========================================================================

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: drink.js
// DESC: Provides features and usage for the drink item type

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: food.js
// DESC: Provides features and usage for the food item type

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type
@@ -11,20 +10,20 @@
// ===========================================================================
function isPlayerHandCuffed(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == V_PEDSTATE_BINDED);
}
// ===========================================================================
function handCuffPlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED;
getPlayerData(client).pedState = V_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function unHandCuffPlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
getPlayerData(client).pedState = V_PEDSTATE_READY;
setPlayerControlState(client, true);
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: phone.js
// DESC: Provides features and usage for the phone item type
@@ -10,7 +9,7 @@
function getItemWithPhoneNumber(phoneNumber) {
for (let i in getServerData().items) {
if (getItemTypeData(getItemData(i).itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_PHONE) {
if (getItemTypeData(getItemData(i).itemTypeIndex).useType == V_ITEM_USE_TYPE_PHONE) {
if (getItemData(i).value == phoneNumber) {
return i;
}
@@ -31,15 +30,15 @@ function ringPhoneForNearbyPlayers(itemIndex) {
/*
if(isPhoneItemEnabled(itemIndex)) {
switch(getItemData(itemIndex).ownerType) {
case AGRP_ITEM_OWNER_GROUND:
case V_ITEM_OWNER_GROUND:
playRingtoneForPlayersInRange(getItemData(itemIndex).position, getItemData(i).extra);
break;
case AGRP_ITEM_OWNER_VEHTRUNK:
case V_ITEM_OWNER_VEHTRUNK:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
case AGRP_ITEM_OWNER_VEHDASH:
case V_ITEM_OWNER_VEHDASH:
playRingtoneForPlayersInRange(getVehiclePosition(getItemData(itemIndex).ownerId), getItemData(i).extra);
break;
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: handcuff.js
// DESC: Provides features and usage for the handcuff item type
@@ -11,20 +10,20 @@
// ===========================================================================
function isPlayerTied(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_BINDED);
return (getPlayerData(client).pedState == V_PEDSTATE_BINDED);
}
// ===========================================================================
function ropeTiePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_BINDED;
getPlayerData(client).pedState = V_PEDSTATE_BINDED;
setPlayerControlState(client, false);
}
// ===========================================================================
function ropeUnTiePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
getPlayerData(client).pedState = V_PEDSTATE_READY;
setPlayerControlState(client, true);
}

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: tazer.js
// DESC: Provides features and usage for the tazer item type
@@ -11,13 +10,13 @@
// ===========================================================================
function isPlayerTazed(client) {
return (getPlayerData(client).pedState == AGRP_PEDSTATE_TAZED);
return (getPlayerData(client).pedState == V_PEDSTATE_TAZED);
}
// ===========================================================================
function tazePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_TAZED;
getPlayerData(client).pedState = V_PEDSTATE_TAZED;
setPlayerControlState(client, false);
let animationId = getAnimationFromParams("tazed");
@@ -34,7 +33,7 @@ function tazePlayer(client) {
// ===========================================================================
function unTazePlayer(client) {
getPlayerData(client).pedState = AGRP_PEDSTATE_READY;
getPlayerData(client).pedState = V_PEDSTATE_READY;
setPlayerControlState(client, true);
setPlayerPosition(client, getPlayerData(client).currentAnimationPositionReturnTo);

View File

@@ -1,7 +1,6 @@
// ===========================================================================
// Asshat Gaming Roleplay
// https://github.com/VortrexFTW/agrp_main
// (c) 2022 Asshat Gaming
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/v-roleplay
// ===========================================================================
// FILE: walkie-talkie.js
// DESC: Provides features and usage for the walkie-talkie item type
@@ -9,7 +8,7 @@
// ===========================================================================
function getPlayerActiveWalkieTalkieFrequency(client) {
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE);
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, V_ITEM_USE_TYPE_WALKIETALKIE);
if (walkieTalkieSlot != -1) {
if (getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
@@ -32,7 +31,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], AGRP_ITEM_USE_TYPE_WALKIETALKIE)]).enabled) {
// if(getItemData(getPlayerData(clients[i]).hotBarItems[getPlayerFirstItemSlotByUseType(clients[i], V_ITEM_USE_TYPE_WALKIETALKIE)]).enabled) {
// walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
// }
// }
@@ -43,7 +42,7 @@ function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
let items = getServerData().items;
for (let i in items) {
if (items[i].enabled) {
if (getItemTypeData(items[i].itemTypeIndex).useType == AGRP_ITEM_USE_TYPE_WALKIETALKIE) {
if (getItemTypeData(items[i].itemTypeIndex).useType == V_ITEM_USE_TYPE_WALKIETALKIE) {
if (items[i].value == radioFrequency) {
walkieTalkieIncomingToNearbyPlayers(null, messageText, getItemPosition(i));
}
@@ -126,12 +125,15 @@ function walkieTalkieChatCommand(command, params, client) {
return false;
}
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, AGRP_ITEM_USE_TYPE_WALKIETALKIE);
let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client, V_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");
}
// ===========================================================================

Some files were not shown because too many files have changed in this diff Show More