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

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

View File

@@ -9,7 +9,9 @@
// ===========================================================================
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!");
}
// ---------------------------------------------------------------------------
@@ -26,7 +28,6 @@ function loadAntiCheatGameScriptWhiteListFromDatabase() {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempWhiteListedGameScriptData = new serverClasses.whiteListedGameScriptData(dbAssoc);
tempWhiteListedGameScripts.push(tempWhiteListedGameScriptData);
console.log(`[Asshat.AntiCheat] Whitelisted game script '${tempWhiteListedGameScriptData.scriptName}' loaded successfully!`);
}
@@ -51,7 +52,6 @@ function loadAntiCheatGameScriptBlackListFromDatabase() {
if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery);
let tempBlackListedGameScriptData = new serverClasses.blackListedGameScriptData(dbAssoc);
tempBlackListedGameScripts.push(tempBlackListedGameScriptData);
console.log(`[Asshat.AntiCheat] Blacklisted game script '${tempBlackListedGameScriptData.scriptName}' loaded successfully!`);
}

View File

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

View File

@@ -13,7 +13,6 @@ function initBusinessScript() {
getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups();
createAllBusinessBlips();
setAllBusinessIndexes();
console.log("[Asshat.Business]: Business script initialized successfully!");
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) {
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) {
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
if(matchingBusinesses.length == 1) {
@@ -632,9 +694,8 @@ function getBusinessDataFromDatabaseId(databaseId) {
function getClosestBusinessEntrance(position) {
let closest = 0;
let businesses = getServerData().businesses;
for(let i in businesses) {
if(getDistance(position, businesses[i].entrancePosition) <= getDistance(position, businesses[closest].entrancePosition)) {
for(let i in getServerData().businesses) {
if(getDistance(position, getServerData().businesses[i].entrancePosition) <= getDistance(position, getServerData().businesses[closest].entrancePosition)) {
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() {
console.log("[Asshat.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
setAllClanDataIndexes();
console.log("[Asshat.Clan]: Clan script initialized successfully!");
return true;
}
@@ -45,7 +46,7 @@ function loadClansFromDatabase() {
return tempClans;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function createClanCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -60,10 +61,10 @@ function createClanCommand(command, params, client) {
// Create clan without owner. Can set owner with /clanowner afterward
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) {
if(areParamsEmpty(params)) {
@@ -78,14 +79,14 @@ function deleteClanCommand(command, params, client) {
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);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
return false;
}
@@ -94,12 +95,31 @@ function setClanOwnerCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
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) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("clanTag"))) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanTag"))) {
messagePlayerError(client, "You can not change the clan tag!");
return false;
}
@@ -108,12 +128,23 @@ function setClanTagCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
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) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("clanName"))) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("clanName"))) {
messagePlayerError(client, "You can not change the clan name!");
return false;
}
@@ -122,12 +153,23 @@ function setClanNameCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
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) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberTag"))) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("memberTag"))) {
messagePlayerError(client, "You can not change a clan member's tag!");
return false;
}
@@ -136,12 +178,31 @@ function setClanMemberTagCommand(command, params, client) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
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) {
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankTag"))) {
if(!doesPlayerHaveClanPermission(client, getClanFlagValue("rankTag"))) {
messagePlayerError(client, "You can not change a clan ranks's tag!");
return false;
}
@@ -168,10 +229,10 @@ function setClanRankTagCommand(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!");
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)}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
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)}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
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}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
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}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
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}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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!");
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}`);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function createClan(name) {
let dbConnection = connectToDatabase();
@@ -402,7 +463,7 @@ function createClan(name) {
return true;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function deleteClan(clanId) {
saveClansToDatabase();
@@ -420,7 +481,7 @@ function deleteClan(clanId) {
return false;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function getClanData(clanId) {
let clans = getServerData().clans;
@@ -433,7 +494,7 @@ function getClanData(clanId) {
return false;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function doesClanNameExist(name) {
let clans = getServerData().clans;
@@ -446,7 +507,7 @@ function doesClanNameExist(name) {
return false;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function doesClanIdExist(clanId) {
let clans = getServerData().clans;
@@ -459,13 +520,13 @@ function doesClanIdExist(clanId) {
return false;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function reloadAllClans() {
getServerData().clans = loadClansFromDatabase();
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function saveClansToDatabase() {
let clans = getServerData().clans;
@@ -474,7 +535,7 @@ function saveClansToDatabase() {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function saveClanToDatabase(clanData) {
let dbConnection = connectToDatabase();
@@ -489,58 +550,88 @@ function saveClanToDatabase(clanData) {
return false;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanTag(clanId, tag) {
getClanData(clanId).tag = tag;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanOwner(clanId, ownerId) {
getClanData(clanId).ownerId = ownerId;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanMemberTag(memberId, tag) {
// finish this later, need to query db
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanMemberFlags(memberId, flags) {
// finish this later, need to query db
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanMemberTitle(memberId, title) {
// finish this later, need to query db
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanRankTag(clanId, rankId, tag) {
getClanRankData(clanId, rankId).tag = tag;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanRankFlags(clanId, rankId, flags) {
getClanRankData(clanId, rankId).flags = flags;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function setClanRankTitle(clanId, rankId, title) {
getClanRankData(clanId, rankId).title = title;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
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.loggedIn = false;
this.index = -1;
this.connectTime = 0;
this.clientVersion = "0.0.0";
this.busRoute = null;
this.busRouteStop = null;
@@ -120,7 +122,7 @@ function initClassTable() {
}
},
accountData: class {
constructor(accountAssoc) {
constructor(dbAssoc) {
this.databaseId = 0;
this.name = "";
this.password = "";
@@ -144,22 +146,22 @@ function initClassTable() {
this.subAccounts = [];
this.loggedIn = false;
if(accountAssoc) {
this.databaseId = accountAssoc["acct_id"];
this.name = accountAssoc["acct_name"];
this.password = accountAssoc["acct_pass"];
this.registerDate = accountAssoc["acct_when_made"];
if(dbAssoc) {
this.databaseId = dbAssoc["acct_id"];
this.name = dbAssoc["acct_name"];
this.password = dbAssoc["acct_pass"];
this.registerDate = dbAssoc["acct_when_made"];
this.flags = {
moderation: accountAssoc["acct_mod_flags"],
settings: accountAssoc["acct_settings"],
admin: accountAssoc["acct_staff_flags"],
moderation: dbAssoc["acct_mod_flags"],
settings: dbAssoc["acct_settings"],
admin: dbAssoc["acct_staff_flags"],
};
this.staffTitle = accountAssoc["acct_staff_title"];
this.ircAccount = accountAssoc["acct_irc"] || "None";
this.discordAccount = accountAssoc["acct_discord"];
this.settings = accountAssoc["acct_settings"];
this.emailAddress = accountAssoc["acct_email"];
this.ipAddress = accountAssoc["ipstring"];
this.staffTitle = dbAssoc["acct_staff_title"];
this.ircAccount = dbAssoc["acct_irc"] || "None";
this.discordAccount = dbAssoc["acct_discord"];
this.settings = dbAssoc["acct_settings"];
this.emailAddress = dbAssoc["acct_email"];
this.ipAddress = dbAssoc["ipstring"];
this.notes = [];
this.messages = [];
@@ -171,53 +173,72 @@ function initClassTable() {
}
},
accountContactData: class {
constructor(accountContactAssoc) {
if(!accountContactAssoc) {
return;
}
constructor(dbAssoc) {
this.databaseId = 0;
this.accountId = 0;
this.contactAccountId = 0;
this.type = 0;
this.whenAdded = 0;
this.databaseId = accountContactAssoc["acct_contact_id"];
this.accountId = accountContactAssoc["acct_contact_acct"];
this.contactAccountId = accountContactAssoc["acct_contact_contact"];
this.type = accountContactAssoc["acct_contact_type"];
this.whenAdded = accountContactAssoc["acct_contact_when_added"];
if(dbAssoc) {
this.databaseId = dbAssoc["acct_contact_id"];
this.accountId = dbAssoc["acct_contact_acct"];
this.contactAccountId = dbAssoc["acct_contact_contact"];
this.type = dbAssoc["acct_contact_type"];
this.whenAdded = dbAssoc["acct_contact_when_added"];
}
}
},
accountMessageData: class {
constructor(accountMessageAssoc) {
if(!accountMessageAssoc) {
return;
}
constructor(dbAssoc) {
this.databaseId = 0;
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"];
this.account = accountMessageAssoc["acct_msg_acct"];
this.whoSent = accountMessageAssoc["acct_msg_who_sent"];
this.whenSent = accountMessageAssoc["acct_msg_when_sent"];
this.whenRead = accountMessageAssoc["acct_msg_when_read"];
this.deleted = intToBool(accountMessageAssoc["acct_msg_deleted"]);
this.whenDeleted = accountMessageAssoc["acct_msg_when_deleted"];
this.folder = accountMessageAssoc["acct_msg_folder"];
this.message = accountMessageAssoc["acct_msg_message"];
if(dbAssoc) {
this.databaseId = dbAssoc["acct_msg_id"];
this.account = dbAssoc["acct_msg_acct"];
this.whoSent = dbAssoc["acct_msg_who_sent"];
this.whenSent = dbAssoc["acct_msg_when_sent"];
this.whenRead = dbAssoc["acct_msg_when_read"];
this.deleted = intToBool(dbAssoc["acct_msg_deleted"]);
this.whenDeleted = dbAssoc["acct_msg_when_deleted"];
this.folder = dbAssoc["acct_msg_folder"];
this.message = dbAssoc["acct_msg_message"];
}
}
},
accountStaffNoteData: class {
constructor(accountStaffNoteAssoc) {
if(!accountStaffNoteAssoc) {
return;
}
constructor(dbAssoc) {
this.databaseId = 0;
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"];
this.account = accountStaffNoteAssoc["acct_note_acct"];
this.whoAdded = accountStaffNoteAssoc["acct_note_who_added"];
this.whenAdded = accountStaffNoteAssoc["acct_note_when_added"];
this.deleted = intToBool(accountMessageAssoc["acct_note_deleted"]);
this.whenDeleted = accountMessageAssoc["acct_note_when_deleted"];
this.server = accountMessageAssoc["acct_note_server"];
this.note = accountMessageAssoc["acct_note_message"];
if(dbAssoc) {
this.databaseId = dbAssoc["acct_note_id"];
this.account = dbAssoc["acct_note_acct"];
this.whoAdded = dbAssoc["acct_note_who_added"];
this.whenAdded = dbAssoc["acct_note_when_added"];
this.deleted = intToBool(dbAssoc["acct_note_deleted"]);
this.whenDeleted = dbAssoc["acct_note_when_deleted"];
this.server = dbAssoc["acct_note_server"];
this.note = dbAssoc["acct_note_message"];
}
}
},
subAccountData: class {
constructor(subAccountAssoc) {
constructor(dbAssoc) {
this.databaseId = 0;
this.server = 0;
this.firstName = "John";
@@ -230,60 +251,45 @@ function initClassTable() {
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
this.spawnHeading = 0.0;
this.lastLogin = 0;
this.clan = 0;
this.clanFlags = 0;
this.clanRank = 0;
this.clanTitle = 0;
this.isWorking = false;
this.jobUniform = this.skin;
this.lastJobVehicle = null;
this.job = 0;
this.weapons = [];
this.inJail = false;
this.interior = 0;
this.dimension = 0;
if(subAccountAssoc) {
this.databaseId = subAccountAssoc["sacct_id"];
this.server = subAccountAssoc["sacct_server"];
this.firstName = subAccountAssoc["sacct_name_first"];
this.lastName = subAccountAssoc["sacct_name_last"];
this.account = subAccountAssoc["sacct_acct"];
this.skin = subAccountAssoc["sacct_skin"];
this.cash = subAccountAssoc["sacct_cash"];
this.placeOfOrigin = subAccountAssoc["sacct_origin"];
this.dateOfBirth = subAccountAssoc["sacct_when_born"];
this.spawnPosition = toVector3(subAccountAssoc["sacct_pos_x"], subAccountAssoc["sacct_pos_y"], subAccountAssoc["sacct_pos_z"]);
this.spawnHeading = toFloat(subAccountAssoc["sacct_angle"]);
this.lastLogin = toInteger(subAccountAssoc["sacct_last_login"]);
this.clan = toInteger(subAccountAssoc["sacct_clan"]);
this.clanFlags = toInteger(subAccountAssoc["sacct_clan_flags"]);
this.clanRank = toInteger(subAccountAssoc["sacct_clan_rank"]);
this.clanTitle = toInteger(subAccountAssoc["sacct_clan_title"]);
this.isWorking = false;
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"];
if(dbAssoc) {
this.databaseId = dbAssoc["sacct_id"];
this.server = dbAssoc["sacct_server"];
this.firstName = dbAssoc["sacct_name_first"];
this.lastName = dbAssoc["sacct_name_last"];
this.account = dbAssoc["sacct_acct"];
this.skin = dbAssoc["sacct_skin"];
this.cash = dbAssoc["sacct_cash"];
this.placeOfOrigin = dbAssoc["sacct_origin"];
this.dateOfBirth = dbAssoc["sacct_when_born"];
this.spawnPosition = toVector3(dbAssoc["sacct_pos_x"], dbAssoc["sacct_pos_y"], dbAssoc["sacct_pos_z"]);
this.spawnHeading = toFloat(dbAssoc["sacct_angle"]);
this.lastLogin = toInteger(dbAssoc["sacct_last_login"]);
this.clan = toInteger(dbAssoc["sacct_clan"]);
this.clanFlags = toInteger(dbAssoc["sacct_clan_flags"]);
this.clanRank = toInteger(dbAssoc["sacct_clan_rank"]);
this.clanTitle = toInteger(dbAssoc["sacct_clan_title"]);
this.job = dbAssoc["sacct_job"];
this.interior = dbAssoc["sacct_int"];
this.dimension = dbAssoc["sacct_vw"];
return;
}
}
},
businessData: class {
constructor(businessAssoc) {
constructor(dbAssoc) {
this.databaseId = 0;
this.name = "";
this.ownerType = AG_BIZOWNER_NONE;
@@ -314,31 +320,31 @@ function initClassTable() {
this.entranceFee = 0;
this.till = 0
if(businessAssoc) {
this.databaseId = toInteger(businessAssoc["biz_id"]);
this.name = toString(businessAssoc["biz_name"]);
this.ownerType = toInteger(businessAssoc["biz_owner_type"]);
this.ownerId = toInteger(businessAssoc["biz_owner_id"]);
this.buyPrice = toInteger(businessAssoc["biz_buy_price"]);
this.locked = intToBool(toInteger(businessAssoc["biz_locked"]));
this.hasInterior = intToBool(toInteger(businessAssoc["biz_has_interior"]));
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["biz_id"]);
this.name = toString(dbAssoc["biz_name"]);
this.ownerType = toInteger(dbAssoc["biz_owner_type"]);
this.ownerId = toInteger(dbAssoc["biz_owner_id"]);
this.buyPrice = toInteger(dbAssoc["biz_buy_price"]);
this.locked = intToBool(toInteger(dbAssoc["biz_locked"]));
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.entranceRotation = toInteger(businessAssoc["biz_entrance_rot_z"]);
this.entranceInterior = toInteger(businessAssoc["biz_entrance_int"]);
this.entranceDimension = toInteger(businessAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(businessAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]);
this.entrancePosition = toVector3(toFloat(dbAssoc["biz_entrance_pos_x"]), toFloat(dbAssoc["biz_entrance_pos_y"]), toFloat(dbAssoc["biz_entrance_pos_z"]));
this.entranceRotation = toInteger(dbAssoc["biz_entrance_rot_z"]);
this.entranceInterior = toInteger(dbAssoc["biz_entrance_int"]);
this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]);
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.exitRotation = toInteger(businessAssoc["biz_exit_rot_z"]);
this.exitInterior = toInteger(businessAssoc["biz_exit_int"]);
this.exitDimension = toInteger(businessAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(businessAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(businessAssoc["biz_exit_blip"]);
this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]);
this.exitInterior = toInteger(dbAssoc["biz_exit_int"]);
this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]);
this.entranceFee = toInteger(businessAssoc["biz_entrance_fee"]);
this.till = toInteger(businessAssoc["biz_till"]);
this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]);
this.till = toInteger(dbAssoc["biz_till"]);
}
}
},
@@ -363,14 +369,14 @@ function initClassTable() {
this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled")));
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.dimension = toInteger(dbAssoc["biz_loc_vw"]);
}
}
},
houseData: class {
constructor(houseAssoc) {
constructor(dbAssoc) {
this.databaseId = 0
this.description = "";
this.ownerType = AG_HOUSEOWNER_NONE;
@@ -398,36 +404,103 @@ function initClassTable() {
this.exitPickup = null;
this.exitBlip = null;
if(houseAssoc != false) {
this.databaseId = toInteger(houseAssoc["house_id"]);
this.description = toString(houseAssoc["house_description"]);
this.ownerType = toInteger(houseAssoc["house_owner_type"]);
this.ownerId = toInteger(houseAssoc["house_owner_id"]);
this.buyPrice = toInteger(houseAssoc["house_buy_price"]);
this.locked = intToBool(toInteger(houseAssoc["house_locked"]));
this.hasInterior = intToBool(toInteger(houseAssoc["house_has_interior"]));
if(dbAssoc) {
this.databaseId = toInteger(dbAssoc["house_id"]);
this.description = toString(dbAssoc["house_description"]);
this.ownerType = toInteger(dbAssoc["house_owner_type"]);
this.ownerId = toInteger(dbAssoc["house_owner_id"]);
this.buyPrice = toInteger(dbAssoc["house_buy_price"]);
this.locked = intToBool(toInteger(dbAssoc["house_locked"]));
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.entranceRotation = toFloat(houseAssoc["house_entrance_rot_z"]);
this.entranceInterior = toInteger(houseAssoc["house_entrance_int"]);
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]);
this.entrancePosition = toVector3(toFloat(dbAssoc["house_entrance_pos_x"]), toFloat(dbAssoc["house_entrance_pos_y"]), toFloat(dbAssoc["house_entrance_pos_z"]));
this.entranceRotation = toFloat(dbAssoc["house_entrance_rot_z"]);
this.entranceInterior = toInteger(dbAssoc["house_entrance_int"]);
this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]);
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.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]);
this.exitInterior = toInteger(houseAssoc["house_exit_int"]);
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]);
this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]);
this.exitInterior = toInteger(dbAssoc["house_exit_int"]);
this.exitDimension = toInteger(dbAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]);
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 {
constructor(vehicleAssoc = false, vehicle = false) {
@@ -600,6 +673,7 @@ function initClassTable() {
this.requiredRank = 0;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_equip_id"];
@@ -618,6 +692,7 @@ function initClassTable() {
this.ammo = 0;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_equip_wep_id"];
@@ -637,6 +712,7 @@ function initClassTable() {
this.skin = -1;
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_uniform_id"];
@@ -659,6 +735,7 @@ function initClassTable() {
this.interior = 0;
this.dimension = 0;
this.index = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_loc_id"];
@@ -679,6 +756,8 @@ function initClassTable() {
this.subAccount = 0
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_wl_id"];
@@ -695,6 +774,7 @@ function initClassTable() {
this.subAccount = 0
this.enabled = false;
this.index = -1;
this.jobIndex = -1;
if(dbAssoc) {
this.databaseId = dbAssoc["job_bl_id"];

View File

@@ -174,4 +174,10 @@ function updatePlayerShowLogoState(client, state) {
triggerNetworkEvent("ag.logo", client, state);
}
// ---------------------------------------------------------------------------
function restorePlayerCamera(client) {
triggerNetworkEvent("ag.restoreCamera", client);
}
// ---------------------------------------------------------------------------

View File

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

View File

@@ -67,6 +67,9 @@ function loadCommands() {
commandData("biztill", viewBusinessTillAmountCommand, "", getStaffFlagValue("none"), true, true),
commandData("bizwithdraw", withdrawFromBusinessCommand, "<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("bizowner", setBusinessOwnerCommand, "<player name/id>", getStaffFlagValue("none"), 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("bizexit", moveBusinessExitCommand, "", 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: [
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("setlogo", toggleServerLogoCommand, "<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("newcharcash", setNewCharacterMoneyCommand, "<amount>", 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),
],
core: [],
database: [],
database: [
commandData("dbquery", executeDatabaseQueryCommand, "<query>", getStaffFlagValue("developer"), true, true),
//commandData("dbinfo", getDatabaseInfoCommand, "", getStaffFlagValue("developer"), true, true),
],
developer: [
commandData("scode", executeServerCodeCommand, "<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),
],
discord: [],
faction: [],
help: [
commandData("help", helpCommand, "", getStaffFlagValue("none"), false, false),
],
@@ -160,7 +171,11 @@ function loadCommands() {
commandData("houseexit", moveHouseExitCommand, "", 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: [
commandData("takejob", takeJobCommand, "", getStaffFlagValue("none"), true, false),
commandData("startwork", startWorkingCommand, "", getStaffFlagValue("none"), true, false),

View File

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

View File

@@ -141,4 +141,60 @@ const AG_ISLAND_SANFIERRO = 2;
const AG_ISLAND_REDCOUNTYSOUTHEAST = 3;
const AG_ISLAND_REDCOUNTYNORTH = 4;
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 serverStartTime = 0;
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
let serverData = {
saveDataIntervalTimer: false,
@@ -22,6 +22,10 @@ let serverData = {
families: [],
factions: [],
commands: {},
antiCheat: {
whiteListedGameScripts: [],
blackListedGameScripts: [],
},
policeStations: [
false,
[ // GTA 3
@@ -381,7 +385,7 @@ let serverData = {
],
};
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function initServerData() {
// Pre-allocate translation cache language slots
@@ -391,10 +395,10 @@ function initServerData() {
global.getServerData().translation.cache.fill(translationCacheFrom);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function getServerData() {
return serverData;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
let databaseConfig = {
host: "127.0.0.1",
@@ -21,14 +21,14 @@ let databaseConfig = {
let persistentDatabaseConnection = null;
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function initDatabaseScript() {
console.log("[Asshat.Database]: Initializing database script ...");
console.log("[Asshat.Database]: Database script initialized successfully!");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function connectToDatabase() {
if(persistentDatabaseConnection == null) {
@@ -48,7 +48,7 @@ function connectToDatabase() {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function disconnectFromDatabase(dbConnection) {
if(!databaseConfig.usePersistentConnection) {
@@ -57,13 +57,13 @@ function disconnectFromDatabase(dbConnection) {
return true;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function queryDatabase(dbConnection, queryString) {
return dbConnection.query(queryString);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function escapeDatabaseString(dbConnection, unsafeString) {
if(!dbConnection) {
@@ -72,32 +72,32 @@ function escapeDatabaseString(dbConnection, unsafeString) {
return dbConnection.escapeString(unsafeString);
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function getDatabaseInsertId(dbConnection) {
return dbConnection.insertId;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function getDatabaseError(dbConnection) {
return dbConnection.error;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function freeDatabaseQuery(dbQuery) {
dbQuery.free();
return;
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc();
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function quickDatabaseQuery(queryString) {
let dbConnection = connectToDatabase();
@@ -123,4 +123,47 @@ function quickDatabaseQuery(queryString) {
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) {
console.log(`[Asshat.Event] ${getPlayerDisplayForConsole(client)} disconnected (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
savePlayerToDatabase(client);
//savePlayerToDatabase(client);
resetClientStuff(client);
getServerData().clients[client.index] = null;

View File

@@ -8,7 +8,7 @@
// TYPE: Server (JavaScript)
// ===========================================================================
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
let randomTips = [
`[#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!`,
];
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function helpCommand(command, params, client) {
if(areParamsEmpty(params)) {
@@ -111,7 +111,7 @@ function helpCommand(command, params, client) {
// == Bindable Keys ============================
// == Clothes ==================================
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showMainHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Help [#FF9900]=================================");
@@ -120,7 +120,7 @@ function showMainHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#A9A9A9]ammunation, skins, mechanic, dealership, discord, colours, keys");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showAccountHelpMessage(client) {
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");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showVehicleHelpMessage(client) {
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.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showVehicleDealershipHelpMessage(client) {
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.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showJobHelpMessage(client) {
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.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showChatHelpMessage(client) {
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)");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showRulesHelpMessage(client) {
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");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showWebsiteHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Website [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]The website is [#AAAAAA]https://asshatgaming.com");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showDiscordHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Discord [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Join our discord! [#AAAAAA]https://discord.gg/4TQ3TGB529");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showAnimationHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Animations [#FF9900]===============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Animations are not yet available.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showAmmunationHelpMessage(client) {
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.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showClothesHelpMessage(client) {
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.");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showBindKeysHelpMessage(client) {
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");
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showEnteredDriverSeatHasKeysHelpTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.enteredDriverSeat) {
@@ -240,7 +240,7 @@ function showEnteredDriverSeatHasKeysHelpTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showApproachJobWhileUnemployedTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachJobWhileUnemployed) {
@@ -249,7 +249,7 @@ function showApproachJobWhileUnemployedTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showTakeNearbyJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.takeJobWhileUnemployed) {
@@ -258,7 +258,7 @@ function showTakeNearbyJobTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showApproachCurrentJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -268,7 +268,7 @@ function showApproachCurrentJobTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showApproachOtherJobTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachCurrentJob) {
@@ -278,7 +278,7 @@ function showApproachOtherJobTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showStartedWorkingTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.startedWorking) {
@@ -288,7 +288,7 @@ function showStartedWorkingTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showApproachOwnedVehicleTip(client) {
if(getPlayerData(client).accountData.shownTips & !shownTipsFlags.approachOwnedVehicle) {
@@ -297,7 +297,7 @@ function showApproachOwnedVehicleTip(client) {
}
}
// ----------------------------------------------------------------------------
// -------------------------------------------------------------------------
function showApproachClanVehicleTip(client) {
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();
createAllHousePickups();
createAllHouseBlips();
setAllHouseIndexes();
console.log("[Asshat.House]: House script initialized successfully!");
return true;

View File

@@ -11,11 +11,9 @@
function initJobScript() {
console.log("[Asshat.Job]: Initializing job script ...");
getServerData().jobs = loadJobsFromDatabase();
setAllJobDataIndexes();
createAllJobPickups();
createAllJobBlips();
setAllJobDataIndexes();
console.log("[Asshat.Job]: Job script initialized successfully!");
return true;
}
@@ -683,11 +681,16 @@ function doesPlayerHaveJobType(client, jobType) {
// ---------------------------------------------------------------------------
function getJobData(jobId) {
for(let i in getServerData().jobs) {
if(getServerData().jobs[i].databaseId == jobId) {
return getServerData().jobs[i];
}
//for(let i in getServerData().jobs) {
// if(getServerData().jobs[i].databaseId == jobId) {
// return getServerData().jobs[i];
// }
//}
if(typeof getServerData().jobs[jobId] != "undefined") {
return getServerData().jobs[jobId];
}
return false;
}
@@ -750,13 +753,15 @@ function createJobLocationCommand(command, params, client) {
function deleteJobLocationCommand(command, params, 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}`);
let tempIndex = closestJobLocation.index;
let tempJob = closestJobLocation.job;
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 jobData = getJobData(closestJobLocation.job);
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;
}
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job;
let jobData = getJobData(jobId);
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
jobData.enabled = !jobData.enabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.enabled)} [#FFFFFF]the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
getJobData(jobId).enabled = !getJobData(jobId).enabled;
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;
}
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job;
let jobData = getJobData(jobId);
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
jobData.whiteListEnabled = !jobData.whiteListEnabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.whiteListEnabled)} [#FFFFFF]the whitelist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
getJobData(jobId).whiteListEnabled = !getJobData(jobId).whiteListEnabled;
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;
}
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).job;
let jobData = getJobData(jobId);
let jobId = getJobFromParams(params) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
jobData.blackListEnabled = !jobData.blackListEnabled;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(jobData.blackListEnabled)} [#FFFFFF]the blacklist for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
getJobData(jobId).blackListEnabled = !getJobData(jobId).blackListEnabled;
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 jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).job;
let jobId = getJobFromParams(splitParams[1]) || getClosestJobLocation(getPlayerPosition(client)).jobIndex;
if(!targetClient) {
messagePlayerError(client, `That player was not found!`);
@@ -858,7 +859,7 @@ function removePlayerFromJobBlackListCommand(command, params, client) {
}
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) {
messagePlayerError(client, `That player was not found!`);
@@ -888,7 +889,7 @@ function addPlayerToJobWhiteListCommand(command, params, client) {
}
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) {
messagePlayerError(client, `That player was not found!`);
@@ -918,7 +919,7 @@ function removePlayerFromJobWhiteListCommand(command, params, client) {
}
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) {
messagePlayerError(client, `That player was not found!`);
@@ -1223,34 +1224,49 @@ function setAllJobDataIndexes() {
getServerData().jobs[i].index = i;
for(let j in getServerData().jobs[i].locations) {
getServerData().jobs[i].locations[j].index = j;
getServerData().jobs[i].locations[j].jobIndex = i;
}
for(let k in getServerData().jobs[i].uniforms) {
getServerData().jobs[i].uniforms[k].index = k;
getServerData().jobs[i].uniforms[k].jobIndex = i;
}
for(let m in getServerData().jobs[i].equipment) {
getServerData().jobs[i].equipment[m].index = m;
getServerData().jobs[i].equipment[m].jobIndex = i;
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].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);
jobLocationData.position = position;
jobLocationData.job = job;
jobLocationData.job = getJobData(jobId).databaseId;
jobLocationData.interior = interior;
jobLocationData.dimension = dimension;
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);
}
@@ -1427,7 +1443,6 @@ function saveAllJobsToDatabase() {
function deleteJobLocationBlip(jobId, locationId) {
if(getJobData(jobId).locations[locationId].blip != null) {
//removeFromWorld(getJobData(jobId).locations[locationId].blip);
destroyElement(getJobData(jobId).locations[locationId].blip);
getJobData(jobId).locations[locationId].blip = null;
}
@@ -1436,10 +1451,9 @@ function deleteJobLocationBlip(jobId, locationId) {
// ---------------------------------------------------------------------------
function deleteJobLocationPickup(jobId, locationId) {
if(getJobData(jobId).locations[locationId].pickup != null) {
//removeFromWorld(getJobData(jobId).locations[locationId].pickup);
if(getServerData().jobs[jobId].locations[locationId].pickup != null) {
destroyElement(getJobData(jobId).locations[locationId].pickup);
getJobData(jobId).locations[locationId].pickup = null;
getServerData().jobs[jobId].locations[locationId].pickup = null;
}
}

View File

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

View File

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