From 0b564d66e87ad53ed082f022603cfa63a2c25826 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:01:10 -0600
Subject: [PATCH 1/6] Rename main.js to core.js for client
---
meta.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta.xml b/meta.xml
index 58c7d8a1..7706aa96 100644
--- a/meta.xml
+++ b/meta.xml
@@ -119,6 +119,7 @@
+
@@ -132,7 +133,6 @@
-
From 833f8872e2797e6cadb76fc080f0a516b4963928 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:02:34 -0600
Subject: [PATCH 2/6] Add entrance fee to business labels
---
scripts/client/business.js | 4 +++-
scripts/client/label.js | 19 ++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/scripts/client/business.js b/scripts/client/business.js
index f151cc6f..7d256938 100644
--- a/scripts/client/business.js
+++ b/scripts/client/business.js
@@ -23,6 +23,7 @@ class BusinessData {
this.blipId = -1;
this.labelInfoType = 0;
this.locked = false;
+ this.entranceFee = 0;
}
}
@@ -35,7 +36,7 @@ function initBusinessScript() {
// ===========================================================================
-function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems) {
+function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel, pickupModel, buyPrice, rentPrice, hasInterior, locked, hasItems, entranceFee) {
logToConsole(LOG_DEBUG, `[AGRP.Business] Received business ${businessId} (${name}) from server`);
if (!areServerElementsSupported() || getGame() == AGRP_GAME_MAFIA_ONE || getGame() == AGRP_GAME_GTA_IV) {
@@ -50,6 +51,7 @@ function receiveBusinessFromServer(businessId, name, entrancePosition, blipModel
businessData.rentPrice = rentPrice;
businessData.hasItems = hasItems;
businessData.locked = locked;
+ businessData.entranceFee = entranceFee;
if (hasInterior && !hasItems) {
businessData.labelInfoType = AGRP_PROPLABEL_INFO_ENTER;
diff --git a/scripts/client/label.js b/scripts/client/label.js
index 8721c13c..34efb3ca 100644
--- a/scripts/client/label.js
+++ b/scripts/client/label.js
@@ -65,7 +65,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;
}
@@ -122,6 +122,15 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
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);
+
+ screenPosition.y -= propertyLabelPriceOffset;
+ }
+
if (isBusiness) {
text = (locked) ? toUpperCase(getLocaleString("Closed")) : toUpperCase(getLocaleString("Open"));
} else {
@@ -318,7 +327,7 @@ function processLabelRendering() {
}
if (getDistance(localPlayer.position, business.entrancePosition) <= propertyLabelRenderDistance) {
- renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType);
+ renderPropertyEntranceLabel(business.name, business.entrancePosition, business.locked, true, business.buyPrice, business.rentPrice, business.labelInfoType, business.entranceFee);
}
}
});
@@ -371,9 +380,13 @@ function processLabelRendering() {
labelInfoType = pickups[i].getData("agrp.label.help");
}
+ if (pickups[i].getData("agrp.label.fee") != null) {
+ fee = pickups[i].getData("agrp.label.fee");
+ }
+
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);
+ renderPropertyEntranceLabel(pickups[i].getData("agrp.label.name"), pickups[i].position, pickups[i].getData("agrp.label.locked"), true, price, rentPrice, labelInfoType, fee);
break;
}
From 4cf72b610e6d9b0bb7605e36500fb909903aa77d Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:02:45 -0600
Subject: [PATCH 3/6] Paintball players array
---
scripts/server/business.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/server/business.js b/scripts/server/business.js
index 774f3ed4..668bd1e5 100644
--- a/scripts/server/business.js
+++ b/scripts/server/business.js
@@ -92,6 +92,8 @@ class BusinessData {
this.streamingRadioStation = 0;
//this.streamingRadioStationIndex = -1;
+ this.paintBallPlayers = [];
+
this.labelHelpType = AGRP_PROPLABEL_INFO_NONE;
if (dbAssoc) {
@@ -861,6 +863,7 @@ function setBusinessEntranceFeeCommand(command, params, client) {
getBusinessData(businessId).entranceFee = entranceFee;
getBusinessData(businessId).needsSaved = true;
+ updateBusinessPickupLabelData(businessId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} entrance fee to {ALTCOLOUR}${getCurrencyString(entranceFee)}`);
}
@@ -2925,6 +2928,7 @@ function updateBusinessPickupLabelData(businessId) {
}
setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.price", getBusinessData(businessId).buyPrice, true);
+ setEntityData(getBusinessData(businessId).entrancePickup, "agrp.label.fee", getBusinessData(businessId).entranceFee, true);
}
}
From 8350edac74ee0b5e81a28dacf66b8b93e25361d3 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:02:55 -0600
Subject: [PATCH 4/6] Use new query assoc stuff
---
scripts/server/config.js | 45 +++++++++++++++-------------------------
1 file changed, 17 insertions(+), 28 deletions(-)
diff --git a/scripts/server/config.js b/scripts/server/config.js
index e8517c1c..b42a7b0d 100644
--- a/scripts/server/config.js
+++ b/scripts/server/config.js
@@ -314,18 +314,14 @@ function loadGlobalConfig() {
// ===========================================================================
-function loadServerConfigFromGameAndPort(gameId, port) {
+async function loadServerConfigFromGameAndPort(gameId, port) {
let dbConnection = connectToDatabase();
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;
- }
+ let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
+ if (dbAssoc.length > 0) {
+ let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
+ return tempServerConfigData;
}
disconnectFromDatabase(dbConnection);
}
@@ -334,18 +330,15 @@ function loadServerConfigFromGameAndPort(gameId, port) {
// ===========================================================================
-function loadServerConfigFromGame(gameId) {
+async function loadServerConfigFromGame(gameId) {
let dbConnection = connectToDatabase();
if (dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`;
- let dbQuery = queryDatabase(dbConnection, dbQueryString);
- if (dbQuery) {
- if (dbQuery.numRows > 0) {
- let dbAssoc = fetchQueryAssoc(dbQuery);
- let tempServerConfigData = new ServerConfigData(dbAssoc);
- freeDatabaseQuery(dbQuery);
- return tempServerConfigData;
- }
+ let dbAssocArray = await fetchQueryAssoc(dbConnection, dbQueryString);
+ logToConsole(LOG_DEBUG | LOG_WARN, `${dbAssocArray[0]}`);
+ if (dbAssocArray.length > 0) {
+ let tempServerConfigData = new ServerConfigData(dbAssocArray[0]);
+ return tempServerConfigData;
}
disconnectFromDatabase(dbConnection);
}
@@ -354,21 +347,17 @@ function loadServerConfigFromGame(gameId) {
// ===========================================================================
-function loadServerConfigFromId(tempServerId) {
+async function loadServerConfigFromId(tempServerId) {
let dbConnection = connectToDatabase();
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;
- }
+ let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
+ if (dbAssoc.length > 0) {
+ let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
+ return tempServerConfigData;
}
- disconnectFromDatabase(dbConnection);
}
+ disconnectFromDatabase(dbConnection);
return false;
}
From ba624f13c38c99b634a4fb013bb2e080505ffee0 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:03:13 -0600
Subject: [PATCH 5/6] New query assoc native
---
scripts/server/native/connected.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js
index 2e247b1d..5c1c4a88 100644
--- a/scripts/server/native/connected.js
+++ b/scripts/server/native/connected.js
@@ -917,8 +917,18 @@ function freeDatabaseQuery(dbQuery) {
// ===========================================================================
-function fetchQueryAssoc(dbQuery) {
- return dbQuery.fetchAssoc();
+async function fetchQueryAssoc(dbConnection, dbQueryString) {
+ //logToConsole(LOG_DEBUG, dbQueryString);
+ let dbQuery = dbConnection.query(dbQueryString);
+ let assocArray = [];
+ let dbAssoc = null;
+
+ while (dbAssoc = dbQuery.fetchAssoc()) {
+ assocArray.push(dbAssoc);
+ //logToConsole(LOG_DEBUG | LOG_WARN, dbAssoc["svr_id"]);
+ }
+
+ return assocArray;
}
// ===========================================================================
From b228981e057bb96fd888851cf85016587d1694d2 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Sun, 11 Dec 2022 02:03:30 -0600
Subject: [PATCH 6/6] Reset paintball on last player leave + payout
---
scripts/server/paintball.js | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/scripts/server/paintball.js b/scripts/server/paintball.js
index 41fdf17b..b11e91cd 100644
--- a/scripts/server/paintball.js
+++ b/scripts/server/paintball.js
@@ -71,10 +71,15 @@ function startPaintBall(client) {
getPlayerData(client).inPaintBall = true;
getPlayerData(client).paintBallBusiness = getPlayerBusiness(client);
+ getPlayerData(client).paintBallKills = 0;
+ getPlayerData(client).paintBallDeaths = 0;
+ getBusinessData(getPlayerData(client).paintBallBusiness).paintBallPlayers.push(client.index);
+ getBusinessData(getPlayerData(client).paintBallBusiness).paintBallPot += getBusinessData(getPlayerData(client).paintBallBusiness).entranceFee * 2;
givePlayerPaintBallItems(client);
messagePlayerAlert(client, getLocaleString(client, "JoinedPaintBall"));
+
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Started paintball for ${getPlayerDisplayForConsole(client)} successfully`);
}
@@ -90,7 +95,31 @@ function stopPaintBall(client) {
deletePaintBallItems(client);
restorePlayerTempLockerItems(client);
+ let tempBusiness = getPlayerData(client).paintBallBusiness;
+
messagePlayerAlert(client, getLocaleString(client, "LeftPaintBall"));
+
+ getBusinessData(tempBusiness).paintBallPlayers.splice(getBusinessData(tempBusiness).paintBallPlayers.indexOf(client.index), 1);
+
+ if (getBusinessData(tempBusiness).paintBallPlayers.length == 0) {
+ messagePlayerAlert(client, getLocaleString(client, "PaintBallEnded"));
+ messagePlayerInfo(client, getLocaleString(client, "YourPaintBallResults", getPlayerData(client).paintBallKills, getPlayerData(client).paintBallDeaths));
+
+ //messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderEventWinners")));
+ //messagePlayerInfo(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderEventWinners")));
+
+ givePlayerCash(client, getBusinessData(tempBusiness).paintBallPot);
+ getBusinessData(tempBusiness).paintBallPot = 0;
+ }
+
+ getPlayerData(client).inPaintBall = false;
+ getPlayerData(client).paintBallBusiness = false;
+ getPlayerData(client).tempLockerType = AGRP_TEMP_LOCKER_TYPE_NONE;
+ getPlayerData(client).paintBallKills = 0;
+ getPlayerData(client).paintBallDeaths = 0;
+
+ //checkRemainingPaintBallPlayers(tempBusiness);
+
logToConsole(LOG_DEBUG, `[AGRP.PaintBall]: Stopped paintball for ${getPlayerDisplayForConsole(client)} successfully`);
}
@@ -164,4 +193,12 @@ function isPlayerInPaintBall(client) {
return getPlayerData(client).inPaintBall;
}
+// ===========================================================================
+
+function checkRemainingPaintBallPlayers(businessIndex) {
+ //if (getBusinessData(businessIndex).paintBallPlayers.length == 0) {
+ //
+ //}
+}
+
// ===========================================================================
\ No newline at end of file