Too much for individual commits

This commit is contained in:
Vortrex
2021-01-05 20:14:15 -06:00
parent 0bc357a662
commit 3ef9e554cc
28 changed files with 834 additions and 384 deletions

View File

@@ -231,3 +231,48 @@ NOTICE: Most of these ideas are totally random and some might be unrealistic. Ev
* Player police officers can issue an APB for a player suspect. NPC police drive and walk around as normal in the game but if they spot the player suspect within a certain distance and line of sight, their position is sent to any player police officers via radio and shown as a blip on the radar. If the suspect evades the NPC police, the blip fades out at the last seen suspect location and eventually disappears, no longer available to player police officers. This means that the blip will continue to show other officers at the suspect's updated location until a) all police officers lose line of sight, b) suspect gets too far away or c) enters a house/business (losing line of sight with police unless they enter). All of these will cause the blip to show the suspects last known and seen location while the blip fades out and eventually disappears. Any officer that re-establishes line of sight within a certain distance will cause the suspect's blip to show again for all police. NPC police will NOT use the built-in wanted level system because this causes excessive spawning of police no matter where the suspect is generally completely unfair. Instead, scripting functions like ped.runTo, vehicle.setCarMission, vehicle.setCruiseSpeed, etc will be used to pursue the suspect. The logic in these functions is not perfect. The NPC officer can wreck the police car, get slowed down by traffic or stuck on something altogether, and the ped can be evaded by continously going around corners and such. All of this provides the ability for the suspect to have a chance of getting away. Changing skin/clothes or driving different/unknown vehicles reduces the NPC's line of sight and distance checking and thus reduces their chance of identifying them when near. * Player police officers can issue an APB for a player suspect. NPC police drive and walk around as normal in the game but if they spot the player suspect within a certain distance and line of sight, their position is sent to any player police officers via radio and shown as a blip on the radar. If the suspect evades the NPC police, the blip fades out at the last seen suspect location and eventually disappears, no longer available to player police officers. This means that the blip will continue to show other officers at the suspect's updated location until a) all police officers lose line of sight, b) suspect gets too far away or c) enters a house/business (losing line of sight with police unless they enter). All of these will cause the blip to show the suspects last known and seen location while the blip fades out and eventually disappears. Any officer that re-establishes line of sight within a certain distance will cause the suspect's blip to show again for all police. NPC police will NOT use the built-in wanted level system because this causes excessive spawning of police no matter where the suspect is generally completely unfair. Instead, scripting functions like ped.runTo, vehicle.setCarMission, vehicle.setCruiseSpeed, etc will be used to pursue the suspect. The logic in these functions is not perfect. The NPC officer can wreck the police car, get slowed down by traffic or stuck on something altogether, and the ped can be evaded by continously going around corners and such. All of this provides the ability for the suspect to have a chance of getting away. Changing skin/clothes or driving different/unknown vehicles reduces the NPC's line of sight and distance checking and thus reduces their chance of identifying them when near.
* Casinos
* Pebble companion app
* More GUI
* Basic layouts
* List
* Columned List (Grid?)
* Single Text Input Prompt
* Complex Layouts
* Info boxes for any type of server entity
* Admin functions for each one (ban, kick, delete, set owner, etc)
* Chat log
* Lists of submitted ideas and bug reports
* Web API
* REST-like URLs
* Type shortened to database table prefix style (/acct, /veh, etc)
* Companion app for my Pebble watch (Rebble)
* Whole thing streamlined
* Server select, then use GUI colours of server
* Connected players
* Links to account/character info
* Character Info leads to owned vehicles, houses, businesses, current clan, etc
* Clan info leads to owned businesses, houses, vehicles, etc
* Business, house, vehicle info has links back to owners info pages
* Alerts for reports, submitted bugs/ideas, hacker detection
* Silent mode to block incoming alerts
* Moderation action choices.
* Players
* Kick, ban, mute, unmute, etc
* Vehicles
* Set owner (select job, public, biz, house, player, clan, etc)
* Despawn
* Delete
* Business/House
* Set owner (select job, public, biz, house, player, clan, etc)
* Lock/unlock
* Delete
* Server
* Config options
* Shutdown, restart, gmx, etc
* Alert (probably pre-made messages, configurable in pebble app)

View File

@@ -8,7 +8,7 @@
// TYPE: Client (JavaScript) // TYPE: Client (JavaScript)
// =========================================================================== // ===========================================================================
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnLostFocus", function(event) { addEventHandler("OnLostFocus", function(event) {
triggerNetworkEvent("ag.afk", true); triggerNetworkEvent("ag.afk", true);
@@ -19,7 +19,7 @@ addEventHandler("OnLostFocus", function(event) {
} }
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnFocus", function(event) { addEventHandler("OnFocus", function(event) {
triggerNetworkEvent("ag.afk", false); triggerNetworkEvent("ag.afk", false);
@@ -32,4 +32,4 @@ addEventHandler("OnFocus", function(event) {
} }
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -37,7 +37,7 @@ let login = {
let twoFactorAuth = { let twoFactorAuth = {
window: null, window: null,
logoImage: null, logoImage: null,
qrCodeHTML: null, qrCode: null,
messageLabel: null, messageLabel: null,
codeLabel: null, codeLabel: null,
codeInput: null, codeInput: null,
@@ -1160,7 +1160,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created login GUI`); console.log(`[Asshat.GUI] Created login GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating two factor auth GUI ...`); console.log(`[Asshat.GUI] Creating two factor auth GUI ...`);
twoFactorAuth.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', { twoFactorAuth.window = mexui.window(game.width/2-150, game.height/2-129, 300, 258, 'LOGIN', {
@@ -1183,13 +1183,13 @@ app.init = function()
twoFactorAuth.window.titleBarIconSize = toVector2(0,0); twoFactorAuth.window.titleBarIconSize = toVector2(0,0);
twoFactorAuth.window.titleBarHeight = 0; twoFactorAuth.window.titleBarHeight = 0;
twoFactorAuth.logoImage = twoFactorAuth.window.image(100, 20, 100, 100, mainLogoPath, { twoFactorAuth.qrCode = twoFactorAuth.window.image(100, 20, 100, 100, mainLogoPath, {
focused: { focused: {
borderColour: toColour(0, 0, 0, 0), borderColour: toColour(0, 0, 0, 0),
}, },
}); });
twoFactorAuth.messageLabel = twoFactorAuth.window.text(20, 135, 260, 20, 'Please enter the code from your authenticator app!', { twoFactorAuth.codeLabel = twoFactorAuth.window.text(20, 135, 260, 20, 'Please enter the code from your authenticator app!', {
main: { main: {
textSize: 10.0, textSize: 10.0,
textAlign: 0.5, textAlign: 0.5,
@@ -1201,7 +1201,7 @@ app.init = function()
}, },
}); });
twoFactorAuth.passwordInput = twoFactorAuth.window.textInput(20, 170, 260, 25, '', { twoFactorAuth.codeInput = twoFactorAuth.window.textInput(20, 170, 260, 25, '', {
main: { main: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha), borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha),
@@ -1238,7 +1238,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created two factor auth GUI`); console.log(`[Asshat.GUI] Created two factor auth GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating new character GUI ...`); console.log(`[Asshat.GUI] Creating new character GUI ...`);
@@ -1445,7 +1445,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created new character GUI`); console.log(`[Asshat.GUI] Created new character GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating register GUI ...`); console.log(`[Asshat.GUI] Creating register GUI ...`);
@@ -1560,7 +1560,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created register GUI`); console.log(`[Asshat.GUI] Created register GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating error GUI ...`); console.log(`[Asshat.GUI] Creating error GUI ...`);
@@ -1602,7 +1602,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created error GUI ...`); console.log(`[Asshat.GUI] Created error GUI ...`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Created prompt GUI ...`); console.log(`[Asshat.GUI] Created prompt GUI ...`);
@@ -1654,7 +1654,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created prompt GUI`); console.log(`[Asshat.GUI] Created prompt GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating info dialog GUI ...`); console.log(`[Asshat.GUI] Creating info dialog GUI ...`);
@@ -1695,7 +1695,7 @@ app.init = function()
console.log(`[Asshat.GUI] Created info dialog GUI`); console.log(`[Asshat.GUI] Created info dialog GUI`);
// --------------------------------------------------------------------------------- // ------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating character select GUI ...`); console.log(`[Asshat.GUI] Creating character select GUI ...`);

View File

@@ -11,7 +11,7 @@
let lastKeyBindUse = 0; let lastKeyBindUse = 0;
let keyBindDelayTime = 2000; let keyBindDelayTime = 2000;
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function bindAccountKey(key, keyState) { function bindAccountKey(key, keyState) {
bindKey(toInteger(key), keyState, function(event) { bindKey(toInteger(key), keyState, function(event) {
@@ -24,7 +24,7 @@ function bindAccountKey(key, keyState) {
} }
addNetworkHandler("ag.keybinds.add", bindAccountKey); addNetworkHandler("ag.keybinds.add", bindAccountKey);
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function unBindAccountKey(key) { function unBindAccountKey(key) {
unbindKey(key); unbindKey(key);
@@ -32,7 +32,7 @@ function unBindAccountKey(key) {
} }
addNetworkHandler("ag.keybinds.del", unBindAccountKey); addNetworkHandler("ag.keybinds.del", unBindAccountKey);
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function hasKeyBindDelayElapsed() { function hasKeyBindDelayElapsed() {
if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) { if(sdl.ticks-lastKeyBindUse >= keyBindDelayTime) {
@@ -42,4 +42,4 @@ function hasKeyBindDelayElapsed() {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -25,7 +25,7 @@ let unlockedColour = toColour(50, 205, 50, 255);
let lockedColour = toColour(205, 92, 92, 255); let lockedColour = toColour(205, 92, 92, 255);
let jobHelpColour = toColour(234, 198, 126, 255); let jobHelpColour = toColour(234, 198, 126, 255);
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
bindEventHandler("onResourceReady", thisResource, function(event, resource) { bindEventHandler("onResourceReady", thisResource, function(event, resource) {
propertyLabelNameFont = lucasFont.createDefaultFont(16.0, "Roboto", "Regular"); propertyLabelNameFont = lucasFont.createDefaultFont(16.0, "Roboto", "Regular");
@@ -35,7 +35,7 @@ bindEventHandler("onResourceReady", thisResource, function(event, resource) {
jobHelpLabelFont = lucasFont.createDefaultFont(10.0, "Roboto", "Light"); jobHelpLabelFont = lucasFont.createDefaultFont(10.0, "Roboto", "Light");
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) { function renderPropertyEntranceLabel(name, position, locked, isBusiness, price) {
if(localPlayer == null) { if(localPlayer == null) {
@@ -82,7 +82,7 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price)
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true); propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderPropertyExitLabel(position) { function renderPropertyExitLabel(position) {
if(localPlayer == null) { if(localPlayer == null) {
@@ -110,7 +110,7 @@ function renderPropertyExitLabel(position) {
propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true); propertyLabelNameFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, propertyLabelNameFont.size, COLOUR_WHITE, false, true, false, true);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function renderJobLabel(name, position, jobType) { function renderJobLabel(name, position, jobType) {
if(localPlayer == null) { if(localPlayer == null) {
@@ -158,7 +158,7 @@ function renderJobLabel(name, position, jobType) {
jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true); jobNameLabelFont.render(text, [screenPosition.x-size[0]/2, screenPosition.y-size[1]/2], game.width, 0.0, 0.0, jobNameLabelFont.size, COLOUR_WHITE, false, true, false, true);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function (event) { addEventHandler("OnDrawnHUD", function (event) {
if(!renderHUD) { if(!renderHUD) {
@@ -208,4 +208,4 @@ addEventHandler("OnDrawnHUD", function (event) {
} }
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -143,7 +143,7 @@ addNetworkHandler("ag.runCode", function(code, returnTo) {
triggerNetworkEvent("ag.runCodeSuccess", returnTo, code, returnValue); triggerNetworkEvent("ag.runCodeSuccess", returnTo, code, returnValue);
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function enterVehicleAsPassenger() { function enterVehicleAsPassenger() {
if(localPlayer.vehicle == null) { if(localPlayer.vehicle == null) {
@@ -154,13 +154,13 @@ function enterVehicleAsPassenger() {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getClosestVehicle(pos) { function getClosestVehicle(pos) {
return getVehicles().reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j); return getVehicles().reduce((i, j) => (i.position.distance(pos) < j.position.distance(pos)) ? i : j);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addNetworkHandler("ag.clearWeapons", function() { addNetworkHandler("ag.clearWeapons", function() {
console.log(`[Asshat.Main] Clearing weapons`); console.log(`[Asshat.Main] Clearing weapons`);

View File

@@ -20,7 +20,7 @@ let playerColours = {};
let playerPaused = {}; let playerPaused = {};
let playerPing = {}; let playerPing = {};
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnResourceReady", function(event, resource) { addEventHandler("OnResourceReady", function(event, resource) {
if (resource == thisResource) { if (resource == thisResource) {
@@ -29,7 +29,7 @@ addEventHandler("OnResourceReady", function(event, resource) {
} }
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addNetworkHandler("ag.nametag", function(clientName, characterName, colour, paused, ping) { addNetworkHandler("ag.nametag", function(clientName, characterName, colour, paused, ping) {
playerNames[clientName] = characterName; playerNames[clientName] = characterName;
@@ -38,13 +38,13 @@ addNetworkHandler("ag.nametag", function(clientName, characterName, colour, paus
playerPing[clientName] = ping; playerPing[clientName] = ping;
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addNetworkHandler("ag.ping", function(clientName, ping) { addNetworkHandler("ag.ping", function(clientName, ping) {
playerPing[clientName] = ping; playerPing[clientName] = ping;
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) { function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour, afk, skin) {
if(nametagFont == null) { if(nametagFont == null) {
@@ -113,7 +113,7 @@ function drawNametag(x, y, health, armour, text, ping, alpha, distance, colour,
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function updateNametags(element) { function updateNametags(element) {
if(localPlayer != null) { if(localPlayer != null) {
@@ -166,7 +166,7 @@ function updateNametags(element) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getClientFromPlayer(player) { function getClientFromPlayer(player) {
getClients().forEach(function(client) { getClients().forEach(function(client) {
@@ -176,7 +176,7 @@ function getClientFromPlayer(player) {
}); });
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function(event) { addEventHandler("OnDrawnHUD", function(event) {
if(gta.game >= GAME_GTA_IV) { if(gta.game >= GAME_GTA_IV) {
@@ -190,10 +190,10 @@ addEventHandler("OnDrawnHUD", function(event) {
}); });
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function createColour(alpha, red, green, blue) { function createColour(alpha, red, green, blue) {
return alpha << 24 | red << 16 | green << 8 | blue; return alpha << 24 | red << 16 | green << 8 | blue;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -13,14 +13,14 @@ let listFont = null;
let pausedColour = COLOUR_RED; let pausedColour = COLOUR_RED;
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
bindEventHandler("OnResourceReady", thisResource, function(event, resource) { bindEventHandler("OnResourceReady", thisResource, function(event, resource) {
titleFont = lucasFont.createDefaultFont(22.0, "Roboto", "Regular"); titleFont = lucasFont.createDefaultFont(22.0, "Roboto", "Regular");
listFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light"); listFont = lucasFont.createDefaultFont(12.0, "Roboto", "Light");
}); });
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
addEventHandler("OnDrawnHUD", function (event) { addEventHandler("OnDrawnHUD", function (event) {
if(!renderHUD) { if(!renderHUD) {

View File

@@ -764,12 +764,11 @@ function initClient(client) {
let tempAccountData = loadAccountFromName(client.name, true); let tempAccountData = loadAccountFromName(client.name, true);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts); getServerData().clients[client.index] = new serverClasses.clientData(client, tempAccountData, tempSubAccounts);
let sessionId = saveConnectionToDatabase(client); let sessionId = saveConnectionToDatabase(client);
getServerData().clients[client.index].session = sessionId; getServerData().clients[client.index].session = sessionId;
getServerData().clients[client.index].connectTime = Math.ceil(sdl.ticks);
if(tempAccountData != false) { if(tempAccountData != false) {
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) { if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) {

View File

@@ -9,7 +9,9 @@
// =========================================================================== // ===========================================================================
function initAntiCheatScript() { function initAntiCheatScript() {
console.log("[Asshat.AntiCheat]: Initializing anticheat script ..."); console.log("[Asshat.AntiCheat]: Initializing anticheat script ...");
getServerData().antiCheat.whiteListedGameScripts = loadAntiCheatGameScriptWhiteListFromDatabase();
getServerData().antiCheat.blackListedGameScripts = loadAntiCheatGameScriptBlackListFromDatabase();
console.log("[Asshat.AntiCheat]: Anticheat script initialized!"); console.log("[Asshat.AntiCheat]: Anticheat script initialized!");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -26,7 +28,6 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() {
if(dbQuery.numRows > 0) { if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery); let dbAssoc = fetchQueryAssoc(dbQuery);
let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc); let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc);
tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData); tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData);
console.log(`[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`); console.log(`[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`);
} }
@@ -51,7 +52,6 @@ function loadAntiCheatGameScriptBlackListFromDatabase() {
if(dbQuery.numRows > 0) { if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery); let dbAssoc = fetchQueryAssoc(dbQuery);
let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc); let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc);
tempBlackListedGameScripts.push(tempBlackListedGameScriptData); tempBlackListedGameScripts.push(tempBlackListedGameScriptData);
console.log(`[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`); console.log(`[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`);
} }

View File

@@ -67,7 +67,10 @@ let serverBitFlagKeys = {
], ],
clanPermissionFlagKeys: [ clanPermissionFlagKeys: [
"none", "none",
"startTurfWar",
"startPointWar",
"inviteMember", "inviteMember",
"suspendMember",
"removeMember", "removeMember",
"memberRank", "memberRank",
"memberFlags", "memberFlags",
@@ -170,7 +173,7 @@ function doesPlayerHaveStaffPermission(client, requiredFlags) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function doesClientHaveClanPermission(client, requiredFlags) { function doesPlayerHaveClanPermission(client, requiredFlags) {
if(isConsole(client)) { if(isConsole(client)) {
return true; return true;
} }

View File

@@ -13,7 +13,6 @@ function initBusinessScript() {
getServerData().businesses = loadBusinessesFromDatabase(); getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups(); createAllBusinessPickups();
createAllBusinessBlips(); createAllBusinessBlips();
setAllBusinessIndexes(); setAllBusinessIndexes();
console.log("[Asshat.Business]: Business script initialized successfully!"); console.log("[Asshat.Business]: Business script initialized successfully!");
return true; return true;
@@ -549,6 +548,45 @@ function depositIntoBusinessCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function stockItemInBusinessCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let itemType = getItemTypeFromParams(splitParams[0]);
let amount = toInteger(splitParams[1]) || 1;
let sellPrice = toInteger(splitParams[2]) || 0;
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
if(!getItemTypeData(itemType)) {
messagePlayerError(client, "Invalid item type name or ID!");
messagePlayerInfo(client, "Use /itemtypes for a list of items");
return false;
}
let orderTotalCost = getItemTypeData(itemType).orderPrice*amount;
if(getBusinessData(businessId).till < orderTotalCost) {
let neededAmount = orderTotalCost-getBusinessData(businessId).till;
messagePlayerError(client, `The business doesn't have enough money (needs [#AAAAAA]$${neededAmount} [#FFFFFF]more)! Use [#AAAAAA]/bizdeposit [#FFFFFF]to add money to the business.`);
return false;
}
getBusinessData(businessId).till -= orderTotalCost;
addToBusinessInventory(businessId, itemType, amount);
messagePlayerSuccess(client, `You ordered ${amount} ${getPluralForm(getItemTypeData(itemType).name)} at $${getItemTypeData(itemType).orderPrice} each for business [#0099FF]'${getBusinessData(businessId).name} [#FFFFFF] and set their sell price [#AAAAAA]$${sellPrice}`);
}
// ---------------------------------------------------------------------------
function viewBusinessTillAmountCommand(command, params, client) { function viewBusinessTillAmountCommand(command, params, client) {
let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)); let businessId = (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
@@ -620,6 +658,30 @@ 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 == AG_BIZTYPE_CLOTHES) {
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) {
@@ -632,9 +694,8 @@ function getBusinessDataFromDatabaseId(databaseId) {
function getClosestBusinessEntrance(position) { function getClosestBusinessEntrance(position) {
let closest = 0; let closest = 0;
let businesses = getServerData().businesses; for(let i in getServerData().businesses) {
for(let i in businesses) { if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) {
if(getDistance(position, businesses[i].entrancePosition) <= getDistance(position, businesses[closest].entrancePosition)) {
closest = i; closest = i;
} }
} }
@@ -975,3 +1036,21 @@ function setAllBusinessIndexes() {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function addToBusinessInventory(businessId, itemType, amount, buyPrice) {
let tempItemData = new serverClasses.itemData(false);
tempItemData.amount = amount;
tempItemData.buyPrice = buyPrice;
tempItemData.itemType = getItemTypeData(itemType);
tempItemData.ownerId = getBusinessData(business).databaseId;
tempItemData.ownerType = AG_ITEMOWNER_BIZ;
tempItemData.ownerIndex = businessId;
tempItemData.itemTypeIndex = itemType;
saveItemToDatabase(tempItemData);
getServerData().items.push(tempItemData);
let index = getServerData().items.length-1;
getServerData().items[index].index = index;
}
// ---------------------------------------------------------------------------

View File

@@ -11,6 +11,7 @@
function initClanScript() { function initClanScript() {
console.log("[Asshat.Clan]: Initializing clans script ..."); console.log("[Asshat.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase(); getServerData().clans = loadClansFromDatabase();
setAllClanDataIndexes();
console.log("[Asshat.Clan]: Clan script initialized successfully!"); console.log("[Asshat.Clan]: Clan script initialized successfully!");
return true; return true;
} }
@@ -45,7 +46,7 @@ function loadClansFromDatabase() {
return tempClans; return tempClans;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function createClanCommand(command, params, client) { function createClanCommand(command, params, client) {
if(areParamsEmpty(params)) { if(areParamsEmpty(params)) {
@@ -60,10 +61,10 @@ function createClanCommand(command, params, client) {
// Create clan without owner. Can set owner with /clanowner afterward // Create clan without owner. Can set owner with /clanowner afterward
createClan(params); createClan(params);
messagePlayerSuccess(client, `The [#FF9900]${params} [#FFFFFF]clan has been created!`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created clan[#FF9900]${params}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function deleteClanCommand(command, params, client) { function deleteClanCommand(command, params, client) {
if(areParamsEmpty(params)) { if(areParamsEmpty(params)) {
@@ -78,14 +79,14 @@ function deleteClanCommand(command, params, client) {
return false; return false;
} }
messagePlayerSuccess(client, `The [#FF9900]${getClanData(clanId).name} [#FFFFFF]clan has been deleted!`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted clan[#FF9900]${getClanData(clanId).name}`);
deleteClan(clanId); deleteClan(clanId);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanOwnerCommand(command, params, client) { function setClanOwnerCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("owner"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("owner"))) {
messagePlayerError(client, "You must be the clan owner to use this command!"); messagePlayerError(client, "You must be the clan owner to use this command!");
return false; return false;
} }
@@ -94,12 +95,31 @@ function setClanOwnerCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let splitParams = params.split(" ");
let clanId = getClanFromParams(splitParams[0]);
let targetClient = getPlayerFromParams(splitParams[1]);
if(!targetClient) {
messagePlayerError(client, "Player not found!");
return false;
}
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
return false;
}
getClanData(clanId).owner = getPlayerCurrentSubAccount(targetClient).databaseId;
getPlayerCurrentSubAccount(targetClient).clanFlags = getClanFlagValue("all");
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).name} [#FFFFFF]owner to [#AAAAAA]${getCharacterFullName(targetClient)}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanTagCommand(command, params, client) { function setClanTagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("clanTag"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanTag"))) {
messagePlayerError(client, "You can not change the clan tag!"); messagePlayerError(client, "You can not change the clan tag!");
return false; return false;
} }
@@ -108,12 +128,23 @@ function setClanTagCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
return false;
}
getClanData(clanId).params = params;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).index} [#FFFFFF]tag to [#AAAAAA]${params}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanNameCommand(command, params, client) { function setClanNameCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("clanName"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanName"))) {
messagePlayerError(client, "You can not change the clan name!"); messagePlayerError(client, "You can not change the clan name!");
return false; return false;
} }
@@ -122,12 +153,23 @@ function setClanNameCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let clanId = getPlayerClan(client);
if(!getClanData(clanId)) {
messagePlayerError(client, "Clan not found!");
return false;
}
getClanData(clanId).name = params;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set clan[#FF9900]${getClanData(clanId).index} [#FFFFFF]name to [#AAAAAA]${params}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanMemberTagCommand(command, params, client) { function setClanMemberTagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberTag"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberTag"))) {
messagePlayerError(client, "You can not change a clan member's tag!"); messagePlayerError(client, "You can not change a clan member's tag!");
return false; return false;
} }
@@ -136,12 +178,31 @@ function setClanMemberTagCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command)); messagePlayerSyntax(client, getCommandSyntaxText(command));
return false; return false;
} }
let splitParams = params.split(" ");
let targetClient = getPlayerFromParams(splitParams[0]);
let tag = splitParams[1] || "";
if(!targetClient) {
messagePlayerError(client, "Player not found!");
return false;
}
if(!arePlayersInSameClan(client, targetClient) && !doesPlayerHaveStaffPermission(client, getStaffFlagValue("manageClans"))) {
messagePlayerError(client, `${getCharacterFullName(targetClient)} is not in your clan!`);
return false;
}
getPlayerCurrentSubAccount(targetClient).clanTag = tag;
messagePlayerSuccess(client, `You set [#AAAAAA]${getCharacterFullName(targetClient)}'s [#FFFFFF]clan tag to [#AAAAAA]${tag}`);
messagePlayerAlert(client, `[#AAAAAA]${getCharacterFullName(targetClient)} [#FFFFFF]set your clan tag to [#AAAAAA]${tag}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanRankTagCommand(command, params, client) { function setClanRankTagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankTag"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankTag"))) {
messagePlayerError(client, "You can not change a clan ranks's tag!"); messagePlayerError(client, "You can not change a clan ranks's tag!");
return false; return false;
} }
@@ -168,10 +229,10 @@ function setClanRankTagCommand(command, params, client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function addClanMemberFlagCommand(command, params, client) { function addClanMemberFlagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
messagePlayerError(client, "You can not change a clan member's permissions!"); messagePlayerError(client, "You can not change a clan member's permissions!");
return false; return false;
} }
@@ -205,10 +266,10 @@ function addClanMemberFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to [#AAAAAA]${getCharacterFullName(client)}`); messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to [#AAAAAA]${getCharacterFullName(client)}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function removeClanMemberFlagCommand(command, params, client) { function removeClanMemberFlagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
messagePlayerError(client, "You can not change a clan member's permissions!"); messagePlayerError(client, "You can not change a clan member's permissions!");
return false; return false;
} }
@@ -242,10 +303,10 @@ function removeClanMemberFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`); messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function addClanRankFlagCommand(command, params, client) { function addClanRankFlagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankFlags"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
messagePlayerError(client, "You can not change a clan rank's permissions!"); messagePlayerError(client, "You can not change a clan rank's permissions!");
return false; return false;
} }
@@ -280,10 +341,10 @@ function addClanRankFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); messagePlayerSuccess(client, `You added the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag to rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function removeClanRankFlagCommand(command, params, client) { function removeClanRankFlagCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankFlags"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
messagePlayerError(client, "You can not change a clan rank's permissions!"); messagePlayerError(client, "You can not change a clan rank's permissions!");
return false; return false;
} }
@@ -318,10 +379,10 @@ function removeClanRankFlagCommand(command, params, client) {
messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`); messagePlayerSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from rank [#AAAAAA]${getClanRankData(clanId, rankId).name}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanMemberTitleCommand(command, params, client) { function setClanMemberTitleCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberTitle"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberTitle"))) {
messagePlayerError(client, "You can not change a clan member's title!"); messagePlayerError(client, "You can not change a clan member's title!");
return false; return false;
} }
@@ -350,10 +411,10 @@ function setClanMemberTitleCommand(command, params, client) {
messagePlayerSuccess(client, `You changed the name of [#AAAAAA]${getCharacterFullName(client)} [#FFFFFF]from [#AAAAAA]${oldMemberTitle} [#FFFFFF]to [#AAAAAA]${params}`); messagePlayerSuccess(client, `You changed the name of [#AAAAAA]${getCharacterFullName(client)} [#FFFFFF]from [#AAAAAA]${oldMemberTitle} [#FFFFFF]to [#AAAAAA]${params}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanRankTitleCommand(command, params, client) { function setClanRankTitleCommand(command, params, client) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankTitle"))) { if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankTitle"))) {
messagePlayerError(client, "You can not change your clan's rank titles!"); messagePlayerError(client, "You can not change your clan's rank titles!");
return false; return false;
} }
@@ -382,7 +443,7 @@ function setClanRankTitleCommand(command, params, client) {
messagePlayerSuccess(client, `You changed the name of rank ${rankId} from [#AAAAAA]${oldRankName} [#FFFFFF]to [#AAAAAA]${params}`); messagePlayerSuccess(client, `You changed the name of rank ${rankId} from [#AAAAAA]${oldRankName} [#FFFFFF]to [#AAAAAA]${params}`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function createClan(name) { function createClan(name) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -402,7 +463,7 @@ function createClan(name) {
return true; return true;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function deleteClan(clanId) { function deleteClan(clanId) {
saveClansToDatabase(); saveClansToDatabase();
@@ -420,7 +481,7 @@ function deleteClan(clanId) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getClanData(clanId) { function getClanData(clanId) {
let clans = getServerData().clans; let clans = getServerData().clans;
@@ -433,7 +494,7 @@ function getClanData(clanId) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function doesClanNameExist(name) { function doesClanNameExist(name) {
let clans = getServerData().clans; let clans = getServerData().clans;
@@ -446,7 +507,7 @@ function doesClanNameExist(name) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function doesClanIdExist(clanId) { function doesClanIdExist(clanId) {
let clans = getServerData().clans; let clans = getServerData().clans;
@@ -459,13 +520,13 @@ function doesClanIdExist(clanId) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function reloadAllClans() { function reloadAllClans() {
getServerData().clans = loadClansFromDatabase(); getServerData().clans = loadClansFromDatabase();
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function saveClansToDatabase() { function saveClansToDatabase() {
let clans = getServerData().clans; let clans = getServerData().clans;
@@ -474,7 +535,7 @@ function saveClansToDatabase() {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function saveClanToDatabase(clanData) { function saveClanToDatabase(clanData) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -489,58 +550,88 @@ function saveClanToDatabase(clanData) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanTag(clanId, tag) { function setClanTag(clanId, tag) {
getClanData(clanId).tag = tag; getClanData(clanId).tag = tag;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanOwner(clanId, ownerId) { function setClanOwner(clanId, ownerId) {
getClanData(clanId).ownerId = ownerId; getClanData(clanId).ownerId = ownerId;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanMemberTag(memberId, tag) { function setClanMemberTag(memberId, tag) {
// finish this later, need to query db // finish this later, need to query db
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanMemberFlags(memberId, flags) { function setClanMemberFlags(memberId, flags) {
// finish this later, need to query db // finish this later, need to query db
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanMemberTitle(memberId, title) { function setClanMemberTitle(memberId, title) {
// finish this later, need to query db // finish this later, need to query db
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanRankTag(clanId, rankId, tag) { function setClanRankTag(clanId, rankId, tag) {
getClanRankData(clanId, rankId).tag = tag; getClanRankData(clanId, rankId).tag = tag;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanRankFlags(clanId, rankId, flags) { function setClanRankFlags(clanId, rankId, flags) {
getClanRankData(clanId, rankId).flags = flags; getClanRankData(clanId, rankId).flags = flags;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setClanRankTitle(clanId, rankId, title) { function setClanRankTitle(clanId, rankId, title) {
getClanRankData(clanId, rankId).title = title; getClanRankData(clanId, rankId).title = title;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function saveAllClansToDatabase() { function saveAllClansToDatabase() {
for(let i in getServerData().clans) {
saveClanToDatabase(getServerData().clans[i]);
}
}
// ---------------------------------------------------------------------------
function setAllClanDataIndexes() {
for(let i in getServerData().clans) {
getServerData().clans[i].index = i;
for(let j in getServerData().clans[i].ranks) {
getServerData().clans[i].ranks[j].index = j;
getServerData().clans[i].ranks[j].clanIndex = i;
}
for(let k in getServerData().clans[i].members) {
getServerData().clans[i].members[k].index = k;
getServerData().clans[i].members[k].clanIndex = i;
}
}
}
// ---------------------------------------------------------------------------
function arePlayersInSameClan(client1, client2) {
if(getPlayerClan(client1) == getPlayerClan(client2)) {
return true;
}
return false;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -97,6 +97,8 @@ function initClassTable() {
this.currentSubAccount = -1; this.currentSubAccount = -1;
this.loggedIn = false; this.loggedIn = false;
this.index = -1; this.index = -1;
this.connectTime = 0;
this.clientVersion = "0.0.0";
this.busRoute = null; this.busRoute = null;
this.busRouteStop = null; this.busRouteStop = null;
@@ -120,7 +122,7 @@ function initClassTable() {
} }
}, },
accountData: class { accountData: class {
constructor(accountAssoc) { constructor(dbAssoc) {
this.databaseId = 0; this.databaseId = 0;
this.name = ""; this.name = "";
this.password = ""; this.password = "";
@@ -144,22 +146,22 @@ function initClassTable() {
this.subAccounts = []; this.subAccounts = [];
this.loggedIn = false; this.loggedIn = false;
if(accountAssoc) { if(dbAssoc) {
this.databaseId = accountAssoc["acct_id"]; this.databaseId = dbAssoc["acct_id"];
this.name = accountAssoc["acct_name"]; this.name = dbAssoc["acct_name"];
this.password = accountAssoc["acct_pass"]; this.password = dbAssoc["acct_pass"];
this.registerDate = accountAssoc["acct_when_made"]; this.registerDate = dbAssoc["acct_when_made"];
this.flags = { this.flags = {
moderation: accountAssoc["acct_mod_flags"], moderation: dbAssoc["acct_mod_flags"],
settings: accountAssoc["acct_settings"], settings: dbAssoc["acct_settings"],
admin: accountAssoc["acct_staff_flags"], admin: dbAssoc["acct_staff_flags"],
}; };
this.staffTitle = accountAssoc["acct_staff_title"]; this.staffTitle = dbAssoc["acct_staff_title"];
this.ircAccount = accountAssoc["acct_irc"] || "None"; this.ircAccount = dbAssoc["acct_irc"] || "None";
this.discordAccount = accountAssoc["acct_discord"]; this.discordAccount = dbAssoc["acct_discord"];
this.settings = accountAssoc["acct_settings"]; this.settings = dbAssoc["acct_settings"];
this.emailAddress = accountAssoc["acct_email"]; this.emailAddress = dbAssoc["acct_email"];
this.ipAddress = accountAssoc["ipstring"]; this.ipAddress = dbAssoc["ipstring"];
this.notes = []; this.notes = [];
this.messages = []; this.messages = [];
@@ -171,53 +173,72 @@ function initClassTable() {
} }
}, },
accountContactData: class { accountContactData: class {
constructor(accountContactAssoc) { constructor(dbAssoc) {
if(!accountContactAssoc) { this.databaseId = 0;
return; this.accountId = 0;
} this.contactAccountId = 0;
this.type = 0;
this.whenAdded = 0;
this.databaseId = accountContactAssoc["acct_contact_id"]; if(dbAssoc) {
this.accountId = accountContactAssoc["acct_contact_acct"]; this.databaseId = dbAssoc["acct_contact_id"];
this.contactAccountId = accountContactAssoc["acct_contact_contact"]; this.accountId = dbAssoc["acct_contact_acct"];
this.type = accountContactAssoc["acct_contact_type"]; this.contactAccountId = dbAssoc["acct_contact_contact"];
this.whenAdded = accountContactAssoc["acct_contact_when_added"]; this.type = dbAssoc["acct_contact_type"];
this.whenAdded = dbAssoc["acct_contact_when_added"];
}
} }
}, },
accountMessageData: class { accountMessageData: class {
constructor(accountMessageAssoc) { constructor(dbAssoc) {
if(!accountMessageAssoc) { this.databaseId = 0;
return; this.account = 0;
} this.whoSent = 0;
this.whenSent = 0;
this.whenRead = 0;
this.deleted = false;
this.whenDeleted = 0;
this.folder = 0;
this.message = "";
this.databaseId = accountMessageAssoc["acct_msg_id"]; if(dbAssoc) {
this.account = accountMessageAssoc["acct_msg_acct"]; this.databaseId = dbAssoc["acct_msg_id"];
this.whoSent = accountMessageAssoc["acct_msg_who_sent"]; this.account = dbAssoc["acct_msg_acct"];
this.whenSent = accountMessageAssoc["acct_msg_when_sent"]; this.whoSent = dbAssoc["acct_msg_who_sent"];
this.whenRead = accountMessageAssoc["acct_msg_when_read"]; this.whenSent = dbAssoc["acct_msg_when_sent"];
this.deleted = intToBool(accountMessageAssoc["acct_msg_deleted"]); this.whenRead = dbAssoc["acct_msg_when_read"];
this.whenDeleted = accountMessageAssoc["acct_msg_when_deleted"]; this.deleted = intToBool(dbAssoc["acct_msg_deleted"]);
this.folder = accountMessageAssoc["acct_msg_folder"]; this.whenDeleted = dbAssoc["acct_msg_when_deleted"];
this.message = accountMessageAssoc["acct_msg_message"]; this.folder = dbAssoc["acct_msg_folder"];
this.message = dbAssoc["acct_msg_message"];
}
} }
}, },
accountStaffNoteData: class { accountStaffNoteData: class {
constructor(accountStaffNoteAssoc) { constructor(dbAssoc) {
if(!accountStaffNoteAssoc) { this.databaseId = 0;
return; this.account = 0;
} this.whoAdded = 0;
this.whenAdded = 0;
this.deleted = false;
this.whenDeleted = 0;
this.server = 0;
this.note = "";
this.databaseId = accountStaffNoteAssoc["acct_note_id"]; if(dbAssoc) {
this.account = accountStaffNoteAssoc["acct_note_acct"]; this.databaseId = dbAssoc["acct_note_id"];
this.whoAdded = accountStaffNoteAssoc["acct_note_who_added"]; this.account = dbAssoc["acct_note_acct"];
this.whenAdded = accountStaffNoteAssoc["acct_note_when_added"]; this.whoAdded = dbAssoc["acct_note_who_added"];
this.deleted = intToBool(accountMessageAssoc["acct_note_deleted"]); this.whenAdded = dbAssoc["acct_note_when_added"];
this.whenDeleted = accountMessageAssoc["acct_note_when_deleted"]; this.deleted = intToBool(dbAssoc["acct_note_deleted"]);
this.server = accountMessageAssoc["acct_note_server"]; this.whenDeleted = dbAssoc["acct_note_when_deleted"];
this.note = accountMessageAssoc["acct_note_message"]; this.server = dbAssoc["acct_note_server"];
this.note = dbAssoc["acct_note_message"];
}
} }
}, },
subAccountData: class { subAccountData: class {
constructor(subAccountAssoc) { constructor(dbAssoc) {
this.databaseId = 0; this.databaseId = 0;
this.server = 0; this.server = 0;
this.firstName = "John"; this.firstName = "John";
@@ -230,60 +251,45 @@ function initClassTable() {
this.spawnPosition = toVector3(0.0, 0.0, 0.0); this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0; this.spawnHeading = 0.0;
this.lastLogin = 0; this.lastLogin = 0;
this.clan = 0; this.clan = 0;
this.clanFlags = 0; this.clanFlags = 0;
this.clanRank = 0; this.clanRank = 0;
this.clanTitle = 0; this.clanTitle = 0;
this.isWorking = false; this.isWorking = false;
this.jobUniform = this.skin; this.jobUniform = this.skin;
this.lastJobVehicle = null; this.lastJobVehicle = null;
this.job = 0; this.job = 0;
this.weapons = []; this.weapons = [];
this.inJail = false; this.inJail = false;
this.interior = 0; this.interior = 0;
this.dimension = 0; this.dimension = 0;
if(subAccountAssoc) { if(dbAssoc) {
this.databaseId = subAccountAssoc["sacct_id"]; this.databaseId = dbAssoc["sacct_id"];
this.server = subAccountAssoc["sacct_server"]; this.server = dbAssoc["sacct_server"];
this.firstName = subAccountAssoc["sacct_name_first"]; this.firstName = dbAssoc["sacct_name_first"];
this.lastName = subAccountAssoc["sacct_name_last"]; this.lastName = dbAssoc["sacct_name_last"];
this.account = subAccountAssoc["sacct_acct"]; this.account = dbAssoc["sacct_acct"];
this.skin = subAccountAssoc["sacct_skin"]; this.skin = dbAssoc["sacct_skin"];
this.cash = subAccountAssoc["sacct_cash"]; this.cash = dbAssoc["sacct_cash"];
this.placeOfOrigin = subAccountAssoc["sacct_origin"]; this.placeOfOrigin = dbAssoc["sacct_origin"];
this.dateOfBirth = subAccountAssoc["sacct_when_born"]; this.dateOfBirth = dbAssoc["sacct_when_born"];
this.spawnPosition = toVector3(subAccountAssoc["sacct_pos_x"], subAccountAssoc["sacct_pos_y"], subAccountAssoc["sacct_pos_z"]); this.spawnPosition = toVector3(dbAssoc["sacct_pos_x"], dbAssoc["sacct_pos_y"], dbAssoc["sacct_pos_z"]);
this.spawnHeading = toFloat(subAccountAssoc["sacct_angle"]); this.spawnHeading = toFloat(dbAssoc["sacct_angle"]);
this.lastLogin = toInteger(subAccountAssoc["sacct_last_login"]); this.lastLogin = toInteger(dbAssoc["sacct_last_login"]);
this.clan = toInteger(dbAssoc["sacct_clan"]);
this.clan = toInteger(subAccountAssoc["sacct_clan"]); this.clanFlags = toInteger(dbAssoc["sacct_clan_flags"]);
this.clanFlags = toInteger(subAccountAssoc["sacct_clan_flags"]); this.clanRank = toInteger(dbAssoc["sacct_clan_rank"]);
this.clanRank = toInteger(subAccountAssoc["sacct_clan_rank"]); this.clanTitle = toInteger(dbAssoc["sacct_clan_title"]);
this.clanTitle = toInteger(subAccountAssoc["sacct_clan_title"]); this.job = dbAssoc["sacct_job"];
this.interior = dbAssoc["sacct_int"];
this.isWorking = false; this.dimension = dbAssoc["sacct_vw"];
this.jobUniform = this.skin;
this.lastJobVehicle = null;
this.job = subAccountAssoc["sacct_job"];
this.weapons = [];
this.inJail = false;
this.interior = subAccountAssoc["sacct_int"];
this.dimension = subAccountAssoc["sacct_vw"];
return; return;
} }
} }
}, },
businessData: class { businessData: class {
constructor(businessAssoc) { constructor(dbAssoc) {
this.databaseId = 0; this.databaseId = 0;
this.name = ""; this.name = "";
this.ownerType = AG_BIZOWNER_NONE; this.ownerType = AG_BIZOWNER_NONE;
@@ -314,31 +320,31 @@ function initClassTable() {
this.entranceFee = 0; this.entranceFee = 0;
this.till = 0 this.till = 0
if(businessAssoc) { if(dbAssoc) {
this.databaseId = toInteger(businessAssoc["biz_id"]); this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(businessAssoc["biz_name"]); this.name = toString(dbAssoc["biz_name"]);
this.ownerType = toInteger(businessAssoc["biz_owner_type"]); this.ownerType = toInteger(dbAssoc["biz_owner_type"]);
this.ownerId = toInteger(businessAssoc["biz_owner_id"]); this.ownerId = toInteger(dbAssoc["biz_owner_id"]);
this.buyPrice = toInteger(businessAssoc["biz_buy_price"]); this.buyPrice = toInteger(dbAssoc["biz_buy_price"]);
this.locked = intToBool(toInteger(businessAssoc["biz_locked"])); this.locked = intToBool(toInteger(dbAssoc["biz_locked"]));
this.hasInterior = intToBool(toInteger(businessAssoc["biz_has_interior"])); this.hasInterior = intToBool(toInteger(dbAssoc["biz_has_interior"]));
this.entrancePosition = toVector3(toFloat(businessAssoc["biz_entrance_pos_x"]), toFloat(businessAssoc["biz_entrance_pos_y"]), toFloat(businessAssoc["biz_entrance_pos_z"])); this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"]));
this.entranceRotation = toInteger(businessAssoc["biz_entrance_rot_z"]); this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]);
this.entranceInterior = toInteger(businessAssoc["biz_entrance_int"]); this.entranceInterior = toInteger(dbAssoc["biz_entrance_int"]);
this.entranceDimension = toInteger(businessAssoc["biz_entrance_vw"]); this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(businessAssoc["biz_entrance_pickup"]); this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]); this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]);
this.exitPosition = toVector3(businessAssoc["biz_exit_pos_x"], businessAssoc["biz_exit_pos_y"], businessAssoc["biz_exit_pos_z"]); this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(businessAssoc["biz_exit_rot_z"]); this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
this.exitInterior = toInteger(businessAssoc["biz_exit_int"]); this.exitInterior = toInteger(dbAssoc["biz_exit_int"]);
this.exitDimension = toInteger(businessAssoc["biz_exit_vw"]); this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(businessAssoc["biz_exit_pickup"]); this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(businessAssoc["biz_exit_blip"]); this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.entranceFee = toInteger(businessAssoc["biz_entrance_fee"]); this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(businessAssoc["biz_till"]); this.till = toInteger(dbAssoc["biz_till"]);
} }
} }
}, },
@@ -363,14 +369,14 @@ function initClassTable() {
this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled"))); this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled")));
this.index = -1; this.index = -1;
this.position = toVector3(toFloat(dbAssoc("biz_loc_pos_x")), toFloat(dbAssoc("biz_loc_pos_y")), toFloat(dbAssoc("biz_loc_pos_z"))); this.position = toVector3(toFloat(dbAssoc["biz_loc_pos_x"]), toFloat(dbAssoc["biz_loc_pos_y"]), toFloat(dbAssoc["biz_loc_pos_z"]));
this.interior = toInteger(dbAssoc["biz_loc_int"]); this.interior = toInteger(dbAssoc["biz_loc_int"]);
this.dimension = toInteger(dbAssoc["biz_loc_vw"]); this.dimension = toInteger(dbAssoc["biz_loc_vw"]);
} }
} }
}, },
houseData: class { houseData: class {
constructor(houseAssoc) { constructor(dbAssoc) {
this.databaseId = 0 this.databaseId = 0
this.description = ""; this.description = "";
this.ownerType = AG_HOUSEOWNER_NONE; this.ownerType = AG_HOUSEOWNER_NONE;
@@ -398,36 +404,103 @@ function initClassTable() {
this.exitPickup = null; this.exitPickup = null;
this.exitBlip = null; this.exitBlip = null;
if(houseAssoc != false) { if(dbAssoc) {
this.databaseId = toInteger(houseAssoc["house_id"]); this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(houseAssoc["house_description"]); this.description = toString(dbAssoc["house_description"]);
this.ownerType = toInteger(houseAssoc["house_owner_type"]); this.ownerType = toInteger(dbAssoc["house_owner_type"]);
this.ownerId = toInteger(houseAssoc["house_owner_id"]); this.ownerId = toInteger(dbAssoc["house_owner_id"]);
this.buyPrice = toInteger(houseAssoc["house_buy_price"]); this.buyPrice = toInteger(dbAssoc["house_buy_price"]);
this.locked = intToBool(toInteger(houseAssoc["house_locked"])); this.locked = intToBool(toInteger(dbAssoc["house_locked"]));
this.hasInterior = intToBool(toInteger(houseAssoc["house_has_interior"])); this.hasInterior = intToBool(toInteger(dbAssoc["house_has_interior"]));
this.entrancePosition = toVector3(toFloat(houseAssoc["house_entrance_pos_x"]), toFloat(houseAssoc["house_entrance_pos_y"]), toFloat(houseAssoc["house_entrance_pos_z"])); this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"]));
this.entranceRotation = toFloat(houseAssoc["house_entrance_rot_z"]); this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]);
this.entranceInterior = toInteger(houseAssoc["house_entrance_int"]); this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]);
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]); this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]); this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]); this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]);
this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"])); this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]); this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
this.exitInterior = toInteger(houseAssoc["house_exit_int"]); this.exitInterior = toInteger(dbAssoc["house_exit_int"]);
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]); this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]); this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]); this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]);
} }
} }
}, },
familyData: class { clanData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.name = "";
this.owner = 0;
this.tag = "";
this.enabled = false;
this.index = -1;
this.colour = COLOUR_WHITE;
this.initialRank = 0;
this.members = [];
this.ranks = [];
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["clan_id"]);
this.name = dbAssoc["clan_name"];
this.owner = toInteger(dbAssoc["clan_owner"]);
this.tag = dbAssoc["clan_tag"];
this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"]));
this.colour = toColour(toInteger(dbAssoc["clan_colour_r"]), toInteger(dbAssoc["clan_colour_g"]), toInteger(dbAssoc["clan_colour_b"]));
}
}
}, },
factionData: class { clanRankData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.clan = 0;
this.name = "";
this.aboveRank = 0;
this.flags = 0;
this.tag = "";
this.enabled = false;
this.index = -1;
this.clanIndex = -1;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["clan_rank_id"]);
this.clan = toInteger(dbAssoc["clan_rank_clan"]);
this.name = dbAssoc["clan_rank_name"];
this.aboveRank = toInteger(dbAssoc["clan_rank_above"]);
this.flags = toInteger(dbAssoc["clan_rank_flags"]);
this.tag = dbAssoc["clan_rank_tag"];
this.enabled = intToBool(toInteger(dbAssoc["clan_enabled"]));
this.colour = toColour(toInteger(dbAssoc["clan_colour_r"]), toInteger(dbAssoc["clan_colour_g"]), toInteger(dbAssoc["clan_colour_b"]));
}
}
},
clanMemberData: class {
constructor(dbAssoc) {
this.databaseId = 0;
this.clan = 0;
this.subAccount = 0;
this.flags = 0;
this.customTitle = "";
this.customTag = "";
this.rank = 0;
this.enabled = false;
this.index = -1;
this.clanIndex = -1;
this.rankIndex = -1;
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["clan_member_id"]);
this.subAccount = toInteger(dbAssoc["clan_member_sacct"]);
this.clan = toInteger(dbAssoc["clan_member_clan"]);
this.name = dbAssoc["clan_member_name"];
this.rank = toInteger(dbAssoc["clan_member_rank"]);
this.flags = toInteger(dbAssoc["clan_member_flags"]);
this.customTag = dbAssoc["clan_member_tag"];
this.customTitle = dbAssoc["clan_member_title"];
}
}
}, },
vehicleData: class { vehicleData: class {
constructor(vehicleAssoc = false, vehicle = false) { constructor(vehicleAssoc = false, vehicle = false) {
@@ -600,6 +673,7 @@ function initClassTable() {
this.requiredRank = 0; this.requiredRank = 0;
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_equip_id"]; this.databaseId = dbAssoc["job_equip_id"];
@@ -618,6 +692,7 @@ function initClassTable() {
this.ammo = 0; this.ammo = 0;
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_equip_wep_id"]; this.databaseId = dbAssoc["job_equip_wep_id"];
@@ -637,6 +712,7 @@ function initClassTable() {
this.skin = -1; this.skin = -1;
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_uniform_id"]; this.databaseId = dbAssoc["job_uniform_id"];
@@ -659,6 +735,7 @@ function initClassTable() {
this.interior = 0; this.interior = 0;
this.dimension = 0; this.dimension = 0;
this.index = -1; this.index = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_loc_id"]; this.databaseId = dbAssoc["job_loc_id"];
@@ -679,6 +756,8 @@ function initClassTable() {
this.subAccount = 0 this.subAccount = 0
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_wl_id"]; this.databaseId = dbAssoc["job_wl_id"];
@@ -695,6 +774,7 @@ function initClassTable() {
this.subAccount = 0 this.subAccount = 0
this.enabled = false; this.enabled = false;
this.index = -1; this.index = -1;
this.jobIndex = -1;
if(dbAssoc) { if(dbAssoc) {
this.databaseId = dbAssoc["job_bl_id"]; this.databaseId = dbAssoc["job_bl_id"];

View File

@@ -175,3 +175,9 @@ function updatePlayerShowLogoState(client, state) {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function restorePlayerCamera(client) {
triggerNetworkEvent("ag.restoreCamera", client);
}
// ---------------------------------------------------------------------------

View File

@@ -52,19 +52,19 @@ let serverColours = {
} }
}; };
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getServerColours() { function getServerColours() {
return serverColours; return serverColours;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getColourByType(typeName) { function getColourByType(typeName) {
return getServerColours().byType[typeName]; return getServerColours().byType[typeName];
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getColourByName(colourName) { function getColourByName(colourName) {
return getServerColours().byName[colourName]; return getServerColours().byName[colourName];

View File

@@ -67,6 +67,9 @@ function loadCommands() {
commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true), commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true),
commandData("bizwithdraw", withdrawFromBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true), commandData("bizwithdraw", withdrawFromBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true),
commandData("bizdeposit", depositIntoBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true), commandData("bizdeposit", depositIntoBusinessCommand, "<amount>", getStaffFlagValue("none"), true, true),
commandData("buy", buyFromBusinessCommand, "<slot> [amount]", getStaffFlagValue("none"), true, true),
commandData("bizstockitem", stockItemInBusinessCommand, "<item name> <amount> <sell price>", getStaffFlagValue("none"), true, true),
commandData("bizitemprice", setBusinessItemSellPriceCommand, "<item slot> <sell price>", getStaffFlagValue("none"), true, true),
commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true), commandData("bizname", setBusinessNameCommand, "<name>", getStaffFlagValue("none"), true, true),
commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true), commandData("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), true, true),
commandData("bizblip", setBusinessBlipCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizblip", setBusinessBlipCommand, "<type name/model id>", getStaffFlagValue("manageBusinesses"), true, true),
@@ -75,6 +78,11 @@ function loadCommands() {
commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true),
commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true),
commandData("bizinttype", setBusinessInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizinttype", setBusinessInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageBusinesses"), true, true),
// TEMPORARY
commandData("buyskin", buySkinFromBusinessCommand, "<skin id>", getStaffFlagValue("none"), true, true),
commandData("buygun", buyWeaponFromBusinessCommand, "<weapon id>", getStaffFlagValue("none"), true, true),
commandData("buyammo", buyWeaponFromBusinessCommand, "<weapon id>", getStaffFlagValue("none"), true, true),
], ],
chat: [ chat: [
commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false), commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false),
@@ -123,6 +131,7 @@ function loadCommands() {
commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true), commandData("setsnow", setSnowingCommand, "<falling snow> <ground snow>", getStaffFlagValue("manageServer"), true, true),
commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), commandData("setlogo", toggleServerLogoCommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true),
commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true), commandData("setgui", toggleServerGUICommand, "<0/1 state>", getStaffFlagValue("manageServer"), true, true),
//commandData("setguicolours", setServerGUIColoursCommand, "<red> <green> <blue>", getStaffFlagValue("manageServer"), true, true),
commandData("newcharspawn", setNewCharacterSpawnPositionCommand, "", getStaffFlagValue("manageServer"), true, true), commandData("newcharspawn", setNewCharacterSpawnPositionCommand, "", getStaffFlagValue("manageServer"), true, true),
commandData("newcharcash", setNewCharacterMoneyCommand, "<amount>", getStaffFlagValue("manageServer"), true, true), commandData("newcharcash", setNewCharacterMoneyCommand, "<amount>", getStaffFlagValue("manageServer"), true, true),
commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true), commandData("newcharskin", setNewCharacterSkinCommand, "[skin id]", getStaffFlagValue("manageServer"), true, true),
@@ -130,7 +139,10 @@ function loadCommands() {
commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true), commandData("joblocinfo", getJobLocationInfoCommand, "", getStaffFlagValue("none"), true, true),
], ],
core: [], core: [],
database: [], database: [
commandData("dbquery", executeDatabaseQueryCommand, "<query>", getStaffFlagValue("developer"), true, true),
//commandData("dbinfo", getDatabaseInfoCommand, "", getStaffFlagValue("developer"), true, true),
],
developer: [ developer: [
commandData("scode", executeServerCodeCommand, "<code>", getStaffFlagValue("developer"), true, true), commandData("scode", executeServerCodeCommand, "<code>", getStaffFlagValue("developer"), true, true),
commandData("ccode", executeClientCodeCommand, "<code>", getStaffFlagValue("developer"), true, true), commandData("ccode", executeClientCodeCommand, "<code>", getStaffFlagValue("developer"), true, true),
@@ -140,7 +152,6 @@ function loadCommands() {
commandData("docmdall", simulateCommandForAllPlayers, "<command> [params]", getStaffFlagValue("developer"), true, true), commandData("docmdall", simulateCommandForAllPlayers, "<command> [params]", getStaffFlagValue("developer"), true, true),
], ],
discord: [], discord: [],
faction: [],
help: [ help: [
commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false), commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false),
], ],
@@ -160,7 +171,11 @@ function loadCommands() {
commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true), commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true),
commandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true), commandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true),
], ],
item: [], item: [
commandData("giveitem", givePlayerItemCommand, "", getStaffFlagValue("none"), true, false),
commandData("takeitem", takePlayerItemCommand, "", getStaffFlagValue("none"), true, false),
commandData("takeallitems", takeAllPlayerItemsCommand, "", getStaffFlagValue("none"), true, false),
],
job: [ job: [
commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false), commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false),
commandData("startwork", startWorkingCommand, "", getStaffFlagValue("none"), true, false), commandData("startwork", startWorkingCommand, "", getStaffFlagValue("none"), true, false),

View File

@@ -258,7 +258,7 @@ let gameConfig = {
], ],
}; };
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function initConfigScript() { function initConfigScript() {
console.log("[Asshat.Config]: Initializing config script ..."); console.log("[Asshat.Config]: Initializing config script ...");
@@ -307,7 +307,7 @@ function loadServerConfigFromId(tempServerId) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function applyConfigToServer(tempServerConfig) { function applyConfigToServer(tempServerConfig) {
server.name = tempServerConfig.name; server.name = tempServerConfig.name;
@@ -319,7 +319,7 @@ function applyConfigToServer(tempServerConfig) {
updateServerRules(); updateServerRules();
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function saveServerConfigToDatabase(serverConfigData) { function saveServerConfigToDatabase(serverConfigData) {
console.log(`[Asshat.Config]: Saving server ${serverConfigData.databaseId} configuration to database ...`); console.log(`[Asshat.Config]: Saving server ${serverConfigData.databaseId} configuration to database ...`);
@@ -335,31 +335,31 @@ function saveServerConfigToDatabase(serverConfigData) {
console.log(`[Asshat.Config]: Server ${serverConfigData.databaseId} configuration saved to database!`); console.log(`[Asshat.Config]: Server ${serverConfigData.databaseId} configuration saved to database!`);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getServerConfig() { function getServerConfig() {
return serverConfig; return serverConfig;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getGameConfig() { function getGameConfig() {
return gameConfig; return gameConfig;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getGlobalConfig() { function getGlobalConfig() {
return globalConfig; return globalConfig;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getServerId() { function getServerId() {
return getServerConfig().databaseId; return getServerConfig().databaseId;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function setTimeCommand(command, params, client) { function setTimeCommand(command, params, client) {
if(getCommand(command).requireLogin) { if(getCommand(command).requireLogin) {
@@ -518,4 +518,4 @@ function toggleServerGUICommand(command, params, client) {
return true; return true;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -142,3 +142,59 @@ const AG_ISLAND_REDCOUNTYSOUTHEAST = 3;
const AG_ISLAND_REDCOUNTYNORTH = 4; const AG_ISLAND_REDCOUNTYNORTH = 4;
const AG_ISLAND_BONECOUNTYNORTH = 5; const AG_ISLAND_BONECOUNTYNORTH = 5;
const AG_ISLAND_BONECOUNTYSOUTH = 6; const AG_ISLAND_BONECOUNTYSOUTH = 6;
// Item Owners
const AG_ITEM_OWNER_NONE = 0;
const AG_ITEM_OWNER_PLAYER = 1;
const AG_ITEM_OWNER_VEHTRUNK = 2;
const AG_ITEM_OWNER_VEHDASH = 3;
const AG_ITEM_OWNER_BIZFLOOR = 4;
const AG_ITEM_OWNER_BIZSTORAGE = 5;
const AG_ITEM_OWNER_HOUSE = 6;
const AG_ITEM_OWNER_SAFE = 7;
const AG_ITEM_OWNER_ITEM = 8;
// Item Use Types
const AG_ITEM_USETYPE_NONE = 0; // Has no effect
const AG_ITEM_USETYPE_WEAPON = 1; // Equips weapon
const AG_ITEM_USETYPE_AMMO_CLIP = 2; // Magazine for weapon. If in inventory, R will load it into gun
const AG_ITEM_USETYPE_PHONE = 3; // Pulls out phone
const AG_ITEM_USETYPE_GPS = 4; // Not sure how I want this to work yet
const AG_ITEM_USETYPE_MAP = 5; // Shows minimap on HUD
const AG_ITEM_USETYPE_SKIN = 6; // Changes skin (item skin is replaced with previous skin before changing)
const AG_ITEM_USETYPE_CLOTHESUPPER = 7; // Changes upper clothing (GTA IV shirts)
const AG_ITEM_USETYPE_CLOTHESLOWER = 8; // Changes lower clothing (GTA IV pants)
const AG_ITEM_USETYPE_STORAGE = 9; // Shows stored items. Backpack, crate, briefcase, wallet, etc
const AG_ITEM_USETYPE_VEHKEY = 10; // Locks/unlocks a vehicle and allows starting engine without hotwire
const AG_ITEM_USETYPE_BIZKEY = 11; // Locks/unlocks a business
const AG_ITEM_USETYPE_HOUSEKEY = 12; // Locks/unlocks a house
const AG_ITEM_USETYPE_SEED = 13; // Plants a seed
const AG_ITEM_USETYPE_WEED = 14; // Light drug effect (short term relief of addiction symptoms?)
const AG_ITEM_USETYPE_COKE = 15; // Medium drug effect (medium term relief of addiction symptoms?)
const AG_ITEM_USETYPE_METH = 16; // Heavy drug effect (extended term relief of addiction symptoms?)
const AG_ITEM_USETYPE_CIGAR = 17; // Just for appearance. Makes people look cool I guess
const AG_ITEM_USETYPE_WATER = 18; // Replenishes small amount of health
const AG_ITEM_USETYPE_FOOD = 19; // Eat food. Replenishes a small amount of health
const AG_ITEM_USETYPE_BEER = 20; // Subtle drunk effect. Replenishes small amount of health.
const AG_ITEM_USETYPE_WINE = 21; // Moderate drunk effect. Replenishes moderate 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_AMMO_ROUND = 23; // Bullet. Loads into magazine.
// Item Drop Types
const AG_ITEM_DROPTYPE_NONE = 0; // Can't be dropped
const AG_ITEM_DROPTYPE_OBJECT = 1; // Drops as an object on the ground
const AG_ITEM_DROPTYPE_PICKUP = 2; // Drops as a pickup
const AG_ITEM_DROPTYPE_OBJECTLIGHT = 3; // Object that produces an area light effect (lamp, flashlight, etc)
const AG_ITEM_DROPTYPE_DESTROY = 4; // Will destroy the item on drop (keys mostly but for any tiny object)
const AG_ITEM_DROPTYPE_OBJECTSTACK = 5; // Stackable objects (crates and such). Will sit on top of closest other stackable
// Forensic Types
const AG_FORENSICS_NONE = 0;
const AG_FORENSICS_BULLET = 1; // Bullet. The actual tip that hits a target. Has rifling and ballistics information of the weapon.
const AG_FORENSICS_BLOOD = 2; // Blood. Automatically applied to ground and bullets that hit when somebody is shot
const AG_FORENSICS_BODY = 3; // Body. A dead body lol
const AG_FORENSICS_HAIR = 4; // Hair. Automatically applied to
const AG_FORENSICS_SWEAT = 5; // Sweat. Automatically applied to clothing when worn
const AG_FORENSICS_SALIVA = 6; // Saliva. Automatically applied to drinks when drank
const AG_FORENSICS_BULLETCASINGS = 7; // Bullet casings. Automatically dropped when fired from a weapon except when used in a vehicle (driveby)

View File

@@ -11,7 +11,7 @@
let scriptVersion = "1.0"; let scriptVersion = "1.0";
let serverStartTime = 0; let serverStartTime = 0;
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
let serverData = { let serverData = {
saveDataIntervalTimer: false, saveDataIntervalTimer: false,
@@ -22,6 +22,10 @@ let serverData = {
families: [], families: [],
factions: [], factions: [],
commands: {}, commands: {},
antiCheat: {
whiteListedGameScripts: [],
blackListedGameScripts: [],
},
policeStations: [ policeStations: [
false, false,
[ // GTA 3 [ // GTA 3
@@ -381,7 +385,7 @@ let serverData = {
], ],
}; };
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function initServerData() { function initServerData() {
// Pre-allocate translation cache language slots // Pre-allocate translation cache language slots
@@ -391,10 +395,10 @@ function initServerData() {
global.getServerData().translation.cache.fill(translationCacheFrom); global.getServerData().translation.cache.fill(translationCacheFrom);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getServerData() { function getServerData() {
return serverData; return serverData;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
let databaseConfig = { let databaseConfig = {
host: "127.0.0.1", host: "127.0.0.1",
@@ -21,14 +21,14 @@ let databaseConfig = {
let persistentDatabaseConnection = null; let persistentDatabaseConnection = null;
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function initDatabaseScript() { function initDatabaseScript() {
console.log("[Asshat.Database]: Initializing database script ..."); console.log("[Asshat.Database]: Initializing database script ...");
console.log("[Asshat.Database]: Database script initialized successfully!"); console.log("[Asshat.Database]: Database script initialized successfully!");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function connectToDatabase() { function connectToDatabase() {
if(persistentDatabaseConnection == null) { if(persistentDatabaseConnection == null) {
@@ -48,7 +48,7 @@ function connectToDatabase() {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function disconnectFromDatabase(dbConnection) { function disconnectFromDatabase(dbConnection) {
if(!databaseConfig.usePersistentConnection) { if(!databaseConfig.usePersistentConnection) {
@@ -57,13 +57,13 @@ function disconnectFromDatabase(dbConnection) {
return true; return true;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function queryDatabase(dbConnection, queryString) { function queryDatabase(dbConnection, queryString) {
return dbConnection.query(queryString); return dbConnection.query(queryString);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function escapeDatabaseString(dbConnection, unsafeString) { function escapeDatabaseString(dbConnection, unsafeString) {
if(!dbConnection) { if(!dbConnection) {
@@ -72,32 +72,32 @@ function escapeDatabaseString(dbConnection, unsafeString) {
return dbConnection.escapeString(unsafeString); return dbConnection.escapeString(unsafeString);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getDatabaseInsertId(dbConnection) { function getDatabaseInsertId(dbConnection) {
return dbConnection.insertId; return dbConnection.insertId;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getDatabaseError(dbConnection) { function getDatabaseError(dbConnection) {
return dbConnection.error; return dbConnection.error;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function freeDatabaseQuery(dbQuery) { function freeDatabaseQuery(dbQuery) {
dbQuery.free(); dbQuery.free();
return; return;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function fetchQueryAssoc(dbQuery) { function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc(); return dbQuery.fetchAssoc();
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function quickDatabaseQuery(queryString) { function quickDatabaseQuery(queryString) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
@@ -123,4 +123,47 @@ function quickDatabaseQuery(queryString) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function executeDatabaseQueryCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isPlayerLoggedIn(client)) {
messagePlayerError(client, "You must be logged in to use this command!");
return false;
}
}
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messagePlayerError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
if(!targetClient) {
messagePlayerError(client, "That player was not found!");
return false;
}
if(targetCode == "") {
messagePlayerError(client, "You didn't enter any code!");
return false;
}
let success = quickDatabaseQuery(params);
if(!success) {
messagePlayerAlert(client, `Database query failed to execute: [#AAAAAA]${query}`);
} else if(typeof success != "boolean") {
messagePlayeSuccess(client, `Database query successful: [#AAAAAA]${query}`);
messagePlayerInfo(client, `Returns: ${success}`);
} else {
messagePlayeSuccess(client, `Database query successful: [#AAAAAA]${query}`);
}
return true;
}
// -------------------------------------------------------------------------

View File

@@ -43,8 +43,8 @@ addEventHandler("OnPlayerJoined", function(event, client) {
addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) { addEventHandler("OnPlayerQuit", function(event, client, quitReasonId) {
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`); console.log(`[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;

View File

@@ -8,7 +8,7 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
let randomTips = [ let randomTips = [
`[#FFFFFF]Press [#0066FF]E [#FFFFFF]near a taxi if you need a ride.`, `[#FFFFFF]Press [#0066FF]E [#FFFFFF]near a taxi if you need a ride.`,
@@ -26,7 +26,7 @@ let randomTips = [
`[#FFFFFF]Want to advertise your business? Visit the news station and place an /ad today!`, `[#FFFFFF]Want to advertise your business? Visit the news station and place an /ad today!`,
]; ];
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function helpCommand(command, params, client) { function helpCommand(command, params, client) {
if(areParamsEmpty(params)) { if(areParamsEmpty(params)) {
@@ -111,7 +111,7 @@ function helpCommand(command, params, client) {
// == Bindable Keys ============================ // == Bindable Keys ============================
// == Clothes ================================== // == Clothes ==================================
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showMainHelpMessage(client) { function showMainHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Help [#FF9900]================================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Help [#FF9900]=================================");
@@ -120,7 +120,7 @@ function showMainHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#A9A9A9]ammunation, skins, mechanic, dealership, discord, colours, keys"); messagePlayerNormal(client, "[#FF9900]• [#A9A9A9]ammunation, skins, mechanic, dealership, discord, colours, keys");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showAccountHelpMessage(client) { function showAccountHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Account Help [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Account Help [#FF9900]=============================");
@@ -129,7 +129,7 @@ function showAccountHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some settings you can use: [#AAAAAA]/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some settings you can use: [#AAAAAA]/gui, /logo, /iplogin, /autolastchar, /2fa, /loginalert");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showVehicleHelpMessage(client) { function showVehicleHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]=============================");
@@ -140,7 +140,7 @@ function showVehicleHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Don't forget to register and insure your vehicle! Use [#AAAAAA]/gps [#FFFFFF]to find a DMV for this."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Don't forget to register and insure your vehicle! Use [#AAAAAA]/gps [#FFFFFF]to find a DMV for this.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showVehicleDealershipHelpMessage(client) { function showVehicleDealershipHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Dealerships [#FF9900]======================"); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Dealerships [#FF9900]======================");
@@ -150,7 +150,7 @@ function showVehicleDealershipHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]A new car for sale will appear when you drive away from the dealer."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]A new car for sale will appear when you drive away from the dealer.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showJobHelpMessage(client) { function showJobHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Job Help [#FF9900]================================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Job Help [#FF9900]=================================");
@@ -161,7 +161,7 @@ function showJobHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]When entering a job vehicle, information on how to do the job will be shown to you."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]When entering a job vehicle, information on how to do the job will be shown to you.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showChatHelpMessage(client) { function showChatHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Chat Help [#FF9900]================================"); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Chat Help [#FF9900]================================");
@@ -171,7 +171,7 @@ function showChatHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some have shorter names available ([#AAAAAA]/t [#FFFFFF]for talk, [#AAAAAA]/s [#FFFFFF]for shout, etc)"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some have shorter names available ([#AAAAAA]/t [#FFFFFF]for talk, [#AAAAAA]/s [#FFFFFF]for shout, etc)");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showRulesHelpMessage(client) { function showRulesHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Server Rules [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Server Rules [#FF9900]=============================");
@@ -182,28 +182,28 @@ function showRulesHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help language"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help language");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showWebsiteHelpMessage(client) { function showWebsiteHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Website [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Website [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]The website is [#AAAAAA]https://asshatgaming.com"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]The website is [#AAAAAA]https://asshatgaming.com");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showDiscordHelpMessage(client) { function showDiscordHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Discord [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Discord [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Join our discord! [#AAAAAA]https://discord.gg/4TQ3TGB529"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Join our discord! [#AAAAAA]https://discord.gg/4TQ3TGB529");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showAnimationHelpMessage(client) { function showAnimationHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Animations [#FF9900]==============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Animations [#FF9900]===============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Animations are not yet available."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Animations are not yet available.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showAmmunationHelpMessage(client) { function showAmmunationHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Ammunation [#FF9900]==============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Ammunation [#FF9900]===============================");
@@ -213,7 +213,7 @@ function showAmmunationHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Weapons can also be purchased illegally from weapon dealers and clans."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Weapons can also be purchased illegally from weapon dealers and clans.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showClothesHelpMessage(client) { function showClothesHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Clothes [#FF9900]=================================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Clothes [#FF9900]==================================");
@@ -222,7 +222,7 @@ function showClothesHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some skins are restricted to jobs, clans, or for other reasons."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some skins are restricted to jobs, clans, or for other reasons.");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showBindKeysHelpMessage(client) { function showBindKeysHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Bindable Keys [#FF9900]============================"); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Bindable Keys [#FF9900]============================");
@@ -231,7 +231,7 @@ function showBindKeysHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your keybinds will automatically be usable on all servers"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your keybinds will automatically be usable on all servers");
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showEnteredDriverSeatHasKeysHelpTip(client) { function showEnteredDriverSeatHasKeysHelpTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.enteredDriverSeat) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.enteredDriverSeat) {
@@ -240,7 +240,7 @@ function showEnteredDriverSeatHasKeysHelpTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showApproachJobWhileUnemployedTip(client) { function showApproachJobWhileUnemployedTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachJobWhileUnemployed) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachJobWhileUnemployed) {
@@ -249,7 +249,7 @@ function showApproachJobWhileUnemployedTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showTakeNearbyJobTip(client) { function showTakeNearbyJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.takeJobWhileUnemployed) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.takeJobWhileUnemployed) {
@@ -258,7 +258,7 @@ function showTakeNearbyJobTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showApproachCurrentJobTip(client) { function showApproachCurrentJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -268,7 +268,7 @@ function showApproachCurrentJobTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showApproachOtherJobTip(client) { function showApproachOtherJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -278,7 +278,7 @@ function showApproachOtherJobTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showStartedWorkingTip(client) { function showStartedWorkingTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.startedWorking) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.startedWorking) {
@@ -288,7 +288,7 @@ function showStartedWorkingTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showApproachOwnedVehicleTip(client) { function showApproachOwnedVehicleTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachOwnedVehicle) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachOwnedVehicle) {
@@ -297,7 +297,7 @@ function showApproachOwnedVehicleTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function showApproachClanVehicleTip(client) { function showApproachClanVehicleTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachAnyVehicle) { if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachAnyVehicle) {
@@ -306,4 +306,4 @@ function showApproachClanVehicleTip(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -13,7 +13,6 @@ function initHouseScript() {
getServerData().houses = loadHousesFromDatabase(); getServerData().houses = loadHousesFromDatabase();
createAllHousePickups(); createAllHousePickups();
createAllHouseBlips(); createAllHouseBlips();
setAllHouseIndexes(); setAllHouseIndexes();
console.log("[Asshat.House]: House script initialized successfully!"); console.log("[Asshat.House]: House script initialized successfully!");
return true; return true;

View File

@@ -11,11 +11,9 @@
function initJobScript() { function initJobScript() {
console.log("[Asshat.Job]: Initializing job script ..."); console.log("[Asshat.Job]: Initializing job script ...");
getServerData().jobs = loadJobsFromDatabase(); getServerData().jobs = loadJobsFromDatabase();
setAllJobDataIndexes();
createAllJobPickups(); createAllJobPickups();
createAllJobBlips(); createAllJobBlips();
setAllJobDataIndexes();
console.log("[Asshat.Job]: Job script initialized successfully!"); console.log("[Asshat.Job]: Job script initialized successfully!");
return true; return true;
} }
@@ -683,11 +681,16 @@ function doesPlayerHaveJobType(client, jobType) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function getJobData(jobId) { function getJobData(jobId) {
for(let i in getServerData().jobs) { //for(let i in getServerData().jobs) {
if(getServerData().jobs[i].databaseId == jobId) { // if(getServerData().jobs[i].databaseId == jobId) {
return getServerData().jobs[i]; // return getServerData().jobs[i];
} // }
//}
if(typeof getServerData().jobs[jobId] != "undefined") {
return getServerData().jobs[jobId];
} }
return false; return false;
} }
@@ -750,13 +753,15 @@ function createJobLocationCommand(command, params, client) {
function deleteJobLocationCommand(command, params, client) { function deleteJobLocationCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client)); let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
let jobData = getJobData(closestJobLocation.job);
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${getJobData(closestJobLocation.jobIndex).name} [#FFFFFF]job`);
quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${closestJobLocation.databaseId}`); quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${closestJobLocation.databaseId}`);
let tempIndex = closestJobLocation.index;
let tempJob = closestJobLocation.job;
deleteJobLocation(closestJobLocation); deleteJobLocation(closestJobLocation);
getJobData(closestJobLocation.job).locations.splice(getClosestJobLocation.index, 1); getJobData(tempJob).locations.splice(tempIndex, 1);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -768,10 +773,9 @@ function toggleJobLocationEnabledCommand(command, params, client) {
} }
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client)); let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
let jobData = getJobData(closestJobLocation.job);
closestJobLocation.enabled = !closestJobLocation.enabled; closestJobLocation.enabled = !closestJobLocation.enabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(closestJobLocation.enabled)} location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(closestJobLocation.enabled)} location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${getJobData(closestJobLocation.jobIndex).name} [#FFFFFF]job`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -782,11 +786,10 @@ function toggleJobEnabledCommand(command, params, client) {
return false; return false;
} }
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
let jobData = getJobData(jobId);
jobData.enabled = !jobData.enabled; getJobData(jobId).enabled = !getJobData(jobId).enabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.enabled)} [#FFFFFF]the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).enabled)} [#FFFFFF]the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -797,11 +800,10 @@ function toggleJobWhiteListCommand(command, params, client) {
return false; return false;
} }
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
let jobData = getJobData(jobId);
jobData.whiteListEnabled = !jobData.whiteListEnabled; getJobData(jobId).whiteListEnabled = !getJobData(jobId).whiteListEnabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.whiteListEnabled)} [#FFFFFF]the whitelist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).whiteListEnabled)} [#FFFFFF]the whitelist for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -812,11 +814,10 @@ function toggleJobBlackListCommand(command, params, client) {
return false; return false;
} }
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
let jobData = getJobData(jobId);
jobData.blackListEnabled = !jobData.blackListEnabled; getJobData(jobId).blackListEnabled = !getJobData(jobId).blackListEnabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.blackListEnabled)} [#FFFFFF]the blacklist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(getJobData(jobId).blackListEnabled)} [#FFFFFF]the blacklist for the [#AAAAAA]${getJobData(jobId).name} [#FFFFFF]job`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -828,7 +829,7 @@ function addPlayerToJobBlackListCommand(command, params, client) {
} }
let targetClient = getPlayerFromParams(splitParams[0]); let targetClient = getPlayerFromParams(splitParams[0]);
let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
if(!targetClient) { if(!targetClient) {
messagePlayerError(client, `That player was not found!`); messagePlayerError(client, `That player was not found!`);
@@ -858,7 +859,7 @@ function removePlayerFromJobBlackListCommand(command, params, client) {
} }
let targetClient = getPlayerFromParams(splitParams[0]); let targetClient = getPlayerFromParams(splitParams[0]);
let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
if(!targetClient) { if(!targetClient) {
messagePlayerError(client, `That player was not found!`); messagePlayerError(client, `That player was not found!`);
@@ -888,7 +889,7 @@ function addPlayerToJobWhiteListCommand(command, params, client) {
} }
let targetClient = getPlayerFromParams(splitParams[0]); let targetClient = getPlayerFromParams(splitParams[0]);
let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
if(!targetClient) { if(!targetClient) {
messagePlayerError(client, `That player was not found!`); messagePlayerError(client, `That player was not found!`);
@@ -918,7 +919,7 @@ function removePlayerFromJobWhiteListCommand(command, params, client) {
} }
let targetClient = getPlayerFromParams(splitParams[0]); let targetClient = getPlayerFromParams(splitParams[0]);
let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).job; let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
if(!targetClient) { if(!targetClient) {
messagePlayerError(client, `That player was not found!`); messagePlayerError(client, `That player was not found!`);
@@ -1223,34 +1224,49 @@ function setAllJobDataIndexes() {
getServerData().jobs[i].index = i; getServerData().jobs[i].index = i;
for(let j in getServerData().jobs[i].locations) { for(let j in getServerData().jobs[i].locations) {
getServerData().jobs[i].locations[j].index = j; getServerData().jobs[i].locations[j].index = j;
getServerData().jobs[i].locations[j].jobIndex = i;
} }
for(let k in getServerData().jobs[i].uniforms) { for(let k in getServerData().jobs[i].uniforms) {
getServerData().jobs[i].uniforms[k].index = k; getServerData().jobs[i].uniforms[k].index = k;
getServerData().jobs[i].uniforms[k].jobIndex = i;
} }
for(let m in getServerData().jobs[i].equipment) { for(let m in getServerData().jobs[i].equipment) {
getServerData().jobs[i].equipment[m].index = m; getServerData().jobs[i].equipment[m].index = m;
getServerData().jobs[i].equipment[m].jobIndex = i;
for(let n in getServerData().jobs[i].equipment[m].weapons) { for(let n in getServerData().jobs[i].equipment[m].weapons) {
getServerData().jobs[i].equipment[m].weapons[n].index = n; getServerData().jobs[i].equipment[m].weapons[n].index = n;
getServerData().jobs[i].equipment[m].weapons[n].jobIndex = i;
getServerData().jobs[i].equipment[m].weapons[n].equipmentIndex = m;
} }
} }
for(let o in getServerData().jobs[i].blackList) {
getServerData().jobs[i].blackList[o].index = o;
getServerData().jobs[i].blackList[o].jobIndex = i;
}
for(let v in getServerData().jobs[i].whiteList) {
getServerData().jobs[i].blackList[v].index = v;
getServerData().jobs[i].blackList[v].jobIndex = i;
}
} }
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function createJobLocation(job, position, interior, dimension) { function createJobLocation(jobId, position, interior, dimension) {
let jobLocationData = new serverClasses.jobLocationData(false); let jobLocationData = new serverClasses.jobLocationData(false);
jobLocationData.position = position; jobLocationData.position = position;
jobLocationData.job = job; jobLocationData.job = getJobData(jobId).databaseId;
jobLocationData.interior = interior; jobLocationData.interior = interior;
jobLocationData.dimension = dimension; jobLocationData.dimension = dimension;
jobLocationData.enabled = true; jobLocationData.enabled = true;
getServerData().jobs[job].locations.push(jobLocationData); getServerData().jobs[jobId].locations.push(jobLocationData);
createJobLocationPickup(job, getServerData().jobs[job].locations.length-1); createJobLocationPickup(jobId, getServerData().jobs[jobId].locations.length-1);
saveJobLocationToDatabase(jobLocationData); saveJobLocationToDatabase(jobLocationData);
} }
@@ -1427,7 +1443,6 @@ function saveAllJobsToDatabase() {
function deleteJobLocationBlip(jobId, locationId) { function deleteJobLocationBlip(jobId, locationId) {
if(getJobData(jobId).locations[locationId].blip != null) { if(getJobData(jobId).locations[locationId].blip != null) {
//removeFromWorld(getJobData(jobId).locations[locationId].blip);
destroyElement(getJobData(jobId).locations[locationId].blip); destroyElement(getJobData(jobId).locations[locationId].blip);
getJobData(jobId).locations[locationId].blip = null; getJobData(jobId).locations[locationId].blip = null;
} }
@@ -1436,10 +1451,9 @@ function deleteJobLocationBlip(jobId, locationId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function deleteJobLocationPickup(jobId, locationId) { function deleteJobLocationPickup(jobId, locationId) {
if(getJobData(jobId).locations[locationId].pickup != null) { if(getServerData().jobs[jobId].locations[locationId].pickup != null) {
//removeFromWorld(getJobData(jobId).locations[locationId].pickup);
destroyElement(getJobData(jobId).locations[locationId].pickup); destroyElement(getJobData(jobId).locations[locationId].pickup);
getJobData(jobId).locations[locationId].pickup = null; getServerData().jobs[jobId].locations[locationId].pickup = null;
} }
} }

View File

@@ -274,3 +274,20 @@ function loadGameFixesResource() {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function getPlayerInfoCommand(command, params, client) {
if(areParamsEmpty(params)) {
return false;
}
let targetClient = getPlayerFromParams(params);
if(!getPlayerData(targetClient)) {
messagePlayerError(client, "Player not found!");
return false;
}
messagePlayerInfo(client, `[#AAAAAA][Player Info] [#FFFFFF]Account: [#AAAAAA]${getPlayerData(targetClient).accountData.name}[${getPlayerData(targetClient).accountData.databaseId}], [#FFFFFF]Character: [#AAAAAA]${getCharacterFullName(client)}[${getPlayerCurrentSubAccount(client).databaseId}], [#FFFFFF]Connected: [#AAAAAA]${getTimeDifferenceDisplay(Math.ceil(sdl.tick/1000), getPlayerData(targetClient).connectTime)} ago, [#FFFFFF]Game Version: [#AAAAAA]${targetClient.gameVersion}, [#FFFFFFF]Client Version: [#AAAAAA]${getPlayerData(targetClient).clientVersion}`);
}
// ---------------------------------------------------------------------------

View File

@@ -1456,7 +1456,6 @@ function processHoldActionKey(client) {
let closestBusiness = getClosestBusiness(client.player.position); let closestBusiness = getClosestBusiness(client.player.position);
let jobData = getJobData(closestJobId); let jobData = getJobData(closestJobId);
if(getPlayerCurrentSubAccount(client).job == AG_JOB_NONE) { if(getPlayerCurrentSubAccount(client).job == AG_JOB_NONE) {
if(jobData.position.distance(client.player.position) <= getGlobalConfig().takeJobDistance) { if(jobData.position.distance(client.player.position) <= getGlobalConfig().takeJobDistance) {
takeJob(client, closestJobId); takeJob(client, closestJobId);
@@ -1616,12 +1615,12 @@ function getJobFromParams(params) {
if(isNaN(params)) { if(isNaN(params)) {
for(let i in getServerData().jobs) { for(let i in getServerData().jobs) {
if(toLowerCase(getServerData().jobs[i].name).indexOf(toLowerCase(params)) != -1) { if(toLowerCase(getServerData().jobs[i].name).indexOf(toLowerCase(params)) != -1) {
return getServerData().jobs[i].databaseId; return i;
} }
} }
} else { } else {
if(typeof getServerData().jobs[params] != "undefined") { if(typeof getServerData().jobs[params] != "undefined") {
return getServerData().jobs[params].databaseId; return params;
} }
} }
@@ -1776,25 +1775,25 @@ function getClosestPoliceStation(position) {
return getServerData().policeStations[getServerGame()][closest]; return getServerData().policeStations[getServerGame()][closest];
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function isGTAIV() { function isGTAIV() {
return (getServerGame() == GAME_GTA_IV); return (getServerGame() == GAME_GTA_IV);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function arrayBufferToString(arrayBuffer) { function arrayBufferToString(arrayBuffer) {
return String.fromCharCode.apply(null, new Uint8Array(arrayBuffer)); return String.fromCharCode.apply(null, new Uint8Array(arrayBuffer));
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getPlayerDisplayForConsole(client) { function getPlayerDisplayForConsole(client) {
return `${client.name}[${client.index}]`; return `${client.name}[${client.index}]`;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getPlayerNameForNameTag(client) { function getPlayerNameForNameTag(client) {
if(isPlayerSpawned(client)) { if(isPlayerSpawned(client)) {
@@ -1803,31 +1802,31 @@ function getPlayerNameForNameTag(client) {
return client.name; return client.name;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function isPlayerSpawned(client) { function isPlayerSpawned(client) {
return (client.player != null); return (client.player != null);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getLockedUnlockedTextFromBool(boolVal) { function getLockedUnlockedTextFromBool(boolVal) {
return (boolVal) ? "locked" : "unlocked"; return (boolVal) ? "locked" : "unlocked";
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getLockedUnlockedEmojiFromBool(boolVal) { function getLockedUnlockedEmojiFromBool(boolVal) {
return (boolVal) ? "🔒" : "🔓"; return (boolVal) ? "🔒" : "🔓";
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getPlayerIsland(client) { function getPlayerIsland(client) {
return getIsland(getPlayerPosition(client)); return getIsland(getPlayerPosition(client));
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function isAtPayAndSpray(position) { function isAtPayAndSpray(position) {
for(let i in payAndSprays[getServerGame()]) { for(let i in payAndSprays[getServerGame()]) {
@@ -1839,7 +1838,7 @@ function isAtPayAndSpray(position) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
async function waitUntil(condition) { async function waitUntil(condition) {
return new Promise((resolve) => { return new Promise((resolve) => {
@@ -1854,7 +1853,7 @@ async function waitUntil(condition) {
}); });
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function resetClientStuff(client) { function resetClientStuff(client) {
console.log(`[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`); console.log(`[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
@@ -1874,4 +1873,4 @@ function resetClientStuff(client) {
getPlayerData(client).lastVehicle = null; getPlayerData(client).lastVehicle = null;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@@ -558,7 +558,7 @@ function doesClientOwnVehicle(client, vehicle) {
if(vehicleData.ownerType == AG_VEHOWNER_CLAN) { if(vehicleData.ownerType == AG_VEHOWNER_CLAN) {
if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) { if(vehicleData.ownerId == getPlayerCurrentSubAccount(client).clan) {
if(doesClientHaveClanPermission(client, "manageVehicles") || doesClientHaveClanPermission(client, "owner")) { if(doesPlayerHaveClanPermission(client, "manageVehicles") || doesPlayerHaveClanPermission(client, "owner")) {
return true; return true;
} }
} }
@@ -958,7 +958,7 @@ function setVehicleLocked(vehicle, locked) {
vehicle.locked = locked; vehicle.locked = locked;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function getVehicleOwnerTypeText(ownerType) { function getVehicleOwnerTypeText(ownerType) {
switch(ownerType) { switch(ownerType) {
@@ -979,7 +979,7 @@ function getVehicleOwnerTypeText(ownerType) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function isVehicleOwnedByJob(vehicle, jobId) { function isVehicleOwnedByJob(vehicle, jobId) {
if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) { if(getVehicleData(vehicle).ownerType == AG_VEHOWNER_JOB) {
@@ -988,7 +988,7 @@ function isVehicleOwnedByJob(vehicle, jobId) {
return false; return false;
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
async function getPlayerNewVehicle(client) { async function getPlayerNewVehicle(client) {
while(true) { while(true) {
@@ -999,7 +999,7 @@ async function getPlayerNewVehicle(client) {
} }
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------
function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, dealershipId) { function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price, dealershipId) {
let vehicleDataSlot = getServerData().vehicles.length; let vehicleDataSlot = getServerData().vehicles.length;
@@ -1025,4 +1025,4 @@ function createNewDealershipVehicle(model, spawnPosition, spawnRotation, price,
getServerData().vehicles.push(tempVehicleData); getServerData().vehicles.push(tempVehicleData);
} }
// ---------------------------------------------------------------------------- // -------------------------------------------------------------------------