Prefix
This commit is contained in:
@@ -826,24 +826,24 @@ function getPlayerWeapon(client) {
|
||||
function connectToDatabase() {
|
||||
if (getDatabaseConfig().usePersistentConnection) {
|
||||
if (persistentDatabaseConnection == null) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Initializing database connection ...`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Initializing database connection ...`);
|
||||
persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if (persistentDatabaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
persistentDatabaseConnection = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection successful!`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Database connection successful!`);
|
||||
return persistentDatabaseConnection;
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Using existing database connection.`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Using existing database connection.`);
|
||||
return persistentDatabaseConnection;
|
||||
}
|
||||
} else {
|
||||
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if (databaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
return false;
|
||||
} else {
|
||||
return databaseConnection;
|
||||
@@ -857,9 +857,9 @@ function disconnectFromDatabase(dbConnection, force = false) {
|
||||
if (!getDatabaseConfig().usePersistentConnection || force == true) {
|
||||
try {
|
||||
dbConnection.close();
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection closed successfully`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Database connection closed successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -868,7 +868,7 @@ function disconnectFromDatabase(dbConnection, force = false) {
|
||||
// ===========================================================================
|
||||
|
||||
function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
if (useThread == true) {
|
||||
Promise.resolve().then(() => {
|
||||
let queryResult = dbConnection.query(queryString);
|
||||
@@ -942,19 +942,19 @@ function quickDatabaseQuery(queryString) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let insertId = 0;
|
||||
if (dbConnection) {
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
//logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
let dbQuery = queryDatabase(dbConnection, queryString);
|
||||
if (getDatabaseInsertId(dbConnection)) {
|
||||
insertId = getDatabaseInsertId(dbConnection);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query returned insert id ${insertId}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query returned insert id ${insertId}`);
|
||||
}
|
||||
|
||||
if (dbQuery) {
|
||||
try {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query result free'd successfully`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query result free'd successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,9 +1006,9 @@ function setConstantsAsGlobalVariablesInDatabase() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let entries = Object.entries(global);
|
||||
for (let i in entries) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Checking entry ${i} (${entries[i]})`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Checking entry ${i} (${entries[i]})`);
|
||||
if (toString(i).slice(0, 3).indexOf("V_") != -1) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Adding ${i} (${entries[i]}) to database global variables`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Adding ${i} (${entries[i]}) to database global variables`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ function setVehicleHealth(vehicle, health) {
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerWeapon(client, weaponId, ammo, active = true) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
|
||||
sendNetworkEventToPlayer("v.rp.giveWeapon", client, weaponId, ammo, active);
|
||||
}
|
||||
|
||||
@@ -1447,7 +1447,7 @@ function hideElementForPlayer(element, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Native.Connected] Hiding element ${element.id} for player ${getPlayerDisplayForConsole(client)}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Native.Connected] Hiding element ${element.id} for player ${getPlayerDisplayForConsole(client)}`);
|
||||
element.setExistsFor(client, false);
|
||||
}
|
||||
|
||||
@@ -1462,7 +1462,7 @@ function showElementForPlayer(element, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Native.Connected] Showing element ${element.id} for player ${getPlayerDisplayForConsole(client)}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Native.Connected] Showing element ${element.id} for player ${getPlayerDisplayForConsole(client)}`);
|
||||
element.setExistsFor(client, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -742,24 +742,24 @@ function getPlayerWeapon(client) {
|
||||
function connectToDatabase() {
|
||||
if (getDatabaseConfig().usePersistentConnection) {
|
||||
if (persistentDatabaseConnection == null) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Initializing database connection ...`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Initializing database connection ...`);
|
||||
persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if (persistentDatabaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
persistentDatabaseConnection = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection successful!`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Database connection successful!`);
|
||||
return persistentDatabaseConnection;
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Using existing database connection.`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Using existing database connection.`);
|
||||
return persistentDatabaseConnection;
|
||||
}
|
||||
} else {
|
||||
let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port);
|
||||
if (databaseConnection.error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection error: ${persistentDatabaseConnection.error}`);
|
||||
return false;
|
||||
} else {
|
||||
return databaseConnection;
|
||||
@@ -773,9 +773,9 @@ function disconnectFromDatabase(dbConnection) {
|
||||
if (!getDatabaseConfig().usePersistentConnection) {
|
||||
try {
|
||||
dbConnection.close();
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Database connection closed successfully`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Database connection closed successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -784,7 +784,7 @@ function disconnectFromDatabase(dbConnection) {
|
||||
// ===========================================================================
|
||||
|
||||
function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
if (useThread == true) {
|
||||
Promise.resolve().then(() => {
|
||||
let queryResult = dbConnection.query(queryString);
|
||||
@@ -849,19 +849,19 @@ function quickDatabaseQuery(queryString) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let insertId = 0;
|
||||
if (dbConnection) {
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.Database] Query string: ${queryString}`);
|
||||
//logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
let dbQuery = queryDatabase(dbConnection, queryString);
|
||||
if (getDatabaseInsertId(dbConnection)) {
|
||||
insertId = getDatabaseInsertId(dbConnection);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query returned insert id ${insertId}`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query returned insert id ${insertId}`);
|
||||
}
|
||||
|
||||
if (dbQuery) {
|
||||
try {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Database] Query result free'd successfully`);
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query result free'd successfully`);
|
||||
} catch (error) {
|
||||
logToConsole(LOG_ERROR, `[AGRP.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[V.RP.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ function setVehicleHealth(vehicle, health) {
|
||||
// ===========================================================================
|
||||
|
||||
function givePlayerWeapon(client, weaponId, ammo, active = true) {
|
||||
//logToConsole(LOG_DEBUG, `[AGRP.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
|
||||
//logToConsole(LOG_DEBUG, `[V.RP.Client] Sending signal to ${getPlayerDisplayForConsole(client)} to give weapon (Weapon: ${weaponId}, Ammo: ${ammo})`);
|
||||
//sendNetworkEventToPlayer("v.rp.giveWeapon", client, weaponId, ammo, active);
|
||||
client.giveWeapon(weaponId, ammo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user