From 7f2ee0c8d5bf2071f90c0c29eeb3ee0ac85552b0 Mon Sep 17 00:00:00 2001
From: Vortrex <3858226+VortrexFTW@users.noreply.github.com>
Date: Mon, 11 Jan 2021 10:31:49 -0600
Subject: [PATCH] No message. 83 files changed.
---
meta.xml | 7 +
scripts/client/chatbox.js | 75 +++++
scripts/client/gui.js | 4 +
scripts/client/keybind.js | 12 +-
scripts/client/label.js | 76 ++---
scripts/client/main.js | 130 ++++++--
scripts/client/nametag.js | 4 +-
scripts/client/scoreboard.js | 2 +-
scripts/client/sync.js | 29 +-
scripts/server/accent.js | 2 +-
scripts/server/account.js | 86 ++---
scripts/server/ammunation.js | 2 +-
scripts/server/anticheat.js | 2 +-
scripts/server/ban.js | 2 +-
scripts/server/bitflag.js | 18 +-
scripts/server/business.js | 28 +-
scripts/server/business/bakery.js | 2 +-
scripts/server/business/bar.js | 2 +-
scripts/server/business/burger.js | 2 +-
scripts/server/business/clothing.js | 2 +-
scripts/server/business/club.js | 2 +-
scripts/server/business/fuel.js | 2 +-
scripts/server/business/mechanic.js | 2 +-
scripts/server/business/pizza.js | 2 +-
scripts/server/business/restaurant.js | 2 +-
scripts/server/business/vehicle.js | 2 +-
scripts/server/business/weapon.js | 2 +-
scripts/server/chat.js | 22 +-
scripts/server/clan.js | 2 +-
scripts/server/class.js | 29 +-
scripts/server/client.js | 343 +++++++++++++++----
scripts/server/colour.js | 4 +-
scripts/server/command.js | 7 +-
scripts/server/config.js | 12 +-
scripts/server/const.js | 28 +-
scripts/server/core.js | 2 +-
scripts/server/database.js | 2 +-
scripts/server/developer.js | 14 +-
scripts/server/discord.js | 6 +-
scripts/server/event.js | 191 +++++------
scripts/server/fishing.js | 2 +-
scripts/server/gui.js | 69 ++--
scripts/server/help.js | 2 +-
scripts/server/house.js | 2 +-
scripts/server/item.js | 461 ++++++++++++++++++--------
scripts/server/item/drink.js | 11 +
scripts/server/item/food.js | 11 +
scripts/server/item/phone.js | 11 +
scripts/server/item/walkie-talkie.js | 103 ++++++
scripts/server/job.js | 122 ++++---
scripts/server/job/bus.js | 6 +-
scripts/server/job/drug.js | 2 +-
scripts/server/job/fire.js | 2 +-
scripts/server/job/garbage.js | 4 +-
scripts/server/job/medic.js | 2 +-
scripts/server/job/police.js | 4 +-
scripts/server/job/taxi.js | 2 +-
scripts/server/job/weapon.js | 2 +-
scripts/server/keybind.js | 15 +-
scripts/server/locale.js | 2 +-
scripts/server/messaging.js | 20 +-
scripts/server/misc.js | 16 +-
scripts/server/moderation.js | 38 +--
scripts/server/native.js | 46 ++-
scripts/server/npc.js | 2 +-
scripts/server/npc/biker.js | 2 +-
scripts/server/npc/drugdealer.js | 2 +-
scripts/server/npc/firefighter.js | 2 +-
scripts/server/npc/gang.js | 2 +-
scripts/server/npc/mafia.js | 2 +-
scripts/server/npc/normal.js | 2 +-
scripts/server/npc/paramedic.js | 2 +-
scripts/server/npc/police.js | 2 +-
scripts/server/security.js | 2 +-
scripts/server/startup.js | 9 +-
scripts/server/subaccount.js | 37 +--
scripts/server/timers.js | 2 +-
scripts/server/translate.js | 2 +-
scripts/server/tutorial.js | 2 +-
scripts/server/utilities.js | 8 +-
scripts/server/vehicle.js | 79 +++--
scripts/shared/const.js | 1 +
scripts/shared/native.js | 12 +-
83 files changed, 1544 insertions(+), 746 deletions(-)
create mode 100644 scripts/client/chatbox.js
create mode 100644 scripts/server/item/drink.js
create mode 100644 scripts/server/item/food.js
create mode 100644 scripts/server/item/phone.js
create mode 100644 scripts/server/item/walkie-talkie.js
diff --git a/meta.xml b/meta.xml
index f895dcb9..14889b51 100644
--- a/meta.xml
+++ b/meta.xml
@@ -27,6 +27,7 @@
+
@@ -69,6 +70,11 @@
+
+
+
+
+
@@ -82,6 +88,7 @@
+
diff --git a/scripts/client/chatbox.js b/scripts/client/chatbox.js
new file mode 100644
index 00000000..44e75bc4
--- /dev/null
+++ b/scripts/client/chatbox.js
@@ -0,0 +1,75 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: chatbox.js
+// DESC: Provides extra chatbox features
+// TYPE: Client (JavaScript)
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+
+let chatBoxHistory = [];
+let bottomMessageIndex = 0;
+
+let scrollAmount = 1;
+let maxChatBoxLines = 6;
+
+bindKey(SDLK_PAGEUP, KEYSTATE_DOWN, chatBoxScrollUp);
+bindKey(SDLK_PAGEDOWN, KEYSTATE_DOWN, chatBoxScrollDown);
+
+// ---------------------------------------------------------------------------
+
+addNetworkHandler("ag.m", function(messageString, colour) {
+ message(messageString, colour);
+ addToChatBoxHistory(messageString, colour);
+ bottomMessageIndex = chatBoxHistory.length-1;
+});
+
+// ---------------------------------------------------------------------------
+
+function addToChatBoxHistory(messageString, colour) {
+ chatBoxHistory.push([messageString, colour]);
+}
+
+// ---------------------------------------------------------------------------
+
+function chatBoxScrollUp() {
+ if(bottomMessageIndex > maxChatBoxLines) {
+ bottomMessageIndex = bottomMessageIndex-scrollAmount;
+ updateChatBox();
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function chatBoxScrollDown() {
+ if(bottomMessageIndex < chatBoxHistory.length-1) {
+ bottomMessageIndex = bottomMessageIndex+scrollAmount;
+ updateChatBox();
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function clearChatBox() {
+ for(let i = 0 ; i <= maxChatBoxLines ; i++) {
+ message("", COLOUR_WHITE);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function updateChatBox() {
+ clearChatBox();
+ for(let i = bottomMessageIndex-maxChatBoxLines ; i <= bottomMessageIndex ; i++) {
+ if(typeof chatBoxHistory[i] != "undefined") {
+ message(chatBoxHistory[i][0], chatBoxHistory[i][1]);
+ } else {
+ message("", COLOUR_WHITE);
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/client/gui.js b/scripts/client/gui.js
index c7deadff..c34d8dda 100644
--- a/scripts/client/gui.js
+++ b/scripts/client/gui.js
@@ -2178,7 +2178,11 @@ addNetworkHandler("ag.guiColour", function(red, green, blue) {
logToConsole(LOG_DEBUG, `[Asshat.GUI] Received new GUI colours from server`);
primaryColour = [red, green, blue];
focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset];
+});
+// ---------------------------------------------------------------------------
+
+addNetworkHandler("ag.guiInit", function() {
logToConsole(LOG_DEBUG, `[Asshat.GUI] Initializing MexUI app`);
app.init();
triggerNetworkEvent("ag.guiReady", true);
diff --git a/scripts/client/keybind.js b/scripts/client/keybind.js
index 29b73211..af261e40 100644
--- a/scripts/client/keybind.js
+++ b/scripts/client/keybind.js
@@ -3,26 +3,26 @@
// https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
-// FILE: afk.js
-// DESC: Provides AFK detection
+// FILE: keybind.js
+// DESC: Provides keybind features
// TYPE: Client (JavaScript)
// ===========================================================================
let lastKeyBindUse = 0;
-let keyBindDelayTime = 2000;
+let keyBindDelayTime = 2500;
// -------------------------------------------------------------------------
function bindAccountKey(key, keyState) {
bindKey(toInteger(key), keyState, function(event) {
if(hasKeyBindDelayElapsed()) {
- triggerNetworkEvent("ag.keybind.trig", key);
lastKeyBindUse = sdl.ticks;
+ triggerNetworkEvent("ag.useKeyBind", key);
}
});
return false;
}
-addNetworkHandler("ag.keybinds.add", bindAccountKey);
+addNetworkHandler("ag.addKeyBind", bindAccountKey);
// -------------------------------------------------------------------------
@@ -30,7 +30,7 @@ function unBindAccountKey(key) {
unbindKey(key);
return true;
}
-addNetworkHandler("ag.keybinds.del", unBindAccountKey);
+addNetworkHandler("ag.delKeyBind", unBindAccountKey);
// -------------------------------------------------------------------------
diff --git a/scripts/client/label.js b/scripts/client/label.js
index 3cfe53e9..410760f5 100644
--- a/scripts/client/label.js
+++ b/scripts/client/label.js
@@ -48,10 +48,6 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
if(propertyLabelLockedFont == null) {
return false;
- }
-
- if(localPlayer.position.distance(position) > 7.5) {
- return false;
}
let tempPosition = position;
@@ -97,10 +93,6 @@ function renderPropertyExitLabel(position) {
return false;
}
- if(localPlayer.position.distance(position) > 7.5) {
- return false;
- }
-
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -125,10 +117,6 @@ function renderJobLabel(name, position, jobType) {
return false;
}
- if(localPlayer.position.distance(position) > 7.5) {
- return false;
- }
-
let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -160,52 +148,38 @@ function renderJobLabel(name, position, jobType) {
// -------------------------------------------------------------------------
-addEventHandler("OnDrawnHUD", function (event) {
- if(!renderHUD) {
- return false;
- }
-
- if(!renderLabels) {
- return false;
- }
-
+function processLabelRendering() {
if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) {
if(pickups[i].getData("ag.label.type") != null) {
- //if(pickups[i].isOnScreen) {
- if(getDistance(localPlayer.position, pickups[i].position)) {
- //if(pickups[i].interior == localPlayer.interior) {
- //if(pickups[i].dimension == localPlayer.dimension) {
- let price = 0;
- if(pickups[i].getData("ag.label.price") != null) {
- price = pickups[i].getData("ag.label.price");
- }
-
- switch(pickups[i].getData("ag.label.type")) {
- case AG_LABEL_BUSINESS:
- renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price);
- break;
-
- case AG_LABEL_HOUSE:
- renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), false, price);
- break;
-
- case AG_LABEL_JOB:
- renderJobLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.jobType"));
- break;
-
- case AG_LABEL_EXIT:
- renderPropertyExitLabel(pickups[i].position);
- break;
- }
- //}
- //}
+ if(getDistance(localPlayer.position, pickups[i].position) <= 7.5) {
+ let price = 0;
+ if(pickups[i].getData("ag.label.price") != null) {
+ price = pickups[i].getData("ag.label.price");
}
- //}
+
+ switch(pickups[i].getData("ag.label.type")) {
+ case AG_LABEL_BUSINESS:
+ renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), true, price);
+ break;
+
+ case AG_LABEL_HOUSE:
+ renderPropertyEntranceLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.locked"), false, price);
+ break;
+
+ case AG_LABEL_JOB:
+ renderJobLabel(pickups[i].getData("ag.label.name"), pickups[i].position, pickups[i].getData("ag.label.jobType"));
+ break;
+
+ case AG_LABEL_EXIT:
+ renderPropertyExitLabel(pickups[i].position);
+ break;
+ }
+ }
}
}
}
-});
+}
// -------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/client/main.js b/scripts/client/main.js
index 56c2b406..d147ab1e 100644
--- a/scripts/client/main.js
+++ b/scripts/client/main.js
@@ -40,24 +40,34 @@ let garbageCollectorInterval = null;
let parkedVehiclePosition = false;
let parkedVehicleHeading = false;
-let renderHUD = false;
-let renderLabels = false;
-let renderLogo = false;
-let renderSmallGameMessage = false;
-let renderScoreboard = false;
-let renderHotBar = false;
+let renderHUD = true;
+let renderLabels = true;
+let renderLogo = true;
+let renderSmallGameMessage = true;
+let renderScoreboard = true;
+let renderHotBar = true;
+let renderItemActionDelay = true;
-let logLevel = LOG_DEBUG;
+let logLevel = LOG_ALL;
let weaponDamageEnabled = {};
-let weaponDamageEvent = AG_WEAPON_DAMAGE_EVENT_NONE;
+let weaponDamageEvent = {};
+
+let forceWeapon = 0;
+
+let itemActionDelayDuration = 0;
+let itemActionDelayStart = 0;
+let itemActionDelayEnabled = false;
+let itemActionDelayPosition = toVector2(gta.width/2, gta.height-100);
+let itemActionDelaySize = toVector2(100, 10);
// ---------------------------------------------------------------------------
addEvent("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1);
-addEvent("OnLocalPlayerEnterVehicle", 1);
-addEvent("OnLocalPlayerExitVehicle", 1);
+addEvent("OnLocalPlayerEnteredVehicle", 1);
+addEvent("OnLocalPlayerExitedVehicle", 1);
+addEvent("OnLocalPlayerSwitchWeapon", 2);
// ---------------------------------------------------------------------------
@@ -171,6 +181,7 @@ function getClosestVehicle(pos) {
addNetworkHandler("ag.clearWeapons", function() {
logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing weapons`);
localPlayer.clearWeapons();
+ forceWeapon = 0;
});
// ---------------------------------------------------------------------------
@@ -178,11 +189,12 @@ addNetworkHandler("ag.clearWeapons", function() {
addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active);
+ forceWeapon = weaponId;
});
// ---------------------------------------------------------------------------
-addEventHandler("onElementStreamIn", function(event, element) {
+addEventHandler("OnElementStreamIn", function(event, element) {
switch(element.type) {
case ELEMENT_VEHICLE:
syncVehicleProperties(element);
@@ -196,6 +208,10 @@ addEventHandler("onElementStreamIn", function(event, element) {
syncPlayerProperties(element);
break;
+ case ELEMENT_OBJECT:
+ syncObjectProperties(element);
+ break;
+
default:
break;
}
@@ -305,6 +321,8 @@ function initLocalPlayer(player) {
// ---------------------------------------------------------------------------
function processEvent(event, deltaTime) {
+ gta.clearMessages();
+
if(localPlayer != null) {
localPlayer.wantedLevel = 0;
@@ -361,29 +379,27 @@ function processEvent(event, deltaTime) {
if(localPlayer.vehicle) {
if(!inVehicle) {
- triggerNetworkEvent("ag.onPlayerEnterVehicle");
inVehicle = localPlayer.vehicle;
inVehicleSeat = getLocalPlayerVehicleSeat();
-
- if(inVehicleSeat == 0) {
- inVehicle.engine = false;
- if(!inVehicle.engine) {
- parkedVehiclePosition = inVehicle.position;
- parkedVehicleHeading = inVehicle.heading;
- }
- }
+ triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat);
}
} else {
if(inVehicle) {
- triggerNetworkEvent("ag.onPlayerExitVehicle");
- if(inVehicleSeat) {
- parkedVehiclePosition = false;
- parkedVehicleHeading = false;
- }
+ triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat);
inVehicle = false;
inVehicleSeat = false;
}
}
+
+ if(forceWeapon != 0) {
+ if(localPlayer.weapon != forceWeapon) {
+ localPlayer.weapon = forceWeapon;
+ }
+ } else {
+ if(localPlayer.weapon > 0) {
+ localPlayer.clearWeapons();
+ }
+ }
}
}
@@ -403,7 +419,6 @@ addEventHandler("OnDrawnHUD", function (event) {
if(smallGameMessageFont != "") {
smallGameMessageFont.render(smallGameMessageText, [0, gta.height-50], gta.width, 0.5, 0.0, smallGameMessageFont.size, smallGameMessageColour, true, true, false, true);
}
- return false;
}
}
@@ -414,8 +429,31 @@ addEventHandler("OnDrawnHUD", function (event) {
}
if(renderScoreboard) {
- if(localPlayer != nul && isKeyDown()) {
- renderScoreboard();
+ if(isKeyDown(SDLK_TAB)) {
+ processScoreboardRendering();
+ }
+ }
+
+ if(renderLabels) {
+ processLabelRendering();
+ }
+
+ if(renderItemActionDelay) {
+ //logToConsole(LOG_DEBUG, `Item action delay render enabled`);
+ if(itemActionDelayEnabled) {
+ //logToConsole(LOG_DEBUG, `Item action delay enabled`);
+ let finishTime = itemActionDelayStart+itemActionDelayDuration;
+ if(sdl.ticks >= finishTime) {
+ logToConsole(LOG_DEBUG, `Item action delay finish time reached`);
+ itemActionDelayEnabled = false;
+ itemActionDelayDuration = 0;
+ itemActionDelayStart = 0;
+ triggerNetworkEvent("ag.itemActionDelayComplete");
+ } else {
+ let progressWidth = itemActionDelaySize.x-Math.ceil((finishTime-sdl.ticks)/100);
+ logToConsole(LOG_DEBUG, `Item action delay in progress - ${Math.ceil((finishTime-sdl.ticks)/100)} - ${progressWidth}/${itemActionDelaySize.x}`);
+ drawing.drawRectangle(null, [itemActionDelayPosition.x-(itemActionDelaySize.x/2), itemActionDelayPosition.y-(itemActionDelaySize.y/2)], [progressWidth, itemActionDelaySize.y], COLOUR_LIME, COLOUR_LIME, COLOUR_LIME, COLOUR_LIME);
+ }
}
}
});
@@ -631,7 +669,7 @@ function clearSelfOwnedPeds() {
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.set2DRendering", function(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState) {
+addNetworkHandler("ag.set2DRendering", function(hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState) {
renderHUD = hudState;
setHUDEnabled(hudState);
@@ -639,6 +677,7 @@ addNetworkHandler("ag.set2DRendering", function(hudState, labelState, smallGameM
renderSmallGameMessage = smallGameMessageState;
renderScoreboard = scoreboardState;
renderHotBar = hotBarState;
+ renderItemActionDelay = itemActionDelayState;
});
// ---------------------------------------------------------------------------
@@ -659,4 +698,37 @@ addEventHandler("OnPedInflictDamage", function(event, damagedPed, damagerEntity,
//
// }
// if(damagerEntity.isType(ELEMENT_PLAYER))
+});
+
+// ---------------------------------------------------------------------------
+
+addEventHandler("OnLocalPlayerExitedVehicle", function(event, vehicle, seat) {
+ triggerNetworkEvent("ag.onPlayerExitVehicle");
+ if(inVehicleSeat) {
+ parkedVehiclePosition = false;
+ parkedVehicleHeading = false;
+ }
+});
+
+// ---------------------------------------------------------------------------
+
+addEventHandler("OnLocalPlayerEnteredVehicle", function(event, vehicle, seat) {
+ triggerNetworkEvent("ag.onPlayerEnterVehicle");
+
+ if(inVehicleSeat == 0) {
+ inVehicle.engine = false;
+ if(!inVehicle.engine) {
+ parkedVehiclePosition = inVehicle.position;
+ parkedVehicleHeading = inVehicle.heading;
+ }
+ }
+});
+
+// ---------------------------------------------------------------------------
+
+addNetworkHandler("ag.showItemActionDelay", function(duration) {
+ itemActionDelayDuration = duration;
+ itemActionDelayStart = sdl.ticks;
+ itemActionDelayEnabled = true;
+ logToConsole(LOG_DEBUG, `Item action delay event called. Duration: ${itemActionDelayDuration}, Start: ${itemActionDelayStart}, Render: ${renderItemActionDelay}`);
});
\ No newline at end of file
diff --git a/scripts/client/nametag.js b/scripts/client/nametag.js
index 847505be..a2111f9e 100644
--- a/scripts/client/nametag.js
+++ b/scripts/client/nametag.js
@@ -74,9 +74,9 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
if(health > 0.0) {
let hx = x-width/2;
let hy = y-10/2;
- let colourB = createColour(0, 0, 0, Math.floor(255.0*alpha)); // Background colour (black)
+ let colourB = toColour(0, 0, 0, Math.floor(255.0*alpha)); // Background colour (black)
drawing.drawRectangle(null, [hx, hy], [width, 8], colourB, colourB, colourB, colourB);
- let colour = createColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health)
+ let colour = toColour(Math.floor(255.0*alpha), Math.floor(255.0-(health*255.0)), Math.floor(health*255.0), 0); // Health bar colour (varies, depending on health)
drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
}
diff --git a/scripts/client/scoreboard.js b/scripts/client/scoreboard.js
index 0804b659..4581fd15 100644
--- a/scripts/client/scoreboard.js
+++ b/scripts/client/scoreboard.js
@@ -24,7 +24,7 @@ bindEventHandler("OnResourceReady", thisResource, function(event, resource) {
// -------------------------------------------------------------------------
-function renderScoreboard() {
+function processScoreboardRendering() {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20);
let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);
diff --git a/scripts/client/sync.js b/scripts/client/sync.js
index 3bc5c175..e5756fba 100644
--- a/scripts/client/sync.js
+++ b/scripts/client/sync.js
@@ -87,7 +87,9 @@ function syncVehicleProperties(vehicle) {
vehicle.setSuspensionHeight(suspensionHeight);
}
}
-addNetworkHandler("ag.veh.sync", syncVehicleProperties);
+addNetworkHandler("ag.veh.sync", function(event, vehicle) {
+ syncVehicleProperties(vehicle);
+});
// ---------------------------------------------------------------------------
@@ -102,7 +104,9 @@ function syncCivilianProperties(civilian) {
civilian.position = tempPosition;
}
}
-addNetworkHandler("ag.civ.sync", syncCivilianProperties);
+addNetworkHandler("ag.civ.sync", function(event, civilian) {
+ syncCivilianProperties(civilian);
+});
// ---------------------------------------------------------------------------
@@ -117,6 +121,25 @@ function syncPlayerProperties(player) {
player.position = tempPosition;
}
}
-addNetworkHandler("ag.player.sync", syncPlayerProperties);
+addNetworkHandler("ag.player.sync", function(event, player) {
+ syncPlayerProperties(player);
+});
+
+// ---------------------------------------------------------------------------
+
+function syncObjectProperties(object) {
+ if(doesEntityDataExist(object, "ag.scale")) {
+ let scaleFactor = getEntityData(object, "ag.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;
+ }
+}
+addNetworkHandler("ag.obj.sync", function(event, object) {
+ syncObjectProperties(object);
+});
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/accent.js b/scripts/server/accent.js
index 2154c013..962b1ea1 100644
--- a/scripts/server/accent.js
+++ b/scripts/server/accent.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: accent.js
// DESC: Provides accent functions and usage
diff --git a/scripts/server/account.js b/scripts/server/account.js
index 5c91ec1c..c40b0922 100644
--- a/scripts/server/account.js
+++ b/scripts/server/account.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: account.js
// DESC: Provides account functions and usage
@@ -81,7 +81,7 @@ function toggleAccountGUICommand(command, params, client) {
showPlayerLoginGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else {
- messageClient(`👋 Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen"));
+ messagePlayerNormal(client, `👋 Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, getColourByName("softGreen"));
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
}
} else {
@@ -89,7 +89,7 @@ function toggleAccountGUICommand(command, params, client) {
showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
- messageClient(`👋 Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, getColourByName("softGreen"));
+ messagePlayerNormal(client, `👋 Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, getColourByName("softGreen"));
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled)`);
}
}
@@ -416,13 +416,13 @@ function loginSuccess(client) {
getPlayerData(client).loggedIn = true;
if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) {
- console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
+ logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
client.administrator = true;
}
if(getPlayerData(client).subAccounts.length == 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No characters");
+ showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else {
@@ -438,7 +438,7 @@ function loginSuccess(client) {
sendRemovedWorldObjectsToPlayer(client);
sendAccountKeyBindsToClient(client);
- message(`👋 ${client.name} has joined the server`, getColourByName("softYellow"));
+ messagePlayerNormal(null, `👋 ${client.name} has joined the server`, getColourByName("softYellow"));
}
// ---------------------------------------------------------------------------
@@ -543,12 +543,12 @@ function createAccount(name, password, email = "") {
// ---------------------------------------------------------------------------
function checkLogin(client, password) {
- let loginAttemptsRemaining = getEntityData(client, "ag.loginAttemptsRemaining")-1;
+ getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1;
if(isPlayerLoggedIn(client)) {
- console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
+ logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.loginSuccess", client);
+ sendPlayerLoginSuccess(client);
} else {
messagePlayerError(client, "You are already logged in!");
}
@@ -557,9 +557,9 @@ function checkLogin(client, password) {
}
if(!isPlayerRegistered(client)) {
- console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
+ logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is not registered`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.showRegistration", client);
+ showPlayerRegistratonGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else {
messagePlayerError(client, "Your name is not registered! Use /register to make an account.");
@@ -569,36 +569,35 @@ function checkLogin(client, password) {
}
if(areParamsEmpty(password)) {
- console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${loginAttemptsRemaining} login attempts remaining`);
+ logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (empty password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
- logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
+ showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
+ logToConsole(LOG_DEBUG, `[Asshat.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! ${loginAttemptsRemaining} tries remaining.`);
- logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
+ messagePlayerError(client, `You must enter a password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
+ logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
return false;
}
if(!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(client.name, password))) {
- console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${loginAttemptsRemaining} login attempts remaining`);
+ logToConsole(LOG_WARN, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but failed (wrong password). ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
- logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`);
+ showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
+ logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else {
- messagePlayerError(client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`);
- logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${loginAttemptsRemaining} login attempts remaining alert.`);
+ messagePlayerError(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
+ logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled) with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
}
return false;
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.loginSuccess", client);
+ showPlayerLoginSuccessGUI(client);
}
loginSuccess(client);
}
-addNetworkHandler("ag.checkLogin", checkLogin);
// ---------------------------------------------------------------------------
@@ -607,7 +606,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(isPlayerRegistered(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.showLogin", client);
+ showPlayerLoginGUI(client);
} else {
messagePlayerError(client, "Your name is already registered!");
}
@@ -616,7 +615,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(isPlayerLoggedIn(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.loginSuccess", client);
+ showPlayerLoginSuccessGUI(client);
} else {
messagePlayerError(client, "You are already logged in!");
}
@@ -625,7 +624,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(areParamsEmpty(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.registrationFailed", client, "Password cannot be blank!");
+ showPlayerRegistrationFailedGUI(client, "Password cannot be blank!");
} else {
messagePlayerError(client, "The password cannot be blank!");
}
@@ -634,21 +633,21 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(confirmPassword)) {
- triggerNetworkEvent("ag.registrationFailed", client, "Password confirm cannot be blank!");
+ showPlayerRegistrationFailedGUI(client, "Password confirm cannot be blank!");
return false;
}
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(emailAddress)) {
- triggerNetworkEvent("ag.registrationFailed", client, "Email address cannot be blank!");
+ showPlayerRegistrationFailedGUI(client, "Email address cannot be blank!");
return false;
}
}
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(password != confirmPassword) {
- triggerNetworkEvent("ag.registrationFailed", client, "The passwords must match!");
+ showPlayerRegistrationFailedGUI(client, "The passwords must match!");
return false;
}
}
@@ -656,7 +655,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(!doesPasswordMeetRequirements(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
// Work on this later. Function should return true by default anyway for now.
- triggerNetworkEvent("ag.registrationFailed", client, "Password doesn't meet requirements!");
+ showPlayerRegistrationFailedGUI(client, "Password doesn't meet requirements!");
} else {
messagePlayerError(client, "Password doesn't meet requirements!");
}
@@ -665,7 +664,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(!isValidEmailAddress(emailAddress)) {
- triggerNetworkEvent("ag.registrationFailed", client, "You must put a valid email!");
+ showPlayerRegistrationFailedGUI(client, "You must put a valid email!");
return false
}
}
@@ -673,9 +672,9 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
let accountData = createAccount(client.name, password, emailAddress);
if(!accountData) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.registrationFailed", client, "Something went wrong. Your account could not be created!");
+ showPlayerRegistrationFailedGUI(client, "Your account could not be created!");
} else {
- messagePlayerAlert(client, "Something went wrong. Your account could not be created!");
+ messagePlayerAlert(client, "Your account could not be created!");
}
messagePlayerAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
@@ -689,14 +688,13 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
messagePlayerAlert(client, "To play on the server, you will need to make a character.");
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.registrationSuccess", client);
- triggerNetworkEvent("ag.showPrompt", client, "You have no characters. Would you like to make one?", "No Characters");
+ showPlayerRegistrationSuccessGUI(client);
+ showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No Characters");
setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
} else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
}
};
-addNetworkHandler("ag.checkRegistration", checkRegistration);
// ---------------------------------------------------------------------------
@@ -751,7 +749,9 @@ function initClient(client) {
return false;
}
- triggerNetworkEvent("ag.guiColour", client, getServerConfig().guiColour[0], getServerConfig().guiColour[1], getServerConfig().guiColour[2]);
+ sendPlayerGUIColours(client);
+ sendPlayerGUIInit(client);
+
showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen"));
@@ -775,19 +775,19 @@ function initClient(client) {
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
- triggerNetworkEvent("ag.showLogin", client);
+ showPlayerLoginGUI(client);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`);
- messageClient(`Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, client, getColourByName("softGreen"));
+ messagePlayerNormal(client, `Welcome back to Asshat Gaming RP, ${client.name}! Please /login to continue.`, getColourByName("softGreen"));
}
}
} else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
- triggerNetworkEvent("ag.showRegistration", client);
+ showPlayerRegistrationGUI(client);
} else {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`);
- messageClient(`Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, client, getColourByName("softGreen"));
+ messagePlayerNormal(client, `Welcome to Asshat Gaming RP, ${client.name}! Please /register to continue.`, getColourByName("softGreen"));
}
}
}
@@ -978,4 +978,6 @@ function doesPlayerHaveAutoSelectLastCharacterEnabled(client) {
function getPlayerStaffTitle(client) {
return getPlayerData(client).accountData.staffTitle;
-}
\ No newline at end of file
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/ammunation.js b/scripts/server/ammunation.js
index 44a2ba7f..ea9357fc 100644
--- a/scripts/server/ammunation.js
+++ b/scripts/server/ammunation.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: ammunation.js
// DESC: Provides ammunation functions and usage
diff --git a/scripts/server/anticheat.js b/scripts/server/anticheat.js
index 84e57049..d075b9da 100644
--- a/scripts/server/anticheat.js
+++ b/scripts/server/anticheat.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: anticheat.js
// DESC: Provides anticheat functions and usage
diff --git a/scripts/server/ban.js b/scripts/server/ban.js
index a88fb750..4e66a0ee 100644
--- a/scripts/server/ban.js
+++ b/scripts/server/ban.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bans.js
// DESC: Provides ban functions and usage
diff --git a/scripts/server/bitflag.js b/scripts/server/bitflag.js
index 8cd158ae..9beb624a 100644
--- a/scripts/server/bitflag.js
+++ b/scripts/server/bitflag.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage
@@ -138,6 +138,14 @@ function createBitFlagTable(keyNames) {
// ---------------------------------------------------------------------------
function hasBitFlag(allFlags, checkForFlag) {
+ if(allFlags == 0) {
+ return false;
+ }
+
+ if(allFlags == -1) {
+ return true;
+ }
+
return (allFlags & checkForFlag);
}
@@ -153,10 +161,8 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
}
let staffFlags = 0;
- if(!isClientFromDiscord(client)) {
+ if(getPlayerData(client)) {
staffFlags = getPlayerData(client).accountData.flags.admin;
- } else {
- staffFlags = getDiscordUserData(client).accountData.flags.admin;
}
// -1 is automatic override (having -1 for staff flags is basically god mode admin level)
@@ -319,4 +325,6 @@ function getServerBitFlags() {
function getServerBitFlagKeys() {
return serverBitFlagKeys;
-}
\ No newline at end of file
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/business.js b/scripts/server/business.js
index b7c1567f..1a55f7cd 100644
--- a/scripts/server/business.js
+++ b/scripts/server/business.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: business.js
// DESC: Provides business functions and usage
@@ -658,30 +658,6 @@ function moveBusinessExitCommand(command, params, client) {
// ---------------------------------------------------------------------------
-function buySkinFromBusinessCommand(command, params, client) {
- let businessId = toInteger((isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)));
-
- if(getBusinessData(businessId)) {
- messagePlayerError(client, `You need to be in a business (or at the door if there is no interior)`);
- return false;
- }
-
- if(getBusinessData(businessId).type == getGlobalConfig().buySkinPrice) {
- messagePlayerError(client, `This business doesn't sell clothes (skins)!`);
- return false;
- }
-
- if(getPlayerCurrentSubAccount(client).cash <= AG_TEMPBIZPRICE_CLOTHES) {
- messagePlayerError(client, `You don't have enough money! You need [#AAAAAA]$${AG_TEMPBIZPRICE_CLOTHES-getPlayerCurrentSubAccount(client).cash} [#FFFFFF]more!`);
- return false;
- }
-
- setPlayerSkin(client, skinId);
- messageClientSuccess(client, "You bought a new set of clothes ([#AAAAAA]skinId[#FFFFFF]!");
-}
-
-// ---------------------------------------------------------------------------
-
function getBusinessDataFromDatabaseId(databaseId) {
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
if(matchingBusinesses.length == 1) {
@@ -739,7 +715,7 @@ function saveBusinessToDatabase(businessId) {
if(dbConnection) {
let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name);
if(tempBusinessData.databaseId == 0) {
- let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.databaseId+getGlobalConfig().businessDimensionStart}, ${boolToInt(tempBusinessData.hasInterior)})`;
+ let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw, biz_has_interior) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.databaseId+getGlobalConfig().businessDimensionStart}, ${boolToInt(tempBusinessData.hasInterior)})`;
queryDatabase(dbConnection, dbQueryString);
getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection);
} else {
diff --git a/scripts/server/business/bakery.js b/scripts/server/business/bakery.js
index e984a522..7be06872 100644
--- a/scripts/server/business/bakery.js
+++ b/scripts/server/business/bakery.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bakery.js
// DESC: Provides bakery business functions and usage
diff --git a/scripts/server/business/bar.js b/scripts/server/business/bar.js
index 3adb630c..714ff50c 100644
--- a/scripts/server/business/bar.js
+++ b/scripts/server/business/bar.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bar.js
// DESC: Provides bar/pub business functions and usage
diff --git a/scripts/server/business/burger.js b/scripts/server/business/burger.js
index b955c4f1..b8fd1a6a 100644
--- a/scripts/server/business/burger.js
+++ b/scripts/server/business/burger.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage
diff --git a/scripts/server/business/clothing.js b/scripts/server/business/clothing.js
index 9c1f54c6..cccbd96d 100644
--- a/scripts/server/business/clothing.js
+++ b/scripts/server/business/clothing.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage
diff --git a/scripts/server/business/club.js b/scripts/server/business/club.js
index 7508981a..942305ee 100644
--- a/scripts/server/business/club.js
+++ b/scripts/server/business/club.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: club.js
// DESC: Provides club/nightclub business functions and usage
diff --git a/scripts/server/business/fuel.js b/scripts/server/business/fuel.js
index 8fbd0c8e..fb7ce59d 100644
--- a/scripts/server/business/fuel.js
+++ b/scripts/server/business/fuel.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage
diff --git a/scripts/server/business/mechanic.js b/scripts/server/business/mechanic.js
index f15290be..a5d1f4f3 100644
--- a/scripts/server/business/mechanic.js
+++ b/scripts/server/business/mechanic.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage
diff --git a/scripts/server/business/pizza.js b/scripts/server/business/pizza.js
index 907e04b6..5c3d5540 100644
--- a/scripts/server/business/pizza.js
+++ b/scripts/server/business/pizza.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage
diff --git a/scripts/server/business/restaurant.js b/scripts/server/business/restaurant.js
index 2349a34c..312b3309 100644
--- a/scripts/server/business/restaurant.js
+++ b/scripts/server/business/restaurant.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage
diff --git a/scripts/server/business/vehicle.js b/scripts/server/business/vehicle.js
index 9c047c6c..737deda3 100644
--- a/scripts/server/business/vehicle.js
+++ b/scripts/server/business/vehicle.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage
diff --git a/scripts/server/business/weapon.js b/scripts/server/business/weapon.js
index 84e3dd22..e6e3145c 100644
--- a/scripts/server/business/weapon.js
+++ b/scripts/server/business/weapon.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: weapon.js
// DESC: Provides weapon (ammu) business functions and usage
diff --git a/scripts/server/chat.js b/scripts/server/chat.js
index e913629d..46d9b8e6 100644
--- a/scripts/server/chat.js
+++ b/scripts/server/chat.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: chat.js
// DESC: Provides chat functions and usage
@@ -99,7 +99,7 @@ function clanChatCommand(command, params, client) {
// ---------------------------------------------------------------------------
function talkToNearbyPlayers(client, messageText) {
- let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance);
+ let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for(let i in clients) {
//if(clients[i] != client) {
messagePlayerTalk(getClientFromPlayerElement(clients[i]), client, messageText);
@@ -109,6 +109,24 @@ function talkToNearbyPlayers(client, messageText) {
// ---------------------------------------------------------------------------
+function phoneOutgoingToNearbyPlayers(client, messageText) {
+ let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
+ for(let i in clients) {
+ messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](to phone): [#FFFFFF]${messageText}`);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function phoneIncomingToNearbyPlayers(client, messageText) {
+ let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().radioSpeakerDistance);
+ for(let i in clients) {
+ messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](from phone): [#FFFFFF]${messageText}`);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
function whisperToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance);
for(let i in clients) {
diff --git a/scripts/server/clan.js b/scripts/server/clan.js
index 0b450811..ef193e47 100644
--- a/scripts/server/clan.js
+++ b/scripts/server/clan.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: clan.js
// DESC: Provides clan functions and usage
diff --git a/scripts/server/class.js b/scripts/server/class.js
index 016e8a9b..fad00f7f 100644
--- a/scripts/server/class.js
+++ b/scripts/server/class.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: class.js
// DESC: Provides classes
@@ -101,6 +101,7 @@ function initClassTable() {
this.index = -1;
this.connectTime = 0;
this.clientVersion = "0.0.0";
+ this.loginAttemptsRemaining = 3;
this.busRoute = null;
this.busRouteStop = null;
@@ -128,10 +129,14 @@ function initClassTable() {
this.tutorialVehicle = null;
this.hotBarItems = new Array(9).fill(-1);
- this.activeHotBarSlot = 0;
+ this.activeHotBarSlot = -1;
+ this.toggleUseItem = false;
this.jobLockerCache = new Array(9).fill(-1);
this.jobEquipmentCache = [];
+
+ this.itemActionState = AG_ITEM_ACTION_NONE;
+ this.itemActionItem = -1;
}
},
accountData: class {
@@ -302,7 +307,6 @@ function initClassTable() {
this.interior = dbAssoc["sacct_int"];
this.dimension = dbAssoc["sacct_vw"];
this.pedScale = toVector3(dbAssoc["sacct_scale_x"], dbAssoc["sacct_scale_y"], dbAssoc["sacct_scale_z"]);
- return;
}
}
},
@@ -793,7 +797,6 @@ function initClassTable() {
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
- this.jobIndex = -1;
this.needsSaved = false;
if(dbAssoc) {
@@ -909,6 +912,7 @@ function initClassTable() {
this.needsSaved = false;
this.amount = 0;
this.value = 0;
+ this.enabled = false;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["item_id"]);
@@ -923,6 +927,7 @@ function initClassTable() {
this.buyPrice = toInteger(dbAssoc["item_buy_price"]);
this.amount = toInteger(dbAssoc["item_amount"]);
this.value = toInteger(dbAssoc["item_value"]);
+ this.enabled = intToBool(toInteger(dbAssoc["item_enabled"]));
}
}
},
@@ -943,6 +948,12 @@ function initClassTable() {
this.dropModel = 0;
this.orderPrice = 0;
this.needsSaved = false;
+ this.switchDelay = 0;
+ this.pickupDelay = 0;
+ this.putDelay = 0;
+ this.takeDelay = 0;
+ this.giveDelay = 0;
+ this.dropDelay = 0;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["item_type_id"]);
@@ -963,6 +974,13 @@ function initClassTable() {
this.orderPrice = toInteger(dbAssoc["item_type_order_price"]);
this.size = toInteger(dbAssoc["item_type_size"]);
this.capacity = toInteger(dbAssoc["item_type_capacity"]);
+ this.useDelay = toInteger(dbAssoc["item_type_delay_use"]);
+ this.switchDelay = toInteger(dbAssoc["item_type_delay_switch"]);
+ this.pickupDelay = toInteger(dbAssoc["item_type_delay_pickup"]);
+ this.putDelay = toInteger(dbAssoc["item_type_delay_put"]);
+ this.takeDelay = toInteger(dbAssoc["item_type_delay_take"]);
+ this.giveDelay = toInteger(dbAssoc["item_type_delay_give"]);
+ this.dropDelay = toInteger(dbAssoc["item_type_delay_drop"]);
}
}
}
@@ -984,6 +1002,3 @@ function getClass(className) {
}
// ---------------------------------------------------------------------------
-
-
-
diff --git a/scripts/server/client.js b/scripts/server/client.js
index 261f5b38..8fe74a22 100644
--- a/scripts/server/client.js
+++ b/scripts/server/client.js
@@ -1,74 +1,66 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: client.js
// DESC: Provides client communication and cross-endpoint operations
// TYPE: Server (JavaScript)
// ===========================================================================
-// ---------------------------------------------------------------------------
-
-addNetworkHandler("ag.promptAnswerNo", function(client) {
- if(!getEntityData(client, "ag.prompt")) {
- return false;
- }
-
- switch(getEntityData(client, "ag.prompt")) {
- case AG_PROMPT_CREATEFIRSTCHAR:
- triggerNetworkEvent("ag.showError", client, "You don't have a character to play. Goodbye!", "No Characters");
- setTimeout(function() { client.disconnect(); }, 5000);
- break;
-
- default:
- break;
- }
-
- client.removeData("ag.prompt");
-});
+function initClientScript() {
+ logToConsole(LOG_DEBUG, "[Asshat.Client]: Initializing client script ...");
+ addAllNetworkHandlers();
+ logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing client script ...");
+}
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.promptAnswerYes", function(client) {
- if(!getEntityData(client, "ag.prompt")) {
- return false;
- }
+function addAllNetworkHandlers() {
+ logToConsole(LOG_DEBUG, "[Asshat.Client]: Adding network handlers ...");
- switch(getEntityData(client, "ag.prompt")) {
- case AG_PROMPT_CREATEFIRSTCHAR:
- triggerNetworkEvent("ag.showNewCharacter", client);
- break;
+ // KeyBind
+ addNetworkHandler("ag.useKeyBind", playerUsedKeyBind);
- default:
- break;
- }
+ // GUI
+ addNetworkHandler("ag.promptAnswerNo", playerPromptAnswerNo);
+ addNetworkHandler("ag.promptAnswerYes", playerPromptAnswerYes);
- client.removeData("ag.prompt");
-});
+ // AFK
+ addNetworkHandler("ag.afk", playerChangeAFKState);
-// ---------------------------------------------------------------------------
+ // Event
+ addNetworkHandler("ag.enteredSphere", onPlayerEnteredSphere);
+ addNetworkHandler("ag.exitedSphere", onPlayerExitedSphere);
+ addNetworkHandler("ag.playerDeath", onPlayerDeath);
+ addNetworkHandler("ag.onPlayerEnterVehicle", onPlayerEnteredVehicle);
+ addNetworkHandler("ag.onPlayerExitVehicle", onPlayerExitedVehicle);
-addNetworkHandler("ag.onPlayerEnterSphere", function(client, sphere) {
- //let ownerType = getEntityData(sphere, "ag.ownerType");
- //let ownerId = getEntityData(sphere, "ag.ownerId");
-});
+ // Job
+ addNetworkHandler("ag.arrivedAtJobRouteStop", playerArrivedAtJobRouteStop);
-// ---------------------------------------------------------------------------
+ // Client
+ addNetworkHandler("ag.clientReady", playerClientReady);
+ addNetworkHandler("ag.guiReady", playerGUIReady);
+ addNetworkHandler("ag.clientStarted", playerClientStarted);
-addNetworkHandler("ag.afk", function(client, afkState) {
- if(afkState) {
- setEntityData(client, "ag.afk", true, true);
- } else {
- client.removeData("ag.afk");
- }
-});
+ // Account
+ addNetworkHandler("ag.checkLogin", checkLogin);
+ addNetworkHandler("ag.checkRegistration", checkRegistration);
-// ---------------------------------------------------------------------------
+ // Developer
+ addNetworkHandler("ag.runCodeSuccess", clientRunCodeSuccess);
+ addNetworkHandler("ag.runCodeFail", clientRunCodeFail);
-addNetworkHandler("ag.player.death", function(client, position) {
- processPlayerDeath(client, position);
-});
+ // SubAccount
+ addNetworkHandler("ag.checkNewCharacter", checkNewCharacter);
+ addNetworkHandler("ag.nextCharacter", checkNextCharacter);
+ addNetworkHandler("ag.previousCharacter", checkPreviousCharacter);
+ addNetworkHandler("ag.selectCharacter", selectCharacter);
+
+ // Item
+ addNetworkHandler("ag.itemActionDelayComplete", playerItemActionDelayComplete);
+}
// ---------------------------------------------------------------------------
@@ -93,37 +85,30 @@ function updatePlayerPing(client) {
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.arrivedAtBusStop", function(client) {
- logToConsole(LOG_DEBUG, client);
- arrivedAtBusStop(client);
-});
-
-// ---------------------------------------------------------------------------
-
-addNetworkHandler("ag.clientReady", function(client) {
+function playerClientReady(client) {
setEntityData(client, "ag.isReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(client.getData("ag.isStarted") == true) {
initClient(client);
}
-});
+}
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.guiReady", function(client) {
+function playerGUIReady(client) {
setEntityData(client, "ag.guiReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
-});
+}
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.clientStarted", function(client) {
+function playerClientStarted(client) {
setEntityData(client, "ag.isStarted", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(client.getData("ag.isReady") == true) {
initClient(client);
}
-});
+}
// ---------------------------------------------------------------------------
@@ -182,8 +167,8 @@ function restorePlayerCamera(client) {
// -------------------------------------------------------------------------
-function setPlayer2DRendering(client, hudState = false, labelState = false, smallGameMessageState = false, scoreboardState = false, hotBarState = false) {
- triggerNetworkEvent("ag.set2DRendering", client, hudState, labelState, smallGameMessageState, scoreboardState, hotBarState);
+function setPlayer2DRendering(client, hudState = false, labelState = false, smallGameMessageState = false, scoreboardState = false, hotBarState = false, itemActionDelayState = false) {
+ triggerNetworkEvent("ag.set2DRendering", client, hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState);
}
// ---------------------------------------------------------------------------
@@ -201,7 +186,7 @@ function updatePlayerSnowState(client) {
// ---------------------------------------------------------------------------
function sendExcludedModelsForGroundSnowToPlayer(client) {
- if(getGameConfig().excludedGroundSnowModels[getServerGame()]) {
+ if(getGameConfig().excludedGroundSnowModels[getServerGame()].length > 0) {
for(let i in getGameConfig().excludedGroundSnowModels[getServerGame()]) {
logToConsole(LOG_DEBUG, `[Asshat.Misc] Sending excluded model ${i} for ground snow to ${client.name}`);
triggerNetworkEvent("ag.excludeGroundSnow", client, getGameConfig().excludedGroundSnowModels[getServerGame()][i]);
@@ -251,4 +236,228 @@ function setPlayerWeaponDamageEnabled(client, state) {
function setPlayerWeaponDamageEvent(client, eventType) {
triggerNetworkEvent("ag.weaponDamageEvent", null, client.name, eventType);
-}
\ No newline at end of file
+}
+
+// ---------------------------------------------------------------------------
+
+function sendJobRouteStopToPlayer(client, position, colour) {
+ triggerNetworkEvent("ag.showJobRouteStop", client, position, colour);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerLoginSuccessGUI(client) {
+ triggerNetworkEvent("ag.loginSuccess", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerLoginFailedGUI(client, errorMessage) {
+ triggerNetworkEvent("ag.loginFailed", client, errorMessage);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerRegistrationSuccessGUI(client) {
+ triggerNetworkEvent("ag.registrationSuccess", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerRegistrationFailedGUI(client, errorMessage) {
+ triggerNetworkEvent("ag.registrationFailed", client, errorMessage);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerGUIColours(client) {
+ triggerNetworkEvent("ag.guiColour", client, getServerConfig().guiColour[0], getServerConfig().guiColour[1], getServerConfig().guiColour[2]);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerGUIInit(client) {
+ triggerNetworkEvent("ag.guiInit", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerLoginGUI(client, errorMessage = "") {
+ triggerNetworkEvent("ag.showLogin", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerRegistrationGUI(client, errorMessage = "") {
+ triggerNetworkEvent("ag.showRegistration", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerNewCharacterGUI(client) {
+ triggerNetworkEvent("ag.showNewCharacter", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerCharacterSelectGUI(client, firstName, lastName, placeOfOrigin, dateOfBirth, skin) {
+ triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, placeOfOrigin, dateOfBirth, skin);
+}
+
+// ---------------------------------------------------------------------------
+
+function updatePlayerCharacterSelectGUI(client, firstName, lastName, placeOfOrigin, dateOfBirth, skin) {
+ triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, placeOfOrigin, dateOfBirth, skin);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerCharacterSelectSuccessGUI(client) {
+ triggerNetworkEvent("ag.characterSelectSuccess", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerPromptGUI(client, promptMessage, promptTitle) {
+ triggerNetworkEvent("ag.showPrompt", client, promptMessage, promptTitle);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendRunCodeToClient(client, code, returnTo) {
+ triggerNetworkEvent("ag.runCode", client, code, returnTo);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerWorkingState(client, state) {
+ triggerNetworkEvent("ag.working", client, state);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerJobType(client, jobType) {
+ triggerNetworkEvent("ag.jobType", client, jobType);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerStopJobRoute(client) {
+ triggerNetworkEvent("ag.stopJobRoute", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerMouseCameraToggle(client) {
+ triggerNetworkEvent("ag.mouseCamera", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerMouseCursorToggle(client) {
+ triggerNetworkEvent("ag.mouseCursor", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendAddAccountKeyBindToClient(client, key, keyState) {
+ triggerNetworkEvent("ag.addKeyBind", client, toInteger(key), (keyState) ? KEYSTATE_DOWN : KEYSTATE_UP);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendRemoveAccountKeyBindToClient(client, key, keyState) {
+ triggerNetworkEvent("ag.delKeyBind", client, toInteger(key));
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerSetPosition(client, position) {
+ triggerNetworkEvent("ag.position", client, position);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerSetHeading(client, heading) {
+ triggerNetworkEvent("ag.heading", client, heading);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerSetInterior(client, interior) {
+ triggerNetworkEvent("ag.interior", client, interior);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerFrozenState(client, state) {
+ triggerNetworkEvent("ag.frozen", client, state);
+}
+
+// ---------------------------------------------------------------------------
+
+function givePlayerWeapon(client, weaponId, ammo, active) {
+ triggerNetworkEvent("ag.giveWeapon", client, weaponId, ammo, active);
+}
+
+// ---------------------------------------------------------------------------
+
+function clearPlayerWeapons(client) {
+ triggerNetworkEvent("ag.clearWeapons", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerNewCharacterFailedGUI(client, errorMessage) {
+ triggerNetworkEvent("ag.newCharacterFailed", client, errorMessage);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendPlayerRemoveFromVehicle(client) {
+ triggerNetworkEvent("ag.removeFromVehicle", client);
+}
+
+// ---------------------------------------------------------------------------
+
+function sendChatBoxMessageToPlayer(client, message, colour) {
+ triggerNetworkEvent("ag.m", client, message, colour)
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemTakeDelay(client, itemId) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(itemId).itemTypeIndex).takeDelay);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemUseDelay(client, itemSlot) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).useDelay);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemDropDelay(client, itemSlot) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).dropDelay);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemPickupDelay(client, itemId) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(itemId).itemTypeIndex).pickupDelay);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemPutDelay(client, itemSlot) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).putDelay);
+}
+
+// ---------------------------------------------------------------------------
+
+function showPlayerItemSwitchDelay(client, itemSlot) {
+ triggerNetworkEvent("ag.showItemActionDelay", client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[itemSlot]).itemTypeIndex).switchDelay);
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/colour.js b/scripts/server/colour.js
index 92a47ab0..9e1e1cc4 100644
--- a/scripts/server/colour.js
+++ b/scripts/server/colour.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: colour.js
// DESC: Provides colours, functions and usage
@@ -78,7 +78,7 @@ function getPlayerColour(client) {
return getColourByName("darkGrey");
} else {
if(isPlayerWorking(client)) {
- return getJobData(getPlayerCurrentSubAccount(client).job).colour;
+ return getJobData(getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client).job)).colour;
}
}
}
diff --git a/scripts/server/command.js b/scripts/server/command.js
index 7cbda6a7..55882467 100644
--- a/scripts/server/command.js
+++ b/scripts/server/command.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: command.js
// DESC: Provides command data, functions and usage
@@ -188,6 +188,11 @@ function loadCommands() {
commandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizfloor", listBusinessFloorInventoryCommand, "", getStaffFlagValue("none"), true, false),
+
+ commandData("power", toggleItemEnabledCommand, "", getStaffFlagValue("none"), true, false),
+ commandData("freq", setWalkieTalkieFrequencyCommand, "[frequncy number]", getStaffFlagValue("none"), true, false),
+ commandData("call", callWithPhoneCommand, "[number]", getStaffFlagValue("none"), true, false),
+ commandData("speakerphone", togglePhoneSpeakerCommand, "", getStaffFlagValue("none"), true, false),
],
job: [
commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false),
diff --git a/scripts/server/config.js b/scripts/server/config.js
index 85e70755..d142d5db 100644
--- a/scripts/server/config.js
+++ b/scripts/server/config.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: config.js
// DESC: Provides server configuration
@@ -36,7 +36,7 @@ let globalConfig = {
new serverClasses.keyBindData(false, toInteger(SDLK_m), "cursor"),
new serverClasses.keyBindData(false, toInteger(SDLK_o), "drop"),
new serverClasses.keyBindData(false, toInteger(SDLK_p), "pickup"),
- new serverClasses.keyBindData(false, toInteger(SDLK_e), "use"),
+ new serverClasses.keyBindData(false, toInteger(SDLK_u), "use"),
new serverClasses.keyBindData(false, toInteger(SDLK_i), "inv"),
new serverClasses.keyBindData(false, toInteger(SDLK_0), "i 0"),
new serverClasses.keyBindData(false, toInteger(SDLK_1), "i 1"),
@@ -55,6 +55,10 @@ let globalConfig = {
houseDimensionStart: 100,
buyVehicleDriveAwayDistance: 25.0,
returnToJobVehicleTime: 30,
+ walkieTalkieSpeakerDistance: 15,
+ walkieTalkieTalkDistance: 15,
+ phoneSpeakerDistance: 15,
+ phoneTalkDistance: 15,
};
let gameConfig = {
@@ -605,7 +609,7 @@ function setSnowingCommand(command, params, client) {
getServerConfig().fallingSnow = fallingSnow;
getServerConfig().groundSnow = groundSnow;
- triggerNetworkEvent("ag.snow", null, fallingSnow, groundSnow);
+ updatePlayerSnowState(null);
messageAdminAction(`${client.name} turned falling snow ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} [#FFFFFF]and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
updateServerRules();
@@ -629,7 +633,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().useLogo = !getServerConfig().useLogo;
- triggerNetworkEvent("ag.logo", null, intToBool(getServerConfig().useLogo));
+ updatePlayerShowLogoState(null, getServerConfig().useLogo);
messageAdminAction(`${client.name} turned the server logo image ${getBoolRedGreenInlineColour(getServerConfig().useLogo)}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
diff --git a/scripts/server/const.js b/scripts/server/const.js
index 98c73c94..9b1fe411 100644
--- a/scripts/server/const.js
+++ b/scripts/server/const.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: const.js
// DESC: Provides constants
@@ -180,11 +180,16 @@ const AG_ITEM_USETYPE_WINE = 21; // Moderate drunk effect. Replen
const AG_ITEM_USETYPE_LIQUOR = 22; // Heavy drunk effect. Replenishes large amount of health.
const AG_ITEM_USETYPE_COFFEE = 23; // Replenishes moderate amount of health.
const AG_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine.
-const AG_ITEM_USETYPE_HANDCUFF = 24;
-const AG_ITEM_USETYPE_ROPE = 25;
-const AG_ITEM_USETYPE_BLINDFOLD = 26;
-const AG_ITEM_USETYPE_TAZER = 27;
-const AG_ITEM_USETYPE_ARMOUR = 28;
+const AG_ITEM_USETYPE_HANDCUFF = 24; //
+const AG_ITEM_USETYPE_ROPE = 25; //
+const AG_ITEM_USETYPE_BLINDFOLD = 26; //
+const AG_ITEM_USETYPE_TAZER = 27; //
+const AG_ITEM_USETYPE_ARMOUR = 28; //
+const AG_ITEM_USETYPE_HEALTH = 29; //
+const AG_ITEM_USETYPE_AED = 30; //
+const AG_ITEM_USETYPE_WALKIETALKIE = 31; //
+const AG_ITEM_USETYPE_BOOMBOX = 32; //
+const AG_ITEM_USETYPE_EARBUDS = 33; //
// Item Drop Types
const AG_ITEM_DROPTYPE_NONE = 0; // Can't be dropped
@@ -234,4 +239,13 @@ const AG_TUTORIAL_STATE_USEITEM = 5;
const AG_TUTORIAL_STATE_PUTITEM = 6;
const AG_TUTORIAL_STATE_TAKEITEM = 7;
const AG_TUTORIAL_STATE_EXITBIZ = 9;
-const AG_TUTORIAL_STATE_DROPITEM = 10;
\ No newline at end of file
+const AG_TUTORIAL_STATE_DROPITEM = 10;
+
+// Item Occupied States
+const AG_ITEM_ACTION_NONE = 0;
+const AG_ITEM_ACTION_USE = 1;
+const AG_ITEM_ACTION_PICKUP = 2;
+const AG_ITEM_ACTION_DROP = 3;
+const AG_ITEM_ACTION_SWITCH = 4;
+const AG_ITEM_ACTION_PUT = 5;
+const AG_ITEM_ACTION_TAKE = 6;
\ No newline at end of file
diff --git a/scripts/server/core.js b/scripts/server/core.js
index 0df14e81..ecd81a92 100644
--- a/scripts/server/core.js
+++ b/scripts/server/core.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: core.js
// DESC: Provides core data structures, function, and operations
diff --git a/scripts/server/database.js b/scripts/server/database.js
index ad8a77f0..b4d162a4 100644
--- a/scripts/server/database.js
+++ b/scripts/server/database.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: database.js
// DESC: Provides database handling, functions and usage
diff --git a/scripts/server/developer.js b/scripts/server/developer.js
index 35e1a5fc..25bb5a7d 100644
--- a/scripts/server/developer.js
+++ b/scripts/server/developer.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage
@@ -223,7 +223,7 @@ function executeClientCodeCommand(command, params, client) {
return false;
}
- triggerNetworkEvent("ag.runCode", targetClient, targetCode, client.index);
+ sendRunCodeToClient(client, targetClient, targetCode, client.index);
messagePlayerSuccess(client, "Executing client code for " + toString(targetClient.name) + "!");
messagePlayerNormal(client, "Code: " + targetCode);
@@ -242,7 +242,7 @@ function saveAllServerDataCommand(command, params, client) {
// ---------------------------------------------------------------------------
function restartGameModeCommand(command, params, client) {
- message(`[#FF9900]The server game mode is restarting!`, getColourByName("orange"));
+ messagePlayerNormal(null, `[#FF9900]The server game mode is restarting!`, getColourByName("orange"));
consoleCommand("refresh");
thisResource.restart();
return true;
@@ -250,7 +250,7 @@ function restartGameModeCommand(command, params, client) {
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.runCodeFail", function(client, returnTo, code) {
+function clientRunCodeFail(client, returnTo, code) {
let returnClient = getClients()[returnTo];
if(!returnClient) {
return false;
@@ -258,11 +258,11 @@ addNetworkHandler("ag.runCodeFail", function(client, returnTo, code) {
messagePlayerError(returnClient, `Client code failed to execute for ${client.name}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
-});
+}
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.runCodeSuccess", function(client, returnTo, returnVal, code) {
+function clientRunCodeSuccess(client, returnTo, returnVal, code) {
let returnClient = getClients()[returnTo];
if(!returnClient) {
return false;
@@ -271,7 +271,7 @@ addNetworkHandler("ag.runCodeSuccess", function(client, returnTo, returnVal, cod
messagePlayerSuccess(returnClient, `Client code executed for ${client.name}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
messagePlayerNormal(returnClient, `Returns: ${returnVal}`, getColourByName("yellow"));
-});
+}
// ---------------------------------------------------------------------------
diff --git a/scripts/server/discord.js b/scripts/server/discord.js
index 06abf977..a64ca5f6 100644
--- a/scripts/server/discord.js
+++ b/scripts/server/discord.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage
@@ -57,6 +57,10 @@ function sendDiscordSocketData(socketData) {
// ---------------------------------------------------------------------------
function isClientFromDiscord(client) {
+ if(client == null) {
+ return false;
+ }
+
if(client instanceof Client) {
return false;
} else {
diff --git a/scripts/server/event.js b/scripts/server/event.js
index d0f7be59..c19b75a5 100644
--- a/scripts/server/event.js
+++ b/scripts/server/event.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -11,49 +11,67 @@
// ---------------------------------------------------------------------------
function initEventScript() {
- logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
- addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle);
- addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle);
+ logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
+ addAllEventHandlers();
logToConsole(LOG_DEBUG, "[Asshat.Event]: Event script initialized!");
}
// ---------------------------------------------------------------------------
-addEventHandler("OnPlayerConnect", function(event, ipAddress, port) {
+function addAllEventHandlers() {
+ addEventHandler("onResourceStart", onResourceStart);
+ addEventHandler("onResourceStop", onResourceStop);
+
+ addEventHandler("onProcess", onProcess);
+
+ addEventHandler("onPlayerConnect", onPlayerConnect);
+ addEventHandler("onPlayerJoin", onPlayerJoin);
+ addEventHandler("onPlayerJoined", onPlayerJoined);
+ addEventHandler("onPlayerChat", onPlayerChat);
+ addEventHandler("onPlayerQuit", onPlayerQuit);
+
+ addEventHandler("onPedSpawn", onPedSpawn);
+ addEventHandler("onPedEnterVehicle", onPedEnteringVehicle);
+ //addEventHandler("onPedExitingVehicle", onPedExitingVehicle);
+}
+
+// ---------------------------------------------------------------------------
+
+function onPlayerConnect(event, ipAddress, port) {
logToConsole(LOG_DEBUG, `[Asshat.Event] Client connecting (IP: ${ipAddress})`);
if(isIpAddressBanned(ipAddress)) {
messagePlayerError(client, "You are banned from this server!");
return false;
}
-});
+}
// ---------------------------------------------------------------------------
-addEventHandler("OnPlayerJoin", function(event, client) {
+function onPlayerJoin(event, client) {
fadeCamera(client, true, 1.0);
-});
+}
// ---------------------------------------------------------------------------
-addEventHandler("OnPlayerJoined", function(event, client) {
- //message(`👋 ${client.name} has joined the server`, getColourByName("softYellow"));
-});
+function onPlayerJoined(event, client) {
+
+}
// ---------------------------------------------------------------------------
-addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) {
+function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
//savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;
- message(`👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
-});
+ messagePlayerNormal(null, `👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]})`, getColourByName("softYellow"));
+}
// ---------------------------------------------------------------------------
-addEventHandler("onPlayerChat", function(event, client, messageText) {
+function onPlayerChat(event, client, messageText) {
event.preventDefault();
if(!getPlayerData(client).loggedIn) {
messagePlayerError(client, "You need to login before you can chat!");
@@ -62,65 +80,18 @@ addEventHandler("onPlayerChat", function(event, client, messageText) {
messageText = messageText.substring(0, 128);
- message(`${getCharacterFullName(client)}: [#FFFFFF]${messageText}`, getPlayerColour(client));
-});
+ messagePlayerNormal(null, `${getCharacterFullName(client)}: [#FFFFFF]${messageText}`, getPlayerColour(client));
+}
// ---------------------------------------------------------------------------
-addEventHandler("OnPedExitVehicle", function(event, ped, vehicle) {
- //if(!vehicle || vehicle.owner != -1) {
- // return false;
- //}
-
- //if(!getVehicleData(vehicle)) {
- // return false;
- //}
-});
+function onProcess(event, deltaTime) {
+ checkVehicleBuying();
+}
// ---------------------------------------------------------------------------
-addEventHandler("OnProcess", function(event, deltaTime) {
- let clients = getClients();
- for(let i in clients) {
- if(getPlayerData(clients[i])) {
- if(getPlayerData(clients[i]).buyingVehicle) {
- if(getPlayerVehicle(clients[i]) == getPlayerData(clients[i]).buyingVehicle) {
- if(getDistance(getVehiclePosition(getPlayerData(clients[i]).buyingVehicle), getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
- if(getPlayerCurrentSubAccount(clients[i]).cash < getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice) {
- messagePlayerError(client, "You don't have enough money to buy this vehicle!");
- respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
- getPlayerData(clients[i]).buyingVehicle = false;
- return false;
- }
-
- createNewDealershipVehicle(getVehicleData(getPlayerData(clients[i]).buyingVehicle).model, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice, getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId);
- getPlayerCurrentSubAccount(clients[i]).cash -= getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice;
- updatePlayerCash(clients[i]);
- getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId = getPlayerCurrentSubAccount(clients[i]).databaseId;
- getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerType = AG_VEHOWNER_PLAYER;
- getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice = 0;
- getVehicleData(getPlayerData(clients[i]).buyingVehicle).rentPrice = 0;
- getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnLocked = false;
- getPlayerData(clients[i]).buyingVehicle = false;
- messagePlayerSuccess(clients[i], "This vehicle is now yours! It will save wherever you leave it.");
- }
- } else {
- messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!");
- respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
- getPlayerData(clients[i]).buyingVehicle = false;
- }
- }
- }
- }
-});
-
-// ---------------------------------------------------------------------------
-
-addEventHandler("OnPedEnterVehicle", function(event, ped, vehicle, seat) {
- //if(!vehicle || vehicle.owner != -1) {
- // return false;
- //}
-
+function onPedEnteringVehicle(event, ped, vehicle, seat) {
if(!getVehicleData(vehicle)) {
return false;
}
@@ -143,11 +114,47 @@ addEventHandler("OnPedEnterVehicle", function(event, ped, vehicle, seat) {
}
}
}
-});
+}
// ---------------------------------------------------------------------------
-async function playerEnteredVehicle(client) {
+function onResourceStart(event, resource) {
+ logToConsole(LOG_WARN, `[Asshat.Event] ${resource.name} started!`);
+
+ if(resource != thisResource) {
+ messageAdmins(`[#FFFFFF]Resource [#AAAAAA]${resource.name} [#FFFFFF]started!`);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function onResourceStop(event, resource) {
+ logToConsole(LOG_WARN, `[Asshat.Event] ${resource.name} stopped!`);
+
+ if(resource != thisResource) {
+ messageAdmins(`[#FFFFFF]Resource [#AAAAAA]${resource.name} [#FFFFFF]stopped!`);
+ }
+
+ if(resource == thisResource) {
+ //saveAllServerDataToDatabase();
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function onPlayerEnteredSphere(client, sphere) {
+
+}
+
+// ---------------------------------------------------------------------------
+
+function onPlayerExitedSphere(client, sphere) {
+
+}
+
+// ---------------------------------------------------------------------------
+
+async function onPlayerEnteredVehicle(client) {
if(client.player == null) {
return false;
}
@@ -208,7 +215,7 @@ async function playerEnteredVehicle(client) {
// ---------------------------------------------------------------------------
-function playerExitedVehicle(client) {
+function onPlayerExitedVehicle(client) {
let vehicle = getPlayerData(client).lastVehicle;
if(!getVehicleData(vehicle)) {
@@ -228,7 +235,7 @@ function playerExitedVehicle(client) {
// ---------------------------------------------------------------------------
-function processPlayerDeath(client, position) {
+function onPlayerDeath(client, position) {
updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false);
setTimeout(function() {
@@ -252,17 +259,17 @@ function processPlayerDeath(client, position) {
// ---------------------------------------------------------------------------
-function processPedSpawn(ped) {
+function onPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) {
- setTimeout(processPlayerSpawn, 500, ped);
+ setTimeout(onPlayerSpawn, 500, ped);
}
}
// ---------------------------------------------------------------------------
-function processPlayerSpawn(ped) {
+function onPlayerSpawn(ped) {
if(getClientFromPlayerElement(ped) == null) {
- setTimeout(processPlayerSpawn, 500, ped);
+ setTimeout(onPlayerSpawn, 500, ped);
return false;
}
@@ -289,7 +296,7 @@ function processPlayerSpawn(ped) {
getPlayerData(client).switchingCharacter = false;
updatePlayerCash(client);
updatePlayerJobType(client);
- setPlayer2DRendering(client, true, true, true, true, true);
+ setPlayer2DRendering(client, true, true, true, true, true, true);
updatePlayerSnowState(client);
updatePlayerHotBar(client);
@@ -305,34 +312,4 @@ function processPlayerSpawn(ped) {
}
}
-// ---------------------------------------------------------------------------
-
-addEventHandler("OnPedSpawn", function(event, ped) {
- processPedSpawn(ped);
-});
-
-// ---------------------------------------------------------------------------
-
-addEventHandler("OnResourceStart", function(event, resource) {
- console.warn(`[Asshat.Event] ${resource.name} started!`);
-
- if(resource != thisResource) {
- messageAdmins(`[#FFFFFF]Resource [#AAAAAA]${resource.name} [#FFFFFF]started!`);
- }
-});
-
-// ---------------------------------------------------------------------------
-
-addEventHandler("OnResourceStop", function(event, resource) {
- console.warn(`[Asshat.Event] ${resource.name} stopped!`);
-
- if(resource != thisResource) {
- messageAdmins(`[#FFFFFF]Resource [#AAAAAA]${resource.name} [#FFFFFF]stopped!`);
- }
-
- if(resource == thisResource) {
- //saveAllServerDataToDatabase();
- }
-});
-
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/fishing.js b/scripts/server/fishing.js
index d0ceaf5f..f69e86c8 100644
--- a/scripts/server/fishing.js
+++ b/scripts/server/fishing.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: fishing.js
// DESC: Provides fishing functions and commands
diff --git a/scripts/server/gui.js b/scripts/server/gui.js
index 4c2e1665..fab862fb 100644
--- a/scripts/server/gui.js
+++ b/scripts/server/gui.js
@@ -1,41 +1,13 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: gui.js
// DESC: Provides GUI functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
-function showPlayerLoginGUI(client, errorMessage = "") {
- triggerNetworkEvent("ag.showLogin", client);
-}
-
-// ---------------------------------------------------------------------------
-
-function showPlayerRegistrationGUI(client, errorMessage = "") {
- triggerNetworkEvent("ag.showRegistration", client);
-}
-
-// ---------------------------------------------------------------------------
-
-function showPlayerNewCharacterGUI(client) {
- triggerNetworkEvent("ag.showNewCharacter", client);
-}
-
-// ---------------------------------------------------------------------------
-
-function showPlayerCharacterSelectGUI(client, firstName, lastName, placeOfOrigin, dateOfBirth, skin) {
- triggerNetworkEvent("ag.showCharacterSelect", client, firstName, lastName, placeOfOrigin, dateOfBirth, skin);
-}
-
-// ---------------------------------------------------------------------------
-
-function showPlayerPromptGUI(client, promptMessage, promptTitle) {
- triggerNetworkEvent("ag.showPrompt", client, promptMessage, promptTitle);
-}
-
// ---------------------------------------------------------------------------
function showPlayerPromptGUI(client) {
@@ -54,4 +26,43 @@ function showPlayerItemInventoryGUI(client) {
}
+// ---------------------------------------------------------------------------
+
+function playerPromptAnswerNo(client) {
+ if(!getEntityData(client, "ag.prompt")) {
+ return false;
+ }
+
+ switch(getEntityData(client, "ag.prompt")) {
+ case AG_PROMPT_CREATEFIRSTCHAR:
+ showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters")
+ setTimeout(function() { client.disconnect(); }, 5000);
+ break;
+
+ default:
+ break;
+ }
+
+ client.removeData("ag.prompt");
+}
+
+// ---------------------------------------------------------------------------
+
+function playerPromptAnswerYes(client) {
+ if(!getEntityData(client, "ag.prompt")) {
+ return false;
+ }
+
+ switch(getEntityData(client, "ag.prompt")) {
+ case AG_PROMPT_CREATEFIRSTCHAR:
+ showPlayerNewCharacterGUI(client);
+ break;
+
+ default:
+ break;
+ }
+
+ client.removeData("ag.prompt");
+}
+
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/help.js b/scripts/server/help.js
index 120af72a..b5e86c69 100644
--- a/scripts/server/help.js
+++ b/scripts/server/help.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: help.js
// DESC: Provides update info, help commands, and documentation
diff --git a/scripts/server/house.js b/scripts/server/house.js
index 108cb419..3bb33969 100644
--- a/scripts/server/house.js
+++ b/scripts/server/house.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: house.js
// DESC: Provides house commands, functions, and usage
diff --git a/scripts/server/item.js b/scripts/server/item.js
index c138c4fb..9e275695 100644
--- a/scripts/server/item.js
+++ b/scripts/server/item.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: item.js
// DESC: Provides item functions and usage
@@ -104,6 +104,7 @@ function createGroundItemObject(itemId) {
getItemData(itemId).object = gta.createObject(getItemTypeData(getItemData(itemId).itemTypeIndex).dropModel, applyOffsetToVector3(getItemData(itemId).position, getItemTypeData(getItemData(itemId).itemTypeIndex).dropPosition));
getItemData(itemId).object.setRotation(getItemTypeData(getItemData(itemId).itemTypeIndex).dropRotation);
getItemData(itemId).object.dimension = getItemData(itemId).dimension;
+ setEntityData(getItemData(itemId).object, "ag.scale", getItemTypeData(getItemData(itemId).itemTypeIndex).dropScale, true);
addToWorld(getItemData(itemId).object);
getServerData().groundItemCache.push(itemId);
@@ -146,7 +147,19 @@ function createGroundItemCommand(command, params, client) {
// ---------------------------------------------------------------------------
function useItemCommand(command, params, client) {
- let hotBarSlot = toInteger(params) || getPlayerData(client).activeHotBarSlot;
+ let hotBarSlot = getPlayerData(client).activeHotBarSlot;
+ if(!areParamsEmpty(params)) {
+ hotBarSlot = toInteger(params);
+ hotBarSlot = hotBarSlot-1;
+ }
+
+ if(hotBarSlot == -1) {
+ return false;
+ }
+
+ if(getPlayerData(client).hotBarItems[hotBarSlot] == -1) {
+ return false;
+ }
let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
@@ -162,10 +175,17 @@ function useItemCommand(command, params, client) {
return false;
}
- playerUseItem(client, itemId);
+ if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_NONE || getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) {
+ return false;
+ }
- getPlayerData(client).hotBarItems[hotBarSlot] = -1;
- updatePlayerHotBar(client);
+ if(getPlayerData(client).itemOccupiedDelay) {
+ return false;
+ }
+
+ getPlayerData(client).itemActionItem = hotBarSlot;
+ getPlayerData(client).itemOccupiedDelay = true;
+ showPlayerItemUseDelay(client, hotBarSlot);
}
// ---------------------------------------------------------------------------
@@ -218,9 +238,13 @@ function pickupItemCommand(command, params, client) {
return false;
}
- meActionToNearbyPlayers(client, `picks up ${getProperDeterminerForName(getItemTypeData(getItemData(itemId).itemTypeIndex).name)} ${getItemTypeData(getItemData(itemId).itemTypeIndex).name} from the ground`);
+ if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
+ return false;
+ }
- playerPickupItem(client, itemId);
+ getPlayerData(client).itemActionItem = itemId;
+ getPlayerData(client).itemOccupiedDelay = true;
+ showPlayerItemPickupDelay(client, itemId);
}
// ---------------------------------------------------------------------------
@@ -251,18 +275,19 @@ function dropItemCommand(command, params, client) {
return false;
}
- playerDropItem(client, itemId);
+ if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
+ return false;
+ }
- meActionToNearbyPlayers(client, `drops ${getProperDeterminerForName(getItemTypeData(getItemData(itemId).itemTypeIndex).name)} ${getItemTypeData(getItemData(itemId).itemTypeIndex).name} on the ground`);
-
- getPlayerData(client).hotBarItems[hotBarSlot] = -1;
- updatePlayerHotBar(client);
+ getPlayerData(client).itemActionItem = hotBarSlot;
+ getPlayerData(client).itemActionState = AG_ITEM_ACTION_DROP;
+ showPlayerItemDropDelay(client, itemId);
}
// ---------------------------------------------------------------------------
function putItemCommand(command, params, client) {
- let hotBarSlot = toInteger(params) || getPlayerData(client).activeHotBarSlot;
+ let hotBarSlot = toInteger(params);
let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
@@ -278,32 +303,13 @@ function putItemCommand(command, params, client) {
return false;
}
- let bestNewOwner = getBestNewOwnerToPutItem(client);
-
- let itemName = getItemTypeData(getItemData(itemId).itemTypeIndex).name;
-
- switch(bestNewOwner[0]) {
- case AG_ITEM_OWNER_HOUSE:
- meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the house`);
- break;
-
- case AG_ITEM_OWNER_BIZFLOOR:
- meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} for sale in the business`);
- break;
-
- case AG_ITEM_OWNER_BIZSTORAGE:
- meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the business storage room`);
- break;
-
- case AG_ITEM_OWNER_VEHTRUNK:
- meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the ${getVehicleName(bestNewOwner[1])}'s trunk`);
- break;
+ if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
+ return false;
}
- playerPutItem(client, itemId, bestNewOwner[0], bestNewOwner[1]);
-
- getPlayerData(client).hotBarItems[hotBarSlot] = -1;
- updatePlayerHotBar(client);
+ getPlayerData(client).itemActionItem = hotBarSlot;
+ getPlayerData(client).itemActionState = AG_ITEM_ACTION_PUT;
+ showPlayerItemPutDelay(client, hotBarSlot);
}
// ---------------------------------------------------------------------------
@@ -325,48 +331,20 @@ function takeItemCommand(command, params, client) {
return false;
}
- if(!getItemData(itemId)) {
- messagePlayerError(client, `The item you're trying to take is bugged. A bug report has been sent to the server developers.`);
- submitBugReport(client, `(AUTOMATED REPORT) Put Item: Getting item data for item ${itemId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
+ if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
return false;
}
- if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) {
- messagePlayerError(client, `The item you're trying to take is bugged. A bug report has been sent to the server developers.`);
- submitBugReport(client, `(AUTOMATED REPORT) Put Item: Getting item type ${getItemData(itemId).itemType} data for item ${itemId}/${getItemData(itemId).databaseId} in player hotbar slot ${hotBarSlot} (cache ${getPlayerData(client).hotBarItems[hotBarSlot]}) returned false.`);
- return false;
- }
-
- let itemName = getItemTypeData(getItemData(itemId).itemTypeIndex).name;
-
- switch(bestOwner[1]) {
- case AG_ITEM_OWNER_HOUSE:
- meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the house`);
- break;
-
- case AG_ITEM_OWNER_BIZFLOOR:
- meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the business`);
- break;
-
- case AG_ITEM_OWNER_BIZSTORAGE:
- meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the business storage room`);
- break;
-
- case AG_ITEM_OWNER_VEHTRUNK:
- meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the ${getVehicleName(bestOwner[1])}'s trunk`);
- break;
- }
-
- playerTakeItem(client, itemId);
-
- getPlayerData(client).hotBarItems[hotBarSlot] = -1;
- updatePlayerHotBar(client);
+ getPlayerData(client).itemActionItem = itemId;
+ getPlayerData(client).itemActionState = AG_ITEM_ACTION_TAKE;
+ showPlayerItemTakeDelay(client, itemId);
}
// ---------------------------------------------------------------------------
function playerUseItem(client, itemIndex) {
let closestPlayer;
+ let tempUseValue;
switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) {
case AG_ITEM_USETYPE_SKIN:
@@ -378,10 +356,7 @@ function playerUseItem(client, itemIndex) {
break;
case AG_ITEM_USETYPE_WEAPON:
- //let weaponId = getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId;
- //let ammo = getItemData(itemIndex).useValue;
- //givePlayerWeapon(client, weaponId, ammo);
- //meActionToNearbyPlayers(client, `changes their clothes to ${getItemData(itemIndex).name}`);
+ messagePlayerError(client, `The ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name} is a weapon. To use it, switch to it from your items. The use key has no effect.`);
break;
case AG_ITEM_USETYPE_PHONE:
@@ -393,7 +368,7 @@ function playerUseItem(client, itemIndex) {
break;
case AG_ITEM_USETYPE_FOOD:
- tempUseValue = (getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId-getItemData(itemIndex).value > 0) ? getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId : getItemData(itemIndex).value;
+ tempUseValue = (getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue-getItemData(itemIndex).value > 0) ? getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue : getItemData(itemIndex).value;
givePlayerHealth(client, tempUseValue);
if(getItemData(itemIndex).value-tempUseValue <= 0) {
getPlayerData(client).hotBarItems[getPlayerData(client).hotBarItems.indexOf(itemIndex)] = -1;
@@ -401,11 +376,11 @@ function playerUseItem(client, itemIndex) {
} else {
getItemData(itemIndex).value = getItemData(itemIndex).value-tempUseValue;
}
- meActionToNearbyPlayers(client, `takes a bite of their ${getItemData(itemIndex).name}`);
+ meActionToNearbyPlayers(client, `takes a bite of their ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}`);
break;
case AG_ITEM_USETYPE_DRINK:
- tempUseValue = (getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId-getItemData(itemIndex).value > 0) ? getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId : getItemData(itemIndex).value;
+ tempUseValue = (getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue-getItemData(itemIndex).value > 0) ? getItemTypeData(getItemData(itemIndex).itemTypeIndex).useValue : getItemData(itemIndex).value;
givePlayerHealth(client, tempUseValue);
getItemData(itemIndex).value = getItemData(itemIndex).value - tempUseValue;
if(getItemData(itemIndex).value-tempUseValue <= 0) {
@@ -413,7 +388,7 @@ function playerUseItem(client, itemIndex) {
deleteItem(itemIndex);
} else {
getItemData(itemIndex).value = getItemData(itemIndex).value-tempUseValue;
- meActionToNearbyPlayers(client, `takes a drink of their ${getItemData(itemIndex).name}`);
+ meActionToNearbyPlayers(client, `takes a drink of their ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name}`);
}
break;
@@ -444,111 +419,220 @@ function playerUseItem(client, itemIndex) {
return false;
}
break;
+
+ case AG_ITEM_USETYPE_NONE:
+ messagePlayerError(client, `The ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name} doesn't do anything when you try to use it.`);
+ break;
+
+ case AG_ITEM_USETYPE_WALKIETALKIE:
+ getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled;
+ messagePlayerAlert(client, `You turned ${toUpperCase(getBoolRedGreenInlineColour(getOnOffFromBool(getItemData(itemIndex).enabled)))} your walkie talkie in slot ${getPlayerData(client).activeHotBarSlot+1} (${getItemValueDisplay(itemIndex)})`);
+ break;
+
+ case AG_ITEM_USETYPE_PHONE:
+ getItemData(itemIndex).enabled = !getItemData(itemIndex).enabled;
+ if(getItemData(itemIndex).enabled) {
+ messagePlayerAlert(client, `You turned on your phone in slot ${getPlayerData(client).activeHotBarSlot+1} (${getItemValueDisplay(itemIndex)})`);
+ } else {
+ messagePlayerAlert(client, `You turned OFF your phone in slot ${getPlayerData(client).activeHotBarSlot+1}`);
+ }
+ break;
+
+ default:
+ messagePlayerError(client, `The ${getItemTypeData(getItemData(itemIndex).itemTypeIndex).name} doesn't do anything when you try to use it.`);
+ break;
}
+
getItemData(itemIndex).needsSaved = true;
updatePlayerHotBar(client);
}
// ---------------------------------------------------------------------------
-function playerDropItem(client, itemIndex) {
- getItemData(itemIndex).ownerType = AG_ITEM_OWNER_GROUND;
- getItemData(itemIndex).ownerId = 0;
- getItemData(itemIndex).position = getPlayerPosition(client);
- getItemData(itemIndex).dimension = getPlayerDimension(client);
- createGroundItemObject(itemIndex);
- getItemData(itemIndex).needsSaved = true;
+function playerDropItem(client, hotBarSlot) {
+ let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
+ if(itemId != -1) {
+ meActionToNearbyPlayers(client, `drops ${getProperDeterminerForName(getItemTypeData(getItemData(itemId).itemTypeIndex).name)} ${getItemTypeData(getItemData(itemId).itemTypeIndex).name} on the ground`);
+
+ getPlayerData(client).hotBarItems[hotBarSlot] = -1;
+ updatePlayerHotBar(client);
+
+ getItemData(itemId).ownerType = AG_ITEM_OWNER_GROUND;
+ getItemData(itemId).ownerId = 0;
+ getItemData(itemId).position = getPlayerPosition(client);
+ getItemData(itemId).dimension = getPlayerDimension(client);
+ createGroundItemObject(itemId);
+ getItemData(itemId).needsSaved = true;
+ }
}
// ---------------------------------------------------------------------------
-function playerPutItem(client, itemIndex, ownerType, ownerId) {
- getItemData(itemIndex).ownerType = ownerType;
- getItemData(itemIndex).ownerId = ownerId;
- getItemData(itemIndex).position = toVector(0.0, 0.0, 0.0);
- getItemData(itemIndex).dimension = 0;
- getItemData(itemIndex).needsSaved = true;
+function playerPutItem(client, hotBarSlot) {
+ let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
+
+ let bestNewOwner = getBestNewOwnerToPutItem(client);
+
+ let itemName = getItemTypeData(getItemData(itemId).itemTypeIndex).name;
+
+ switch(bestNewOwner[0]) {
+ case AG_ITEM_OWNER_HOUSE:
+ meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the house`);
+ break;
+
+ case AG_ITEM_OWNER_BIZFLOOR:
+ meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} for sale in the business`);
+ break;
+
+ case AG_ITEM_OWNER_BIZSTORAGE:
+ meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the business storage room`);
+ break;
+
+ case AG_ITEM_OWNER_VEHTRUNK:
+ meActionToNearbyPlayers(client, `places ${getProperDeterminerForName(itemName)} ${itemName} in the ${getVehicleName(bestNewOwner[1])}'s trunk`);
+ break;
+ }
+
+ getItemData(itemId).ownerType = ownerType;
+ getItemData(itemId).ownerId = ownerId;
+ getItemData(itemId).position = toVector(0.0, 0.0, 0.0);
+ getItemData(itemId).dimension = 0;
+ getItemData(itemId).needsSaved = true;
+
+ getPlayerData(client).hotBarItems[hotBarSlot] = -1;
+ updatePlayerHotBar(client);
}
// ---------------------------------------------------------------------------
-function playerPickupItem(client, itemIndex) {
+function playerPickupItem(client, itemId) {
+ meActionToNearbyPlayers(client, `picks up ${getProperDeterminerForName(getItemTypeData(getItemData(itemId).itemTypeIndex).name)} ${getItemTypeData(getItemData(itemId).itemTypeIndex).name} from the ground`);
+
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
if(firstSlot != -1) {
- getItemData(itemIndex).ownerType = AG_ITEM_OWNER_PLAYER;
- getItemData(itemIndex).ownerId = getPlayerCurrentSubAccount(client).databaseId;
- getItemData(itemIndex).position = toVector3(0.0, 0.0, 0.0);
- getItemData(itemIndex).dimension = 0;
+ getItemData(itemId).ownerType = AG_ITEM_OWNER_PLAYER;
+ getItemData(itemId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
+ getItemData(itemId).position = toVector3(0.0, 0.0, 0.0);
+ getItemData(itemId).dimension = 0;
deleteGroundItemObject(itemIndex);
- getPlayerData(client).hotBarItems[firstSlot] = itemIndex;
+ getPlayerData(client).hotBarItems[firstSlot] = itemId;
updatePlayerHotBar(client);
}
}
// ---------------------------------------------------------------------------
-function playerTakeItem(client, itemIndex) {
+function playerTakeItem(client, itemId) {
+ let itemName = getItemTypeData(getItemData(itemId).itemTypeIndex).name;
+
+ switch(bestOwner[1]) {
+ case AG_ITEM_OWNER_HOUSE:
+ meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the house`);
+ break;
+
+ case AG_ITEM_OWNER_BIZFLOOR:
+ meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the business`);
+ break;
+
+ case AG_ITEM_OWNER_BIZSTORAGE:
+ meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the business storage room`);
+ break;
+
+ case AG_ITEM_OWNER_VEHTRUNK:
+ meActionToNearbyPlayers(client, `takes ${getProperDeterminerForName(itemName)} ${itemName} from the trunk`);
+ break;
+ }
+
let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
if(firstSlot != -1) {
- getItemData(itemIndex).ownerType = AG_ITEM_OWNER_PLAYER;
- getItemData(itemIndex).ownerId = getPlayerCurrentSubAccount(client).databaseId;
+ getItemData(itemId).ownerType = AG_ITEM_OWNER_PLAYER;
+ getItemData(itemId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
- getPlayerData(client).hotBarItems[firstSlot] = itemIndex;
+ getPlayerData(client).hotBarItems[firstSlot] = itemId;
updatePlayerHotBar(client);
}
}
// ---------------------------------------------------------------------------
+function playerSwitchItem(client, hotBarSlot) {
+ let currentHotBarSlot = getPlayerData(client).activeHotBarSlot;
+ logToConsole(LOG_DEBUG, `[Asshat.Item] ${getPlayerDisplayForConsole(client)} switched from hotbar slot ${currentHotBarSlot} to ${hotBarSlot}`);
+
+ if(currentHotBarSlot != -1 && getPlayerData(client).hotBarItems[currentHotBarSlot] != -1 && getPlayerData(client).hotBarItems[hotBarSlot] != -1) {
+ meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name} and pulls out ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name}`);
+ } else if(currentHotBarSlot != -1 && getPlayerData(client).hotBarItems[currentHotBarSlot] != -1 && (hotBarSlot == -1 || getPlayerData(client).hotBarItems[hotBarSlot] == -1)) {
+ meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name}`);
+ } else if((currentHotBarSlot == -1 || getPlayerData(client).hotBarItems[currentHotBarSlot] == -1) && getPlayerData(client).hotBarItems[hotBarSlot] != -1) {
+ meActionToNearbyPlayers(client, `pulls out ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name}`);
+ } else {
+ return false;
+ }
+
+ if(currentHotBarSlot != -1) {
+ if(getPlayerData(client).hotBarItems[currentHotBarSlot] != -1) {
+ if(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot])) {
+ if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) {
+ getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).value = getPlayerWeaponAmmo(client);
+ clearPlayerWeapons(client);
+ }
+ }
+ }
+ }
+
+ if(hotBarSlot != -1) {
+ if(getPlayerData(client).hotBarItems[hotBarSlot] != -1) {
+ if(getItemData(getPlayerData(client).hotBarItems[hotBarSlot])) {
+ if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) {
+ givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useId), toInteger(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value), true, true);
+ setPlayerWeaponDamageEnabled(client, true);
+ setPlayerWeaponDamageEvent(client, AG_WEAPON_DAMAGE_EVENT_NONE);
+ } else if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_TAZER) {
+ givePlayerWeapon(client, toInteger(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useId), toInteger(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value), true, true);
+ setPlayerWeaponDamageEnabled(client, false);
+ setPlayerWeaponDamageEvent(client, AG_WEAPON_DAMAGE_EVENT_TAZER);
+ }
+ }
+ }
+ }
+
+ getPlayerData(client).activeHotBarSlot = hotBarSlot;
+ updatePlayerHotBar(client);
+}
+
+// ---------------------------------------------------------------------------
+
function playerSwitchHotBarSlotCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
- let hotBarSlot = toInteger(params) || getPlayerData(client).activeHotBarSlot;
+ let hotBarSlot = toInteger(params);
if(hotBarSlot < 0 || hotBarSlot > 9) {
- messagePlayerError(client, "The slot to switch to must be between 0 and 9!");
+ messagePlayerError(client, "Use slot number between 1 and 9, or 0 for none!");
return false;
}
- hotBarSlot = hotBarSlot-1;
-
- let currentHotBarSlot = getPlayerData(client).activeHotBarSlot;
-
- if(currentHotBarSlot != 0) {
- if(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot])) {
- if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) {
- getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).value = getPlayerWeaponAmmo(client);
- clearPlayerWeapons(client);
- }
- }
+ if(hotBarSlot == 0) {
+ hotBarSlot = -1;
+ } else {
+ hotBarSlot = hotBarSlot-1;
}
- if(getItemData(getPlayerData(client).hotBarItems[hotBarSlot])) {
- if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) {
- givePlayerWeapon(client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useId, getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value, true);
- setPlayerWeaponDamageEnabled(client, true);
- setPlayerWeaponDamageEvent(client, AG_WEAPON_DAMAGE_EVENT_NONE);
- } else if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_TAZER) {
- givePlayerWeapon(client, getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useId, getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).value, true);
- setPlayerWeaponDamageEnabled(client, false);
- setPlayerWeaponDamageEvent(client, AG_WEAPON_DAMAGE_EVENT_TAZER);
- }
+ if(getPlayerData(client).activeHotBarSlot == hotBarSlot) {
+ return false;
}
- if(getPlayerData(client).hotBarItems[currentHotBarSlot] != -1 && getPlayerData(client).hotBarItems[hotBarSlot] != -1) {
- meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name} and pulls out ${getProperDeterminerForName(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).name)} ${getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).name}`);
- } else if(getPlayerData(client).hotBarItems[currentHotBarSlot] != -1 && getPlayerData(client).hotBarItems[hotBarSlot] == -1) {
- meActionToNearbyPlayers(client, `puts away ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[currentHotBarSlot]).itemTypeIndex).name}`);
- } else if(getPlayerData(client).hotBarItems[currentHotBarSlot] == -1 && getPlayerData(client).hotBarItems[hotBarSlot] != -1) {
- meActionToNearbyPlayers(client, `pulls out ${getProperDeterminerForName(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name)} ${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).name}`);
+ if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
+ return false;
}
- getPlayerData(client).activeHotBarSlot = hotBarSlot;
- updatePlayerHotBar(client);
+ getPlayerData(client).itemActionItem = hotBarSlot;
+ getPlayerData(client).itemActionState = AG_ITEM_ACTION_SWITCH;
+ showPlayerItemSwitchDelay(client, hotBarSlot);
}
// ---------------------------------------------------------------------------
@@ -720,7 +804,7 @@ function listPlayerInventoryCommand(command, params, client) {
if(getPlayerData(client).hotBarItems[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA](Empty)`);
} else {
- itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).name}[${getItemData(getPlayerData(client).hotBarItems[i]).value}]`);
+ itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).name}[${getItemValueDisplay(getPlayerData(client).hotBarItems[i])}]`);
}
}
@@ -761,7 +845,7 @@ function listBusinessStorageInventoryCommand(command, params, client) {
if(getBusinessData(businessId).storageItemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else {
- itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[i]).itemTypeIndex).name}[${getItemData(getBusinessData(businessId).storageItemCache[i]).value}]`);
+ itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getBusinessData(businessId).storageItemCache[i]).itemTypeIndex).name}[${getItemValueDisplay(getBusinessData(businessId).storageItemCache[i])}]`);
}
}
@@ -798,7 +882,7 @@ function listBusinessFloorInventoryCommand(command, params, client) {
if(getBusinessData(businessId).floorItemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else {
- itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name}[${getItemData(getBusinessData(businessId).floorItemCache[i]).value}]`);
+ itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getBusinessData(businessId).floorItemCache[i]).itemTypeIndex).name}[${getItemValueDisplay(getBusinessData(businessId).floorItemCache[i])}]`);
}
}
@@ -835,7 +919,7 @@ function listHouseInventoryCommand(command, params, client) {
if(getHouseData(houseId).itemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else {
- itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getHouseData(houseId).itemCache[i]).itemTypeIndex).name}[${getItemData(getBusinessData(houseId).itemCache[i]).value}]`);
+ itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getHouseData(houseId).itemCache[i]).itemTypeIndex).name}[${getItemValueDisplay(getBusinessData(houseId).itemCache[i])}]`);
}
}
@@ -872,7 +956,7 @@ function listItemInventoryCommand(command, params, client) {
if(getItemData(itemId).itemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else {
- itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getItemData(itemId).itemCache[i]).itemTypeIndex).name}[${getItemData(getItemData(itemId).itemCache[i]).value}]`);
+ itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA]${getItemTypeData(getItemData(getItemData(itemId).itemCache[i]).itemTypeIndex).name}[${getItemValueDisplay(getItemData(itemId).itemCache[i])}]`);
}
}
@@ -994,4 +1078,107 @@ function getItemTypeIndexFromDatabaseId(databaseId) {
}
}
+// ---------------------------------------------------------------------------
+
+function playerItemActionDelayComplete(client) {
+ switch(getPlayerData(client).itemActionState) {
+ case AG_ITEM_ACTION_USE:
+ playerUseItem(client, getPlayerData(client).itemActionItem);
+ break;
+
+ case AG_ITEM_ACTION_DROP:
+ playerDropItem(client, getPlayerData(client).itemActionItem);
+ break;
+
+ case AG_ITEM_ACTION_TAKE:
+ playerTakeItem(client, getPlayerData(client).itemActionItem);
+ break;
+
+ case AG_ITEM_ACTION_PUT:
+ playerPutItem(client, getPlayerData(client).itemActionItem);
+ break;
+
+ case AG_ITEM_ACTION_PICKUP:
+ playerPickupItem(client, getPlayerData(client).itemActionItem);
+ break;
+
+ case AG_ITEM_ACTION_SWITCH:
+ playerSwitchItem(client, getPlayerData(client).itemActionItem);
+ break;
+ }
+
+ getPlayerData(client).itemActionState = AG_ITEM_ACTION_NONE;
+ getPlayerData(client).itemActionItem = -1;
+}
+
+// ---------------------------------------------------------------------------
+
+function getItemValueDisplay(itemId) {
+ if(getItemData(itemId)) {
+ if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_SKIN) {
+ return getSkinNameFromId(getItemData(itemId).value);
+ } else if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_FOOD) {
+ return toString(getItemData(itemId).value)+"%";
+ } else if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_PHONE) {
+ return toString(getItemData(itemId).value);
+ } else if(getItemTypeData(getItemData(itemId).itemTypeIndex).useType == AG_ITEM_USETYPE_WALKIETALKIE) {
+ return toString(toString(getItemData(itemId).value.slice(0,-2))+"."+toString(getItemData(itemId).value.slice(0,-2))+"MHz");
+ } else {
+ return getItemData(itemId).value;
+ }
+ }
+ return "unknown";
+}
+
+// ---------------------------------------------------------------------------
+
+function getPlayerFirstItemSlotByUseType(client, useType) {
+ for(let i in getPlayerData(client).hotBarItems) {
+ if(getPlayerData(client).hotBarItems[i] != -1) {
+ if(getItemData(getPlayerData(client).hotBarItems[i])) {
+ if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[i]).itemTypeIndex).useType == useType) {
+ return i;
+ }
+ }
+ }
+ }
+
+ return -1;
+}
+
+// ---------------------------------------------------------------------------
+
+function toggleItemEnabledCommand(command, params, client) {
+ if(!getPlayerActiveItem(client)) {
+ messagePlayerError(client, `You aren't holding anything!`);
+ return false;
+ }
+
+ if(!getItemData(getPlayerActiveItem(client))) {
+ messagePlayerError(client, `You aren't holding anything!`);
+ return false;
+ }
+
+ getItemData(getPlayerActiveItem(client)).enabled = !getItemData(getPlayerActiveItem(client)).enabled;
+ messagePlayerNormal(client, `You turned ${toUpperCase(getOnOffFromBool(getBoolRedGreenInlineColour(getItemData(getPlayerActiveItem(client)).enabled)))} (your ${getItemName(getPlayerActiveItem(client))} in slot ${getPlayerActiveItemSlot(client)}`)
+}
+
+// ---------------------------------------------------------------------------
+
+function getItemName(itemId) {
+ if(getItemData(itemId)) {
+ return getItemTypeData(getItemData(itemId).typeIndex).name;
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function getPlayerActiveItem(client) {
+ if(getPlayerData(client).activeHotBarSlot != -1) {
+ if(getPlayerData(client).hotBarItems[getPlayerData(client).activeHotBarSlot] != -1) {
+ return getPlayerData(client).hotBarItems[getPlayerData(client).activeHotBarSlot];
+ }
+ }
+}
+
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/item/drink.js b/scripts/server/item/drink.js
new file mode 100644
index 00000000..ca037190
--- /dev/null
+++ b/scripts/server/item/drink.js
@@ -0,0 +1,11 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: drink.js
+// DESC: Provides features and usage for the drink item type
+// TYPE: Server (JavaScript)
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/item/food.js b/scripts/server/item/food.js
new file mode 100644
index 00000000..2cc44d66
--- /dev/null
+++ b/scripts/server/item/food.js
@@ -0,0 +1,11 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: food.js
+// DESC: Provides features and usage for the food item type
+// TYPE: Server (JavaScript)
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/item/phone.js b/scripts/server/item/phone.js
new file mode 100644
index 00000000..0122fde6
--- /dev/null
+++ b/scripts/server/item/phone.js
@@ -0,0 +1,11 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: phone.js
+// DESC: Provides features and usage for the phone item type
+// TYPE: Server (JavaScript)
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/item/walkie-talkie.js b/scripts/server/item/walkie-talkie.js
new file mode 100644
index 00000000..27a4e670
--- /dev/null
+++ b/scripts/server/item/walkie-talkie.js
@@ -0,0 +1,103 @@
+// ===========================================================================
+// Asshat-Gaming Roleplay
+// https://github.com/VortrexFTW/gtac_asshat_rp
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
+// ---------------------------------------------------------------------------
+// FILE: walkie-talkie.js
+// DESC: Provides features and usage for the walkie-talkie item type
+// TYPE: Server (JavaScript)
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+
+function getPlayerActiveWalkieTalkieFrequency(client) {
+ let walkieTalkieSlot = getPlayerFirstItemSlotByUseType(client);
+
+ if(walkieTalkieSlot != -1) {
+ if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot])) {
+ if(getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).enabled) {
+ return getItemData(getPlayerData(client).hotBarItems[walkieTalkieSlot]).value;
+ }
+ }
+ }
+
+ return false;
+}
+
+// ---------------------------------------------------------------------------
+
+function walkieTalkieTransmit(radioFrequency, messageText, transmittingPlayer) {
+ walkieTalkieOutgoingToNearbyPlayers(transmittingPlayer, messageText);
+
+ let clients = getPlayingClients();
+ for(let i in clients) {
+ if(!samePlayer(transmittingPlayer, clients[i])) {
+ if(getPlayerActiveWalkieTalkieFrequency(clients[i]) == radioFrequency) {
+ walkieTalkieIncomingToNearbyPlayers(clients[i], messageText);
+ }
+ }
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function walkieTalkieOutgoingToNearbyPlayers(client, messageText) {
+ let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
+ for(let i in clients) {
+ messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](to radio): [#FFFFFF]${messageText}`);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function walkieTalkieIncomingToNearbyPlayers(client, messageText) {
+ let clients = getPlayersInRange(getPlayerPosition(client), getGlobalConfig().walkieTalkieSpeakerDistance);
+ for(let i in clients) {
+ messagePlayerNormal(`[#CCCCCC]${getCharacterFullName(client)} [#AAAAAA](from radio): [#FFFFFF]${messageText}`);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+function setWalkieTalkieFrequencyCommand(command, params, client) {
+ if(areParamsEmpty(params)) {
+ messagePlayerSyntax(client, getCommandSyntaxText(command));
+ return false;
+ }
+
+ if(isNaN(params)) {
+ messagePlayerError(client, `The frequency channel must be a number!`);
+ return false;
+ }
+
+ params = toInteger(params);
+
+ if(params < 100 || params > 500) {
+ messagePlayerError(client, `The frequency channel must be between 100 and 500!`);
+ return false;
+ }
+
+ if(!getPlayerActiveItem(client)) {
+ messagePlayerError(client, `You aren't holding a walkie talkie!`);
+ return false;
+ }
+
+ if(!getItemData(getPlayerActiveItem(client))) {
+ messagePlayerError(client, `You aren't holding a walkie talkie!`);
+ return false;
+ }
+
+ if(getItemData(getPlayerActiveItem(client)).enabled) {
+ if(doesPlayerHaveKeyBindForCommand(client, "use")) {
+ messagePlayerError(client, `Your walkie talkie is turned off. Press ${sdl.getKeyName(getPlayerKeyBindForCommand(client, "use").key)} to turn it on`);
+ } else {
+ messagePlayerError(client, `Your walkie talkie is turned off. Type [#AAAAAA]/use [#FFFFFF]to turn it on`);
+ }
+ return false;
+ }
+
+ getItemData(getPlayerActiveItem(client)).value = params*100;
+ messagePlayerSuccess(client, `You set the frequency of you walkie talkie in slot ${getPlayerData(client).activeHotbarSlot} to ${getItemValueDisplay(getPlayerActiveItem(client))}`)
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/job.js b/scripts/server/job.js
index b61b26b8..e79621a5 100644
--- a/scripts/server/job.js
+++ b/scripts/server/job.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: job.js
// DESC: Provides job functions and usage
@@ -371,7 +371,7 @@ function startWorkingCommand(command, params, client) {
return false;
}
- if(getPlayerCurrentSubAccount(client).job != closestJobLocation.jobIndex) {
+ if(getPlayerCurrentSubAccount(client).job != closestJobLocation.job) {
messagePlayerError(client, "This is not your job!");
messagePlayerInfo(client, `If you want this job, use /quitjob to quit your current job.`);
return false;
@@ -456,7 +456,7 @@ function startWorking(client) {
}
updatePlayerNameTag(client);
- triggerNetworkEvent("ag.working", client, true);
+ sendPlayerWorkingState(client, true);
//showStartedWorkingTip(client);
}
@@ -473,11 +473,6 @@ function getJobInfoCommand(command, params, client) {
function getJobLocationInfoCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
- //if(!getJobData(getJobIdFromDatabaseId(closestJobLocation.job))) {
- // messagePlayerError(client, "Job not found!");
- // return false;
- //}
-
messagePlayerInfo(client, `[#FFFF00][Job Location Info] [#FFFFFF]Job: [#AAAAAA]${getJobData(closestJobLocation.job).name} (${getJobData(closestJobLocation.job).id}/${closestJobLocation.job}), [#FFFFFF]Enabled: [#AAAAAA]${getYesNoFromBool(closestJobLocation.enabled)}, [#FFFFFF]Database ID: [#AAAAAA]${closestJobLocation.databaseId}`);
}
@@ -490,10 +485,13 @@ function givePlayerJobEquipment(client, equipmentId) {
let jobId = getPlayerJob(client);
- for(let i in equipments[equipmentId].items) {
+ for(let i in getJobData(jobId).equipment[equipmentId].items) {
let itemId = createItem(getJobData(jobId).equipment[equipmentId].items[i].itemType, getJobData(jobId).equipment[equipmentId].items[i].value, AG_ITEM_OWNER_PLAYER, getPlayerCurrentSubAccount(client).databaseId);
let freeSlot = getPlayerFirstEmptyHotBarSlot(client);
+ getPlayerData(client).hotBarItems[freeSlot] = itemId;
getPlayerData(client).jobEquipmentCache.push(itemId);
+
+ updatePlayerHotBar(client);
}
}
@@ -570,7 +568,7 @@ function stopWorking(client) {
}
updatePlayerNameTag(client);
- triggerNetworkEvent("ag.working", client, false);
+ sendPlayerWorkingState(client, false);
}
// ---------------------------------------------------------------------------
@@ -712,14 +710,14 @@ function getJobData(jobId) {
function quitJob(client) {
stopWorking(client);
getPlayerCurrentSubAccount(client).job = AG_JOB_NONE;
- triggerNetworkEvent("ag.jobType", client, AG_JOB_NONE);
+ sendPlayerJobType(client, jobType);
}
// ---------------------------------------------------------------------------
function takeJob(client, jobId) {
- getPlayerCurrentSubAccount(client).job = jobId;
- triggerNetworkEvent("ag.jobType", client, jobId);
+ getPlayerCurrentSubAccount(client).job = getJobData(jobId).databaseId;
+ sendPlayerJobType(client, getJobData(jobId).databaseId);
}
// ---------------------------------------------------------------------------
@@ -1070,7 +1068,7 @@ function startJobRoute(client) {
function stopJobRoute(client, successful = false) {
stopReturnToJobVehicleCountdown(client);
- triggerNetworkEvent("ag.stopJobRoute", client);
+ sendPlayerStopJobRoute(client);
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
respawnVehicle(getPlayerData(client).busRouteVehicle);
@@ -1150,38 +1148,6 @@ function stopReturnToJobVehicleCountdown(client) {
// ---------------------------------------------------------------------------
-function sendAllJobLabelsToPlayer(client) {
- let tempJobLocations = [];
- for(let k in getServerData().jobs) {
- for(let m in getServerData().jobs[k].locations) {
- tempJobLocations.push({
- id: getServerData().jobs[k].locations[m].databaseId,
- jobType: getServerData().jobs[k].jobType,
- name: getServerData().jobs[k].name,
- position: getServerData().jobs[k].locations[m].position,
- });
- }
- }
-
- let totalJobLocations = tempJobLocations.length;
- let tempJobLabels = [];
- let jobLocationsPerNetworkEvent = 100;
- let totalNetworkEvents = Math.ceil(totalJobLocations/jobLocationsPerNetworkEvent);
- for(let i = 0 ; i < totalNetworkEvents ; i++) {
- for(let j = 0 ; j < jobLocationsPerNetworkEvent ; j++) {
- let tempJobLocationId = (i*jobLocationsPerNetworkEvent)+j;
- //if(typeof getServerData().jobs[i] != "undefined") {
- let tempJobLabels = [];
- tempJobLabels.push([tempJobLocations[i].id, tempJobLocations[i].position, getGameConfig().propertyLabelHeight[getServerGame()], tempJobLocations[i].name, tempJobLocations[i].jobType, false]);
- //}
- }
- triggerNetworkEvent("ag.joblabel.all", client, tempJobLabels);
- tempJobLabels = [];
- }
-}
-
-// ---------------------------------------------------------------------------
-
function canPlayerUseJob(client, jobId) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageJobs"))) {
return true;
@@ -1191,11 +1157,19 @@ function canPlayerUseJob(client, jobId) {
return false;
}
- if(getJobData(jobId).whiteListEnabled) {
+ if(isJobWhiteListed(jobId)) {
if(!isPlayerOnJobWhiteList(client, jobId)) {
- return false
+ return false;
}
}
+
+ if(!isJobBlackListed(jobId)) {
+ if(isPlayerOnJobBlackList(client, jobId)) {
+ return false;
+ }
+ }
+
+ return true;
}
// ---------------------------------------------------------------------------
@@ -1544,4 +1518,56 @@ function getJobIndexFromDatabaseId(databaseId) {
return false;
}
+// ---------------------------------------------------------------------------
+
+function isJobWhiteListed(jobId) {
+ return getJobData(jobId).whiteListEnabled;
+}
+
+// ---------------------------------------------------------------------------
+
+function isPlayerOnJobWhiteList(client, jobId) {
+ for(let i in getJobData(jobId).whiteList) {
+ if(getJobData(jobId).whiteList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// ---------------------------------------------------------------------------
+
+function isJobBlackListed(jobId) {
+ return getJobData(jobId).blackListEnabled;
+}
+
+// ---------------------------------------------------------------------------
+
+function isPlayerOnJobBlackList(client, jobId) {
+ for(let i in getJobData(jobId).blackList) {
+ if(getJobData(jobId).blackList[i].subAccount == getPlayerCurrentSubAccount(client).databaseId) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// ---------------------------------------------------------------------------
+
+function playerArrivedAtJobRouteStop(client) {
+ if(!isPlayerOnJobRoute(client)) {
+ return false;
+ }
+
+ if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
+ playerArrivedAtBusStop(client);
+ } else if(doesPlayerHaveJobType(client, AG_JOB_GARBAGE)) {
+ playerArrivedAtGarbageStop(client);
+ } else if(doesPlayerHaveJobType(client, AG_JOB_POLICE)) {
+ playerArrivedAtPolicePatrolPoint(client);
+ }
+}
+
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/job/bus.js b/scripts/server/job/bus.js
index f0a7a2a0..28f373f5 100644
--- a/scripts/server/job/bus.js
+++ b/scripts/server/job/bus.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: bus.js
// DESC: Provides bus driver job functions and usage
@@ -398,12 +398,12 @@ function showNextBusStop(client) {
// ---------------------------------------------------------------------------
function showCurrentBusStop(client) {
- triggerNetworkEvent("ag.showBusStop", client, getBusRouteStopPosition(getPlayerIsland(client), getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop), getColourByName("busDriverGreen"));
+ sendJobRouteStopToPlayer(client, getBusRouteStopPosition(getPlayerIsland(client), getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop), getColourByName("busDriverGreen"))
}
// ---------------------------------------------------------------------------
-function arrivedAtBusStop(client) {
+function playerArrivedAtBusStop(client) {
if(isLastStopOnBusRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle);
messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your bus has been returned to the bus depot.`, getColourByName("yellow"));
diff --git a/scripts/server/job/drug.js b/scripts/server/job/drug.js
index 2148f519..a8c3ee77 100644
--- a/scripts/server/job/drug.js
+++ b/scripts/server/job/drug.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: drug.js
// DESC: Provides drug runner/dealer job functions and usage
diff --git a/scripts/server/job/fire.js b/scripts/server/job/fire.js
index a93cf65f..74517e3b 100644
--- a/scripts/server/job/fire.js
+++ b/scripts/server/job/fire.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: fire.js
// DESC: Provides firefighter job functions and usage
diff --git a/scripts/server/job/garbage.js b/scripts/server/job/garbage.js
index 18c74d46..88f7859a 100644
--- a/scripts/server/job/garbage.js
+++ b/scripts/server/job/garbage.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: garbage.js
// DESC: Provides garbage collector job functions and usage
@@ -113,7 +113,7 @@ function showCurrentGarbageStop(client) {
// ---------------------------------------------------------------------------
-function arrivedAtGarbageStop(client) {
+function playerArrivedAtGarbageStop(client) {
if(isLastStopOnGarbageRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle);
messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! You earned $${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your trashmaster has been returned to the garbage depot.`, getColourByName("yellow"));
diff --git a/scripts/server/job/medic.js b/scripts/server/job/medic.js
index 44b73f05..aee7add0 100644
--- a/scripts/server/job/medic.js
+++ b/scripts/server/job/medic.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: medic.js
// DESC: Provides paramedic job functions and usage
diff --git a/scripts/server/job/police.js b/scripts/server/job/police.js
index 863ab729..32e946dc 100644
--- a/scripts/server/job/police.js
+++ b/scripts/server/job/police.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: police.js
// DESC: Provides police officer job functions and usage
@@ -231,7 +231,7 @@ function policeDetainCommand(command, params, client) {
// ---------------------------------------------------------------------------
-function arrivedAtPolicePatrolPoint(client) {
+function playerArivedAtPolicePatrolPoint(client) {
if(isLastStopOnPolicePatrolRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
messagePlayerNormal(client, `You finished the ${getPatrolRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} patrol route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout}`, getColourByName("yellow"));
messagePlayerNormal(client, `You can either continue driving the patrol route again, or use /stoproute to end your patrol.`, getColourByName("yellow"));
diff --git a/scripts/server/job/taxi.js b/scripts/server/job/taxi.js
index 9225de24..91c37ed5 100644
--- a/scripts/server/job/taxi.js
+++ b/scripts/server/job/taxi.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: taxi.js
// DESC: Provides taxi driver job functions and usage
diff --git a/scripts/server/job/weapon.js b/scripts/server/job/weapon.js
index 2f07fd3b..af534ff2 100644
--- a/scripts/server/job/weapon.js
+++ b/scripts/server/job/weapon.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: weapon.js
// DESC: Provides weapons dealer job functions and usage
diff --git a/scripts/server/keybind.js b/scripts/server/keybind.js
index e0b27fff..bdbe3236 100644
--- a/scripts/server/keybind.js
+++ b/scripts/server/keybind.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: keybind.js
// DESC: Provides keybind handlers and functions
@@ -191,7 +191,7 @@ function removeKeyBindCommand(command, params, client) {
function addPlayerKeyBind(client, keyId, tempCommand, tempParams) {
let keyBindData = new serverClasses.keyBindData(keyId, `${tempCommand} ${tempParams}`);
getPlayerData(client).accountData.keyBinds.push(keyBindData);
- sendAccountKeyBindToClient(client, getPlayerKeyBindForKey(client, keyId));
+ sendAddAccountKeyBindToClient(client, getPlayerKeyBindForKey(client, keyId));
}
// ---------------------------------------------------------------------------
@@ -203,7 +203,7 @@ function removePlayerKeyBind(client, keyId) {
accountKeyBinds.splice(i, 1);
}
}
- removeAccountKeyBindFromClient(client, keyId);
+ sendRemoveAccountKeyBindToClient(client, keyId);
}
// ---------------------------------------------------------------------------
@@ -280,24 +280,17 @@ function playerUsedKeyBind(client, key) {
}
}
}
-addNetworkHandler("ag.keybind.trig", playerUsedKeyBind);
// ---------------------------------------------------------------------------
function sendAccountKeyBindsToClient(client) {
for(let i in getPlayerData(client).accountData.keyBinds) {
- sendAccountKeyBindToClient(client, getPlayerData(client).accountData.keyBinds[i].key, getPlayerData(client).accountData.keyBinds[i].keyState);
+ sendAddAccountKeyBindToClient(client, getPlayerData(client).accountData.keyBinds[i].key, getPlayerData(client).accountData.keyBinds[i].keyState);
}
}
// ---------------------------------------------------------------------------
-function sendAccountKeyBindToClient(client, key, keyState) {
- triggerNetworkEvent("ag.keybinds.add", client, toInteger(key), (keyState) ? KEYSTATE_DOWN : KEYSTATE_UP);
-}
-
-// ---------------------------------------------------------------------------
-
function getKeyIdFromParams(params) {
let tempParams = toLowerCase(toString(params));
diff --git a/scripts/server/locale.js b/scripts/server/locale.js
index 4fa4238a..b01a4dca 100644
--- a/scripts/server/locale.js
+++ b/scripts/server/locale.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: locale.js
// DESC: Provides locale structures, functions and usage
diff --git a/scripts/server/messaging.js b/scripts/server/messaging.js
index 01a2beb4..7d5e8c73 100644
--- a/scripts/server/messaging.js
+++ b/scripts/server/messaging.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: messaging.js
// DESC: Provides messaging functions and usage
@@ -11,7 +11,7 @@
// ---------------------------------------------------------------------------
function messageAdminAction(messageText) {
- message(`⚠️ ${messageText}`, getColourByName("orange"));
+ messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`);
}
@@ -26,11 +26,13 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
return true;
}
- if(!isClientFromDiscord(client)) {
- messageClient(`${messageText}`, client, colour);
- } else {
- messageDiscordUser(client, `${messageText}`);
- }
+ sendChatBoxMessageToPlayer(client, `${messageText}`, colour);
+
+ //if(!isClientFromDiscord(client)) {
+ //
+ //} else {
+ // messageDiscordUser(client, `${messageText}`);
+ //}
}
// ---------------------------------------------------------------------------
@@ -38,11 +40,11 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
function messageAdmins(messageText, colour = COLOUR_WHITE) {
let clients = getClients();
for(let i in clients) {
- if(clients[i].console) {
+ if(isConsole(clients[i])) {
logToConsole(LOG_INFO, `[Asshat.Messaging] ADMINS: ${messageText}`);
} else {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("basicModeration"))) {
- messageClient(`🛡️ ${messageText}`, clients[i], getColourByName("softRed"));
+ sendChatBoxMessageToPlayer(clients[i], `🛡️ ${messageText}`, getColourByName("softRed"));
}
}
diff --git a/scripts/server/misc.js b/scripts/server/misc.js
index 7cee2a3b..f0f05907 100644
--- a/scripts/server/misc.js
+++ b/scripts/server/misc.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: misc.js
// DESC: Provides any uncategorized functions and usage
@@ -29,14 +29,14 @@ function getPositionCommand(command, params, client) {
// ---------------------------------------------------------------------------
function toggleMouseCursorCommand(command, params, client) {
- triggerNetworkEvent("ag.cursorToggle", client);
+ sendPlayerMouseCursorToggle(client);
return true;
}
// ---------------------------------------------------------------------------
function toggleMouseCameraCommand(command, params, client) {
- triggerNetworkEvent("ag.mouseCamera", client);
+ sendPlayerMouseCameraToggle(client);
return true;
}
@@ -280,4 +280,14 @@ function getPlayerInfoCommand(command, params, client) {
messagePlayerInfo(client, `[#AAAAAA][Player Info] [#FFFFFF]Account: [#AAAAAA]${getPlayerData(targetClient).accountData.name}[${getPlayerData(targetClient).accountData.databaseId}], [#FFFFFF]Character: [#AAAAAA]${getCharacterFullName(client)}[${getPlayerCurrentSubAccount(client).databaseId}], [#FFFFFF]Connected: [#AAAAAA]${getTimeDifferenceDisplay(Math.ceil(sdl.tick/1000), getPlayerData(targetClient).connectTime)} ago, [#FFFFFF]Game Version: [#AAAAAA]${targetClient.gameVersion}, [#FFFFFFF]Client Version: [#AAAAAA]${getPlayerData(targetClient).clientVersion}`);
}
+// ---------------------------------------------------------------------------
+
+function playerChangeAFKState(client, afkState) {
+ if(afkState) {
+ setEntityData(client, "ag.afk", true, true);
+ } else {
+ client.removeData("ag.afk");
+ }
+}
+
// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/moderation.js b/scripts/server/moderation.js
index e2b58c40..17175927 100644
--- a/scripts/server/moderation.js
+++ b/scripts/server/moderation.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: moderation.js
// DESC: Provides moderation commands, functions and usage
@@ -144,7 +144,7 @@ function freezeClientCommand(command, params, client) {
}
messageAdminAction(`${toString(targetClient.name)} has been frozen by an admin!`);
- triggerNetworkEvent("ag.frozen", client, true);
+ setPlayerFrozenState(client, state);
}
// ---------------------------------------------------------------------------
@@ -170,7 +170,7 @@ function unFreezeClientCommand(command, params, client) {
}
messageAdminAction(`${toString(targetClient.name)} has been un-frozen by an admin!`);
- triggerNetworkEvent("ag.frozen", client, false);
+ sendPlayerFrozenState(client, false);
}
// ---------------------------------------------------------------------------
@@ -187,24 +187,14 @@ function gotoPlayerCommand(command, params, client) {
return false;
}
- //message(`[#996600][ADMIN]: [#FFFFFF]${toString(targetClient.name)} has been un-frozen by an admin!`);
- client.player.velocity = toVector3(0.0, 0.0, 0.0);
- setPlayerPosition(client, getPosBehindPos(getPlayerPosition(targetClient), getPlayerHeading(targetClient), 2));
- setPlayerHeading(client, getPlayerHeading(targetClient));
+ setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
+ setTimeout(function() {
+ setPlayerPosition(client, getPosBehindPos(getPlayerPosition(targetClient), getPlayerHeading(targetClient), 2));
+ setPlayerHeading(client, getPlayerHeading(targetClient));
+ setPlayerInterior(client, getPlayerInterior(targetClient));
+ setPlayerDimension(client, getPlayerInterior(targetClient));
+ }, 1000);
- if(isPlayerInAnyBusiness(targetClient)) {
- let businessData = getBusinessData(getPlayerBusiness(targetClient));
- triggerNetworkEvent("ag.interior", client, businessData.exitInterior);
- //triggerNetworkEvent("ag.dimension", client, businessData.exitInterior);
- client.player.dimension = businessData.exitDimension;
- }
-
- if(isPlayerInAnyHouse(targetClient)) {
- let houseData = getHouseData(getPlayerHouse(targetClient));
- triggerNetworkEvent("ag.interior", client, houseData.exitInterior);
- //triggerNetworkEvent("ag.dimension", client, houseData.exitInterior);
- client.player.dimension = houseData.exitDimension;
- }
messagePlayerSuccess(client, `You teleported to [#AAAAAA]${targetClient.name}`);
}
@@ -222,11 +212,11 @@ function gotoVehicleCommand(command, params, client) {
let vehicle = getServerData().vehicles[toInteger(params)].vehicle;
- client.player.velocity = toVector3(0.0, 0.0, 0.0);
+ setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setTimeout(function() {
setPlayerPosition(client, getPosAbovePos(getVehiclePosition(vehicle), 3.0));
setPlayerInterior(client, 0);
- setPlayerDimension(client, vehicle.dimension);
+ setPlayerDimension(client, getVehicleDimension(vehicle));
}, 500);
messagePlayerSuccess(client, `You teleported to a [#CC22CC]${getVehicleName(vehicle)} [#AAAAAA](ID ${vehicle.id})`);
@@ -247,7 +237,7 @@ function gotoBusinessCommand(command, params, client) {
return false;
}
- client.player.velocity = toVector3(0.0, 0.0, 0.0);
+ setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setTimeout(function() {
setPlayerPosition(client, getBusinessData(businessId).entrancePosition);
setPlayerInterior(client, getBusinessData(businessId).entranceInterior);
@@ -401,7 +391,7 @@ function teleportDownCommand(command, params, client) {
return false;
}
- triggerNetworkEvent("ag.position", client, getPosBelowPos(getPlayerPosition(client), params));
+ setPlayerPosition(client, getPosBelowPos(getPlayerPosition(client), params));
messagePlayerSuccess(client, `You teleported down [#AAAAAA]${params} [#FFFFFF]meters`);
}
diff --git a/scripts/server/native.js b/scripts/server/native.js
index 252f73fe..7060659c 100644
--- a/scripts/server/native.js
+++ b/scripts/server/native.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: native.js
// DESC: Provides util function to wrap mod-specific stuff
@@ -51,7 +51,7 @@ function getPlayerPosition(client) {
// ---------------------------------------------------------------------------
function setPlayerPosition(client, position) {
- return triggerNetworkEvent("ag.position", client, position);
+ sendPlayerSetPosition(client, position);
}
// ---------------------------------------------------------------------------
@@ -63,7 +63,7 @@ function getPlayerHeading(client) {
// ---------------------------------------------------------------------------
function setPlayerHeading(client, heading) {
- return triggerNetworkEvent("ag.heading", client, heading);
+ sendPlayerSetHeading(client, heading);
}
// ---------------------------------------------------------------------------
@@ -97,7 +97,7 @@ function setPlayerDimension(client, dimension) {
// ---------------------------------------------------------------------------
function setPlayerInterior(client, interior) {
- triggerNetworkEvent("ag.interior", client, interior);
+ sendPlayerSetInterior(client, interior);
getPlayerCurrentSubAccount(client).interior = interior;
}
@@ -172,7 +172,7 @@ function isPlayerInFrontVehicleSeat(client) {
// ---------------------------------------------------------------------------
function removePlayerFromVehicle(client) {
- triggerNetworkEvent("ag.removeFromVehicle", client);
+ sendPlayerRemoveFromVehicle(client);
return true;
}
@@ -196,16 +196,42 @@ function getElementSyncer(element) {
// ---------------------------------------------------------------------------
-function givePlayerWeapon(client, weaponId, ammo, active) {
- triggerNetworkEvent("ag.giveWeapon", client, weaponId, ammo, active);
+function getPlayerWeaponAmmo(client) {
+ client.player.weaponAmmunition + client.player.weaponClipAmmunition;
}
// ---------------------------------------------------------------------------
-function clearPlayerWeapons(client) {
- triggerNetworkEvent("ag.clearWeapons", client);
+function setPlayerVelocity(client, velocity) {
+ client.player.velocity = velocity;
}
// ---------------------------------------------------------------------------
-//triggerNetworkEvent("ag.veh.engine", getElementSyncer(getPlayerVehicle(client)), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).engine);
\ No newline at end of file
+function getPlayerVelocity(client, velocity) {
+ return client.player.velocity;
+}
+
+// ---------------------------------------------------------------------------
+
+function getElementDimension(element) {
+ return element.dimension;
+}
+
+// ---------------------------------------------------------------------------
+
+function setElementDimension(element, dimension) {
+ return element.dimension = dimension;
+}
+
+// ---------------------------------------------------------------------------
+
+function givePlayerHealth(client, amount) {
+ if(getPlayerHealth(client)+amount > 100) {
+ setPlayerHealth(client, 100);
+ } else {
+ setPlayerHealth(client, getPlayerHealth(client)+amount);
+ }
+}
+
+// ---------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/server/npc.js b/scripts/server/npc.js
index 3a81179d..545a5a6a 100644
--- a/scripts/server/npc.js
+++ b/scripts/server/npc.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: npc.js
// DESC: Provides NPC usage and functions
diff --git a/scripts/server/npc/biker.js b/scripts/server/npc/biker.js
index d077754b..17c3b6b2 100644
--- a/scripts/server/npc/biker.js
+++ b/scripts/server/npc/biker.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: biker.js
// DESC: Provides biker NPC interaction and functionality
diff --git a/scripts/server/npc/drugdealer.js b/scripts/server/npc/drugdealer.js
index dbc6ec3a..241efa28 100644
--- a/scripts/server/npc/drugdealer.js
+++ b/scripts/server/npc/drugdealer.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: drugdealer.js
// DESC: Provides drug dealer NPC interaction and functionality
diff --git a/scripts/server/npc/firefighter.js b/scripts/server/npc/firefighter.js
index ee1186f9..c52a5f6c 100644
--- a/scripts/server/npc/firefighter.js
+++ b/scripts/server/npc/firefighter.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: firefighter.js
// DESC: Provides firefighter NPC interaction and functionality
diff --git a/scripts/server/npc/gang.js b/scripts/server/npc/gang.js
index 6caca9c8..963f67f3 100644
--- a/scripts/server/npc/gang.js
+++ b/scripts/server/npc/gang.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: gangsta.js
// DESC: Provides street gang/hoodlum NPC interaction and functionality
diff --git a/scripts/server/npc/mafia.js b/scripts/server/npc/mafia.js
index f195d5c3..2e76fdcf 100644
--- a/scripts/server/npc/mafia.js
+++ b/scripts/server/npc/mafia.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: mafia.js
// DESC: Provides mafia/mafioso NPC interaction and functionality
diff --git a/scripts/server/npc/normal.js b/scripts/server/npc/normal.js
index de7701da..1b77b8e7 100644
--- a/scripts/server/npc/normal.js
+++ b/scripts/server/npc/normal.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: normal.js
// DESC: Provides normal/generic civilian NPC interaction and functionality
diff --git a/scripts/server/npc/paramedic.js b/scripts/server/npc/paramedic.js
index 6a74d4ec..b13777a3 100644
--- a/scripts/server/npc/paramedic.js
+++ b/scripts/server/npc/paramedic.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: paramedic.js
// DESC: Provides paramedic NPC interaction and functionality
diff --git a/scripts/server/npc/police.js b/scripts/server/npc/police.js
index 5b7345a6..209c9c46 100644
--- a/scripts/server/npc/police.js
+++ b/scripts/server/npc/police.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: police.js
// DESC: Provides police officer NPC interaction and functionality
diff --git a/scripts/server/security.js b/scripts/server/security.js
index f0d76517..455262d8 100644
--- a/scripts/server/security.js
+++ b/scripts/server/security.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: security.js
// DESC: Provides security functions and usage
diff --git a/scripts/server/startup.js b/scripts/server/startup.js
index fbb8c9f6..f0d6089a 100644
--- a/scripts/server/startup.js
+++ b/scripts/server/startup.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: startup.js
// DESC: Provides startup/shutdown procedures
@@ -32,15 +32,10 @@ function initServerScripts() {
initEventScript();
initAntiCheatScript();
initItemScript();
+ initClientScript();
initTimers();
- //gta.time.hour = getServerConfig().startup.hour;
- //gta.time.minute = getServerConfig().startup.minute;
- //gta.forceWeather(getServerConfig().startup.weather);
-
- initAllClients();
-
loadGameFixesResource();
serverStartTime = new Date().getTime()/1000;
diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js
index 321a5596..bb9099e8 100644
--- a/scripts/server/subaccount.js
+++ b/scripts/server/subaccount.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: subaccount.js
// DESC: Provides subaccount (character) functions and usage
@@ -126,7 +126,7 @@ function showCharacterSelectToClient(client) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).currentSubAccount = 0;
let tempSubAccount = getPlayerData(client).subAccounts[0];
- triggerNetworkEvent("ag.showCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
+ showPlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
} else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
@@ -144,24 +144,24 @@ function showCharacterSelectToClient(client) {
function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrigin, skinId) {
if(areParamsEmpty(firstName)) {
- triggerNetworkEvent("ag.newCharacterFailed", client, "First name cannot be blank!");
+ showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!");
return false;
}
firstName = firstName.trim();
if(areParamsEmpty(lastName)) {
- triggerNetworkEvent("ag.newCharacterFailed", client, "Last name cannot be blank!");
+ showPlayerNewCharacterFailedGUI(client, "Last name cannot be blank!");
return false;
}
lastName = lastName.trim();
if(areParamsEmpty(dateOfBirth)) {
- triggerNetworkEvent("ag.newCharacterFailed", client, "Date of birth cannot be blank!");
+ showPlayerNewCharacterFailedGUI(client, "Date of birth cannot be blank!");
return false;
}
if(areParamsEmpty(placeOfOrigin)) {
- triggerNetworkEvent("ag.newCharacterFailed", client, "Place of origin cannot be blank!");
+ showPlayerNewCharacterFailedGUI(client, "Place of origin cannot be blank!");
return false;
}
@@ -172,9 +172,9 @@ function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrig
let subAccountData = createSubAccount(getPlayerData(client).accountData.databaseId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin);
if(!subAccountData) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.newCharacterFailed", client, "Something went wrong. Your character could not be created!");
+ showPlayerNewCharacterFailedGUI("Your character could not be created!");
} else {
- messagePlayerAlert(client, "Something went wrong. Your character could not be created!");
+ messagePlayerAlert(client, "Your character could not be created!");
}
messagePlayerAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
return false;
@@ -185,11 +185,11 @@ function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrig
let tempSubAccount = getPlayerData(client).subAccounts[0];
showCharacterSelectToClient(client);
}
-addNetworkHandler("ag.checkNewCharacter", checkNewCharacter);
+
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.previousCharacter", function(client) {
+function checkPreviousCharacter(client) {
if(getPlayerData(client).subAccounts.length > 1) {
if(getPlayerData(client).currentSubAccount <= 0) {
getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length-1;
@@ -199,13 +199,13 @@ addNetworkHandler("ag.previousCharacter", function(client) {
let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
- triggerNetworkEvent("ag.switchCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
+ updatePlayerCharacterSelectGUI(client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
}
-});
+}
// ---------------------------------------------------------------------------
-addNetworkHandler("ag.nextCharacter", function(client) {
+function checkNextCharacter(client) {
if(getPlayerData(client).subAccounts.length > 1) {
if(getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length-1) {
getPlayerData(client).currentSubAccount = 0;
@@ -215,15 +215,15 @@ addNetworkHandler("ag.nextCharacter", function(client) {
let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId];
- triggerNetworkEvent("ag.switchCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
+ updatePlayerCharacterSelectGUI("ag.switchCharacterSelect", client, tempSubAccount.firstName, tempSubAccount.lastName, tempSubAccount.placeOfOrigin, tempSubAccount.dateOfBirth, tempSubAccount.skin);
}
-});
+}
// ---------------------------------------------------------------------------
function selectCharacter(client, characterId = -1) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
- triggerNetworkEvent("ag.characterSelectSuccess", client);
+ showPlayerCharacterSelectSuccessGUI(client);
}
if(characterId != -1) {
@@ -236,7 +236,6 @@ function selectCharacter(client, characterId = -1) {
getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime();
cachePlayerHotBarItems(client);
}
-addNetworkHandler("ag.selectCharacter", selectCharacter);
// ---------------------------------------------------------------------------
@@ -244,8 +243,8 @@ function switchCharacterCommand(command, params, client) {
if(isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
- //getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
- //getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
+ getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
+ getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
saveSubAccountToDatabase(getPlayerCurrentSubAccount(client));
diff --git a/scripts/server/timers.js b/scripts/server/timers.js
index 898d12af..f9622c1f 100644
--- a/scripts/server/timers.js
+++ b/scripts/server/timers.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: timers.js
// DESC: Provides timer functions and features
diff --git a/scripts/server/translate.js b/scripts/server/translate.js
index de4f55ef..e3751e76 100644
--- a/scripts/server/translate.js
+++ b/scripts/server/translate.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: translate.js
// DESC: Provides translation functions
diff --git a/scripts/server/tutorial.js b/scripts/server/tutorial.js
index 6b4c2fe1..6d869ed1 100644
--- a/scripts/server/tutorial.js
+++ b/scripts/server/tutorial.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: tutorial.js
// DESC: Provides tutorial functions and features
diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js
index ee1760fd..bfb57c1f 100644
--- a/scripts/server/utilities.js
+++ b/scripts/server/utilities.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: utilities.js
// DESC: Provides util functions and arrays with data
@@ -1544,6 +1544,12 @@ function getEnabledDisabledFromBool(boolVal) {
// ---------------------------------------------------------------------------
+function getLockedUnlockedFromBool(boolVal) {
+ return (boolVal) ? "Locked" : "Unlocked";
+}
+
+// ---------------------------------------------------------------------------
+
function updateServerRules() {
server.setRule("Time", makeReadableTime(getServerConfig().hour, getServerConfig().minute));
server.setRule("Weather", getGameData().weatherNames[getServerGame()][getServerConfig().weather]);
diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js
index 0868551e..2d0a25be 100644
--- a/scripts/server/vehicle.js
+++ b/scripts/server/vehicle.js
@@ -1,7 +1,7 @@
// ===========================================================================
// Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp
-// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
+// Copyright (c) 2021 Asshat-Gaming (https://asshatgaming.com)
// ---------------------------------------------------------------------------
// FILE: vehicle.js
// DESC: Provides vehicle functions and usage
@@ -99,19 +99,10 @@ function saveVehicleToDatabase(vehicleData) {
// ---------------------------------------------------------------------------
function spawnAllVehicles() {
- let vehicles = getServerData().vehicles;
- for(let i in vehicles) {
- if(isGTAIV()) {
- if(!vehicles[i].syncedBy) {
- let closestClient = getClosestPlayer(vehicles[i].spawnPosition);
- triggerNetworkEvent("ag.vehicle", closestClient, i, vehicles[i].modelIndex, vehicles[i].spawnPosition, vehicles[i].spawnRotation, vehicles[i].colour1, vehicles[i].colour2, vehicles[i].locked, vehicles[i].lights);
- vehicles[i].syncedBy = closestClient;
- }
- } else {
- let vehicle = spawnVehicle(vehicles[i]);
- vehicles[i].vehicle = vehicle;
- setEntityData(vehicle, "ag.dataSlot", i, false);
- }
+ for(let i in getServerData().vehicles) {
+ let vehicle = spawnVehicle(getServerData().vehicles[i]);
+ getServerData().vehicles[i].vehicle = vehicle;
+ setEntityData(vehicle, "ag.dataSlot", i, false);
}
}
@@ -195,17 +186,10 @@ function vehicleLockCommand(command, params, client) {
}
}
- if(getVehicleData(vehicle).locked) {
- vehicle.locked = false;
- getVehicleData(vehicle).locked = false;
- } else {
- vehicle.locked = true;
- getVehicleData(vehicle).locked = true;
- }
+ getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
+ vehicle.locked = getVehicleData(vehicle).locked;
- let lockText = (getVehicleData(vehicle).locked) ? "locked" : "unlocked";
-
- meActionToNearbyPlayers(client, `${lockText} the ${getVehicleName(vehicle)}`);
+ meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
}
// ---------------------------------------------------------------------------
@@ -228,11 +212,10 @@ function vehicleLightsCommand(command, params, client) {
return false;
}
- triggerNetworkEvent("ag.veh.lights", getVehicleSyncer(vehicle), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).lights);
-
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
+ vehicle.lights = true;
- meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s lights ${getOnOffFromBool(vehicle)}`);
+ meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s lights ${toLowerCase(getOnOffFromBool(vehicle))}`);
}
// ---------------------------------------------------------------------------
@@ -286,9 +269,8 @@ function vehicleEngineCommand(command, params, client) {
getVehicleData(vehicle).engine = !getVehicleData(vehicle).engine;
vehicle.engine = getVehicleData(vehicle).engine;
- //triggerNetworkEvent("ag.veh.engine", null, getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).engine);
- meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s engine ${getOnOffFromBool(getVehicleData(vehicle).engine)}`);
+ meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s engine ${toLowerCase(getOnOffFromBool(getVehicleData(vehicle).engine))}`);
}
// ---------------------------------------------------------------------------
@@ -319,7 +301,7 @@ function vehicleSirenCommand(command, params, client) {
getVehicleData(vehicle).siren = !getVehicleData(vehicle).siren;
vehicle.siren = getVehicleData(vehicle).siren;
- meActionToNearbyPlayers(client, `turns the ${getVehicleName(vehicle)}'s siren ${getOnOffFromBool(getVehicleData(vehicle).siren)}`);
+ meActionToNearbyPlayers(client, `turns the ${getVehicleName(vehicle)}'s siren ${toLowerCase(getOnOffFromBool(getVehicleData(vehicle).siren))}`);
}
// ---------------------------------------------------------------------------
@@ -1039,4 +1021,41 @@ function createPermanentVehicle(modelId, position, heading) {
return vehicle;
}
+// -------------------------------------------------------------------------
+
+function checkVehicleBuying() {
+ let clients = getClients();
+ for(let i in clients) {
+ if(getPlayerData(clients[i])) {
+ if(getPlayerData(clients[i]).buyingVehicle) {
+ if(getPlayerVehicle(clients[i]) == getPlayerData(clients[i]).buyingVehicle) {
+ if(getDistance(getVehiclePosition(getPlayerData(clients[i]).buyingVehicle), getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition) > getGlobalConfig().buyVehicleDriveAwayDistance) {
+ if(getPlayerCurrentSubAccount(clients[i]).cash < getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice) {
+ messagePlayerError(client, "You don't have enough money to buy this vehicle!");
+ respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
+ getPlayerData(clients[i]).buyingVehicle = false;
+ return false;
+ }
+
+ createNewDealershipVehicle(getVehicleData(getPlayerData(clients[i]).buyingVehicle).model, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnPosition, getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnRotation, getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice, getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId);
+ getPlayerCurrentSubAccount(clients[i]).cash -= getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice;
+ updatePlayerCash(clients[i]);
+ getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerId = getPlayerCurrentSubAccount(clients[i]).databaseId;
+ getVehicleData(getPlayerData(clients[i]).buyingVehicle).ownerType = AG_VEHOWNER_PLAYER;
+ getVehicleData(getPlayerData(clients[i]).buyingVehicle).buyPrice = 0;
+ getVehicleData(getPlayerData(clients[i]).buyingVehicle).rentPrice = 0;
+ getVehicleData(getPlayerData(clients[i]).buyingVehicle).spawnLocked = false;
+ getPlayerData(clients[i]).buyingVehicle = false;
+ messagePlayerSuccess(clients[i], "This vehicle is now yours! It will save wherever you leave it.");
+ }
+ } else {
+ messagePlayerError(client, "You canceled the vehicle purchase by exiting the vehicle!");
+ respawnVehicle(getPlayerData(clients[i]).buyingVehicle);
+ getPlayerData(clients[i]).buyingVehicle = false;
+ }
+ }
+ }
+ }
+}
+
// -------------------------------------------------------------------------
\ No newline at end of file
diff --git a/scripts/shared/const.js b/scripts/shared/const.js
index d7499aec..9b3ab452 100644
--- a/scripts/shared/const.js
+++ b/scripts/shared/const.js
@@ -15,6 +15,7 @@ const AG_LABEL_HOUSE = 3;
const AG_LABEL_EXIT = 3;
// Log Levels
+const LOG_ALL = -1;
const LOG_NONE = 0;
const LOG_INFO = 1;
const LOG_WARN = 2;
diff --git a/scripts/shared/native.js b/scripts/shared/native.js
index f6e498ad..421f77fe 100644
--- a/scripts/shared/native.js
+++ b/scripts/shared/native.js
@@ -111,13 +111,17 @@ function getDistance(vec1, vec2) {
// ---------------------------------------------------------------------------
function isConsole(client) {
+ if(client == null) {
+ return false;
+ }
+
return client.console;
}
// ---------------------------------------------------------------------------
function logToConsole(tempLogLevel, text) {
- if(logLevel & tempLogLevel) {
+ if(logLevel & tempLogLevel || logLevel == LOG_ALL) {
if(tempLogLevel == LOG_ERROR) {
console.error(text);
} else if(tempLogLevel == LOG_WARN) {
@@ -132,4 +136,10 @@ function logToConsole(tempLogLevel, text) {
return false;
}
+// ---------------------------------------------------------------------------
+
+function isSamePlayer(client1, client2) {
+ return (client1 == client2);
+}
+
// ---------------------------------------------------------------------------
\ No newline at end of file