More native utils + move startup stuff into startup.js

This commit is contained in:
Vortrex
2022-04-20 06:47:54 -05:00
parent 16537fa332
commit 6999661bba
30 changed files with 369 additions and 201 deletions

View File

@@ -163,13 +163,13 @@ function onLocalPlayerEnteredVehicle(event, vehicle, seat) {
sendNetworkEventToServer("vrr.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat); sendNetworkEventToServer("vrr.onPlayerEnterVehicle", getVehicleForNetworkEvent(vehicle), seat);
if(inVehicleSeat == 0) { //if(inVehicleSeat == 0) {
inVehicle.engine = false; //setVehicleEngine(vehicle, false);
if(!inVehicle.engine) { //if(!inVehicle.engine) {
parkedVehiclePosition = inVehicle.position; // parkedVehiclePosition = inVehicle.position;
parkedVehicleHeading = inVehicle.heading; // parkedVehicleHeading = inVehicle.heading;
} //}
} //}
} }
// =========================================================================== // ===========================================================================
@@ -182,7 +182,7 @@ function onPedInflictDamage(event, damagedEntity, damagerEntity, weaponId, healt
if(damagedEntity.isType(ELEMENT_PLAYER)) { if(damagedEntity.isType(ELEMENT_PLAYER)) {
if(damagedEntity == localPlayer) { if(damagedEntity == localPlayer) {
//if(!weaponDamageEnabled[damagerEntity.name]) { //if(!weaponDamageEnabled[damagerEntity.name]) {
event.preventDefault(); preventDefaultEventAction(event);
sendNetworkEventToServer("vrr.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss); sendNetworkEventToServer("vrr.weaponDamage", damagerEntity.name, weaponId, pedPiece, healthLoss);
//} //}
} }

View File

@@ -188,4 +188,28 @@ function doesEntityDataExist(entity, dataName) {
return null; return null;
} }
// ===========================================================================
function preventDefaultEventAction(event) {
event.preventDefault();
}
// ===========================================================================
function getPlayerId(client) {
return client.index;
}
// ===========================================================================
function consolePrint(text) {
console.log(text);
}
// ===========================================================================
function getPlayerName(client) {
return client.name;
}
// =========================================================================== // ===========================================================================

View File

@@ -185,7 +185,7 @@ function setLocalPlayerControlState(controlState, cursorState = false) {
logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`); logToConsole(LOG_DEBUG, `[VRR.Utilities] Setting control state to ${controlState} (Cursor: ${cursorState})`);
controlsEnabled = controlState; controlsEnabled = controlState;
if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) {
game.SET_PLAYER_CONTROL(localClient.index, boolToInt(controlState)); game.SET_PLAYER_CONTROL(getPlayerId(localClient), boolToInt(controlState));
} }
if(getGame() != VRR_GAME_GTA_IV) { if(getGame() != VRR_GAME_GTA_IV) {

View File

@@ -91,7 +91,7 @@ function getAccentFromParams(params) {
function reloadAccentConfigurationCommand(command, params, client) { function reloadAccentConfigurationCommand(command, params, client) {
getGlobalConfig().accents = loadAccentConfig(); getGlobalConfig().accents = loadAccentConfig();
messageAdmins(`${client.name} {MAINCOLOUR}has reloaded the accent list`); messageAdmins(`{adminRed}${getPlayerName(client)} {MAINCOLOUR}has reloaded the accent list`);
} }
// =========================================================================== // ===========================================================================
@@ -111,7 +111,7 @@ function addAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName); getGlobalConfig().accents.push(newAccentName);
saveAccentConfig(); saveAccentConfig();
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} added a new accent: {ALTCOLOUR}${newAccentName}{MAINCOLOUR}`);
} }
// =========================================================================== // ===========================================================================
@@ -131,7 +131,7 @@ function removeAccentCommand(command, params, client) {
getGlobalConfig().accents.push(newAccentName); getGlobalConfig().accents.push(newAccentName);
saveAccentConfig(); saveAccentConfig();
messageAdmins(`${client.name}{MAINCOLOUR} added a new accent: ${newAccentName}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} removed an accent: {ALTCOLOUR}${newAccentName}{MAINCOLOUR}`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -583,14 +583,14 @@ function loginSuccess(client) {
if(doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) { if(doesPlayerHaveStaffPermission(client, "Developer") || doesPlayerHaveStaffPermission(client, "ManageServer")) {
logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`); logToConsole(LOG_WARN, `[VRR.Account] ${getPlayerDisplayForConsole(client)} has needed permissions and is being given administrator access`);
client.administrator = true; setPlayerAsNativeAdmin(client);
} }
if(doesServerHaveTesterOnlyEnabled()) { if(doesServerHaveTesterOnlyEnabled()) {
if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) { if(!hasBitFlag(getPlayerData(client).accountData.flags.moderation, getModerationFlagValue("IsTester"))) {
setTimeout(function() { setTimeout(function() {
getPlayerData(client).customDisconnectReason = "Kicked - Not a tester"; getPlayerData(client).customDisconnectReason = "Kicked - Not a tester";
client.disconnect(); disconnectPlayer();
}, 3500); }, 3500);
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
@@ -618,7 +618,7 @@ function loginSuccess(client) {
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
} }
getPlayerData(client).accountData.ipAddress = client.ip; getPlayerData(client).accountData.ipAddress = getPlayerIP(client);
sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines); sendPlayerChatScrollLines(client, getPlayerData(client).accountData.chatScrollLines);
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow")); messagePlayerNormal(null, `👋 ${getPlayerName(client)} has joined the server`, getColourByName("softYellow"));
@@ -794,7 +794,7 @@ function createAccount(name, password, email = "") {
function checkLogin(client, password) { function checkLogin(client, password) {
getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1; getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining-1;
if(getPlayerData(client).loginAttemptsRemaining <= 0) { if(getPlayerData(client).loginAttemptsRemaining <= 0) {
client.disconnect(); disconnectPlayer();
} }
if(isPlayerLoggedIn(client)) { if(isPlayerLoggedIn(client)) {
@@ -831,7 +831,7 @@ function checkLogin(client, password) {
} }
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame()); sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame());
} }
return false; return false;
} }
@@ -847,7 +847,7 @@ function checkLogin(client, password) {
} }
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame()); sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame());
} }
return false; return false;
} }
@@ -865,7 +865,7 @@ function checkLogin(client, password) {
loginSuccess(client); loginSuccess(client);
if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { if(isAccountEmailVerified(getPlayerData(client).accountData) && isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) {
sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, client.name, client.ip, getServerGame()); sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getServerGame());
} }
} }
@@ -973,7 +973,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) { if(doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) {
setTimeout(function() { setTimeout(function() {
client.disconnect(); disconnectPlayer();
}, 5000); }, 5000);
if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) { if(doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
@@ -1024,7 +1024,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
} else { } else {
getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
client.disconnect(); disconnectPlayer(client);
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct)`); logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct)`);
} }
} }
@@ -1038,7 +1038,7 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
if(!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
if(getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) { if(getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) {
//getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; //getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE;
//client.disconnect(); //disconnectPlayer(client);
logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`); logToConsole(LOG_DEBUG|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
return false; return false;
} }
@@ -1141,11 +1141,11 @@ function initClient(client) {
return false; return false;
} }
if(client.getData("vrr.isInitialized") != null || client.getData("vrr.isInitialized") == true) { if(doesEntityDataExist(client, "vrr.isInitialized") || getEntityData(client, "vrr.isInitialized") == true) {
return false; return false;
} }
client.setData("vrr.isInitialized", true, false); setEntityData(client, "vrr.isInitialized", true, false);
sendPlayerGUIColours(client); sendPlayerGUIColours(client);
sendPlayerGUIInit(client); sendPlayerGUIInit(client);
@@ -1162,14 +1162,14 @@ function initClient(client) {
let tempAccountData = loadAccountFromName(getPlayerName(client), true); let tempAccountData = loadAccountFromName(getPlayerName(client), true);
let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId); let tempSubAccounts = loadSubAccountsFromAccount(tempAccountData.databaseId);
getServerData().clients[client.index] = new ClientData(client, tempAccountData, tempSubAccounts); getServerData().clients[getPlayerId(client)] = new ClientData(client, tempAccountData, tempSubAccounts);
getServerData().clients[client.index].sessionId = saveConnectionToDatabase(client); getServerData().clients[getPlayerId(client)].sessionId = saveConnectionToDatabase(client);
getServerData().clients[client.index].connectTime = getCurrentUnixTimestamp(); getServerData().clients[getPlayerId(client)].connectTime = getCurrentUnixTimestamp();
requestClientInfo(client); requestClientInfo(client);
if(tempAccountData != false) { if(tempAccountData != false) {
if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) { if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == getPlayerIp(client)) {
messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP")); messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP"));
loginSuccess(client); loginSuccess(client);
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
@@ -1182,7 +1182,7 @@ function initClient(client) {
messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen")); messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client), "/login"),getColourByName("softGreen"));
//if(checkForGeoIPModule()) { //if(checkForGeoIPModule()) {
// let iso = module.geoip.getCountryISO(client.ip); // let iso = module.geoip.getCountryISO(getPlayerIp(client));
// let localeId = getLocaleFromCountryISO(iso); // let localeId = getLocaleFromCountryISO(iso);
//} //}
//showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto"); //showGameMessage(client, getLocaleString(client, "LocaleOffer", `/lang ${getLocaleData(localeId)[2]}`), getColourByName("white"), 10000, "Roboto");
@@ -1200,7 +1200,7 @@ function initClient(client) {
playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client));
} }
getServerData().clients[client.index].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[client.index].accountData.databaseId); getServerData().clients[getPlayerId(client)].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[getPlayerId(client)].accountData.databaseId);
sendAccountKeyBindsToClient(client); sendAccountKeyBindsToClient(client);
} }
}, 2500); }, 2500);
@@ -1212,7 +1212,7 @@ function saveConnectionToDatabase(client) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
let safeName = escapeDatabaseString(dbConnection, getPlayerName(client)); let safeName = escapeDatabaseString(dbConnection, getPlayerName(client));
let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (NOW(), ${getServerConfig().databaseId}, '${scriptVersion}', '${client.gameVersion}', '0.0.0', '${safeName}', '${client.ip}')`; let dbQueryString = `INSERT INTO conn_main (conn_when_connect, conn_server, conn_script_version, conn_game_version, conn_client_version, conn_name, conn_ip) VALUES (NOW(), ${getServerConfig().databaseId}, '${scriptVersion}', '${getPlayerGameVersion(client)}', '0.0.0', '${safeName}', '${getPlayerIP(client)}')`;
queryDatabase(dbConnection, dbQueryString); queryDatabase(dbConnection, dbQueryString);
return getDatabaseInsertId(dbConnection); return getDatabaseInsertId(dbConnection);
} }
@@ -1520,7 +1520,7 @@ function checkPlayerTwoFactorAuthentication(client, authCode) {
} }
} }
client.disconnect(); disconnectPlayer(client);
return false; return false;
} }

View File

@@ -39,7 +39,7 @@ function accountBanCommand(command, params, client) {
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`); logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name}) account was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`); announceAdminAction(`PlayerAccountBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason); banAccount(getPlayerData(targetClient).accountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client); disconnectPlayer(client);
} }
@@ -69,7 +69,7 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`); logToConsole(LOG_WARN, `[VRR.Ban]: ${getPlayerDisplayForConsole(targetClient)} (${getPlayerData(targetClient).accountData.name})'s subaccount was banned by ${getPlayerDisplayForConsole(client)}. Reason: ${reason}`);
announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`); announceAdminAction(`PlayerCharacterBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason); banSubAccount(getPlayerData(targetClient).currentSubAccountData.databaseId, getPlayerData(client).accountData.databaseId, reason);
disconnectPlayer(client); disconnectPlayer(client);
@@ -98,11 +98,11 @@ function ipBanCommand(command, params, client, fromDiscord) {
return false; return false;
} }
announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`); announceAdminAction(`PlayerIPBanned`, `{ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR}`);
banIPAddress(targetClient.ip, getPlayerData(client).accountData.databaseId, reason); banIPAddress(getPlayerIP(targetClient), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip); server.banIP(getPlayerIP(targetClient));
targetClient.disconnect(); disconnectPlayer(targetClient);
} }
// =========================================================================== // ===========================================================================
@@ -129,10 +129,10 @@ function subNetBanCommand(command, params, client, fromDiscord) {
return false; return false;
} }
announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${targetClient.name}{MAINCOLOUR}`); announceAdminAction(`PlayerSubNetBanned`, `{ALTCOLOUR}${getPlayerName(client)}{MAINCOLOUR}`);
banSubNet(targetClient.ip, getSubNet(targetClient.ip, octetAmount), getPlayerData(client).accountData.databaseId, reason); banSubNet(getPlayerIP(targetClient), getSubNet(getPlayerIP(targetClient), octetAmount), getPlayerData(client).accountData.databaseId, reason);
server.banIP(targetClient.ip); server.banIP(getPlayerIP(targetClient));
} }
// =========================================================================== // ===========================================================================

View File

@@ -9,15 +9,7 @@
function initBusinessScript() { function initBusinessScript() {
logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ..."); logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ...");
if(!getServerConfig().devServer) {
getServerData().businesses = loadBusinessesFromDatabase();
}
createAllBusinessPickups();
createAllBusinessBlips();
setAllBusinessIndexes();
cacheAllBusinessItems();
logToConsole(LOG_INFO, "[VRR.Business]: Business script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Business]: Business script initialized successfully!");
return true; return true;
@@ -151,7 +143,7 @@ function createBusinessCommand(command, params, client) {
let tempBusinessData = createBusiness(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].Business, getGameConfig().blipSprites[getServerGame()].Business, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene); let tempBusinessData = createBusiness(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getServerGame()].Business, getGameConfig().blipSprites[getServerGame()].Business, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene);
tempBusinessData.needsSaved = true; tempBusinessData.needsSaved = true;
let businessId = getServerData().businesses.push(tempBusinessData); let businessId = getServerData().businesses.push(tempBusinessData);
setAllBusinessIndexes(); setBusinessDataIndexes();
saveBusinessesToDatabase(); saveBusinessesToDatabase();
@@ -2111,7 +2103,7 @@ function reloadAllBusinessesCommand(command, params, client) {
getServerData().businesses = loadBusinessesFromDatabase(); getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups(); createAllBusinessPickups();
createAllBusinessBlips(); createAllBusinessBlips();
setAllBusinessIndexes(); setBusinessDataIndexes();
cacheAllBusinessItems(); cacheAllBusinessItems();
announceAdminAction(`AllBusinessesReloaded`); announceAdminAction(`AllBusinessesReloaded`);
@@ -2124,7 +2116,7 @@ function reloadAllBusinessesCommand(command, params, client) {
* *
* @returns {Boolean} Whether or not the exit blip of the business was deleted * @returns {Boolean} Whether or not the exit blip of the business was deleted
*/ */
function setAllBusinessIndexes() { function setBusinessDataIndexes() {
for(let i in getServerData().businesses) { for(let i in getServerData().businesses) {
getServerData().businesses[i].index = i; getServerData().businesses[i].index = i;
} }
@@ -2486,10 +2478,10 @@ function updateBusinessPickupLabelData(businessId) {
} else if(getBusinessData(businessId).labelHelpType == VRR_PROPLABEL_INFO_REPAIR) { } else if(getBusinessData(businessId).labelHelpType == VRR_PROPLABEL_INFO_REPAIR) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_REPAIR, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_REPAIR, true);
} else { } else {
if(getBusinessData(businessId).buyPrice > 0) { //if(getBusinessData(businessId).buyPrice > 0) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true); // setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.price", getBusinessData(businessId).buyPrice, true);
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYBIZ, true); // setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUYBIZ, true);
} else { //} else {
if(getBusinessData(businessId).hasInterior) { if(getBusinessData(businessId).hasInterior) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_ENTER, true);
} else { } else {
@@ -2497,7 +2489,7 @@ function updateBusinessPickupLabelData(businessId) {
setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUY, true); setEntityData(getBusinessData(businessId).entrancePickup, "vrr.label.help", VRR_PROPLABEL_INFO_BUY, true);
} }
} }
} //}
} }
if(getBusinessData(businessId).buyPrice > 0) { if(getBusinessData(businessId).buyPrice > 0) {

View File

@@ -9,11 +9,6 @@
function initClanScript() { function initClanScript() {
logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ..."); logToConsole(LOG_INFO, "[VRR.Clan]: Initializing clans script ...");
if(!getServerConfig().devServer) {
getServerData().clans = loadClansFromDatabase();
}
setAllClanDataIndexes();
logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Clan]: Clan script initialized successfully!");
return true; return true;
} }

View File

@@ -98,7 +98,7 @@ function updateAllPlayerNameTags() {
function updatePlayerPing(client) { function updatePlayerPing(client) {
//logToConsole(LOG_DEBUG, `[VRR.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`); //logToConsole(LOG_DEBUG, `[VRR.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`);
sendNetworkEventToPlayer("vrr.ping", null, getPlayerName(client), client.ping); sendNetworkEventToPlayer("vrr.ping", null, getPlayerName(client), getPlayerPing(client));
} }
// =========================================================================== // ===========================================================================
@@ -106,7 +106,7 @@ function updatePlayerPing(client) {
function playerClientReady(client) { function playerClientReady(client) {
setEntityData(client, "vrr.isReady", true, false); setEntityData(client, "vrr.isReady", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are downloaded and ready!`);
if(client.getData("vrr.isStarted") == true) { if(getEntityData(client, "vrr.isStarted") == true) {
initClient(client); initClient(client);
} }
} }
@@ -123,7 +123,7 @@ function playerGUIReady(client) {
function playerClientStarted(client) { function playerClientStarted(client) {
setEntityData(client, "vrr.isStarted", true, false); setEntityData(client, "vrr.isStarted", true, false);
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);
if(client.getData("vrr.isReady") == true) { if(getEntityData(client, "vrr.isReady") == true) {
initClient(client); initClient(client);
} }
} }
@@ -132,7 +132,7 @@ function playerClientStarted(client) {
function playerClientStopped(client) { function playerClientStopped(client) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s client resources have stopped (possibly error?). Kicking them from the server ...`);
client.disconnect(); disconnectPlayer(client);
} }
// =========================================================================== // ===========================================================================
@@ -739,7 +739,7 @@ function forcePlayerIntoSkinSelect(client) {
setPlayerPosition(client, getGameConfig().skinChangePosition[getServerGame()][0]); setPlayerPosition(client, getGameConfig().skinChangePosition[getServerGame()][0]);
setPlayerHeading(client, getGameConfig().skinChangePosition[getServerGame()][1]); setPlayerHeading(client, getGameConfig().skinChangePosition[getServerGame()][1]);
setPlayerInterior(client, getGameConfig().skinChangePosition[getServerGame()][2]); setPlayerInterior(client, getGameConfig().skinChangePosition[getServerGame()][2]);
setPlayerDimension(client, client.index+500); setPlayerDimension(client, getPlayerId(client)+500);
} }
sendNetworkEventToPlayer("vrr.skinSelect", client, true); sendNetworkEventToPlayer("vrr.skinSelect", client, true);

View File

@@ -756,7 +756,7 @@ function processPlayerCommand(command, params, client) {
// } // }
//} //}
if(!client.console) { if(!isConsole(client)) {
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) { if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`); console.warn(`[VRR.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
messagePlayerError(client, `You do not have permission to use the {ALTCOLOUR}/${toLowerCase(command)} {MAINCOLOUR}command!`); messagePlayerError(client, `You do not have permission to use the {ALTCOLOUR}/${toLowerCase(command)} {MAINCOLOUR}command!`);

View File

@@ -94,6 +94,7 @@ function initConfigScript() {
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod()); serverConfig = loadServerConfigFromGameAndPort(server.game, server.port, getMultiplayerMod());
logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ..."); logToConsole(LOG_INFO, "[VRR.Config]: Applying server config ...");
getServerConfig().devServer = intToBool(toInteger(server.getCVar("vrr_devserver")));
getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("vrr_fallingsnow"))); getServerConfig().fallingSnow = intToBool(toInteger(server.getCVar("vrr_fallingsnow")));
getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("vrr_groundsnow"))); getServerConfig().groundSnow = intToBool(toInteger(server.getCVar("vrr_groundsnow")));
getServerConfig().useGUI = intToBool(toInteger(server.getCVar("vrr_gui"))); getServerConfig().useGUI = intToBool(toInteger(server.getCVar("vrr_gui")));

View File

@@ -35,6 +35,7 @@ let serverData = {
npcs: [], npcs: [],
locales: [], locales: [],
accents: [], accents: [],
races: [],
}; };
// =========================================================================== // ===========================================================================

View File

@@ -350,7 +350,7 @@ function executeClientCodeCommand(command, params, client) {
return false; return false;
} }
sendRunCodeToClient(client, targetClient, targetCode, client.index); sendRunCodeToClient(client, targetClient, targetCode, getPlayerId(client));
messagePlayerSuccess(client, "Executing client code for " + toString(targetgetPlayerName(client)) + "!"); messagePlayerSuccess(client, "Executing client code for " + toString(targetgetPlayerName(client)) + "!");
messagePlayerNormal(client, "Code: " + targetCode); messagePlayerNormal(client, "Code: " + targetCode);
@@ -380,7 +380,7 @@ function setPlayerTesterStatusCommand(command, params, client) {
let enabled = hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester")); let enabled = hasBitFlag(getPlayerData(targetClient).accountData.flags.moderation, getModerationFlagValue("IsTester"));
messageAdmins(`{ALTCOLOUR}${client.name} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${targetClient.name}'s {MAINCOLOUR}tester status`) messageAdmins(`{ALTCOLOUR}${getPlayerName(client)} ${getBoolRedGreenInlineColour(enabled)}${toUpperCase(getEnabledDisabledFromBool(enabled))} {ALTCOLOUR}${getPlayerName(targetClient)}'s {MAINCOLOUR}tester status`)
return true; return true;
} }
@@ -667,7 +667,7 @@ function resetAllServerAmbienceElementsCommand(command, params, client) {
function reloadEconomyConfigurationCommand(command, params, client) { function reloadEconomyConfigurationCommand(command, params, client) {
getGlobalConfig().economy = loadEconomyConfig(); getGlobalConfig().economy = loadEconomyConfig();
messageAdmins(`${client.name} {MAINCOLOUR}has reloaded the economy settings`); messageAdmins(`{adminRed}${getPlayerName(client)} {MAINCOLOUR}has reloaded the economy settings`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -89,7 +89,7 @@ function getDiscordUserData(discordUserId) {
// =========================================================================== // ===========================================================================
function messageDiscordChatChannel(messageString) { function messageDiscordChatChannel(messageString) {
if(getServerConfig().devServer) { if(getServerConfig().devServer == true) {
return false; return false;
} }

View File

@@ -111,7 +111,7 @@ function forcePlayerPayDayCommand(command, params, client) {
return false; return false;
} }
messageAdmins(`${client.name} gave ${targetClient.name} an instant payday`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} an instant payday`);
playerPayDay(targetClient); playerPayDay(targetClient);
} }
@@ -132,7 +132,7 @@ function setPayDayBonusMultiplier(command, params, client) {
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier; getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
announceAdminAction(`PaydayBonusSet`, `{adminRed}${client.name}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`); announceAdminAction(`PaydayBonusSet`, `{adminRed}${getPlayerName(client)}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
} }
// =========================================================================== // ===========================================================================
@@ -147,7 +147,7 @@ function taxInfoCommand(command, params, client) {
function wealthInfoCommand(command, params, client) { function wealthInfoCommand(command, params, client) {
let wealth = calculateWealth(client); let wealth = calculateWealth(client);
messagePlayerInfo(client, `Your wealth is: $${wealth}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`); messagePlayerInfo(client, `Your wealth is: {ALTCOLOUR}$${wealth}{MAINCOLOUR}. Use {ALTCOLOUR}/help wealth {MAINCOLOUR}for more information.`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -54,13 +54,13 @@ function onPlayerConnect(event, ipAddress, port) {
// =========================================================================== // ===========================================================================
function onPlayerJoin(event, client) { function onPlayerJoin(event, client) {
logToConsole(LOG_INFO, `[VRR.Event] Client ${client.name}[${client.index}] joining from ${client.ip}`); logToConsole(LOG_INFO, `[VRR.Event] Client ${getPlayerName(client)}[${getPlayerId(client)}] joining from ${getPlayerIP(client)}`);
if(isFadeCameraSupported()) { if(isFadeCameraSupported()) {
fadeCamera(client, true, 1.0); fadeCamera(client, true, 1.0);
} }
messageDiscordEventChannel(`👋 ${client.name} is connecting to the server ...`); messageDiscordEventChannel(`👋 ${getPlayerName(client)} is connecting to the server ...`);
//messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`); //messageDiscordEventChannel(`👋 ${getPlayerDisplayForConsole(client)} has joined the server.`);
} }
@@ -103,13 +103,13 @@ function onPlayerQuit(event, client, quitReasonId) {
reasonText = getPlayerData(client).customDisconnectReason; reasonText = getPlayerData(client).customDisconnectReason;
} }
messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow")); messagePlayerNormal(null, `👋 ${getPlayerName(client)} has left the server (${reasonText})`, getColourByName("softYellow"));
messageDiscordEventChannel(`👋 ${client.name} has left the server (${reasonText})`); messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${reasonText})`);
savePlayerToDatabase(client); savePlayerToDatabase(client);
resetClientStuff(client); resetClientStuff(client);
getServerData().clients[client.index] = null; getServerData().clients[getPlayerId(client)] = null;
} else { } else {
messageDiscordEventChannel(`👋 ${client.name} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`); messageDiscordEventChannel(`👋 ${getPlayerName(client)} has left the server (${disconnectReasons[quitReasonId]}[${quitReasonId}])`);
} }
clearTemporaryVehicles(); clearTemporaryVehicles();
@@ -395,7 +395,7 @@ function onPlayerDeath(client, position) {
setTimeout(function() { setTimeout(function() {
if(getPlayerCurrentSubAccount(client).inJail) { if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestPoliceStation(getPlayerPosition(client)); let closestJail = getClosestPoliceStation(getPlayerPosition(client));
client.despawnPlayer(); despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestJail.interior; getPlayerCurrentSubAccount(client).interior = closestJail.interior;
getPlayerCurrentSubAccount(client).dimension = closestJail.dimension; getPlayerCurrentSubAccount(client).dimension = closestJail.dimension;
@@ -417,7 +417,7 @@ function onPlayerDeath(client, position) {
setPlayerControlState(client, true); setPlayerControlState(client, true);
} else { } else {
let closestHospital = getClosestHospital(getPlayerPosition(client)); let closestHospital = getClosestHospital(getPlayerPosition(client));
client.despawnPlayer(); despawnPlayer(client);
getPlayerCurrentSubAccount(client).interior = closestHospital.interior; getPlayerCurrentSubAccount(client).interior = closestHospital.interior;
getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension; getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension;
@@ -467,21 +467,21 @@ function onPlayerSpawn(client) {
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s player data`);
if(!getPlayerData(client)) { if(!getPlayerData(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)}'s player data is invalid. Kicking them from server.`);
client.disconnect(); disconnectPlayer(client);
return false; return false;
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s login status`);
if(!isPlayerLoggedIn(client)) { if(!isPlayerLoggedIn(client)) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} is NOT logged in. Despawning their player.`);
client.disconnect(); disconnectPlayer(client);
return false; return false;
} }
logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`); logToConsole(LOG_DEBUG, `[VRR.Event] Checking ${getPlayerDisplayForConsole(client)}'s selected character status`);
if(getPlayerData(client).currentSubAccount == -1) { if(getPlayerData(client).currentSubAccount == -1) {
logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`); logToConsole(LOG_DEBUG, `[VRR.Event] ${getPlayerDisplayForConsole(client)} has NOT selected a character. Despawning their player.`);
client.disconnect(); disconnectPlayer(client);
return false; return false;
} }
@@ -622,7 +622,7 @@ function onPlayerSpawn(client) {
getPlayerData(client).payDayTickStart = sdl.ticks; getPlayerData(client).payDayTickStart = sdl.ticks;
messageDiscordEventChannel(`🧍 ${client.name} spawned as ${getCharacterFullName(client)}`); messageDiscordEventChannel(`🧍 ${getPlayerName(client)} spawned as ${getCharacterFullName(client)}`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -25,7 +25,7 @@ function playerPromptAnswerNo(client) {
case VRR_PROMPT_CREATEFIRSTCHAR: case VRR_PROMPT_CREATEFIRSTCHAR:
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)} chose not to create a first character. Kicking them from the server ...`);
showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters"); showPlayerErrorGUI(client, "You don't have a character to play. Goodbye!", "No Characters");
setTimeout(function() { client.disconnect(); }, 5000); setTimeout(function() { disconnectPlayer(client); }, 5000);
break; break;
case VRR_PROMPT_BIZORDER: case VRR_PROMPT_BIZORDER:

View File

@@ -9,19 +9,6 @@
function initHouseScript() { function initHouseScript() {
logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ..."); logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ...");
if(!getServerConfig().devServer) {
getServerData().houses = loadHousesFromDatabase();
}
if(getServerConfig().createHousePickups) {
createAllHousePickups();
}
if(getServerConfig().createHouseBlips) {
createAllHouseBlips();
}
setAllHouseIndexes();
logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!");
return true; return true;
} }
@@ -83,7 +70,7 @@ function createHouseCommand(command, params, client) {
let houseId = getServerData().houses.push(tempHouseData); let houseId = getServerData().houses.push(tempHouseData);
saveHouseToDatabase(houseId-1); saveHouseToDatabase(houseId-1);
setAllHouseIndexes(); setHouseDataIndexes();
createHouseEntrancePickup(houseId-1); createHouseEntrancePickup(houseId-1);
createHouseExitPickup(houseId-1); createHouseExitPickup(houseId-1);
@@ -333,7 +320,7 @@ function setHousePickupCommand(command, params, client) {
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} pickup display to {ALTCOLOUR}${toLowerCase(typeParam)}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} pickup display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
} }
// =========================================================================== // ===========================================================================
@@ -394,7 +381,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior type to {ALTCOLOUR}${toLowerCase(typeParam)}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} interior type to {ALTCOLOUR}${toLowerCase(typeParam)}`);
} }
// =========================================================================== // ===========================================================================
@@ -445,7 +432,7 @@ function setHouseBlipCommand(command, params, client) {
resetHouseBlips(houseId); resetHouseBlips(houseId);
getHouseData(houseId).needsSaved = true; getHouseData(houseId).needsSaved = true;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} blip display to {ALTCOLOUR}${toLowerCase(typeParam)}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set house {houseGreen}${getHouseData(houseId).description}{MAINCOLOUR} blip display to {ALTCOLOUR}${toLowerCase(typeParam)}`);
} }
// =========================================================================== // ===========================================================================
@@ -1279,7 +1266,7 @@ function exitHouse(client) {
// =========================================================================== // ===========================================================================
function setAllHouseIndexes() { function setHouseDataIndexes() {
for(let i in getServerData().houses) { for(let i in getServerData().houses) {
getServerData().houses[i].index = i; getServerData().houses[i].index = i;

View File

@@ -38,6 +38,7 @@ require("scripts/server/messaging.js");
require("scripts/server/misc.js"); require("scripts/server/misc.js");
require("scripts/server/npc.js"); require("scripts/server/npc.js");
require("scripts/server/staff.js"); require("scripts/server/staff.js");
require("scripts/server/race.js");
require("scripts/server/radio.js"); require("scripts/server/radio.js");
require("scripts/server/security.js"); require("scripts/server/security.js");
require("scripts/server/subaccount.js"); require("scripts/server/subaccount.js");

View File

@@ -9,16 +9,6 @@
function initItemScript() { function initItemScript() {
logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ..."); logToConsole(LOG_INFO, "[VRR.Item]: Initializing item script ...");
getServerData().itemTypes = loadItemTypesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().items = loadItemsFromDatabase();
}
setItemTypeDataIndexes();
setItemDataIndexes();
cacheAllGroundItems();
createAllGroundItemObjects();
logToConsole(LOG_INFO, "[VRR.Item]: Item script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Item]: Item script initialized successfully!");
return true; return true;
} }
@@ -2327,7 +2317,6 @@ function createGroundPlant(itemId) {
createGroundItem(getItemTypeData(itemId).useId, 1, position, dimension); createGroundItem(getItemTypeData(itemId).useId, 1, position, dimension);
groundPlantCache.push(itemId); groundPlantCache.push(itemId);
groundItemCache.push(itemId); groundItemCache.push(itemId);
} }
// =========================================================================== // ===========================================================================

View File

@@ -9,13 +9,6 @@
function initJobScript() { function initJobScript() {
logToConsole(LOG_INFO, "[VRR.Job]: Initializing job script ..."); logToConsole(LOG_INFO, "[VRR.Job]: Initializing job script ...");
getServerData().jobs = loadJobsFromDatabase();
createAllJobPickups();
createAllJobBlips();
setAllJobDataIndexes();
logToConsole(LOG_INFO, "[VRR.Job]: Job script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Job]: Job script initialized successfully!");
return true; return true;
} }

View File

@@ -190,7 +190,7 @@ function reloadLocaleConfigurationCommand(command, params, client) {
getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage); getGlobalConfig().locale.defaultLanguageId = getLocaleFromParams(getGlobalConfig().locale.defaultLanguage);
messageAdmins(`${client.name}{MAINCOLOUR} has reloaded the locale settings and texts`); messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} has reloaded the locale settings and texts`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -672,17 +672,9 @@ function lockCommand(command, params, client) {
return false; return false;
} }
if(isPlayerInAnyVehicle(client)) { if(!isPlayerInFrontVehicleSeat(client)) {
vehicle = getPlayerVehicle(client); messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
if(!isPlayerInFrontVehicleSeat(client)) { return false;
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
} else {
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
} }
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked; getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
@@ -728,17 +720,9 @@ function lockCommand(command, params, client) {
return false; return false;
} }
if(isPlayerInAnyVehicle(client)) { if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
vehicle = getPlayerVehicle(client); messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
if(!isPlayerInFrontVehicleSeat(client)) { return false;
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
} else {
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
} }
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked; getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
@@ -752,4 +736,102 @@ function lockCommand(command, params, client) {
} }
} }
// =========================================================================== // ===========================================================================
/**
* This is a command handler function.
*
* @param {string} command - The command name used by the player
* @param {string} params - The parameters/args string used with the command by the player
* @param {Client} client - The client/player that used the command
* @return {bool} Whether or not the command was successful
*
*/
function lightsCommand(command, params, client) {
if(isPlayerInAnyVehicle(client)) {
let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!isPlayerInFrontVehicleSeat(client)) {
messagePlayerError(client, getLocaleString(client, "MustBeInVehicleFrontSeat"));
return false;
}
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
setVehicleLights(vehicle, getVehicleData(vehicle).lights)
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).lights))} the ${getVehicleName(vehicle)}`);
} else {
let vehicle = getClosestVehicle(getPlayerPosition(client));
if(vehicle != false) {
if(getDistance(getPlayerPosition(client), getVehiclePosition(vehicle) <= getGlobalConfig().vehicleLockDistance)) {
return false;
}
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false;
}
if(!doesPlayerHaveVehicleKeys(client, vehicle)) {
messagePlayerError(client, getLocaleString(client, "DontHaveVehicleKey"));
return false;
}
getVehicleData(vehicle).locked = !getVehicleData(vehicle).locked;
vehicle.locked = getVehicleData(vehicle).locked;
getVehicleData(vehicle).needsSaved = true;
meActionToNearbyPlayers(client, `${toLowerCase(getLockedUnlockedFromBool(getVehicleData(vehicle).locked))} the ${getVehicleName(vehicle)}`);
}
let businessId = getPlayerBusiness(client);
if(businessId != false) {
if(!canPlayerManageBusiness(client, businessId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyBusiness"));
return false;
}
getBusinessData(businessId).interiorLights = !getBusinessData(businessId).interiorLights;
let clients = getClients();
for(let i in clients) {
if(getPlayerBusiness(client) == getPlayerBusiness(clients[i]) && getPlayerDimension(clients[i]) == getBusinessData(businessId).exitDimension) {
setPlayerInteriorLights(clients[i], getBusinessData(businessId).interiorLights);
}
}
getBusinessData(businessId).needsSaved = true;
meActionToNearbyPlayers(client, `turned ${getOnOffFromBool((getBusinessData(businessId).interiorLights))} on the business lights`);
return true;
}
let houseId = getPlayerHouse(client);
if(houseId != false) {
if(!canPlayerManageHouse(client, houseId)) {
messagePlayerError(client, getLocaleString(client, "CantModifyHouse"));
return false;
}
getHouseData(businessId).interiorLights = !getHouseData(houseId).interiorLights;
let clients = getClients();
for(let i in clients) {
if(getPlayerHouse(client) == getPlayerHouse(clients[i]) && getPlayerDimension(clients[i]) == getHouseData(houseId).exitDimension) {
setPlayerInteriorLights(clients[i], getHouseData(houseId).interiorLights);
}
}
getHouseData(houseId).needsSaved = true;
meActionToNearbyPlayers(client, `turned ${getOnOffFromBool((getHouseData(houseId).interiorLights))} on the house lights`);
return true;
}
}
}

View File

@@ -261,7 +261,7 @@ function setPlayerHealth(client, health) {
// =========================================================================== // ===========================================================================
function getPlayerHealth(client) { function getPlayerHealth(client) {
return getServerData(client).health; return getPlayerData(client).health;
} }
// =========================================================================== // ===========================================================================
@@ -331,7 +331,7 @@ function takePlayerCash(client, amount) {
function disconnectPlayer(client) { function disconnectPlayer(client) {
logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`); logToConsole(LOG_DEBUG, `Disconnecting (kicking) ${getPlayerDisplayForConsole(client)}`);
client.disconnect(); disconnectPlayer(client);
return false; return false;
} }
@@ -739,7 +739,7 @@ function givePlayerWeaponAmmo(client, ammo) {
function getPlayerWeapon(client) { function getPlayerWeapon(client) {
if(areServerElementsSupported(client)) { if(areServerElementsSupported(client)) {
return getPlayerPed(client).weapon;; return getPlayerPed(client).weapon;
} else { } else {
return getPlayerData(client).syncWeapon; return getPlayerData(client).syncWeapon;
} }
@@ -1166,4 +1166,40 @@ function doesEntityDataExist(entity, dataName) {
return null; return null;
} }
// ===========================================================================
function disconnectPlayer(client) {
client.disconnect();
}
// ===========================================================================
function getPlayerId(client) {
return client.index;
}
// ===========================================================================
function getPlayerIP(client) {
return client.ip;
}
// ===========================================================================
function getPlayerGameVersion(client) {
client.gameVersion;
}
// ===========================================================================
function setPlayerNativeAdminState(client, state) {
client.administrator = state;
}
// ===========================================================================
function despawnPlayer(client) {
client.despawnPlayer();
}
// =========================================================================== // ===========================================================================

View File

@@ -8,12 +8,8 @@
// =========================================================================== // ===========================================================================
function initNPCScript() { function initNPCScript() {
if(!getServerConfig().devServer) { logToConsole(LOG_INFO, "[VRR.NPC]: Initializing NPC script ...");
getServerData().npcs = loadNPCsFromDatabase(); logToConsole(LOG_INFO, "[VRR.NPC]: NPC script initialized successfully!");
}
setNPCDataIndexes();
spawnNPCs();
} }
// =========================================================================== // ===========================================================================
@@ -47,7 +43,7 @@ function createNPCCommand(client, command, params) {
let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3); let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3);
let npcId = createNPC(skinId, position, getPlayerHeading(client)); let npcId = createNPC(skinId, position, getPlayerHeading(client));
messageAdmins(`${client.name}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`); messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} created a ${getSkinNameFromIndex(getNPCData(npcId).skin)} NPC!`);
} }
// =========================================================================== // ===========================================================================
@@ -285,7 +281,7 @@ function spawnNPC(npcIndex) {
// =========================================================================== // ===========================================================================
function spawnNPCs() { function spawnAllNPCs() {
for(let i in getServerData().npcs) { for(let i in getServerData().npcs) {
spawnNPC(npcIndex); spawnNPC(npcIndex);
} }
@@ -309,7 +305,7 @@ function deleteNPCCommand(command, params, client) {
let npcName = getNPCData(closestNPC).name; let npcName = getNPCData(closestNPC).name;
deleteNPC(closestNPC); deleteNPC(closestNPC);
messageAdmins(`${client.name}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`); messageAdmins(`${getPlayerName(client)}{MAINCOLOUR} deleted NPC {npcPink}${npcName}`);
} }
// =========================================================================== // ===========================================================================

View File

@@ -8,11 +8,8 @@
// =========================================================================== // ===========================================================================
function initRaceScript() { function initRaceScript() {
if(!getServerConfig().devServer) { logToConsole(LOG_INFO, "[VRR.Race]: Initializing race script ...");
getServerData().races = loadRacesFromDatabase(); logToConsole(LOG_INFO, "[VRR.Race]: Race script initialized successfully!");
}
setRaceDataIndexes();
} }
// =========================================================================== // ===========================================================================
@@ -28,4 +25,33 @@ function getRaceData(raceId) {
return false; return false;
} }
// ===========================================================================
function setAllRaceDataIndexes() {
for(let i in getServerData().races) {
getServerData().races[i].index = i;
}
}
// ===========================================================================
function loadRacesFromDatabase() {
// To-do
return [];
}
// ===========================================================================
function saveRacesToDatabase() {
for(let i in getServerData().races) {
saveRaceToDatabase(getServerData().races[i]);
}
}
// ===========================================================================
function saveRaceToDatabase(raceData) {
return true;
}
// =========================================================================== // ===========================================================================

View File

@@ -9,11 +9,6 @@
function initRadioScript() { function initRadioScript() {
logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ..."); logToConsole(LOG_INFO, "[VRR.Radio]: Initializing radio script ...");
if(!getServerConfig().devServer) {
getServerData().radioStations = loadRadioStationsFromDatabase();
}
setRadioStationIndexes();
logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!"); logToConsole(LOG_INFO, "[VRR.Radio]: Radio script initialized successfully!");
return true; return true;
} }
@@ -229,7 +224,7 @@ function showRadioStationListCommand(command, params, client) {
// =========================================================================== // ===========================================================================
function setRadioStationIndexes() { function setAllRadioStationIndexes() {
for(let i in getServerData().radioStations) { for(let i in getServerData().radioStations) {
getServerData().radioStations[i].index = i; getServerData().radioStations[i].index = i;
} }

View File

@@ -45,7 +45,7 @@ function kickClientCommand(command, params, client) {
//getPlayerData(targetClient).customDisconnectReason = reason; //getPlayerData(targetClient).customDisconnectReason = reason;
announceAdminAction(`PlayerKicked`, getPlayerName(targetClient)); announceAdminAction(`PlayerKicked`, getPlayerName(targetClient));
targetClient.disconnect(); targetdisconnectPlayer(client);
} }
// =========================================================================== // ===========================================================================
@@ -83,9 +83,9 @@ function setStaffTitleCommand(command, params, client) {
} }
getPlayerData(targetClient).accountData.staffTitle = staffTitle; getPlayerData(targetClient).accountData.staffTitle = staffTitle;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} staff title to ${staffTitle}`);
messagePlayerAlert(client, `${getPlayerName(client)} set your staff title to ${staffTitle}`); messagePlayerAlert(client, `${getPlayerName(client)} set your staff title to ${staffTitle}`);
targetClient.disconnect(); targetdisconnectPlayer(client);
} }
// =========================================================================== // ===========================================================================
@@ -119,7 +119,7 @@ function muteClientCommand(command, params, client) {
} }
} }
messageAdmins(`{adminRed}${targetClient.name}{MAINCOLOUR} has been muted by {adminRed}${client.name}`); messageAdmins(`{adminRed}${targetgetPlayerName(client)}{MAINCOLOUR} has been muted by {adminRed}${getPlayerName(client)}`);
getPlayerData(targetClient).muted = true; getPlayerData(targetClient).muted = true;
} }
@@ -154,7 +154,7 @@ function unMuteClientCommand(command, params, client) {
} }
} }
messageAdmins(`{adminRed}${targetClient.name}{MAINCOLOUR} has been un-muted by {adminRed}${client.name}`); messageAdmins(`{adminRed}${targetgetPlayerName(client)}{MAINCOLOUR} has been un-muted by {adminRed}${getPlayerName(client)}`);
getPlayerData(targetClient).muted = false; getPlayerData(targetClient).muted = false;
} }
@@ -189,7 +189,7 @@ function freezeClientCommand(command, params, client) {
} }
} }
messageAdmins(`{adminRed}${targetClient.name}{MAINCOLOUR} has been frozen by ${client.name}`); messageAdmins(`{adminRed}${targetgetPlayerName(client)}{MAINCOLOUR} has been frozen by ${getPlayerName(client)}`);
//setPlayerFrozenState(client, state); //setPlayerFrozenState(client, state);
setPlayerControlState(client, false); setPlayerControlState(client, false);
} }
@@ -225,7 +225,7 @@ function unFreezeClientCommand(command, params, client) {
} }
} }
messageAdmins(`{adminRed}${targetClient.name}{MAINCOLOUR} has been un-frozen by ${client.name}`); messageAdmins(`{adminRed}${targetgetPlayerName(client)}{MAINCOLOUR} has been un-frozen by ${getPlayerName(client)}`);
//sendPlayerFrozenState(client, false); //sendPlayerFrozenState(client, false);
setPlayerControlState(client, true); setPlayerControlState(client, true);
} }
@@ -294,11 +294,11 @@ function getPlayerGeoIPInformationCommand(command, params, client) {
return false; return false;
} }
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, targetClient.ip); let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, targetgetPlayerIP(client));
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, targetClient.ip); let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, targetgetPlayerIP(client));
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, targetClient.ip); let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, targetgetPlayerIP(client));
messagePlayerInfo(client, `{ALTCOLOUR}${targetClient.name} {MAINCOLOUR}is from {ALTCOLOUR}${cityName}, ${subDivisionName}, ${countryName}`); messagePlayerInfo(client, `{ALTCOLOUR}${targetgetPlayerName(client)} {MAINCOLOUR}is from {ALTCOLOUR}${cityName}, ${subDivisionName}, ${countryName}`);
} }
// =========================================================================== // ===========================================================================
@@ -324,7 +324,7 @@ function getPlayerIPInformationCommand(command, params, client) {
return false; return false;
} }
messagePlayerInfo(client, `{ALTCOLOUR}${targetClient.name}'s{MAINCOLOUR} IP is ${targetClient.ip}`); messagePlayerInfo(client, `{ALTCOLOUR}${targetgetPlayerName(client)}'s{MAINCOLOUR} IP is ${targetgetPlayerIP(client)}`);
} }
// =========================================================================== // ===========================================================================
@@ -393,7 +393,7 @@ function getVehicleCommand(command, params, client) {
setElementInterior(vehicle, getPlayerInterior(client)); setElementInterior(vehicle, getPlayerInterior(client));
setElementDimension(vehicle, getPlayerDimension(client)); setElementDimension(vehicle, getPlayerDimension(client));
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} teleported a {vehiclePurple}${getVehicleName(vehicle)}{ALTCOLOUR} (ID ${vehicle.id}){MAINCOLOUR} to their position`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} teleported a {vehiclePurple}${getVehicleName(vehicle)}{ALTCOLOUR} (ID ${vehicle.id}){MAINCOLOUR} to their position`);
} }
// =========================================================================== // ===========================================================================
@@ -814,7 +814,7 @@ function playerInteriorCommand(command, params, client) {
let interiorId = getParam(params, " ", 2); let interiorId = getParam(params, " ", 2);
setPlayerInterior(targetClient, Number(interiorId)); setPlayerInterior(targetClient, Number(interiorId));
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} interior to {ALTCOLOUR}${interiorId}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} interior to {ALTCOLOUR}${interiorId}`);
} }
// =========================================================================== // ===========================================================================
@@ -847,7 +847,7 @@ function playerVirtualWorldCommand(command, params, client) {
let dimensionId = getParam(params, " ", 2); let dimensionId = getParam(params, " ", 2);
setPlayerDimension(targetClient, Number(dimensionId)); setPlayerDimension(targetClient, Number(dimensionId));
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} virtual world to {ALTCOLOUR}${dimensionId}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getPlayerName(targetClient)}'s{MAINCOLOUR} virtual world to {ALTCOLOUR}${dimensionId}`);
} }
// =========================================================================== // ===========================================================================
@@ -895,7 +895,7 @@ function getPlayerCommand(command, params, client) {
setPlayerInterior(targetClient, getPlayerInterior(client)); setPlayerInterior(targetClient, getPlayerInterior(client));
setPlayerDimension(targetClient, getPlayerDimension(client)); setPlayerDimension(targetClient, getPlayerDimension(client));
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} teleported {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their position.`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} teleported {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their position.`);
messagePlayerAlert(targetClient, `An admin has teleported you to their location`); messagePlayerAlert(targetClient, `An admin has teleported you to their location`);
} }
@@ -942,7 +942,7 @@ function returnPlayerCommand(command, params, client) {
getPlayerData(targetClient).returnToBusiness = null; getPlayerData(targetClient).returnToBusiness = null;
getPlayerData(targetClient).returnToType = VRR_RETURNTO_TYPE_NONE; getPlayerData(targetClient).returnToType = VRR_RETURNTO_TYPE_NONE;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} returned {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their previous position.`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} returned {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} to their previous position.`);
messagePlayerAlert(targetClient, `An admin has returned you to your previous location`); messagePlayerAlert(targetClient, `An admin has returned you to your previous location`);
} }
@@ -985,7 +985,7 @@ function addPlayerStaffFlagCommand(command, params, client) {
} }
givePlayerStaffFlag(targetClient, flagName); givePlayerStaffFlag(targetClient, flagName);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} has given {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} has given {ALTCOLOUR}${getPlayerName(targetClient)}{MAINCOLOUR} the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag`);
} }
// =========================================================================== // ===========================================================================
@@ -1027,7 +1027,7 @@ function removePlayerStaffFlagCommand(command, params, client) {
} }
takePlayerStaffFlag(targetClient, flagName); takePlayerStaffFlag(targetClient, flagName);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} has taken the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag from {ALTCOLOUR}${getPlayerName(targetClient)}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} has taken the {ALTCOLOUR}${flagName}{MAINCOLOUR} staff flag from {ALTCOLOUR}${getPlayerName(targetClient)}`);
} }
// =========================================================================== // ===========================================================================
@@ -1063,7 +1063,7 @@ function removePlayerStaffFlagsCommand(command, params, client) {
} }
clearPlayerStaffFlags(targetClient); clearPlayerStaffFlags(targetClient);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} removed all staff flags from {ALTCOLOUR}${getPlayerName(targetClient)}`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} removed all staff flags from {ALTCOLOUR}${getPlayerName(targetClient)}`);
} }
// =========================================================================== // ===========================================================================
@@ -1190,7 +1190,7 @@ function givePlayerMoneyCommand(command, params, client) {
givePlayerCash(targetClient, toInteger(amount)); givePlayerCash(targetClient, toInteger(amount));
updatePlayerCash(targetClient); updatePlayerCash(targetClient);
//messagePlayerSuccess(client, `You gave {ALTCOLOUR}$${amount} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`); //messagePlayerSuccess(client, `You gave {ALTCOLOUR}$${amount} {MAINCOLOUR}to {ALTCOLOUR}${getCharacterFullName(targetClient)}`);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} gave {ALTCOLOUR}$${amount}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(targetClient)}`) messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} gave {ALTCOLOUR}$${amount}{MAINCOLOUR} to {ALTCOLOUR}${getCharacterFullName(targetClient)}`)
messagePlayerAlert(targetClient, `An admin gave you {ALTCOLOUR}$${amount}`); messagePlayerAlert(targetClient, `An admin gave you {ALTCOLOUR}$${amount}`);
} }
@@ -1227,11 +1227,11 @@ function setPlayerAccentCommand(command, params, client) {
if(newAccent == "") { if(newAccent == "") {
//messagePlayerSuccess(client, `You removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent.`); //messagePlayerSuccess(client, `You removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent.`);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent.`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} removed {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent.`);
messagePlayerAlert(client, `An admin removed your accent.`); messagePlayerAlert(client, `An admin removed your accent.`);
} else { } else {
//messagePlayerSuccess(client, `You set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent to {ALTCOLOUR}${newAccent}`); //messagePlayerSuccess(client, `You set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s {MAINCOLOUR}accent to {ALTCOLOUR}${newAccent}`);
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent to {ALTCOLOUR}${newAccent}`) messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} set {ALTCOLOUR}${getCharacterFullName(targetClient)}'s{MAINCOLOUR} accent to {ALTCOLOUR}${newAccent}`)
messagePlayerAlert(client, `An admin set your accent to {ALTCOLOUR}${newAccent}`); messagePlayerAlert(client, `An admin set your accent to {ALTCOLOUR}${newAccent}`);
} }
} }
@@ -1262,7 +1262,7 @@ function forceCharacterNameChangeCommand(command, params, client) {
getPlayerData(targetClient).changingCharacterName = true; getPlayerData(targetClient).changingCharacterName = true;
messageAdmins(`{adminRed}${client.name}{MAINCOLOUR} forced {ALTCOLOUR}${getPlayerName(targetClient)} (${getCharacterFullName(targetClient)}){MAINCOLOUR} to change their character's name.`); messageAdmins(`{adminRed}${getPlayerName(client)}{MAINCOLOUR} forced {ALTCOLOUR}${getPlayerName(targetClient)} (${getCharacterFullName(targetClient)}){MAINCOLOUR} to change their character's name.`);
showPlayerNewCharacterFailedGUI(targetClient, getLocaleString(targetClient, "NonRPName")); showPlayerNewCharacterFailedGUI(targetClient, getLocaleString(targetClient, "NonRPName"));
} }

View File

@@ -38,14 +38,16 @@ function initServerScripts() {
initEconomyScript(); initEconomyScript();
initRadioScript(); initRadioScript();
initLocaleScript(); initLocaleScript();
initCommandScript(); initCommandScript();
serverStartTime = getCurrentUnixTimestamp(); loadServerDataFromDatabase();
setAllServerDataIndexes();
createAllServerElements();
initAllClients(); initAllClients();
initTimers(); initTimers();
serverStartTime = getCurrentUnixTimestamp();
} }
// =========================================================================== // ===========================================================================
@@ -105,6 +107,54 @@ function checkForAllRequiredModules() {
// =========================================================================== // ===========================================================================
function loadServerDataFromDatabase() {
getServerData().itemTypes = loadItemTypesFromDatabase();
if(!getServerConfig().devServer) {
getServerData().items = loadItemsFromDatabase();
getServerData().businesses = loadBusinessesFromDatabase();
getServerData().houses = loadHousesFromDatabase();
getServerData().vehicles = loadVehiclesFromDatabase();
getServerData().clans = loadClansFromDatabase();
getServerData().jobs = loadJobsFromDatabase();
getServerData().npcs = loadNPCsFromDatabase();
getServerData().races = loadRacesFromDatabase();
getServerData().radioStations = loadRadioStationsFromDatabase();
}
}
// ===========================================================================
function setAllServerDataIndexes() {
setItemTypeDataIndexes();
setItemDataIndexes();
setBusinessDataIndexes();
setHouseDataIndexes();
setAllClanDataIndexes();
setAllJobDataIndexes();
setNPCDataIndexes();
setAllRaceDataIndexes();
setAllRadioStationIndexes();
cacheAllGroundItems();
cacheAllBusinessItems();
}
// ===========================================================================
function createAllServerElements() {
createAllBusinessPickups();
createAllBusinessBlips();
createAllHousePickups();
createAllHouseBlips();
createAllJobPickups();
createAllJobBlips();
createAllGroundItemObjects();
spawnAllVehicles();
spawnAllNPCs();
}
// ===========================================================================
initServerScripts(); initServerScripts();
// =========================================================================== // ===========================================================================

View File

@@ -64,7 +64,7 @@ function getGameAreas(gameId) {
function getPlayerData(client) { function getPlayerData(client) {
if(client != null) { if(client != null) {
if(isClientInitialized(client)) { if(isClientInitialized(client)) {
return getServerData().clients[client.index]; return getServerData().clients[getPlayerId(client)];
} }
} }
return false; return false;
@@ -178,7 +178,7 @@ function getPlayerDisplayForConsole(client) {
if(isNull(client)) { if(isNull(client)) {
return "(Unknown client)"; return "(Unknown client)";
} }
return `${getPlayerName(client)}[${client.index}]`; return `${getPlayerName(client)}[${getPlayerId(client)}]`;
} }
// =========================================================================== // ===========================================================================
@@ -449,7 +449,7 @@ function clearTemporaryPeds() {
function kickAllClients() { function kickAllClients() {
getClients().forEach((client) => { getClients().forEach((client) => {
client.disconnect(); disconnectPlayer(client);
}) })
} }
@@ -464,7 +464,7 @@ function updateTimeRule() {
// =========================================================================== // ===========================================================================
function isClientInitialized(client) { function isClientInitialized(client) {
return (typeof getServerData().clients[client.index] != "undefined"); return (typeof getServerData().clients[getPlayerId(client)] != "undefined");
} }
// =========================================================================== // ===========================================================================