Change serverId to util func
This commit is contained in:
@@ -485,7 +485,7 @@ function saveAccountStaffNotesDatabase(staffNoteData) {
|
||||
if(dbConnection) {
|
||||
let safeNoteContent = escapeDatabaseString(dbConnection, staffNoteData.note);
|
||||
if(staffNoteData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO acct_note (acct_note_message, acct_note_who_added, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${serverId}, ${staffNoteData.account}`;
|
||||
let dbQueryString = `INSERT INTO acct_note (acct_note_message, acct_note_who_added, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${getServerId()}, ${staffNoteData.account}`;
|
||||
staffNoteData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -503,7 +503,7 @@ function saveAccountContactsDatabase(accountContactData) {
|
||||
if(dbConnection) {
|
||||
let safeNoteContent = escapeDatabaseString(dbConnection, accountContactData.note);
|
||||
if(accountContactData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO acct_contact (acct_contact_note, acct_contact_, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${serverId}, ${staffNoteData.account}`;
|
||||
let dbQueryString = `INSERT INTO acct_contact (acct_contact_note, acct_contact_, acct_note_when_added, acct_note_server, acct_note_acct) VALUES ('${safeNoteContent}', ${staffNoteData.whoAdded}, UNIX_TIMESTAMP(), ${getServerId()}, ${staffNoteData.account}`;
|
||||
staffNoteData.databaseId = getDatabaseInsertId(dbConnection);
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
@@ -925,12 +925,6 @@ function isAccountAutoIPLoginEnabled(accountData) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.clientReady", function(client) {
|
||||
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function doesPlayerHaveGUIEnabled(client) {
|
||||
if(hasBitFlag(getPlayerData(client).accountData.settings, getAccountSettingsFlagValue("noGUI"))) {
|
||||
return false;
|
||||
|
||||
@@ -14,13 +14,13 @@ function initAntiCheatScript() {
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function loadAntiCheatGameScriptWhiteListFromDatabase(serverId) {
|
||||
function loadAntiCheatGameScriptWhiteListFromDatabase() {
|
||||
console.log(`[Asshat.AntiCheat] Loading whitelisted game scripts ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempWhiteListedGameScripts = [];
|
||||
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM ac_script_wl WHERE ac_script_wl_enabled = 1 AND ac_script_wl_server = ${serverId}`;
|
||||
let dbQueryString = `SELECT * FROM ac_script_wl WHERE ac_script_wl_enabled = 1 AND ac_script_wl_server = ${getServerId()}`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
@@ -39,13 +39,13 @@ function loadAntiCheatGameScriptWhiteListFromDatabase(serverId) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function loadAntiCheatGameScriptBlackListFromDatabase(serverId) {
|
||||
function loadAntiCheatGameScriptBlackListFromDatabase() {
|
||||
console.log(`[Asshat.AntiCheat] Loading blacklisted game scripts ...`);
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempBlackListedGameScripts = [];
|
||||
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM ac_script_bl WHERE ac_script_bl_enabled = 1 AND ac_script_bl_server = ${serverId}`;
|
||||
let dbQueryString = `SELECT * FROM ac_script_bl WHERE ac_script_bl_enabled = 1 AND ac_script_bl_server = ${getServerId()}`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
|
||||
@@ -46,7 +46,7 @@ function loadBusinessesFromDatabase() {
|
||||
let dbAssoc;
|
||||
|
||||
if(dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${serverId}`);
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_server = ${getServerId()}`);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
@@ -588,7 +588,7 @@ function saveBusinessToDatabase(businessId) {
|
||||
if(dbConnection) {
|
||||
let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name);
|
||||
if(tempBusinessData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${serverId}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.exitDimension})`;
|
||||
let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.exitDimension})`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection);
|
||||
} else {
|
||||
|
||||
@@ -25,7 +25,7 @@ function loadClansFromDatabase() {
|
||||
let dbAssoc;
|
||||
|
||||
if(dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, "SELECT * FROM `clan_main` WHERE `clan_deleted` = 0 AND `clan_server` = " + toString(serverId));
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
@@ -41,7 +41,7 @@ function loadClansFromDatabase() {
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
console.log("[Asshat.Clan]: " + toString(tempClans.length) + " clans loaded from database successfully!");
|
||||
console.log(`[Asshat.Clan]: ${tempClans.length} clans loaded from database successfully!`);
|
||||
return tempClans;
|
||||
}
|
||||
|
||||
@@ -150,11 +150,27 @@ function setClanRankTagCommand(command, params, client) {
|
||||
messageClientSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let splitParams = params.split(" ");
|
||||
|
||||
let clanId = getPlayerClan(client);
|
||||
|
||||
if(!getClanData(clanId)) {
|
||||
messageClientError(client, "Clan not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let rankId = getClanRankFromParams(clanId, splitParams[0]);
|
||||
|
||||
if(!getClanRankData(clanId, rankId)) {
|
||||
messageClientError(client, "Clan rank not found!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function setClanMemberFlagsCommand(command, params, client) {
|
||||
function addClanMemberFlagCommand(command, params, client) {
|
||||
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
|
||||
messageClientError(client, "You can not change a clan member's permissions!");
|
||||
return false;
|
||||
@@ -191,6 +207,43 @@ function setClanMemberFlagsCommand(command, params, client) {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function removeClanMemberFlagCommand(command, params, client) {
|
||||
if(!doesClientHaveClanPermission(client, getClanFlagValue("memberFlags"))) {
|
||||
messageClientError(client, "You can not change a clan member's permissions!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(areParamsEmpty(params)) {
|
||||
messageClientSyntax(client, getCommandSyntaxText(command));
|
||||
return false;
|
||||
}
|
||||
|
||||
let clanId = getPlayerClan(client);
|
||||
|
||||
if(!getClanData(clanId)) {
|
||||
messageClientError(client, "Clan not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let targetClient = getClientFromParams(splitParams[0]);
|
||||
|
||||
if(!targetClient) {
|
||||
messageClientError(client, "Clan member not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getClanFlagValue(splitParams[1])) {
|
||||
messageClientError(client, "Clan flag not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let flagValue = getClanFlagValue(splitParams[1]);
|
||||
getClientCurrentSubAccount(client).clanFlags = getClientCurrentSubAccount(client).clanFlags & ~flagValue;
|
||||
messageClientSuccess(client, `You removed the [#AAAAAA]${splitParams[1]} [#FFFFFF]clan flag from [#AAAAAA]${getCharacterFullName(client)}`);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function addClanRankFlagCommand(command, params, client) {
|
||||
if(!doesClientHaveClanPermission(client, getClanFlagValue("rankFlags"))) {
|
||||
messageClientError(client, "You can not change a clan rank's permissions!");
|
||||
@@ -333,12 +386,11 @@ function setClanRankTitleCommand(command, params, client) {
|
||||
|
||||
function createClan(name) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let serverId = getServerId();
|
||||
let escapedName = name;
|
||||
|
||||
if(dbConnection) {
|
||||
escapedName = escapeDatabaseString(dbConnection, escapedName)
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${serverId}, '${escapedName}')`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO clan_main (clan_server, clan_name) VALUES (${getServerId()}, '${escapedName}')`);
|
||||
disconnectFromDatabase(dbConnection);
|
||||
|
||||
let tempClanData = loadClanFromDatabaseById(getDatabaseInsertId(dbConnection));
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let serverId = 0;
|
||||
let scriptVersion = "1.0";
|
||||
let serverStartTime = new Date().getTime();
|
||||
|
||||
@@ -536,12 +535,6 @@ function initServerData() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function getServerData() {
|
||||
return serverData;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ function submitIdea(client, ideaText) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let safeIdeaMessage = escapeDatabaseString(dbConnection, ideaText);
|
||||
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${serverId}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
queryDatabase(dbConnection, `INSERT INTO idea_main (idea_server, idea_script_ver, idea_who_added, idea_when_added, idea_message, idea_pos_x, idea_pos_y, idea_pos_z, idea_rot_z, idea_svr_start, idea_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeIdeaMessage}',${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ function submitBugReport(client, bugText) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let safeBugMessage = escapeDatabaseString(dbConnection, bugText);
|
||||
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${serverId}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
queryDatabase(dbConnection, `INSERT INTO bug_main (bug_server, bug_script_ver, bug_who_added, bug_when_added, bug_message, bug_pos_x, bug_pos_y, bug_pos_z, bug_rot_z, bug_svr_start, bug_session) VALUES (${getServerId()}, '${scriptVersion}', ${databaseId}, UNIX_TIMESTAMP(), '${safeBugMessage}', ${position.x}, ${position.y}, ${position.z}, ${heading}, ${serverStartTime}, ${session})`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ function loadHousesFromDatabase() {
|
||||
let dbAssoc;
|
||||
|
||||
if(dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${serverId}`);
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_server = ${getServerId()}`);
|
||||
if(dbQuery) {
|
||||
if(dbQuery.numRows > 0) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
@@ -354,7 +354,7 @@ function saveHouseToDatabase(houseId) {
|
||||
if(dbConnection) {
|
||||
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
|
||||
if(tempHouseData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw) VALUES (${serverId}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension})`;
|
||||
let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension})`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
getServerData().houses[houseId].databaseId = getDatabaseInsertId(dbConnection);
|
||||
} else {
|
||||
@@ -540,7 +540,7 @@ function sendAllHouseLabelsToPlayer(client) {
|
||||
for(let j = 0 ; j < housesPerNetworkEvent ; j++) {
|
||||
let tempHouseId = (i*housesPerNetworkEvent)+j;
|
||||
if(typeof getServerData().houses[tempHouseId] != "undefined") {
|
||||
tempHouseLabels.push([tempHouseId, getServerData().houses[tempHouseId].entrancePosition, getGlobalConfig().propertyLabelHeight[getServerGame()], getServerData().houses[tempHouseId].description, getServerData().houses[tempHouseId].locked, false]);
|
||||
tempHouseLabels.push([tempHouseId, getServerData().houses[tempHouseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[tempHouseId].description, getServerData().houses[tempHouseId].locked, false]);
|
||||
}
|
||||
}
|
||||
triggerNetworkEvent("ag.houselabel.all", client, tempHouseLabels);
|
||||
@@ -551,7 +551,7 @@ function sendAllHouseLabelsToPlayer(client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function sendHouseLabelToPlayers(houseId) {
|
||||
triggerNetworkEvent("ag.houselabel.add", null, houseId, getServerData().houses[houseId].entrancePosition, getGlobalConfig().propertyLabelHeight[getServerGame()], getServerData().houses[houseId].description, getServerData().houses[houseId].locked, false);
|
||||
triggerNetworkEvent("ag.houselabel.add", null, houseId, getServerData().houses[houseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[houseId].description, getServerData().houses[houseId].locked, false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -59,7 +59,7 @@ function loadSubAccountsFromAccount(accountId) {
|
||||
if(accountId > 0) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main WHERE sacct_acct = ${accountId} AND sacct_server = ${serverId}`;
|
||||
let dbQueryString = `SELECT * FROM sacct_main WHERE sacct_acct = ${accountId} AND sacct_server = ${getServerId()}`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
@@ -99,7 +99,7 @@ function createSubAccount(accountId, firstName, lastName, skinId, dateOfBirth, p
|
||||
let safeLastName = escapeDatabaseString(dbConnection, lastName);
|
||||
let safePlaceOfOrigin = escapeDatabaseString(dbConnection, placeOfOrigin);
|
||||
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_skin, sacct_origin, sacct_when_born, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_angle, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${skinId}, '${safePlaceOfOrigin}', '${dateOfBirth}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${serverId}, 100, UNIX_TIMESTAMP(), 0)`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO sacct_main (sacct_acct, sacct_name_first, sacct_name_last, sacct_skin, sacct_origin, sacct_when_born, sacct_pos_x, sacct_pos_y, sacct_pos_z, sacct_angle, sacct_cash, sacct_server, sacct_health, sacct_when_made, sacct_when_lastlogin) VALUES (${accountId}, '${safeFirstName}', '${safeLastName}', ${skinId}, '${safePlaceOfOrigin}', '${dateOfBirth}', ${getServerConfig().newCharacter.spawnPosition.x}, ${getServerConfig().newCharacter.spawnPosition.y}, ${getServerConfig().newCharacter.spawnPosition.z}, ${getServerConfig().newCharacter.spawnHeading}, ${getServerConfig().newCharacter.money}, ${getServerId()}, 100, UNIX_TIMESTAMP(), 0)`);
|
||||
if(getDatabaseInsertId(dbConnection) > 0) {
|
||||
return loadSubAccountFromId(getDatabaseInsertId(dbConnection));
|
||||
}
|
||||
@@ -314,7 +314,7 @@ function getPlayerLastUsedSubAccount(client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function transferCharacterToServer(subAccountDatabaseId, newServerId) {
|
||||
quickDatabaseQuery(`UPDATE sacct_main SET sacct_server = ${newServerId}, sacct_skin = ${getConfigForServer(newServerId).newCharacter.skin} WHERE sacct_id = ${subAccountDatabaseId} LIMIT 1;`);
|
||||
quickDatabaseQuery(`UPDATE sacct_main SET sacct_server = ${newServerId}, sacct_skin = ${loadServerConfigFromId(newServerId).newCharacter.skin} WHERE sacct_id = ${subAccountDatabaseId} LIMIT 1;`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
|
||||
function initVehicleScript() {
|
||||
console.log("[Asshat.Vehicle]: Initializing vehicle script ...");
|
||||
getServerData().vehicles = loadVehiclesFromDatabase();
|
||||
@@ -25,7 +24,7 @@ function loadVehiclesFromDatabase() {
|
||||
let tempVehicles = [];
|
||||
let dbAssoc;
|
||||
if(dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${serverId} AND veh_deleted = 0`;
|
||||
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${getServerId()} AND veh_deleted = 0`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
while(dbAssoc = fetchQueryAssoc(dbQuery)) {
|
||||
@@ -82,7 +81,7 @@ function saveVehicleToDatabase(vehicleData) {
|
||||
|
||||
// If vehicle hasn't been added to database, ID will be 0
|
||||
if(vehicleData.databaseId == 0) {
|
||||
let dbQueryString = `INSERT INTO veh_main (veh_model, veh_pos_x, veh_pos_y, veh_pos_z, veh_rot_z, veh_owner_type, veh_owner_id, veh_col1, veh_col2, veh_col3, veh_col4, veh_server, veh_spawn_lock, veh_buy_price, veh_rent_price) VALUES (${vehicleData.model}, ${vehicleData.spawnPosition.x}, ${vehicleData.spawnPosition.y}, ${vehicleData.spawnPosition.z}, ${vehicleData.spawnRotation}, ${vehicleData.ownerType}, ${vehicleData.ownerId}, ${vehicleData.colour1}, ${vehicleData.colour2}, ${vehicleData.colour3}, ${vehicleData.colour4}, ${serverId}, ${boolToInt(vehicleData.spawnLocked)}, ${vehicleData.buyPrice}, ${vehicleData.rentPrice})`;
|
||||
let dbQueryString = `INSERT INTO veh_main (veh_model, veh_pos_x, veh_pos_y, veh_pos_z, veh_rot_z, veh_owner_type, veh_owner_id, veh_col1, veh_col2, veh_col3, veh_col4, veh_server, veh_spawn_lock, veh_buy_price, veh_rent_price) VALUES (${vehicleData.model}, ${vehicleData.spawnPosition.x}, ${vehicleData.spawnPosition.y}, ${vehicleData.spawnPosition.z}, ${vehicleData.spawnRotation}, ${vehicleData.ownerType}, ${vehicleData.ownerId}, ${vehicleData.colour1}, ${vehicleData.colour2}, ${vehicleData.colour3}, ${vehicleData.colour4}, ${getServerId()}, ${boolToInt(vehicleData.spawnLocked)}, ${vehicleData.buyPrice}, ${vehicleData.rentPrice})`;
|
||||
queryDatabase(dbConnection, dbQueryString);
|
||||
getVehicleData(vehicleData.vehicle).databaseId = getDatabaseInsertId(dbConnection);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user