More RageMP prep
This commit is contained in:
@@ -20,13 +20,9 @@ function loadSubAccountFromName(firstName, lastName) {
|
||||
firstName = escapeDatabaseString(dbConnection, firstName);
|
||||
lastName = escapeDatabaseString(dbConnection, lastName);
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_name_first = '${firstName}' AND sacct_name_last = '${lastName}' LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new SubAccountData(dbAssoc);
|
||||
}
|
||||
let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -38,13 +34,9 @@ function loadSubAccountFromId(subAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_id = ${subAccountId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
let dbAssoc = fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new SubAccountData(dbAssoc);
|
||||
}
|
||||
let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
disconnectFromDatabase(dbConnection);
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -59,35 +51,32 @@ function loadSubAccountsFromAccount(accountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_acct = ${accountId} AND sacct_server = ${getServerId()}`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
let tempSubAccount = new SubAccountData(dbAssoc);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
for(let i in dbAssoc) {
|
||||
let tempSubAccount = new SubAccountData(dbAssoc[i]);
|
||||
|
||||
// Make sure skin is valid
|
||||
if(tempSubAccount.skin == -1) {
|
||||
tempSubAccount.skin = getServerConfig().newCharacter.skin;
|
||||
}
|
||||
// Make sure skin is valid
|
||||
if(tempSubAccount.skin == -1) {
|
||||
tempSubAccount.skin = getServerConfig().newCharacter.skin;
|
||||
}
|
||||
|
||||
// Check if clan and rank are still valid
|
||||
if(tempSubAccount.clan != 0) {
|
||||
let clanId = getClanIdFromDatabaseId(tempSubAccount.clan);
|
||||
if(!getClanData(clanId)) {
|
||||
tempSubAccount.clan = 0;
|
||||
// Check if clan and rank are still valid
|
||||
if(tempSubAccount.clan != 0) {
|
||||
let clanId = getClanIdFromDatabaseId(tempSubAccount.clan);
|
||||
if(!getClanData(clanId)) {
|
||||
tempSubAccount.clan = 0;
|
||||
tempSubAccount.clanRank = 0;
|
||||
tempSubAccount.clanTitle = "";
|
||||
tempSubAccount.clanFlags = 0;
|
||||
} else {
|
||||
let rankId = getClanRankIdFromDatabaseId(clanId, tempSubAccount.clanRank);
|
||||
if(!getClanRankData(clanId, rankId)) {
|
||||
tempSubAccount.clanRank = 0;
|
||||
tempSubAccount.clanTitle = "";
|
||||
tempSubAccount.clanFlags = 0;
|
||||
} else {
|
||||
let rankId = getClanRankIdFromDatabaseId(clanId, tempSubAccount.clanRank);
|
||||
if(!getClanRankData(clanId, rankId)) {
|
||||
tempSubAccount.clanRank = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tempSubAccounts.push(tempSubAccount);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
|
||||
tempSubAccounts.push(tempSubAccount);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user