No message. 83 files changed.
This commit is contained in:
7
meta.xml
7
meta.xml
@@ -27,6 +27,7 @@
|
||||
<script src="scripts/server/developer.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/discord.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/event.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/gui.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/help.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/house.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/item.js" type="server" language="javascript" />
|
||||
@@ -69,6 +70,11 @@
|
||||
<script src="scripts/server/job/taxi.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/job/weapon.js" type="server" language="javascript" />
|
||||
|
||||
<script src="scripts/server/item/food.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/item/drink.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/item/walkie-talkie.js" type="server" language="javascript" />
|
||||
<script src="scripts/server/item/phone.js" type="server" language="javascript" />
|
||||
|
||||
<script src="scripts/server/startup.js" type="server" language="javascript" />
|
||||
|
||||
<!-- Client -->
|
||||
@@ -82,6 +88,7 @@
|
||||
<script src="scripts/client/sync.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/scoreboard.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/keybind.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/chatbox.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/label.js" type="client" language="javascript" />
|
||||
<script src="scripts/client/mouse-camera.js" type="client" language="javascript" />
|
||||
|
||||
|
||||
75
scripts/client/chatbox.js
Normal file
75
scripts/client/chatbox.js
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -50,10 +50,6 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(localPlayer.position.distance(position) > 7.5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let tempPosition = position;
|
||||
tempPosition.z = tempPosition.z + propertyLabelHeight;
|
||||
let screenPosition = getScreenFromWorldPosition(tempPosition);
|
||||
@@ -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,23 +148,12 @@ 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) {
|
||||
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");
|
||||
@@ -199,13 +176,10 @@ addEventHandler("OnDrawnHUD", function (event) {
|
||||
renderPropertyExitLabel(pickups[i].position);
|
||||
break;
|
||||
}
|
||||
//}
|
||||
//}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -660,3 +699,36 @@ 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}`);
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -979,3 +979,5 @@ function doesPlayerHaveAutoSelectLastCharacterEnabled(client) {
|
||||
function getPlayerStaffTitle(client) {
|
||||
return getPlayerData(client).accountData.staffTitle;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -320,3 +326,5 @@ function getServerBitFlags() {
|
||||
function getServerBitFlagKeys() {
|
||||
return serverBitFlagKeys;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,75 +1,67 @@
|
||||
// ===========================================================================
|
||||
// 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;
|
||||
function initClientScript() {
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Client]: Initializing client script ...");
|
||||
addAllNetworkHandlers();
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing client script ...");
|
||||
}
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.promptAnswerYes", function(client) {
|
||||
if(!getEntityData(client, "ag.prompt")) {
|
||||
return false;
|
||||
function addAllNetworkHandlers() {
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Client]: Adding network handlers ...");
|
||||
|
||||
// KeyBind
|
||||
addNetworkHandler("ag.useKeyBind", playerUsedKeyBind);
|
||||
|
||||
// GUI
|
||||
addNetworkHandler("ag.promptAnswerNo", playerPromptAnswerNo);
|
||||
addNetworkHandler("ag.promptAnswerYes", playerPromptAnswerYes);
|
||||
|
||||
// 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);
|
||||
|
||||
// Job
|
||||
addNetworkHandler("ag.arrivedAtJobRouteStop", playerArrivedAtJobRouteStop);
|
||||
|
||||
// Client
|
||||
addNetworkHandler("ag.clientReady", playerClientReady);
|
||||
addNetworkHandler("ag.guiReady", playerGUIReady);
|
||||
addNetworkHandler("ag.clientStarted", playerClientStarted);
|
||||
|
||||
// Account
|
||||
addNetworkHandler("ag.checkLogin", checkLogin);
|
||||
addNetworkHandler("ag.checkRegistration", checkRegistration);
|
||||
|
||||
// Developer
|
||||
addNetworkHandler("ag.runCodeSuccess", clientRunCodeSuccess);
|
||||
addNetworkHandler("ag.runCodeFail", clientRunCodeFail);
|
||||
|
||||
// SubAccount
|
||||
addNetworkHandler("ag.checkNewCharacter", checkNewCharacter);
|
||||
addNetworkHandler("ag.nextCharacter", checkNextCharacter);
|
||||
addNetworkHandler("ag.previousCharacter", checkPreviousCharacter);
|
||||
addNetworkHandler("ag.selectCharacter", selectCharacter);
|
||||
|
||||
// Item
|
||||
addNetworkHandler("ag.itemActionDelayComplete", playerItemActionDelayComplete);
|
||||
}
|
||||
|
||||
switch(getEntityData(client, "ag.prompt")) {
|
||||
case AG_PROMPT_CREATEFIRSTCHAR:
|
||||
triggerNetworkEvent("ag.showNewCharacter", client);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
client.removeData("ag.prompt");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.onPlayerEnterSphere", function(client, sphere) {
|
||||
//let ownerType = getEntityData(sphere, "ag.ownerType");
|
||||
//let ownerId = getEntityData(sphere, "ag.ownerId");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.afk", function(client, afkState) {
|
||||
if(afkState) {
|
||||
setEntityData(client, "ag.afk", true, true);
|
||||
} else {
|
||||
client.removeData("ag.afk");
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.player.death", function(client, position) {
|
||||
processPlayerDeath(client, position);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function updatePlayerNameTag(client) {
|
||||
@@ -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]);
|
||||
@@ -252,3 +237,227 @@ function setPlayerWeaponDamageEnabled(client, state) {
|
||||
function setPlayerWeaponDamageEvent(client, eventType) {
|
||||
triggerNetworkEvent("ag.weaponDamageEvent", null, client.name, eventType);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
@@ -235,3 +240,12 @@ const AG_TUTORIAL_STATE_PUTITEM = 6;
|
||||
const AG_TUTORIAL_STATE_TAKEITEM = 7;
|
||||
const AG_TUTORIAL_STATE_EXITBIZ = 9;
|
||||
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;
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -12,48 +12,66 @@
|
||||
|
||||
function initEventScript() {
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
|
||||
addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle);
|
||||
addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle);
|
||||
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);
|
||||
|
||||
@@ -306,33 +313,3 @@ 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();
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
@@ -55,3 +27,42 @@ 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");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
if(hotBarSlot == 0) {
|
||||
hotBarSlot = -1;
|
||||
} else {
|
||||
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(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])}]`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,3 +1079,106 @@ 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
11
scripts/server/item/drink.js
Normal file
11
scripts/server/item/drink.js
Normal file
@@ -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)
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
11
scripts/server/item/food.js
Normal file
11
scripts/server/item/food.js
Normal file
@@ -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)
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
11
scripts/server/item/phone.js
Normal file
11
scripts/server/item/phone.js
Normal file
@@ -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)
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
103
scripts/server/item/walkie-talkie.js
Normal file
103
scripts/server/item/walkie-talkie.js
Normal file
@@ -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))}`)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1545,3 +1519,55 @@ function getJobIndexFromDatabaseId(databaseId) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -281,3 +281,13 @@ function getPlayerInfoCommand(command, params, client) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function playerChangeAFKState(client, afkState) {
|
||||
if(afkState) {
|
||||
setEntityData(client, "ag.afk", true, true);
|
||||
} else {
|
||||
client.removeData("ag.afk");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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);
|
||||
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`);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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,21 +99,12 @@ 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;
|
||||
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))}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1040,3 +1022,40 @@ function createPermanentVehicle(modelId, position, heading) {
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
@@ -133,3 +137,9 @@ function logToConsole(tempLogLevel, text) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function isSamePlayer(client1, client2) {
|
||||
return (client1 == client2);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user