No message. 83 files changed.

This commit is contained in:
Vortrex
2021-01-11 10:31:49 -06:00
parent ce8579364c
commit 7f2ee0c8d5
83 changed files with 1544 additions and 746 deletions

View File

@@ -27,6 +27,7 @@
<script src="scripts/server/developer.js" type="server" language="javascript" /> <script src="scripts/server/developer.js" type="server" language="javascript" />
<script src="scripts/server/discord.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/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/help.js" type="server" language="javascript" />
<script src="scripts/server/house.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" /> <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/taxi.js" type="server" language="javascript" />
<script src="scripts/server/job/weapon.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" /> <script src="scripts/server/startup.js" type="server" language="javascript" />
<!-- Client --> <!-- Client -->
@@ -82,6 +88,7 @@
<script src="scripts/client/sync.js" type="client" language="javascript" /> <script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/scoreboard.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/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/label.js" type="client" language="javascript" />
<script src="scripts/client/mouse-camera.js" type="client" language="javascript" /> <script src="scripts/client/mouse-camera.js" type="client" language="javascript" />

75
scripts/client/chatbox.js Normal file
View 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);
}
}
}
// ---------------------------------------------------------------------------

View File

@@ -2178,7 +2178,11 @@ addNetworkHandler("ag.guiColour", function(red, green, blue) {
logToConsole(LOG_DEBUG, `[Asshat.GUI] Received new GUI colours from server`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Received new GUI colours from server`);
primaryColour = [red, green, blue]; primaryColour = [red, green, blue];
focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset]; focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset];
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.guiInit", function() {
logToConsole(LOG_DEBUG, `[Asshat.GUI] Initializing MexUI app`); logToConsole(LOG_DEBUG, `[Asshat.GUI] Initializing MexUI app`);
app.init(); app.init();
triggerNetworkEvent("ag.guiReady", true); triggerNetworkEvent("ag.guiReady", true);

View File

@@ -3,26 +3,26 @@
// https://github.com/VortrexFTW/gtac_asshat_rp // https://github.com/VortrexFTW/gtac_asshat_rp
// Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com) // Copyright (c) 2020 Asshat-Gaming (https://asshatgaming.com)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// FILE: afk.js // FILE: keybind.js
// DESC: Provides AFK detection // DESC: Provides keybind features
// TYPE: Client (JavaScript) // TYPE: Client (JavaScript)
// =========================================================================== // ===========================================================================
let lastKeyBindUse = 0; let lastKeyBindUse = 0;
let keyBindDelayTime = 2000; let keyBindDelayTime = 2500;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function bindAccountKey(key, keyState) { function bindAccountKey(key, keyState) {
bindKey(toInteger(key), keyState, function(event) { bindKey(toInteger(key), keyState, function(event) {
if(hasKeyBindDelayElapsed()) { if(hasKeyBindDelayElapsed()) {
triggerNetworkEvent("ag.keybind.trig", key);
lastKeyBindUse = sdl.ticks; lastKeyBindUse = sdl.ticks;
triggerNetworkEvent("ag.useKeyBind", key);
} }
}); });
return false; return false;
} }
addNetworkHandler("ag.keybinds.add", bindAccountKey); addNetworkHandler("ag.addKeyBind", bindAccountKey);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@@ -30,7 +30,7 @@ function unBindAccountKey(key) {
unbindKey(key); unbindKey(key);
return true; return true;
} }
addNetworkHandler("ag.keybinds.del", unBindAccountKey); addNetworkHandler("ag.delKeyBind", unBindAccountKey);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -50,10 +50,6 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
return false; return false;
} }
if(localPlayer.position.distance(position) > 7.5) {
return false;
}
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition); let screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -97,10 +93,6 @@ function renderPropertyExitLabel(position) {
return false; return false;
} }
if(localPlayer.position.distance(position) > 7.5) {
return false;
}
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition); let screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -125,10 +117,6 @@ function renderJobLabel(name, position, jobType) {
return false; return false;
} }
if(localPlayer.position.distance(position) > 7.5) {
return false;
}
let tempPosition = position; let tempPosition = position;
tempPosition.z = tempPosition.z + propertyLabelHeight; tempPosition.z = tempPosition.z + propertyLabelHeight;
let screenPosition = getScreenFromWorldPosition(tempPosition); let screenPosition = getScreenFromWorldPosition(tempPosition);
@@ -160,23 +148,12 @@ function renderJobLabel(name, position, jobType) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function (event) { function processLabelRendering() {
if(!renderHUD) {
return false;
}
if(!renderLabels) {
return false;
}
if(localPlayer != null) { if(localPlayer != null) {
let pickups = getElementsByType(ELEMENT_PICKUP); let pickups = getElementsByType(ELEMENT_PICKUP);
for(let i in pickups) { for(let i in pickups) {
if(pickups[i].getData("ag.label.type") != null) { if(pickups[i].getData("ag.label.type") != null) {
//if(pickups[i].isOnScreen) { if(getDistance(localPlayer.position, pickups[i].position) <= 7.5) {
if(getDistance(localPlayer.position, pickups[i].position)) {
//if(pickups[i].interior == localPlayer.interior) {
//if(pickups[i].dimension == localPlayer.dimension) {
let price = 0; let price = 0;
if(pickups[i].getData("ag.label.price") != null) { if(pickups[i].getData("ag.label.price") != null) {
price = pickups[i].getData("ag.label.price"); price = pickups[i].getData("ag.label.price");
@@ -199,13 +176,10 @@ addEventHandler("OnDrawnHUD", function (event) {
renderPropertyExitLabel(pickups[i].position); renderPropertyExitLabel(pickups[i].position);
break; break;
} }
//}
//}
}
//}
} }
} }
} }
}); }
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -40,24 +40,34 @@ let garbageCollectorInterval = null;
let parkedVehiclePosition = false; let parkedVehiclePosition = false;
let parkedVehicleHeading = false; let parkedVehicleHeading = false;
let renderHUD = false; let renderHUD = true;
let renderLabels = false; let renderLabels = true;
let renderLogo = false; let renderLogo = true;
let renderSmallGameMessage = false; let renderSmallGameMessage = true;
let renderScoreboard = false; let renderScoreboard = true;
let renderHotBar = false; let renderHotBar = true;
let renderItemActionDelay = true;
let logLevel = LOG_DEBUG; let logLevel = LOG_ALL;
let weaponDamageEnabled = {}; 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("OnLocalPlayerEnterSphere", 1);
addEvent("OnLocalPlayerExitSphere", 1); addEvent("OnLocalPlayerExitSphere", 1);
addEvent("OnLocalPlayerEnterVehicle", 1); addEvent("OnLocalPlayerEnteredVehicle", 1);
addEvent("OnLocalPlayerExitVehicle", 1); addEvent("OnLocalPlayerExitedVehicle", 1);
addEvent("OnLocalPlayerSwitchWeapon", 2);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -171,6 +181,7 @@ function getClosestVehicle(pos) {
addNetworkHandler("ag.clearWeapons", function() { addNetworkHandler("ag.clearWeapons", function() {
logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing weapons`); logToConsole(LOG_DEBUG, `[Asshat.Main] Clearing weapons`);
localPlayer.clearWeapons(); localPlayer.clearWeapons();
forceWeapon = 0;
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -178,11 +189,12 @@ addNetworkHandler("ag.clearWeapons", function() {
addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) { addNetworkHandler("ag.giveWeapon", function(weaponId, ammo, active) {
logToConsole(LOG_DEBUG, `[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`); logToConsole(LOG_DEBUG, `[Asshat.Main] Giving weapon ${weaponId} with ${ammo} ammo`);
localPlayer.giveWeapon(weaponId, ammo, active); localPlayer.giveWeapon(weaponId, ammo, active);
forceWeapon = weaponId;
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("onElementStreamIn", function(event, element) { addEventHandler("OnElementStreamIn", function(event, element) {
switch(element.type) { switch(element.type) {
case ELEMENT_VEHICLE: case ELEMENT_VEHICLE:
syncVehicleProperties(element); syncVehicleProperties(element);
@@ -196,6 +208,10 @@ addEventHandler("onElementStreamIn", function(event, element) {
syncPlayerProperties(element); syncPlayerProperties(element);
break; break;
case ELEMENT_OBJECT:
syncObjectProperties(element);
break;
default: default:
break; break;
} }
@@ -305,6 +321,8 @@ function initLocalPlayer(player) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processEvent(event, deltaTime) { function processEvent(event, deltaTime) {
gta.clearMessages();
if(localPlayer != null) { if(localPlayer != null) {
localPlayer.wantedLevel = 0; localPlayer.wantedLevel = 0;
@@ -361,29 +379,27 @@ function processEvent(event, deltaTime) {
if(localPlayer.vehicle) { if(localPlayer.vehicle) {
if(!inVehicle) { if(!inVehicle) {
triggerNetworkEvent("ag.onPlayerEnterVehicle");
inVehicle = localPlayer.vehicle; inVehicle = localPlayer.vehicle;
inVehicleSeat = getLocalPlayerVehicleSeat(); inVehicleSeat = getLocalPlayerVehicleSeat();
triggerEvent("OnLocalPlayerEnteredVehicle", inVehicle, inVehicleSeat);
if(inVehicleSeat == 0) {
inVehicle.engine = false;
if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading;
}
}
} }
} else { } else {
if(inVehicle) { if(inVehicle) {
triggerNetworkEvent("ag.onPlayerExitVehicle"); triggerEvent("OnLocalPlayerExitedVehicle", inVehicle, inVehicleSeat);
if(inVehicleSeat) {
parkedVehiclePosition = false;
parkedVehicleHeading = false;
}
inVehicle = false; inVehicle = false;
inVehicleSeat = 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 != "") { if(smallGameMessageFont != "") {
smallGameMessageFont.render(smallGameMessageText, [0, gta.height-50], gta.width, 0.5, 0.0, smallGameMessageFont.size, smallGameMessageColour, true, true, false, true); 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(renderScoreboard) {
if(localPlayer != nul && isKeyDown()) { if(isKeyDown(SDLK_TAB)) {
renderScoreboard(); 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; renderHUD = hudState;
setHUDEnabled(hudState); setHUDEnabled(hudState);
@@ -639,6 +677,7 @@ addNetworkHandler("ag.set2DRendering", function(hudState, labelState, smallGameM
renderSmallGameMessage = smallGameMessageState; renderSmallGameMessage = smallGameMessageState;
renderScoreboard = scoreboardState; renderScoreboard = scoreboardState;
renderHotBar = hotBarState; renderHotBar = hotBarState;
renderItemActionDelay = itemActionDelayState;
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -660,3 +699,36 @@ addEventHandler("OnPedInflictDamage", function(event, damagedPed, damagerEntity,
// } // }
// if(damagerEntity.isType(ELEMENT_PLAYER)) // 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}`);
});

View File

@@ -74,9 +74,9 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
if(health > 0.0) { if(health > 0.0) {
let hx = x-width/2; let hx = x-width/2;
let hy = y-10/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); 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); drawing.drawRectangle(null, [hx+2, hy+2], [(width-4)*health, 10-6], colour, colour, colour, colour);
} }

View File

@@ -24,7 +24,7 @@ bindEventHandler("OnResourceReady", thisResource, function(event, resource) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderScoreboard() { function processScoreboardRendering() {
if(scoreBoardListFont != null && scoreBoardTitleFont != null) { if(scoreBoardListFont != null && scoreBoardTitleFont != null) {
let scoreboardStart = (game.height/2)-(Math.floor(getClients().length/2)*20); 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); let titleSize = scoreBoardTitleFont.measure("PLAYERS", game.width, 0.0, 1.0, 10, false, false);

View File

@@ -87,7 +87,9 @@ function syncVehicleProperties(vehicle) {
vehicle.setSuspensionHeight(suspensionHeight); 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; 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; 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);
});
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: accent.js
// DESC: Provides accent functions and usage // DESC: Provides accent functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: account.js
// DESC: Provides account functions and usage // DESC: Provides account functions and usage
@@ -81,7 +81,7 @@ function toggleAccountGUICommand(command, params, client) {
showPlayerLoginGUI(client); showPlayerLoginGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI`);
} else { } 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)`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled)`);
} }
} else { } else {
@@ -89,7 +89,7 @@ function toggleAccountGUICommand(command, params, client) {
showPlayerRegistrationGUI(client); showPlayerRegistrationGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else { } 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)`); 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; getPlayerData(client).loggedIn = true;
if(doesPlayerHaveStaffPermission(client, "developer") || doesPlayerHaveStaffPermission(client, "manageServer")) { 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; client.administrator = true;
} }
if(getPlayerData(client).subAccounts.length == 0) { if(getPlayerData(client).subAccounts.length == 0) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { 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); setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
} else { } else {
@@ -438,7 +438,7 @@ function loginSuccess(client) {
sendRemovedWorldObjectsToPlayer(client); sendRemovedWorldObjectsToPlayer(client);
sendAccountKeyBindsToClient(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) { function checkLogin(client, password) {
let loginAttemptsRemaining = getEntityData(client, "ag.loginAttemptsRemaining")-1; getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1;
if(isPlayerLoggedIn(client)) { 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)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginSuccess", client); sendPlayerLoginSuccess(client);
} else { } else {
messagePlayerError(client, "You are already logged in!"); messagePlayerError(client, "You are already logged in!");
} }
@@ -557,9 +557,9 @@ function checkLogin(client, password) {
} }
if(!isPlayerRegistered(client)) { 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)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showRegistration", client); showPlayerRegistratonGUI(client);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI`);
} else { } else {
messagePlayerError(client, "Your name is not registered! Use /register to make an account."); messagePlayerError(client, "Your name is not registered! Use /register to make an account.");
@@ -569,36 +569,35 @@ function checkLogin(client, password) {
} }
if(areParamsEmpty(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)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else { } else {
messagePlayerError(client, `You must enter a password! ${loginAttemptsRemaining} tries remaining.`); 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 ${loginAttemptsRemaining} login attempts remaining alert.`); 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; return false;
} }
if(!isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(client.name, password))) { 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)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginFailed", client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); showPlayerLoginFailedGUI(client, `Invalid password! ${getPlayerData(client).loginAttemptsRemaining} tries remaining.`);
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${loginAttemptsRemaining} login attempts remaining alert.`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI with ${getPlayerData(client).loginAttemptsRemaining} login attempts remaining alert.`);
} else { } else {
messagePlayerError(client, `Invalid password! ${loginAttemptsRemaining} tries remaining.`); 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 ${loginAttemptsRemaining} login attempts remaining alert.`); 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; return false;
} }
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginSuccess", client); showPlayerLoginSuccessGUI(client);
} }
loginSuccess(client); loginSuccess(client);
} }
addNetworkHandler("ag.checkLogin", checkLogin);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -607,7 +606,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(isPlayerRegistered(client)) { if(isPlayerRegistered(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.showLogin", client); showPlayerLoginGUI(client);
} else { } else {
messagePlayerError(client, "Your name is already registered!"); messagePlayerError(client, "Your name is already registered!");
} }
@@ -616,7 +615,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(isPlayerLoggedIn(client)) { if(isPlayerLoggedIn(client)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginSuccess", client); showPlayerLoginSuccessGUI(client);
} else { } else {
messagePlayerError(client, "You are already logged in!"); messagePlayerError(client, "You are already logged in!");
} }
@@ -625,7 +624,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(areParamsEmpty(password)) { if(areParamsEmpty(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.registrationFailed", client, "Password cannot be blank!"); showPlayerRegistrationFailedGUI(client, "Password cannot be blank!");
} else { } else {
messagePlayerError(client, "The password cannot be blank!"); messagePlayerError(client, "The password cannot be blank!");
} }
@@ -634,21 +633,21 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(confirmPassword)) { if(areParamsEmpty(confirmPassword)) {
triggerNetworkEvent("ag.registrationFailed", client, "Password confirm cannot be blank!"); showPlayerRegistrationFailedGUI(client, "Password confirm cannot be blank!");
return false; return false;
} }
} }
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(areParamsEmpty(emailAddress)) { if(areParamsEmpty(emailAddress)) {
triggerNetworkEvent("ag.registrationFailed", client, "Email address cannot be blank!"); showPlayerRegistrationFailedGUI(client, "Email address cannot be blank!");
return false; return false;
} }
} }
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(password != confirmPassword) { if(password != confirmPassword) {
triggerNetworkEvent("ag.registrationFailed", client, "The passwords must match!"); showPlayerRegistrationFailedGUI(client, "The passwords must match!");
return false; return false;
} }
} }
@@ -656,7 +655,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(!doesPasswordMeetRequirements(password)) { if(!doesPasswordMeetRequirements(password)) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
// Work on this later. Function should return true by default anyway for now. // 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 { } else {
messagePlayerError(client, "Password doesn't meet requirements!"); messagePlayerError(client, "Password doesn't meet requirements!");
} }
@@ -665,7 +664,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
if(!isValidEmailAddress(emailAddress)) { if(!isValidEmailAddress(emailAddress)) {
triggerNetworkEvent("ag.registrationFailed", client, "You must put a valid email!"); showPlayerRegistrationFailedGUI(client, "You must put a valid email!");
return false return false
} }
} }
@@ -673,9 +672,9 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
let accountData = createAccount(client.name, password, emailAddress); let accountData = createAccount(client.name, password, emailAddress);
if(!accountData) { if(!accountData) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { 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 { } 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."); 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."); messagePlayerAlert(client, "To play on the server, you will need to make a character.");
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.registrationSuccess", client); showPlayerRegistrationSuccessGUI(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); setEntityData(client, "ag.prompt", AG_PROMPT_CREATEFIRSTCHAR, false);
} else { } else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`); messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
} }
}; };
addNetworkHandler("ag.checkRegistration", checkRegistration);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -751,7 +749,9 @@ function initClient(client) {
return false; return false;
} }
triggerNetworkEvent("ag.guiColour", client, getServerConfig().guiColour[0], getServerConfig().guiColour[1], getServerConfig().guiColour[2]); sendPlayerGUIColours(client);
sendPlayerGUIInit(client);
showConnectCameraToPlayer(client); showConnectCameraToPlayer(client);
messageClient(`Please wait ...`, client, getColourByName("softGreen")); messageClient(`Please wait ...`, client, getColourByName("softGreen"));
@@ -775,19 +775,19 @@ function initClient(client) {
} else { } else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login GUI.`);
triggerNetworkEvent("ag.showLogin", client); showPlayerLoginGUI(client);
} else { } else {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); 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 { } else {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register GUI.`);
triggerNetworkEvent("ag.showRegistration", client); showPlayerRegistrationGUI(client);
} else { } else {
logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`); 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) { function getPlayerStaffTitle(client) {
return getPlayerData(client).accountData.staffTitle; return getPlayerData(client).accountData.staffTitle;
} }
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: ammunation.js
// DESC: Provides ammunation functions and usage // DESC: Provides ammunation functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: anticheat.js
// DESC: Provides anticheat functions and usage // DESC: Provides anticheat functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: bans.js
// DESC: Provides ban functions and usage // DESC: Provides ban functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: bitflags.js
// DESC: Provides bitwise operations, functions and usage // DESC: Provides bitwise operations, functions and usage
@@ -138,6 +138,14 @@ function createBitFlagTable(keyNames) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function hasBitFlag(allFlags, checkForFlag) { function hasBitFlag(allFlags, checkForFlag) {
if(allFlags == 0) {
return false;
}
if(allFlags == -1) {
return true;
}
return (allFlags & checkForFlag); return (allFlags & checkForFlag);
} }
@@ -153,10 +161,8 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
} }
let staffFlags = 0; let staffFlags = 0;
if(!isClientFromDiscord(client)) { if(getPlayerData(client)) {
staffFlags = getPlayerData(client).accountData.flags.admin; 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) // -1 is automatic override (having -1 for staff flags is basically god mode admin level)
@@ -320,3 +326,5 @@ function getServerBitFlags() {
function getServerBitFlagKeys() { function getServerBitFlagKeys() {
return serverBitFlagKeys; return serverBitFlagKeys;
} }
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: business.js
// DESC: Provides business functions and usage // 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) { function getBusinessDataFromDatabaseId(databaseId) {
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId) let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
if(matchingBusinesses.length == 1) { if(matchingBusinesses.length == 1) {
@@ -739,7 +715,7 @@ function saveBusinessToDatabase(businessId) {
if(dbConnection) { if(dbConnection) {
let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name);
if(tempBusinessData.databaseId == 0) { 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); queryDatabase(dbConnection, dbQueryString);
getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection); getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection);
} else { } else {

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: bakery.js
// DESC: Provides bakery business functions and usage // DESC: Provides bakery business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: bar.js
// DESC: Provides bar/pub business functions and usage // DESC: Provides bar/pub business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: burger.js
// DESC: Provides burger joint (McDonalds?) business functions and usage // DESC: Provides burger joint (McDonalds?) business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: clothing.js
// DESC: Provides clothing (skin) business functions and usage // DESC: Provides clothing (skin) business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: club.js
// DESC: Provides club/nightclub business functions and usage // DESC: Provides club/nightclub business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: fuel.js
// DESC: Provides fuel/petrol business functions and usage // DESC: Provides fuel/petrol business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: mechanic.js
// DESC: Provides mechanic/vehicle repair business functions and usage // DESC: Provides mechanic/vehicle repair business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: pizza.js
// DESC: Provides pizza restaurant business functions and usage // DESC: Provides pizza restaurant business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: restaurant.js
// DESC: Provides generic restaurant business functions and usage // DESC: Provides generic restaurant business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: vehicle.js
// DESC: Provides vehicle dealership business functions and usage // DESC: Provides vehicle dealership business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: weapon.js
// DESC: Provides weapon (ammu) business functions and usage // DESC: Provides weapon (ammu) business functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: chat.js
// DESC: Provides chat functions and usage // DESC: Provides chat functions and usage
@@ -99,7 +99,7 @@ function clanChatCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function talkToNearbyPlayers(client, messageText) { function talkToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance); let clients = getClientsInRange(getPlayerPosition(client), getGlobalConfig().talkDistance);
for(let i in clients) { for(let i in clients) {
//if(clients[i] != client) { //if(clients[i] != client) {
messagePlayerTalk(getClientFromPlayerElement(clients[i]), client, messageText); 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) { function whisperToNearbyPlayers(client, messageText) {
let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance); let clients = getClientsInRange(client.player.position, getGlobalConfig().talkDistance);
for(let i in clients) { for(let i in clients) {

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: clan.js
// DESC: Provides clan functions and usage // DESC: Provides clan functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: class.js
// DESC: Provides classes // DESC: Provides classes
@@ -101,6 +101,7 @@ function initClassTable() {
this.index = -1; this.index = -1;
this.connectTime = 0; this.connectTime = 0;
this.clientVersion = "0.0.0"; this.clientVersion = "0.0.0";
this.loginAttemptsRemaining = 3;
this.busRoute = null; this.busRoute = null;
this.busRouteStop = null; this.busRouteStop = null;
@@ -128,10 +129,14 @@ function initClassTable() {
this.tutorialVehicle = null; this.tutorialVehicle = null;
this.hotBarItems = new Array(9).fill(-1); this.hotBarItems = new Array(9).fill(-1);
this.activeHotBarSlot = 0; this.activeHotBarSlot = -1;
this.toggleUseItem = false;
this.jobLockerCache = new Array(9).fill(-1); this.jobLockerCache = new Array(9).fill(-1);
this.jobEquipmentCache = []; this.jobEquipmentCache = [];
this.itemActionState = AG_ITEM_ACTION_NONE;
this.itemActionItem = -1;
} }
}, },
accountData: class { accountData: class {
@@ -302,7 +307,6 @@ function initClassTable() {
this.interior = dbAssoc["sacct_int"]; this.interior = dbAssoc["sacct_int"];
this.dimension = dbAssoc["sacct_vw"]; this.dimension = dbAssoc["sacct_vw"];
this.pedScale = toVector3(dbAssoc["sacct_scale_x"], dbAssoc["sacct_scale_y"], dbAssoc["sacct_scale_z"]); 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.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1; this.jobIndex = -1;
this.jobIndex = -1;
this.needsSaved = false; this.needsSaved = false;
if(dbAssoc) { if(dbAssoc) {
@@ -909,6 +912,7 @@ function initClassTable() {
this.needsSaved = false; this.needsSaved = false;
this.amount = 0; this.amount = 0;
this.value = 0; this.value = 0;
this.enabled = false;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["item_id"]); this.databaseId = toInteger(dbAssoc["item_id"]);
@@ -923,6 +927,7 @@ function initClassTable() {
this.buyPrice = toInteger(dbAssoc["item_buy_price"]); this.buyPrice = toInteger(dbAssoc["item_buy_price"]);
this.amount = toInteger(dbAssoc["item_amount"]); this.amount = toInteger(dbAssoc["item_amount"]);
this.value = toInteger(dbAssoc["item_value"]); this.value = toInteger(dbAssoc["item_value"]);
this.enabled = intToBool(toInteger(dbAssoc["item_enabled"]));
} }
} }
}, },
@@ -943,6 +948,12 @@ function initClassTable() {
this.dropModel = 0; this.dropModel = 0;
this.orderPrice = 0; this.orderPrice = 0;
this.needsSaved = false; this.needsSaved = false;
this.switchDelay = 0;
this.pickupDelay = 0;
this.putDelay = 0;
this.takeDelay = 0;
this.giveDelay = 0;
this.dropDelay = 0;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["item_type_id"]); this.databaseId = toInteger(dbAssoc["item_type_id"]);
@@ -963,6 +974,13 @@ function initClassTable() {
this.orderPrice = toInteger(dbAssoc["item_type_order_price"]); this.orderPrice = toInteger(dbAssoc["item_type_order_price"]);
this.size = toInteger(dbAssoc["item_type_size"]); this.size = toInteger(dbAssoc["item_type_size"]);
this.capacity = toInteger(dbAssoc["item_type_capacity"]); 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) {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -1,75 +1,67 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: client.js
// DESC: Provides client communication and cross-endpoint operations // DESC: Provides client communication and cross-endpoint operations
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// --------------------------------------------------------------------------- function initClientScript() {
logToConsole(LOG_DEBUG, "[Asshat.Client]: Initializing client script ...");
addNetworkHandler("ag.promptAnswerNo", function(client) { addAllNetworkHandlers();
if(!getEntityData(client, "ag.prompt")) { logToConsole(LOG_DEBUG, "[Asshat.Clan]: Initializing client script ...");
return false;
} }
switch(getEntityData(client, "ag.prompt")) {
case AG_PROMPT_CREATEFIRSTCHAR:
triggerNetworkEvent("ag.showError", client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000);
break;
default:
break;
}
client.removeData("ag.prompt");
});
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.promptAnswerYes", function(client) { function addAllNetworkHandlers() {
if(!getEntityData(client, "ag.prompt")) { logToConsole(LOG_DEBUG, "[Asshat.Client]: Adding network handlers ...");
return false;
// 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) { function updatePlayerNameTag(client) {
@@ -93,37 +85,30 @@ function updatePlayerPing(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.arrivedAtBusStop", function(client) { function playerClientReady(client) {
logToConsole(LOG_DEBUG, client);
arrivedAtBusStop(client);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.clientReady", function(client) {
setEntityData(client, "ag.isReady", true, false); setEntityData(client, "ag.isReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(client.getData("ag.isStarted") == true) { if(client.getData("ag.isStarted") == true) {
initClient(client); initClient(client);
} }
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.guiReady", function(client) { function playerGUIReady(client) {
setEntityData(client, "ag.guiReady", true, false); setEntityData(client, "ag.guiReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`); 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); setEntityData(client, "ag.isStarted", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(client.getData("ag.isReady") == true) { if(client.getData("ag.isReady") == true) {
initClient(client); initClient(client);
} }
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -182,8 +167,8 @@ function restorePlayerCamera(client) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setPlayer2DRendering(client, hudState = false, labelState = false, smallGameMessageState = false, scoreboardState = false, hotBarState = false) { function setPlayer2DRendering(client, hudState = false, labelState = false, smallGameMessageState = false, scoreboardState = false, hotBarState = false, itemActionDelayState = false) {
triggerNetworkEvent("ag.set2DRendering", client, hudState, labelState, smallGameMessageState, scoreboardState, hotBarState); triggerNetworkEvent("ag.set2DRendering", client, hudState, labelState, smallGameMessageState, scoreboardState, hotBarState, itemActionDelayState);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -201,7 +186,7 @@ function updatePlayerSnowState(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function sendExcludedModelsForGroundSnowToPlayer(client) { function sendExcludedModelsForGroundSnowToPlayer(client) {
if(getGameConfig().excludedGroundSnowModels[getServerGame()]) { if(getGameConfig().excludedGroundSnowModels[getServerGame()].length > 0) {
for(let i in getGameConfig().excludedGroundSnowModels[getServerGame()]) { for(let i in getGameConfig().excludedGroundSnowModels[getServerGame()]) {
logToConsole(LOG_DEBUG, `[Asshat.Misc] Sending excluded model ${i} for ground snow to ${client.name}`); logToConsole(LOG_DEBUG, `[Asshat.Misc] Sending excluded model ${i} for ground snow to ${client.name}`);
triggerNetworkEvent("ag.excludeGroundSnow", client, getGameConfig().excludedGroundSnowModels[getServerGame()][i]); triggerNetworkEvent("ag.excludeGroundSnow", client, getGameConfig().excludedGroundSnowModels[getServerGame()][i]);
@@ -252,3 +237,227 @@ function setPlayerWeaponDamageEnabled(client, state) {
function setPlayerWeaponDamageEvent(client, eventType) { function setPlayerWeaponDamageEvent(client, eventType) {
triggerNetworkEvent("ag.weaponDamageEvent", null, client.name, 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);
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: colour.js
// DESC: Provides colours, functions and usage // DESC: Provides colours, functions and usage
@@ -78,7 +78,7 @@ function getPlayerColour(client) {
return getColourByName("darkGrey"); return getColourByName("darkGrey");
} else { } else {
if(isPlayerWorking(client)) { if(isPlayerWorking(client)) {
return getJobData(getPlayerCurrentSubAccount(client).job).colour; return getJobData(getJobIndexFromDatabaseId(getPlayerCurrentSubAccount(client).job)).colour;
} }
} }
} }

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: command.js
// DESC: Provides command data, functions and usage // DESC: Provides command data, functions and usage
@@ -188,6 +188,11 @@ function loadCommands() {
commandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("none"), true, false), commandData("houseitems", listHouseInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("none"), true, false), commandData("bizstorage", listBusinessStorageInventoryCommand, "", getStaffFlagValue("none"), true, false),
commandData("bizfloor", listBusinessFloorInventoryCommand, "", 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: [ job: [
commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false), commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false),

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: config.js
// DESC: Provides server configuration // DESC: Provides server configuration
@@ -36,7 +36,7 @@ let globalConfig = {
new serverClasses.keyBindData(false, toInteger(SDLK_m), "cursor"), new serverClasses.keyBindData(false, toInteger(SDLK_m), "cursor"),
new serverClasses.keyBindData(false, toInteger(SDLK_o), "drop"), new serverClasses.keyBindData(false, toInteger(SDLK_o), "drop"),
new serverClasses.keyBindData(false, toInteger(SDLK_p), "pickup"), 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_i), "inv"),
new serverClasses.keyBindData(false, toInteger(SDLK_0), "i 0"), new serverClasses.keyBindData(false, toInteger(SDLK_0), "i 0"),
new serverClasses.keyBindData(false, toInteger(SDLK_1), "i 1"), new serverClasses.keyBindData(false, toInteger(SDLK_1), "i 1"),
@@ -55,6 +55,10 @@ let globalConfig = {
houseDimensionStart: 100, houseDimensionStart: 100,
buyVehicleDriveAwayDistance: 25.0, buyVehicleDriveAwayDistance: 25.0,
returnToJobVehicleTime: 30, returnToJobVehicleTime: 30,
walkieTalkieSpeakerDistance: 15,
walkieTalkieTalkDistance: 15,
phoneSpeakerDistance: 15,
phoneTalkDistance: 15,
}; };
let gameConfig = { let gameConfig = {
@@ -605,7 +609,7 @@ function setSnowingCommand(command, params, client) {
getServerConfig().fallingSnow = fallingSnow; getServerConfig().fallingSnow = fallingSnow;
getServerConfig().groundSnow = groundSnow; 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)}`); messageAdminAction(`${client.name} turned falling snow ${getBoolRedGreenInlineColour(fallingSnow)}${getOnOffFromBool(fallingSnow)} [#FFFFFF]and ground snow ${getBoolRedGreenInlineColour(groundSnow)}${getOnOffFromBool(groundSnow)}`);
updateServerRules(); updateServerRules();
@@ -629,7 +633,7 @@ function toggleServerLogoCommand(command, params, client) {
getServerConfig().useLogo = !getServerConfig().useLogo; 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))}`); messageAdminAction(`${client.name} turned the server logo image ${getBoolRedGreenInlineColour(getServerConfig().useLogo)}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules(); updateServerRules();

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: const.js
// DESC: Provides constants // 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_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_COFFEE = 23; // Replenishes moderate amount of health.
const AG_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine. const AG_ITEM_USETYPE_AMMO_ROUND = 23; // Bullet. Loads into magazine.
const AG_ITEM_USETYPE_HANDCUFF = 24; const AG_ITEM_USETYPE_HANDCUFF = 24; //
const AG_ITEM_USETYPE_ROPE = 25; const AG_ITEM_USETYPE_ROPE = 25; //
const AG_ITEM_USETYPE_BLINDFOLD = 26; const AG_ITEM_USETYPE_BLINDFOLD = 26; //
const AG_ITEM_USETYPE_TAZER = 27; const AG_ITEM_USETYPE_TAZER = 27; //
const AG_ITEM_USETYPE_ARMOUR = 28; 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 // Item Drop Types
const AG_ITEM_DROPTYPE_NONE = 0; // Can't be dropped 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_TAKEITEM = 7;
const AG_TUTORIAL_STATE_EXITBIZ = 9; const AG_TUTORIAL_STATE_EXITBIZ = 9;
const AG_TUTORIAL_STATE_DROPITEM = 10; 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;

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: core.js
// DESC: Provides core data structures, function, and operations // DESC: Provides core data structures, function, and operations

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: database.js
// DESC: Provides database handling, functions and usage // DESC: Provides database handling, functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: developer.js
// DESC: Provides developer operation, commands, functions and usage // DESC: Provides developer operation, commands, functions and usage
@@ -223,7 +223,7 @@ function executeClientCodeCommand(command, params, client) {
return false; return false;
} }
triggerNetworkEvent("ag.runCode", targetClient, targetCode, client.index); sendRunCodeToClient(client, targetClient, targetCode, client.index);
messagePlayerSuccess(client, "Executing client code for " + toString(targetClient.name) + "!"); messagePlayerSuccess(client, "Executing client code for " + toString(targetClient.name) + "!");
messagePlayerNormal(client, "Code: " + targetCode); messagePlayerNormal(client, "Code: " + targetCode);
@@ -242,7 +242,7 @@ function saveAllServerDataCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function restartGameModeCommand(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"); consoleCommand("refresh");
thisResource.restart(); thisResource.restart();
return true; 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]; let returnClient = getClients()[returnTo];
if(!returnClient) { if(!returnClient) {
return false; return false;
@@ -258,11 +258,11 @@ addNetworkHandler("ag.runCodeFail", function(client, returnTo, code) {
messagePlayerError(returnClient, `Client code failed to execute for ${client.name}!`); messagePlayerError(returnClient, `Client code failed to execute for ${client.name}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow")); messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.runCodeSuccess", function(client, returnTo, returnVal, code) { function clientRunCodeSuccess(client, returnTo, returnVal, code) {
let returnClient = getClients()[returnTo]; let returnClient = getClients()[returnTo];
if(!returnClient) { if(!returnClient) {
return false; return false;
@@ -271,7 +271,7 @@ addNetworkHandler("ag.runCodeSuccess", function(client, returnTo, returnVal, cod
messagePlayerSuccess(returnClient, `Client code executed for ${client.name}!`); messagePlayerSuccess(returnClient, `Client code executed for ${client.name}!`);
messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow")); messagePlayerNormal(returnClient, `Code: ${code}`, getColourByName("yellow"));
messagePlayerNormal(returnClient, `Returns: ${returnVal}`, getColourByName("yellow")); messagePlayerNormal(returnClient, `Returns: ${returnVal}`, getColourByName("yellow"));
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage // DESC: Provides discord bridging and connection functions and usage
@@ -57,6 +57,10 @@ function sendDiscordSocketData(socketData) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function isClientFromDiscord(client) { function isClientFromDiscord(client) {
if(client == null) {
return false;
}
if(client instanceof Client) { if(client instanceof Client) {
return false; return false;
} else { } else {

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: event.js
// DESC: Provides handlers for built in GTAC and Asshat-Gaming created events // DESC: Provides handlers for built in GTAC and Asshat-Gaming created events
@@ -12,48 +12,66 @@
function initEventScript() { function initEventScript() {
logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ..."); logToConsole(LOG_DEBUG, "[Asshat.Event]: Initializing event script ...");
addNetworkHandler("ag.onPlayerEnterVehicle", playerEnteredVehicle); addAllEventHandlers();
addNetworkHandler("ag.onPlayerExitVehicle", playerExitedVehicle);
logToConsole(LOG_DEBUG, "[Asshat.Event]: Event script initialized!"); 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})`); logToConsole(LOG_DEBUG, `[Asshat.Event] Client connecting (IP: ${ipAddress})`);
if(isIpAddressBanned(ipAddress)) { if(isIpAddressBanned(ipAddress)) {
messagePlayerError(client, "You are banned from this server!"); messagePlayerError(client, "You are banned from this server!");
return false; return false;
} }
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("OnPlayerJoin", function(event, client) { function onPlayerJoin(event, client) {
fadeCamera(client, true, 1.0); fadeCamera(client, true, 1.0);
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("OnPlayerJoined", function(event, client) { function onPlayerJoined(event, client) {
//message(`👋 ${client.name} has joined the server`, getColourByName("softYellow"));
}); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) { function onPlayerQuit(event, client, quitReasonId) {
logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`); logToConsole(LOG_DEBUG, `[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
//savePlayerToDatabase(client); //savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
getServerData().clients[client.index] = null; 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(); event.preventDefault();
if(!getPlayerData(client).loggedIn) { if(!getPlayerData(client).loggedIn) {
messagePlayerError(client, "You need to login before you can chat!"); 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); 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) { function onProcess(event, deltaTime) {
//if(!vehicle || vehicle.owner != -1) { checkVehicleBuying();
// return false; }
//}
//if(!getVehicleData(vehicle)) {
// return false;
//}
});
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addEventHandler("OnProcess", function(event, deltaTime) { function onPedEnteringVehicle(event, ped, vehicle, seat) {
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;
//}
if(!getVehicleData(vehicle)) { if(!getVehicleData(vehicle)) {
return false; 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) { if(client.player == null) {
return false; return false;
} }
@@ -208,7 +215,7 @@ async function playerEnteredVehicle(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function playerExitedVehicle(client) { function onPlayerExitedVehicle(client) {
let vehicle = getPlayerData(client).lastVehicle; let vehicle = getPlayerData(client).lastVehicle;
if(!getVehicleData(vehicle)) { if(!getVehicleData(vehicle)) {
@@ -228,7 +235,7 @@ function playerExitedVehicle(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processPlayerDeath(client, position) { function onPlayerDeath(client, position) {
updatePlayerSpawnedState(client, false); updatePlayerSpawnedState(client, false);
setPlayerControlState(client, false); setPlayerControlState(client, false);
setTimeout(function() { setTimeout(function() {
@@ -252,17 +259,17 @@ function processPlayerDeath(client, position) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processPedSpawn(ped) { function onPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) { if(ped.type == ELEMENT_PLAYER) {
setTimeout(processPlayerSpawn, 500, ped); setTimeout(onPlayerSpawn, 500, ped);
} }
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processPlayerSpawn(ped) { function onPlayerSpawn(ped) {
if(getClientFromPlayerElement(ped) == null) { if(getClientFromPlayerElement(ped) == null) {
setTimeout(processPlayerSpawn, 500, ped); setTimeout(onPlayerSpawn, 500, ped);
return false; return false;
} }
@@ -289,7 +296,7 @@ function processPlayerSpawn(ped) {
getPlayerData(client).switchingCharacter = false; getPlayerData(client).switchingCharacter = false;
updatePlayerCash(client); updatePlayerCash(client);
updatePlayerJobType(client); updatePlayerJobType(client);
setPlayer2DRendering(client, true, true, true, true, true); setPlayer2DRendering(client, true, true, true, true, true, true);
updatePlayerSnowState(client); updatePlayerSnowState(client);
updatePlayerHotBar(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();
}
});
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: fishing.js
// DESC: Provides fishing functions and commands // DESC: Provides fishing functions and commands

View File

@@ -1,41 +1,13 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: gui.js
// DESC: Provides GUI functions and usage // DESC: Provides GUI functions and usage
// TYPE: Server (JavaScript) // 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) { 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");
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: help.js
// DESC: Provides update info, help commands, and documentation // DESC: Provides update info, help commands, and documentation

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: house.js
// DESC: Provides house commands, functions, and usage // DESC: Provides house commands, functions, and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: item.js
// DESC: Provides item functions and usage // 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 = 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.setRotation(getItemTypeData(getItemData(itemId).itemTypeIndex).dropRotation);
getItemData(itemId).object.dimension = getItemData(itemId).dimension; getItemData(itemId).object.dimension = getItemData(itemId).dimension;
setEntityData(getItemData(itemId).object, "ag.scale", getItemTypeData(getItemData(itemId).itemTypeIndex).dropScale, true);
addToWorld(getItemData(itemId).object); addToWorld(getItemData(itemId).object);
getServerData().groundItemCache.push(itemId); getServerData().groundItemCache.push(itemId);
@@ -146,7 +147,19 @@ function createGroundItemCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function useItemCommand(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]; let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
@@ -162,10 +175,17 @@ function useItemCommand(command, params, client) {
return false; 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; if(getPlayerData(client).itemOccupiedDelay) {
updatePlayerHotBar(client); return false;
}
getPlayerData(client).itemActionItem = hotBarSlot;
getPlayerData(client).itemOccupiedDelay = true;
showPlayerItemUseDelay(client, hotBarSlot);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -218,9 +238,13 @@ function pickupItemCommand(command, params, client) {
return false; 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; 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).itemActionItem = hotBarSlot;
getPlayerData(client).itemActionState = AG_ITEM_ACTION_DROP;
getPlayerData(client).hotBarItems[hotBarSlot] = -1; showPlayerItemDropDelay(client, itemId);
updatePlayerHotBar(client);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function putItemCommand(command, params, client) { function putItemCommand(command, params, client) {
let hotBarSlot = toInteger(params) || getPlayerData(client).activeHotBarSlot; let hotBarSlot = toInteger(params);
let itemId = getPlayerData(client).hotBarItems[hotBarSlot]; let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
@@ -278,32 +303,13 @@ function putItemCommand(command, params, client) {
return false; return false;
} }
let bestNewOwner = getBestNewOwnerToPutItem(client); if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
return false;
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;
} }
playerPutItem(client, itemId, bestNewOwner[0], bestNewOwner[1]); getPlayerData(client).itemActionItem = hotBarSlot;
getPlayerData(client).itemActionState = AG_ITEM_ACTION_PUT;
getPlayerData(client).hotBarItems[hotBarSlot] = -1; showPlayerItemPutDelay(client, hotBarSlot);
updatePlayerHotBar(client);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -325,48 +331,20 @@ function takeItemCommand(command, params, client) {
return false; return false;
} }
if(!getItemData(itemId)) { if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
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.`);
return false; return false;
} }
if(!getItemTypeData(getItemData(itemId).itemTypeIndex)) { getPlayerData(client).itemActionItem = itemId;
messagePlayerError(client, `The item you're trying to take is bugged. A bug report has been sent to the server developers.`); getPlayerData(client).itemActionState = AG_ITEM_ACTION_TAKE;
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.`); showPlayerItemTakeDelay(client, itemId);
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);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function playerUseItem(client, itemIndex) { function playerUseItem(client, itemIndex) {
let closestPlayer; let closestPlayer;
let tempUseValue;
switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) { switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) {
case AG_ITEM_USETYPE_SKIN: case AG_ITEM_USETYPE_SKIN:
@@ -378,10 +356,7 @@ function playerUseItem(client, itemIndex) {
break; break;
case AG_ITEM_USETYPE_WEAPON: case AG_ITEM_USETYPE_WEAPON:
//let weaponId = getItemTypeData(getItemData(itemIndex).itemTypeIndex).useId; 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.`);
//let ammo = getItemData(itemIndex).useValue;
//givePlayerWeapon(client, weaponId, ammo);
//meActionToNearbyPlayers(client, `changes their clothes to ${getItemData(itemIndex).name}`);
break; break;
case AG_ITEM_USETYPE_PHONE: case AG_ITEM_USETYPE_PHONE:
@@ -393,7 +368,7 @@ function playerUseItem(client, itemIndex) {
break; break;
case AG_ITEM_USETYPE_FOOD: 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); givePlayerHealth(client, tempUseValue);
if(getItemData(itemIndex).value-tempUseValue <= 0) { if(getItemData(itemIndex).value-tempUseValue <= 0) {
getPlayerData(client).hotBarItems[getPlayerData(client).hotBarItems.indexOf(itemIndex)] = -1; getPlayerData(client).hotBarItems[getPlayerData(client).hotBarItems.indexOf(itemIndex)] = -1;
@@ -401,11 +376,11 @@ function playerUseItem(client, itemIndex) {
} else { } else {
getItemData(itemIndex).value = getItemData(itemIndex).value-tempUseValue; 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; break;
case AG_ITEM_USETYPE_DRINK: 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); givePlayerHealth(client, tempUseValue);
getItemData(itemIndex).value = getItemData(itemIndex).value - tempUseValue; getItemData(itemIndex).value = getItemData(itemIndex).value - tempUseValue;
if(getItemData(itemIndex).value-tempUseValue <= 0) { if(getItemData(itemIndex).value-tempUseValue <= 0) {
@@ -413,7 +388,7 @@ function playerUseItem(client, itemIndex) {
deleteItem(itemIndex); deleteItem(itemIndex);
} else { } else {
getItemData(itemIndex).value = getItemData(itemIndex).value-tempUseValue; 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; break;
@@ -444,111 +419,220 @@ function playerUseItem(client, itemIndex) {
return false; return false;
} }
break; 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; getItemData(itemIndex).needsSaved = true;
updatePlayerHotBar(client); updatePlayerHotBar(client);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function playerDropItem(client, itemIndex) { function playerDropItem(client, hotBarSlot) {
getItemData(itemIndex).ownerType = AG_ITEM_OWNER_GROUND; let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
getItemData(itemIndex).ownerId = 0; if(itemId != -1) {
getItemData(itemIndex).position = getPlayerPosition(client); meActionToNearbyPlayers(client, `drops ${getProperDeterminerForName(getItemTypeData(getItemData(itemId).itemTypeIndex).name)} ${getItemTypeData(getItemData(itemId).itemTypeIndex).name} on the ground`);
getItemData(itemIndex).dimension = getPlayerDimension(client);
createGroundItemObject(itemIndex); getPlayerData(client).hotBarItems[hotBarSlot] = -1;
getItemData(itemIndex).needsSaved = true; 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) { function playerPutItem(client, hotBarSlot) {
getItemData(itemIndex).ownerType = ownerType; let itemId = getPlayerData(client).hotBarItems[hotBarSlot];
getItemData(itemIndex).ownerId = ownerId;
getItemData(itemIndex).position = toVector(0.0, 0.0, 0.0); let bestNewOwner = getBestNewOwnerToPutItem(client);
getItemData(itemIndex).dimension = 0;
getItemData(itemIndex).needsSaved = true; 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); let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
if(firstSlot != -1) { if(firstSlot != -1) {
getItemData(itemIndex).ownerType = AG_ITEM_OWNER_PLAYER; getItemData(itemId).ownerType = AG_ITEM_OWNER_PLAYER;
getItemData(itemIndex).ownerId = getPlayerCurrentSubAccount(client).databaseId; getItemData(itemId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getItemData(itemIndex).position = toVector3(0.0, 0.0, 0.0); getItemData(itemId).position = toVector3(0.0, 0.0, 0.0);
getItemData(itemIndex).dimension = 0; getItemData(itemId).dimension = 0;
deleteGroundItemObject(itemIndex); deleteGroundItemObject(itemIndex);
getPlayerData(client).hotBarItems[firstSlot] = itemIndex; getPlayerData(client).hotBarItems[firstSlot] = itemId;
updatePlayerHotBar(client); 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); let firstSlot = getPlayerFirstEmptyHotBarSlot(client);
if(firstSlot != -1) { if(firstSlot != -1) {
getItemData(itemIndex).ownerType = AG_ITEM_OWNER_PLAYER; getItemData(itemId).ownerType = AG_ITEM_OWNER_PLAYER;
getItemData(itemIndex).ownerId = getPlayerCurrentSubAccount(client).databaseId; getItemData(itemId).ownerId = getPlayerCurrentSubAccount(client).databaseId;
getPlayerData(client).hotBarItems[firstSlot] = itemIndex; getPlayerData(client).hotBarItems[firstSlot] = itemId;
updatePlayerHotBar(client); 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) { function playerSwitchHotBarSlotCommand(command, params, client) {
if(areParamsEmpty(params)) { if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let hotBarSlot = toInteger(params) || getPlayerData(client).activeHotBarSlot; let hotBarSlot = toInteger(params);
if(hotBarSlot < 0 || hotBarSlot > 9) { 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; return false;
} }
if(hotBarSlot == 0) {
hotBarSlot = -1;
} else {
hotBarSlot = hotBarSlot-1; 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(getPlayerData(client).activeHotBarSlot == hotBarSlot) {
if(getItemTypeData(getItemData(getPlayerData(client).hotBarItems[hotBarSlot]).itemTypeIndex).useType == AG_ITEM_USETYPE_WEAPON) { return false;
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).hotBarItems[currentHotBarSlot] != -1 && getPlayerData(client).hotBarItems[hotBarSlot] != -1) { if(getPlayerData(client).itemActionState != AG_ITEM_ACTION_NONE) {
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}`); return false;
} 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}`);
} }
getPlayerData(client).activeHotBarSlot = hotBarSlot; getPlayerData(client).itemActionItem = hotBarSlot;
updatePlayerHotBar(client); 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) { if(getPlayerData(client).hotBarItems[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA](Empty)`); itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}: [#AAAAAA](Empty)`);
} else { } 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) { if(getBusinessData(businessId).storageItemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`); itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else { } 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) { if(getBusinessData(businessId).floorItemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`); itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else { } 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) { if(getHouseData(houseId).itemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`); itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else { } 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) { if(getItemData(itemId).itemCache[i] == -1) {
itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`); itemDisplay.push(`[#CCCCCC]${toInteger(i)+1}[#AAAAAA](Empty)`);
} else { } 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];
}
}
}
// ---------------------------------------------------------------------------

View 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)
// ===========================================================================
// ---------------------------------------------------------------------------

View 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)
// ===========================================================================
// ---------------------------------------------------------------------------

View 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)
// ===========================================================================
// ---------------------------------------------------------------------------

View 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))}`)
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: job.js
// DESC: Provides job functions and usage // DESC: Provides job functions and usage
@@ -371,7 +371,7 @@ function startWorkingCommand(command, params, client) {
return false; return false;
} }
if(getPlayerCurrentSubAccount(client).job != closestJobLocation.jobIndex) { if(getPlayerCurrentSubAccount(client).job != closestJobLocation.job) {
messagePlayerError(client, "This is not your job!"); messagePlayerError(client, "This is not your job!");
messagePlayerInfo(client, `If you want this job, use /quitjob to quit your current job.`); messagePlayerInfo(client, `If you want this job, use /quitjob to quit your current job.`);
return false; return false;
@@ -456,7 +456,7 @@ function startWorking(client) {
} }
updatePlayerNameTag(client); updatePlayerNameTag(client);
triggerNetworkEvent("ag.working", client, true); sendPlayerWorkingState(client, true);
//showStartedWorkingTip(client); //showStartedWorkingTip(client);
} }
@@ -473,11 +473,6 @@ function getJobInfoCommand(command, params, client) {
function getJobLocationInfoCommand(command, params, client) { function getJobLocationInfoCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(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}`); 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); 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 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); let freeSlot = getPlayerFirstEmptyHotBarSlot(client);
getPlayerData(client).hotBarItems[freeSlot] = itemId;
getPlayerData(client).jobEquipmentCache.push(itemId); getPlayerData(client).jobEquipmentCache.push(itemId);
updatePlayerHotBar(client);
} }
} }
@@ -570,7 +568,7 @@ function stopWorking(client) {
} }
updatePlayerNameTag(client); updatePlayerNameTag(client);
triggerNetworkEvent("ag.working", client, false); sendPlayerWorkingState(client, false);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -712,14 +710,14 @@ function getJobData(jobId) {
function quitJob(client) { function quitJob(client) {
stopWorking(client); stopWorking(client);
getPlayerCurrentSubAccount(client).job = AG_JOB_NONE; getPlayerCurrentSubAccount(client).job = AG_JOB_NONE;
triggerNetworkEvent("ag.jobType", client, AG_JOB_NONE); sendPlayerJobType(client, jobType);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function takeJob(client, jobId) { function takeJob(client, jobId) {
getPlayerCurrentSubAccount(client).job = jobId; getPlayerCurrentSubAccount(client).job = getJobData(jobId).databaseId;
triggerNetworkEvent("ag.jobType", client, jobId); sendPlayerJobType(client, getJobData(jobId).databaseId);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1070,7 +1068,7 @@ function startJobRoute(client) {
function stopJobRoute(client, successful = false) { function stopJobRoute(client, successful = false) {
stopReturnToJobVehicleCountdown(client); stopReturnToJobVehicleCountdown(client);
triggerNetworkEvent("ag.stopJobRoute", client); sendPlayerStopJobRoute(client);
if(doesPlayerHaveJobType(client, AG_JOB_BUS)) { if(doesPlayerHaveJobType(client, AG_JOB_BUS)) {
respawnVehicle(getPlayerData(client).busRouteVehicle); 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) { function canPlayerUseJob(client, jobId) {
if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageJobs"))) { if(doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageJobs"))) {
return true; return true;
@@ -1191,11 +1157,19 @@ function canPlayerUseJob(client, jobId) {
return false; return false;
} }
if(getJobData(jobId).whiteListEnabled) { if(isJobWhiteListed(jobId)) {
if(!isPlayerOnJobWhiteList(client, 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);
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: bus.js
// DESC: Provides bus driver job functions and usage // DESC: Provides bus driver job functions and usage
@@ -398,12 +398,12 @@ function showNextBusStop(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function showCurrentBusStop(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)) { if(isLastStopOnBusRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle); 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")); 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"));

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: drug.js
// DESC: Provides drug runner/dealer job functions and usage // DESC: Provides drug runner/dealer job functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: fire.js
// DESC: Provides firefighter job functions and usage // DESC: Provides firefighter job functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: garbage.js
// DESC: Provides garbage collector job functions and usage // 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)) { if(isLastStopOnGarbageRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
respawnVehicle(getPlayerData(client).jobRouteVehicle); 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")); 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"));

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: medic.js
// DESC: Provides paramedic job functions and usage // DESC: Provides paramedic job functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: police.js
// DESC: Provides police officer job functions and usage // 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)) { 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 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")); messagePlayerNormal(client, `You can either continue driving the patrol route again, or use /stoproute to end your patrol.`, getColourByName("yellow"));

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: taxi.js
// DESC: Provides taxi driver job functions and usage // DESC: Provides taxi driver job functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: weapon.js
// DESC: Provides weapons dealer job functions and usage // DESC: Provides weapons dealer job functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: keybind.js
// DESC: Provides keybind handlers and functions // DESC: Provides keybind handlers and functions
@@ -191,7 +191,7 @@ function removeKeyBindCommand(command, params, client) {
function addPlayerKeyBind(client, keyId, tempCommand, tempParams) { function addPlayerKeyBind(client, keyId, tempCommand, tempParams) {
let keyBindData = new serverClasses.keyBindData(keyId, `${tempCommand} ${tempParams}`); let keyBindData = new serverClasses.keyBindData(keyId, `${tempCommand} ${tempParams}`);
getPlayerData(client).accountData.keyBinds.push(keyBindData); 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); 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) { function sendAccountKeyBindsToClient(client) {
for(let i in getPlayerData(client).accountData.keyBinds) { 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) { function getKeyIdFromParams(params) {
let tempParams = toLowerCase(toString(params)); let tempParams = toLowerCase(toString(params));

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: locale.js
// DESC: Provides locale structures, functions and usage // DESC: Provides locale structures, functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: messaging.js
// DESC: Provides messaging functions and usage // DESC: Provides messaging functions and usage
@@ -11,7 +11,7 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function messageAdminAction(messageText) { function messageAdminAction(messageText) {
message(`⚠️ ${messageText}`, getColourByName("orange")); messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
if(getServerConfig().discordEnabled) { if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`); messageDiscord(`:warning: ${messageText}`);
} }
@@ -26,11 +26,13 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
return true; return true;
} }
if(!isClientFromDiscord(client)) { sendChatBoxMessageToPlayer(client, `${messageText}`, colour);
messageClient(`${messageText}`, client, colour);
} else { //if(!isClientFromDiscord(client)) {
messageDiscordUser(client, `${messageText}`); //
} //} else {
// messageDiscordUser(client, `${messageText}`);
//}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -38,11 +40,11 @@ function messagePlayerNormal(client, messageText, colour = COLOUR_WHITE) {
function messageAdmins(messageText, colour = COLOUR_WHITE) { function messageAdmins(messageText, colour = COLOUR_WHITE) {
let clients = getClients(); let clients = getClients();
for(let i in clients) { for(let i in clients) {
if(clients[i].console) { if(isConsole(clients[i])) {
logToConsole(LOG_INFO, `[Asshat.Messaging] ADMINS: ${messageText}`); logToConsole(LOG_INFO, `[Asshat.Messaging] ADMINS: ${messageText}`);
} else { } else {
if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("basicModeration"))) { if(doesPlayerHaveStaffPermission(clients[i], getStaffFlagValue("basicModeration"))) {
messageClient(`🛡️ ${messageText}`, clients[i], getColourByName("softRed")); sendChatBoxMessageToPlayer(clients[i], `🛡️ ${messageText}`, getColourByName("softRed"));
} }
} }

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: misc.js
// DESC: Provides any uncategorized functions and usage // DESC: Provides any uncategorized functions and usage
@@ -29,14 +29,14 @@ function getPositionCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function toggleMouseCursorCommand(command, params, client) { function toggleMouseCursorCommand(command, params, client) {
triggerNetworkEvent("ag.cursorToggle", client); sendPlayerMouseCursorToggle(client);
return true; return true;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function toggleMouseCameraCommand(command, params, client) { function toggleMouseCameraCommand(command, params, client) {
triggerNetworkEvent("ag.mouseCamera", client); sendPlayerMouseCameraToggle(client);
return true; 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");
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: moderation.js
// DESC: Provides moderation commands, functions and usage // 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!`); 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!`); 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; return false;
} }
//message(`[#996600][ADMIN]: [#FFFFFF]${toString(targetClient.name)} has been un-frozen by an admin!`); setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
client.player.velocity = toVector3(0.0, 0.0, 0.0); setTimeout(function() {
setPlayerPosition(client, getPosBehindPos(getPlayerPosition(targetClient), getPlayerHeading(targetClient), 2)); setPlayerPosition(client, getPosBehindPos(getPlayerPosition(targetClient), getPlayerHeading(targetClient), 2));
setPlayerHeading(client, getPlayerHeading(targetClient)); 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}`); messagePlayerSuccess(client, `You teleported to [#AAAAAA]${targetClient.name}`);
} }
@@ -222,11 +212,11 @@ function gotoVehicleCommand(command, params, client) {
let vehicle = getServerData().vehicles[toInteger(params)].vehicle; 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() { setTimeout(function() {
setPlayerPosition(client, getPosAbovePos(getVehiclePosition(vehicle), 3.0)); setPlayerPosition(client, getPosAbovePos(getVehiclePosition(vehicle), 3.0));
setPlayerInterior(client, 0); setPlayerInterior(client, 0);
setPlayerDimension(client, vehicle.dimension); setPlayerDimension(client, getVehicleDimension(vehicle));
}, 500); }, 500);
messagePlayerSuccess(client, `You teleported to a [#CC22CC]${getVehicleName(vehicle)} [#AAAAAA](ID ${vehicle.id})`); messagePlayerSuccess(client, `You teleported to a [#CC22CC]${getVehicleName(vehicle)} [#AAAAAA](ID ${vehicle.id})`);
@@ -247,7 +237,7 @@ function gotoBusinessCommand(command, params, client) {
return false; return false;
} }
client.player.velocity = toVector3(0.0, 0.0, 0.0); setPlayerVelocity(client, toVector3(0.0, 0.0, 0.0));
setTimeout(function() { setTimeout(function() {
setPlayerPosition(client, getBusinessData(businessId).entrancePosition); setPlayerPosition(client, getBusinessData(businessId).entrancePosition);
setPlayerInterior(client, getBusinessData(businessId).entranceInterior); setPlayerInterior(client, getBusinessData(businessId).entranceInterior);
@@ -401,7 +391,7 @@ function teleportDownCommand(command, params, client) {
return false; 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`); messagePlayerSuccess(client, `You teleported down [#AAAAAA]${params} [#FFFFFF]meters`);
} }

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: native.js
// DESC: Provides util function to wrap mod-specific stuff // DESC: Provides util function to wrap mod-specific stuff
@@ -51,7 +51,7 @@ function getPlayerPosition(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function setPlayerPosition(client, position) { function setPlayerPosition(client, position) {
return triggerNetworkEvent("ag.position", client, position); sendPlayerSetPosition(client, position);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -63,7 +63,7 @@ function getPlayerHeading(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function setPlayerHeading(client, heading) { 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) { function setPlayerInterior(client, interior) {
triggerNetworkEvent("ag.interior", client, interior); sendPlayerSetInterior(client, interior);
getPlayerCurrentSubAccount(client).interior = interior; getPlayerCurrentSubAccount(client).interior = interior;
} }
@@ -172,7 +172,7 @@ function isPlayerInFrontVehicleSeat(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function removePlayerFromVehicle(client) { function removePlayerFromVehicle(client) {
triggerNetworkEvent("ag.removeFromVehicle", client); sendPlayerRemoveFromVehicle(client);
return true; return true;
} }
@@ -196,16 +196,42 @@ function getElementSyncer(element) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function givePlayerWeapon(client, weaponId, ammo, active) { function getPlayerWeaponAmmo(client) {
triggerNetworkEvent("ag.giveWeapon", client, weaponId, ammo, active); client.player.weaponAmmunition + client.player.weaponClipAmmunition;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function clearPlayerWeapons(client) { function setPlayerVelocity(client, velocity) {
triggerNetworkEvent("ag.clearWeapons", client); 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);
}
}
// ---------------------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: npc.js
// DESC: Provides NPC usage and functions // DESC: Provides NPC usage and functions

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: biker.js
// DESC: Provides biker NPC interaction and functionality // DESC: Provides biker NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: drugdealer.js
// DESC: Provides drug dealer NPC interaction and functionality // DESC: Provides drug dealer NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: firefighter.js
// DESC: Provides firefighter NPC interaction and functionality // DESC: Provides firefighter NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: gangsta.js
// DESC: Provides street gang/hoodlum NPC interaction and functionality // DESC: Provides street gang/hoodlum NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: mafia.js
// DESC: Provides mafia/mafioso NPC interaction and functionality // DESC: Provides mafia/mafioso NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: normal.js
// DESC: Provides normal/generic civilian NPC interaction and functionality // DESC: Provides normal/generic civilian NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: paramedic.js
// DESC: Provides paramedic NPC interaction and functionality // DESC: Provides paramedic NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: police.js
// DESC: Provides police officer NPC interaction and functionality // DESC: Provides police officer NPC interaction and functionality

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: security.js
// DESC: Provides security functions and usage // DESC: Provides security functions and usage

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: startup.js
// DESC: Provides startup/shutdown procedures // DESC: Provides startup/shutdown procedures
@@ -32,15 +32,10 @@ function initServerScripts() {
initEventScript(); initEventScript();
initAntiCheatScript(); initAntiCheatScript();
initItemScript(); initItemScript();
initClientScript();
initTimers(); initTimers();
//gta.time.hour = getServerConfig().startup.hour;
//gta.time.minute = getServerConfig().startup.minute;
//gta.forceWeather(getServerConfig().startup.weather);
initAllClients();
loadGameFixesResource(); loadGameFixesResource();
serverStartTime = new Date().getTime()/1000; serverStartTime = new Date().getTime()/1000;

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: subaccount.js
// DESC: Provides subaccount (character) functions and usage // DESC: Provides subaccount (character) functions and usage
@@ -126,7 +126,7 @@ function showCharacterSelectToClient(client) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
getPlayerData(client).currentSubAccount = 0; getPlayerData(client).currentSubAccount = 0;
let tempSubAccount = getPlayerData(client).subAccounts[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`); logToConsole(LOG_DEBUG, `[Asshat.Account] ${getPlayerDisplayForConsole(client)} is being shown the character select GUI`);
} else { } else {
//let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"]; //let emojiNumbers = ["➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "➒"];
@@ -144,24 +144,24 @@ function showCharacterSelectToClient(client) {
function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrigin, skinId) { function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrigin, skinId) {
if(areParamsEmpty(firstName)) { if(areParamsEmpty(firstName)) {
triggerNetworkEvent("ag.newCharacterFailed", client, "First name cannot be blank!"); showPlayerNewCharacterFailedGUI(client, "First name cannot be blank!");
return false; return false;
} }
firstName = firstName.trim(); firstName = firstName.trim();
if(areParamsEmpty(lastName)) { if(areParamsEmpty(lastName)) {
triggerNetworkEvent("ag.newCharacterFailed", client, "Last name cannot be blank!"); showPlayerNewCharacterFailedGUI(client, "Last name cannot be blank!");
return false; return false;
} }
lastName = lastName.trim(); lastName = lastName.trim();
if(areParamsEmpty(dateOfBirth)) { if(areParamsEmpty(dateOfBirth)) {
triggerNetworkEvent("ag.newCharacterFailed", client, "Date of birth cannot be blank!"); showPlayerNewCharacterFailedGUI(client, "Date of birth cannot be blank!");
return false; return false;
} }
if(areParamsEmpty(placeOfOrigin)) { if(areParamsEmpty(placeOfOrigin)) {
triggerNetworkEvent("ag.newCharacterFailed", client, "Place of origin cannot be blank!"); showPlayerNewCharacterFailedGUI(client, "Place of origin cannot be blank!");
return false; 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); let subAccountData = createSubAccount(getPlayerData(client).accountData.databaseId, firstName, lastName, skinId, dateOfBirth, placeOfOrigin);
if(!subAccountData) { if(!subAccountData) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { 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 { } 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."); messagePlayerAlert(client, "Asshat Gaming staff have been notified of the problem and will fix it shortly.");
return false; return false;
@@ -185,11 +185,11 @@ function checkNewCharacter(client, firstName, lastName, dateOfBirth, placeOfOrig
let tempSubAccount = getPlayerData(client).subAccounts[0]; let tempSubAccount = getPlayerData(client).subAccounts[0];
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
} }
addNetworkHandler("ag.checkNewCharacter", checkNewCharacter);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.previousCharacter", function(client) { function checkPreviousCharacter(client) {
if(getPlayerData(client).subAccounts.length > 1) { if(getPlayerData(client).subAccounts.length > 1) {
if(getPlayerData(client).currentSubAccount <= 0) { if(getPlayerData(client).currentSubAccount <= 0) {
getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length-1; getPlayerData(client).currentSubAccount = getPlayerData(client).subAccounts.length-1;
@@ -199,13 +199,13 @@ addNetworkHandler("ag.previousCharacter", function(client) {
let subAccountId = getPlayerData(client).currentSubAccount; let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId]; 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).subAccounts.length > 1) {
if(getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length-1) { if(getPlayerData(client).currentSubAccount >= getPlayerData(client).subAccounts.length-1) {
getPlayerData(client).currentSubAccount = 0; getPlayerData(client).currentSubAccount = 0;
@@ -215,15 +215,15 @@ addNetworkHandler("ag.nextCharacter", function(client) {
let subAccountId = getPlayerData(client).currentSubAccount; let subAccountId = getPlayerData(client).currentSubAccount;
let tempSubAccount = getPlayerData(client).subAccounts[subAccountId]; 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) { function selectCharacter(client, characterId = -1) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.characterSelectSuccess", client); showPlayerCharacterSelectSuccessGUI(client);
} }
if(characterId != -1) { if(characterId != -1) {
@@ -236,7 +236,6 @@ function selectCharacter(client, characterId = -1) {
getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime(); getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime();
cachePlayerHotBarItems(client); cachePlayerHotBarItems(client);
} }
addNetworkHandler("ag.selectCharacter", selectCharacter);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -244,8 +243,8 @@ function switchCharacterCommand(command, params, client) {
if(isPlayerSpawned(client)) { if(isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client); getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client); getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
//getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client); getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
//getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client); getPlayerCurrentSubAccount(client).dimension = getPlayerDimension(client);
saveSubAccountToDatabase(getPlayerCurrentSubAccount(client)); saveSubAccountToDatabase(getPlayerCurrentSubAccount(client));

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: timers.js
// DESC: Provides timer functions and features // DESC: Provides timer functions and features

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: translate.js
// DESC: Provides translation functions // DESC: Provides translation functions

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: tutorial.js
// DESC: Provides tutorial functions and features // DESC: Provides tutorial functions and features

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: utilities.js
// DESC: Provides util functions and arrays with data // DESC: Provides util functions and arrays with data
@@ -1544,6 +1544,12 @@ function getEnabledDisabledFromBool(boolVal) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function getLockedUnlockedFromBool(boolVal) {
return (boolVal) ? "Locked" : "Unlocked";
}
// ---------------------------------------------------------------------------
function updateServerRules() { function updateServerRules() {
server.setRule("Time", makeReadableTime(getServerConfig().hour, getServerConfig().minute)); server.setRule("Time", makeReadableTime(getServerConfig().hour, getServerConfig().minute));
server.setRule("Weather", getGameData().weatherNames[getServerGame()][getServerConfig().weather]); server.setRule("Weather", getGameData().weatherNames[getServerGame()][getServerConfig().weather]);

View File

@@ -1,7 +1,7 @@
// =========================================================================== // ===========================================================================
// Asshat-Gaming Roleplay // Asshat-Gaming Roleplay
// https://github.com/VortrexFTW/gtac_asshat_rp // 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 // FILE: vehicle.js
// DESC: Provides vehicle functions and usage // DESC: Provides vehicle functions and usage
@@ -99,21 +99,12 @@ function saveVehicleToDatabase(vehicleData) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function spawnAllVehicles() { function spawnAllVehicles() {
let vehicles = getServerData().vehicles; for(let i in getServerData().vehicles) {
for(let i in vehicles) { let vehicle = spawnVehicle(getServerData().vehicles[i]);
if(isGTAIV()) { getServerData().vehicles[i].vehicle = vehicle;
if(!vehicles[i].syncedBy) {
let closestClient = getClosestPlayer(vehicles[i].spawnPosition);
triggerNetworkEvent("ag.vehicle", closestClient, i, vehicles[i].modelIndex, vehicles[i].spawnPosition, vehicles[i].spawnRotation, vehicles[i].colour1, vehicles[i].colour2, vehicles[i].locked, vehicles[i].lights);
vehicles[i].syncedBy = closestClient;
}
} else {
let vehicle = spawnVehicle(vehicles[i]);
vehicles[i].vehicle = vehicle;
setEntityData(vehicle, "ag.dataSlot", i, false); setEntityData(vehicle, "ag.dataSlot", i, false);
} }
} }
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -195,17 +186,10 @@ function vehicleLockCommand(command, params, client) {
} }
} }
if(getVehicleData(vehicle).locked) { getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
vehicle.locked = false; vehicle.locked = getVehicleData(vehicle).locked;
getVehicleData(vehicle).locked = false;
} else {
vehicle.locked = true;
getVehicleData(vehicle).locked = true;
}
let lockText = (getVehicleData(vehicle).locked) ? "locked" : "unlocked"; meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
meActionToNearbyPlayers(client, `${lockText} the ${getVehicleName(vehicle)}`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -228,11 +212,10 @@ function vehicleLightsCommand(command, params, client) {
return false; return false;
} }
triggerNetworkEvent("ag.veh.lights", getVehicleSyncer(vehicle), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).lights);
getVehicleData(vehicle).lights = !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; getVehicleData(vehicle).engine = !getVehicleData(vehicle).engine;
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; getVehicleData(vehicle).siren = !getVehicleData(vehicle).siren;
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;
}
}
}
}
}
// -------------------------------------------------------------------------

View File

@@ -15,6 +15,7 @@ const AG_LABEL_HOUSE = 3;
const AG_LABEL_EXIT = 3; const AG_LABEL_EXIT = 3;
// Log Levels // Log Levels
const LOG_ALL = -1;
const LOG_NONE = 0; const LOG_NONE = 0;
const LOG_INFO = 1; const LOG_INFO = 1;
const LOG_WARN = 2; const LOG_WARN = 2;

View File

@@ -111,13 +111,17 @@ function getDistance(vec1, vec2) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function isConsole(client) { function isConsole(client) {
if(client == null) {
return false;
}
return client.console; return client.console;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function logToConsole(tempLogLevel, text) { function logToConsole(tempLogLevel, text) {
if(logLevel & tempLogLevel) { if(logLevel & tempLogLevel || logLevel == LOG_ALL) {
if(tempLogLevel == LOG_ERROR) { if(tempLogLevel == LOG_ERROR) {
console.error(text); console.error(text);
} else if(tempLogLevel == LOG_WARN) { } else if(tempLogLevel == LOG_WARN) {
@@ -133,3 +137,9 @@ function logToConsole(tempLogLevel, text) {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function isSamePlayer(client1, client2) {
return (client1 == client2);
}
// ---------------------------------------------------------------------------