Add set house data indexes func
This commit is contained in:
@@ -96,6 +96,7 @@ function initClassTable() {
|
||||
this.client = client;
|
||||
this.currentSubAccount = -1;
|
||||
this.loggedIn = false;
|
||||
this.index = -1;
|
||||
|
||||
this.busRoute = null;
|
||||
this.busRouteStop = null;
|
||||
@@ -217,10 +218,36 @@ function initClassTable() {
|
||||
},
|
||||
subAccountData: class {
|
||||
constructor(subAccountAssoc) {
|
||||
if(!subAccountAssoc) {
|
||||
return;
|
||||
}
|
||||
this.databaseId = 0;
|
||||
this.server = 0;
|
||||
this.firstName = "John";
|
||||
this.lastName = "Doe";
|
||||
this.account = 0;
|
||||
this.skin = 0;
|
||||
this.cash = 0;
|
||||
this.placeOfOrigin = "";
|
||||
this.dateOfBirth = "";
|
||||
this.spawnPosition = toVector3(0.0, 0.0, 0.0);
|
||||
this.spawnHeading = 0.0;
|
||||
this.lastLogin = 0;
|
||||
|
||||
this.clan = 0;
|
||||
this.clanFlags = 0;
|
||||
this.clanRank = 0;
|
||||
this.clanTitle = 0;
|
||||
|
||||
this.isWorking = false;
|
||||
this.jobUniform = this.skin;
|
||||
this.lastJobVehicle = null;
|
||||
this.job = 0;
|
||||
|
||||
this.weapons = [];
|
||||
this.inJail = false;
|
||||
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
|
||||
if(subAccountAssoc) {
|
||||
this.databaseId = subAccountAssoc["sacct_id"];
|
||||
this.server = subAccountAssoc["sacct_server"];
|
||||
this.firstName = subAccountAssoc["sacct_name_first"];
|
||||
@@ -247,8 +274,12 @@ function initClassTable() {
|
||||
this.weapons = [];
|
||||
this.inJail = false;
|
||||
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
this.interior = subAccountAssoc["sacct_int"];
|
||||
this.dimension = subAccountAssoc["sacct_vw"];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
businessData: class {
|
||||
@@ -260,6 +291,7 @@ function initClassTable() {
|
||||
this.buyPrice = 0;
|
||||
this.locked = false;
|
||||
this.hasInterior = false;
|
||||
this.index = -1;
|
||||
|
||||
this.entrancePosition = false;
|
||||
this.entranceRotation = 0.0;
|
||||
@@ -311,20 +343,30 @@ function initClassTable() {
|
||||
}
|
||||
},
|
||||
businessLocationData: class {
|
||||
constructor(businessLocationAssoc) {
|
||||
if(!businessLocationAssoc) {
|
||||
return;
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.type = 0;
|
||||
this.business = 0;
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
this.position = toVector3(0.0, 0.0, 0.0);
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = toInteger(dbAssoc("biz_loc_id"));
|
||||
this.name = toString(dbAssoc("biz_loc_name"));
|
||||
this.type = toInteger(dbAssoc("biz_loc_type"));
|
||||
this.business = toInteger(dbAssoc("biz_loc_biz"));
|
||||
this.enabled = intToBool(toInteger(dbAssoc("biz_loc_enabled")));
|
||||
this.index = -1;
|
||||
|
||||
this.position = toVector3(toFloat(dbAssoc("biz_loc_pos_x")), toFloat(dbAssoc("biz_loc_pos_y")), toFloat(dbAssoc("biz_loc_pos_z")));
|
||||
this.interior = toInteger(dbAssoc["biz_loc_int"]);
|
||||
this.dimension = toInteger(dbAssoc["biz_loc_vw"]);
|
||||
}
|
||||
|
||||
this.databaseId = toInteger(businessLocationAssoc("biz_loc_id"));
|
||||
this.name = toString(businessLocationAssoc("biz_loc_name"));
|
||||
this.type = toInteger(businessLocationAssoc("biz_loc_type"));
|
||||
this.business = toInteger(businessLocationAssoc("biz_loc_biz"));
|
||||
this.enabled = intToBool(toInteger(businessLocationAssoc("biz_loc_enabled")));
|
||||
|
||||
this.position = toVector3(toFloat(businessLocationAssoc("biz_loc_pos_x")), toFloat(businessLocationAssoc("biz_loc_pos_y")), toFloat(businessLocationAssoc("biz_loc_pos_z")));
|
||||
this.interior = toInteger(businessLocationAssoc["biz_loc_int"]);
|
||||
this.dimension = toInteger(businessLocationAssoc["biz_loc_vw"]);
|
||||
}
|
||||
},
|
||||
houseData: class {
|
||||
@@ -336,6 +378,7 @@ function initClassTable() {
|
||||
this.buyPrice = 0;
|
||||
this.locked = false;
|
||||
this.hasInterior = false;
|
||||
this.index = -1;
|
||||
|
||||
this.entrancePosition = false;
|
||||
this.entranceRotation = 0.0;
|
||||
@@ -393,6 +436,7 @@ function initClassTable() {
|
||||
this.server = getServerId();
|
||||
this.model = (vehicle != false) ? vehicle.modelIndex : 0;
|
||||
this.vehicle = vehicle;
|
||||
this.index = -1;
|
||||
|
||||
// Ownership
|
||||
this.ownerType = AG_VEHOWNER_NONE;
|
||||
@@ -511,7 +555,7 @@ function initClassTable() {
|
||||
}
|
||||
},
|
||||
jobData: class {
|
||||
constructor(jobAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.type = AG_JOB_NONE;
|
||||
this.name = "Unnamed";
|
||||
@@ -521,7 +565,7 @@ function initClassTable() {
|
||||
this.colour = toColour(0, 0, 0, 255);
|
||||
this.whiteListEnabled = false;
|
||||
this.blackListEnabled = false;
|
||||
this.id = -1;
|
||||
this.index = -1;
|
||||
|
||||
this.equipment = [];
|
||||
this.uniforms = [];
|
||||
@@ -529,16 +573,16 @@ function initClassTable() {
|
||||
this.whiteList = [];
|
||||
this.blackList = [];
|
||||
|
||||
if(jobAssoc) {
|
||||
this.databaseId = jobAssoc["job_id"];
|
||||
this.type = jobAssoc["job_type"];
|
||||
this.name = jobAssoc["job_name"];
|
||||
this.enabled = jobAssoc["job_enabled"];
|
||||
this.blipModel = jobAssoc["job_blip"];
|
||||
this.pickupModel = jobAssoc["job_pickup"];
|
||||
this.colour = toColour(jobAssoc["job_colour_r"], jobAssoc["job_colour_g"], jobAssoc["job_colour_b"], 255);
|
||||
this.whiteListEnabled = jobAssoc["job_whitelist"];
|
||||
this.blackListEnabled = jobAssoc["job_blacklist"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_id"];
|
||||
this.type = dbAssoc["job_type"];
|
||||
this.name = dbAssoc["job_name"];
|
||||
this.enabled = dbAssoc["job_enabled"];
|
||||
this.blipModel = dbAssoc["job_blip"];
|
||||
this.pickupModel = dbAssoc["job_pickup"];
|
||||
this.colour = toColour(dbAssoc["job_colour_r"], dbAssoc["job_colour_g"], dbAssoc["job_colour_b"], 255);
|
||||
this.whiteListEnabled = dbAssoc["job_whitelist"];
|
||||
this.blackListEnabled = dbAssoc["job_blacklist"];
|
||||
|
||||
this.equipment = [];
|
||||
this.uniforms = [];
|
||||
@@ -549,60 +593,63 @@ function initClassTable() {
|
||||
}
|
||||
},
|
||||
jobEquipmentData: class {
|
||||
constructor(jobEquipmentAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.job = 0;
|
||||
this.name = "Unnamed";
|
||||
this.requiredRank = 0;
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
if(jobEquipmentAssoc) {
|
||||
this.databaseId = jobEquipmentAssoc["job_equip_id"];
|
||||
this.job = jobEquipmentAssoc["job_equip_job"];
|
||||
this.name = jobEquipmentAssoc["job_equip_name"];
|
||||
this.requiredRank = jobEquipmentAssoc["job_equip_minrank"];
|
||||
this.enabled = jobEquipmentAssoc["job_equip_enabled"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_equip_id"];
|
||||
this.job = dbAssoc["job_equip_job"];
|
||||
this.name = dbAssoc["job_equip_name"];
|
||||
this.requiredRank = dbAssoc["job_equip_minrank"];
|
||||
this.enabled = dbAssoc["job_equip_enabled"];
|
||||
}
|
||||
}
|
||||
},
|
||||
jobEquipmentWeaponData: class {
|
||||
constructor(jobEquipmentWeaponAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.equipmentId = 0;
|
||||
this.weaponId = 0;
|
||||
this.ammo = 0;
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
if(jobEquipmentWeaponAssoc) {
|
||||
this.databaseId = jobEquipmentWeaponAssoc["job_equip_wep_id"];
|
||||
this.equipmentId = jobEquipmentWeaponAssoc["job_equip_wep_equip"];
|
||||
this.weaponId = jobEquipmentWeaponAssoc["job_equip_wep_wep"];
|
||||
this.ammo = jobEquipmentWeaponAssoc["job_equip_wep_ammo"];
|
||||
this.enabled = jobEquipmentWeaponAssoc["job_equip_wep_enabled"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_equip_wep_id"];
|
||||
this.equipmentId = dbAssoc["job_equip_wep_equip"];
|
||||
this.weaponId = dbAssoc["job_equip_wep_wep"];
|
||||
this.ammo = dbAssoc["job_equip_wep_ammo"];
|
||||
this.enabled = dbAssoc["job_equip_wep_enabled"];
|
||||
}
|
||||
}
|
||||
},
|
||||
jobUniformData: class {
|
||||
constructor(jobUniformAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.job = 0;
|
||||
this.name = "Unnamed";
|
||||
this.requiredRank = 0
|
||||
this.skin = -1;
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
if(jobUniformAssoc) {
|
||||
this.databaseId = jobUniformAssoc["job_uniform_id"];
|
||||
this.job = jobUniformAssoc["job_uniform_job"];
|
||||
this.name = jobUniformAssoc["job_uniform_name"];
|
||||
this.requiredRank = jobUniformAssoc["job_uniform_minrank"];
|
||||
this.skin = jobUniformAssoc["job_uniform_skin"];
|
||||
this.enabled = jobUniformAssoc["job_uniform_skin"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_uniform_id"];
|
||||
this.job = dbAssoc["job_uniform_job"];
|
||||
this.name = dbAssoc["job_uniform_name"];
|
||||
this.requiredRank = dbAssoc["job_uniform_minrank"];
|
||||
this.skin = dbAssoc["job_uniform_skin"];
|
||||
this.enabled = dbAssoc["job_uniform_skin"];
|
||||
}
|
||||
}
|
||||
},
|
||||
jobLocationData: class {
|
||||
constructor(jobLocationAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.job = 0;
|
||||
this.position = toVector3(0.0, 0.0, 0.0);
|
||||
@@ -611,46 +658,49 @@ function initClassTable() {
|
||||
this.enabled = false;
|
||||
this.interior = 0;
|
||||
this.dimension = 0;
|
||||
this.index = -1;
|
||||
|
||||
if(jobLocationAssoc) {
|
||||
this.databaseId = jobLocationAssoc["job_loc_id"];
|
||||
this.job = jobLocationAssoc["job_loc_job"];
|
||||
this.position = toVector3(jobLocationAssoc["job_loc_pos_x"], jobLocationAssoc["job_loc_pos_y"], jobLocationAssoc["job_loc_pos_z"]);
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_loc_id"];
|
||||
this.job = dbAssoc["job_loc_job"];
|
||||
this.position = toVector3(dbAssoc["job_loc_pos_x"], dbAssoc["job_loc_pos_y"], dbAssoc["job_loc_pos_z"]);
|
||||
this.blip = false;
|
||||
this.pickup = false;
|
||||
this.enabled = jobLocationAssoc["job_loc_enabled"];
|
||||
this.interior = jobLocationAssoc["job_loc_int"];
|
||||
this.dimension = jobLocationAssoc["job_loc_vw"];
|
||||
this.enabled = dbAssoc["job_loc_enabled"];
|
||||
this.interior = dbAssoc["job_loc_int"];
|
||||
this.dimension = dbAssoc["job_loc_vw"];
|
||||
}
|
||||
}
|
||||
},
|
||||
jobWhiteListData: class {
|
||||
constructor(jobWhiteListAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.job = 0;
|
||||
this.subAccount = 0
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
if(jobWhiteListAssoc) {
|
||||
this.databaseId = jobWhiteListAssoc["job_wl_id"];
|
||||
this.job = jobWhiteListAssoc["job_wl_job"];
|
||||
this.subAccount = jobWhiteListAssoc["job_wl_sacct"]
|
||||
this.enabled = jobWhiteListAssoc["job_wl_enabled"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_wl_id"];
|
||||
this.job = dbAssoc["job_wl_job"];
|
||||
this.subAccount = dbAssoc["job_wl_sacct"]
|
||||
this.enabled = dbAssoc["job_wl_enabled"];
|
||||
}
|
||||
}
|
||||
},
|
||||
jobBlackListData: class {
|
||||
constructor(jobBlackListAssoc) {
|
||||
constructor(dbAssoc) {
|
||||
this.databaseId = 0;
|
||||
this.job = 0;
|
||||
this.subAccount = 0
|
||||
this.enabled = false;
|
||||
this.index = -1;
|
||||
|
||||
if(jobBlackListAssoc) {
|
||||
this.databaseId = jobBlackListAssoc["job_bl_id"];
|
||||
this.job = jobBlackListAssoc["job_bl_job"];
|
||||
this.subAccount = jobBlackListAssoc["job_bl_sacct"]
|
||||
this.enabled = jobBlackListAssoc["job_bl_enabled"];
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["job_bl_id"];
|
||||
this.job = dbAssoc["job_bl_job"];
|
||||
this.subAccount = dbAssoc["job_bl_sacct"]
|
||||
this.enabled = dbAssoc["job_bl_enabled"];
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -663,40 +713,50 @@ function initClassTable() {
|
||||
this.whenAdded = 0;
|
||||
this.enabled = true;
|
||||
this.keyState = false;
|
||||
this.index = -1;
|
||||
|
||||
if(keyBindAssoc) {
|
||||
this.databaseId = keyBindAssoc["acct_hotkey_id"];
|
||||
this.key = toInteger(keyBindAssoc["acct_hotkey_key"]);
|
||||
this.account = toInteger(keyBindAssoc["acct_hotkey_acct"]);
|
||||
this.commandString = keyBindAssoc["acct_hotkey_cmdstr"];
|
||||
this.whenAdded = keyBindAssoc["acct_hotkey_when_added"];
|
||||
this.enabled = intToBool(keyBindAssoc["acct_hotkey_enabled"]);
|
||||
this.keyState = intToBool(keyBindAssoc["acct_hotkey_down"]);
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_hotkey_id"];
|
||||
this.key = toInteger(dbAssoc["acct_hotkey_key"]);
|
||||
this.account = toInteger(dbAssoc["acct_hotkey_acct"]);
|
||||
this.commandString = dbAssoc["acct_hotkey_cmdstr"];
|
||||
this.whenAdded = dbAssoc["acct_hotkey_when_added"];
|
||||
this.enabled = intToBool(dbAssoc["acct_hotkey_enabled"]);
|
||||
this.keyState = intToBool(dbAssoc["acct_hotkey_down"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
blackListedGameScriptData: class {
|
||||
constructor(dbAssoc) {
|
||||
if(!dbAssoc) {
|
||||
return;
|
||||
}
|
||||
this.databaseId = 0;
|
||||
this.enabled = false
|
||||
this.server = 0;
|
||||
this.scriptName = "";
|
||||
this.index = -1;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["ac_script_bl_id"];
|
||||
this.enabled = intToBool(dbAssoc["ac_script_bl_enabled"]);
|
||||
this.server = dbAssoc["ac_script_bl_server"];
|
||||
this.scriptName = dbAssoc["ac_script_bl_name"];
|
||||
}
|
||||
}
|
||||
},
|
||||
whiteListedGameScriptData: class {
|
||||
constructor(dbAssoc) {
|
||||
if(!dbAssoc) {
|
||||
return;
|
||||
}
|
||||
this.databaseId = 0;
|
||||
this.enabled = false
|
||||
this.server = 0;
|
||||
this.scriptName = "";
|
||||
this.index = -1;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["ac_script_wl_id"];
|
||||
this.enabled = intToBool(dbAssoc["ac_script_wl_enabled"]);
|
||||
this.server = dbAssoc["ac_script_wl_server"];
|
||||
this.scriptName = dbAssoc["ac_script_wl_name"];
|
||||
}
|
||||
}
|
||||
},
|
||||
removedWorldObjectData: class {
|
||||
constructor(model, position, range) {
|
||||
@@ -706,9 +766,9 @@ function initClassTable() {
|
||||
}
|
||||
},
|
||||
interiorTemplateData: class {
|
||||
constructor(exitPosition, interior) {
|
||||
constructor(exitPosition, exitInterior) {
|
||||
this.exitPosition = exitPosition;
|
||||
this.interior = interior;
|
||||
this.exitInterior = exitInterior;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -50,18 +50,8 @@ addNetworkHandler("ag.promptAnswerYes", function(client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.onPlayerEnterSphere", function(client, sphere) {
|
||||
let ownerType = sphere.getData("ag.ownerType");
|
||||
let ownerId = sphere.getData("ag.ownerId");
|
||||
|
||||
switch(ownerType) {
|
||||
case AG_PICKUP_JOB:
|
||||
let jobData = getJobData(ownerId);
|
||||
showJobInformationToPlayer(client, jobData.jobType);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//let ownerType = getEntityData(sphere, "ag.ownerType");
|
||||
//let ownerId = getEntityData(sphere, "ag.ownerId");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -76,29 +66,6 @@ addNetworkHandler("ag.afk", function(client, afkState) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Not implemented yet
|
||||
addNetworkHandler("ag.heldKey", function(client, key) {
|
||||
switch(key) {
|
||||
case getGlobalConfig().keybinds.actionKey:
|
||||
processHoldActionKey(client);
|
||||
break;
|
||||
|
||||
case getGlobalConfig().keybinds.vehicleLightsKey:
|
||||
processHoldVehicleLightsKey(client);
|
||||
break;
|
||||
|
||||
case getGlobalConfig().keybinds.vehicleLockKey:
|
||||
processHoldVehicleLockKey(client);
|
||||
break;
|
||||
|
||||
case getGlobalConfig().keybinds.vehicleEngineKey:
|
||||
processHoldVehicleEngineKey(client);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addNetworkHandler("ag.player.death", function(client, position) {
|
||||
processPlayerDeath(client, position);
|
||||
});
|
||||
@@ -166,3 +133,21 @@ function showGameMessage(client, text, colour, duration) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function enableCityAmbienceForPlayer(client) {
|
||||
triggerNetworkEvent("ag.ambience", client, true);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function disableCityAmbienceForPlayer(client) {
|
||||
triggerNetworkEvent("ag.ambience", client, false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function clearPlayerOwnedPeds(client) {
|
||||
console.log(`[Asshat.Utilities] Clearing peds owned by ${getPlayerDisplayForConsole(client)}`);
|
||||
triggerNetworkEvent("ag.clearPeds", client);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -8,20 +8,7 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
let serverCommands = {};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function initCommandScript() {
|
||||
console.log("[Asshat.Command]: Initializing commands script ...");
|
||||
serverCommands = loadCommandData();
|
||||
console.log("[Asshat.Command]: Initialized commands script!");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function loadCommandData() {
|
||||
let tempCommands = {
|
||||
let serverCommands = {
|
||||
account: [
|
||||
commandData("login", loginCommand, "<password>", getStaffFlagValue("none"), false, false),
|
||||
commandData("register", registerCommand, "<password>", getStaffFlagValue("none"), false, false),
|
||||
@@ -277,8 +264,13 @@ function loadCommandData() {
|
||||
commandData("passenger", enterVehicleAsPassengerCommand, "", getStaffFlagValue("none"), true, true),
|
||||
|
||||
],
|
||||
}
|
||||
return tempCommands;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function initCommandScript() {
|
||||
console.log("[Asshat.Command]: Initializing commands script ...");
|
||||
console.log("[Asshat.Command]: Initialized commands script!");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -422,14 +414,25 @@ function enableAllCommandsByType(command, params, client) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function onPlayerCommand(event, client, command, params) {
|
||||
let commandData = getCommand(command);
|
||||
processPlayerCommand(command, params, client)
|
||||
}
|
||||
addEventHandler("OnPlayerCommand", onPlayerCommand);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function processPlayerCommand(command, params, client) {
|
||||
if(builtInCommands.indexOf(toLowerCase(command)) != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let commandData = getCommand(toLowerCase(command));
|
||||
|
||||
let paramsDisplay = params;
|
||||
if(areParamsEmpty(params)) {
|
||||
paramsDisplay = ""
|
||||
paramsDisplay = "";
|
||||
}
|
||||
|
||||
if(!commandData) {
|
||||
if(!doesCommandExist(toLowerCase(command))) {
|
||||
console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (invalid command): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, `The command [#AAAAAA]/${command} [#FFFFFF]does not exist! Use /help for commands and information.`);
|
||||
return false;
|
||||
@@ -441,7 +444,7 @@ function onPlayerCommand(event, client, command, params) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(doesCommandRequireLogin(command)) {
|
||||
if(doesCommandRequireLogin(toLowerCase(command))) {
|
||||
if(!isPlayerLoggedIn(client)) {
|
||||
console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (requires login first): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, `You must be logged in to use the [#AAAAAA]/${command} [#FFFFFF]command!`);
|
||||
@@ -457,16 +460,15 @@ function onPlayerCommand(event, client, command, params) {
|
||||
// }
|
||||
//}
|
||||
|
||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
if(!doesPlayerHaveStaffPermission(client, getCommandRequiredPermissions(toLowerCase(command)))) {
|
||||
console.warn(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} attempted to use command, but failed (no permission): /${command} ${paramsDisplay}`);
|
||||
messagePlayerError(client, `You do not have permission to use the [#AAAAAA]/${command} [#FFFFFF]command!`);
|
||||
messagePlayerError(client, `You do not have permission to use the [#AAAAAA]/${toLowerCase(command)} [#FFFFFF]command!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(`[Asshat.Command] ${getPlayerDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`);
|
||||
commandData.handlerFunction(command, params, client);
|
||||
commandData.handlerFunction(toLowerCase(command), params, client);
|
||||
}
|
||||
addEventHandler("OnPlayerCommand", onPlayerCommand);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -493,3 +495,13 @@ function listAllCommands() {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function doesCommandExist(command) {
|
||||
if(getCommandData(command)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
function initDeveloperScript() {
|
||||
console.log("[Asshat.Developer]: Initializing developer script ...");
|
||||
|
||||
// Use GTAC command handlers for these since they need to be available on console
|
||||
addCommandHandler("sc", executeServerCodeCommand);
|
||||
addCommandHandler("cc", executeServerCodeCommand);
|
||||
addCommandHandler("docmd", simulateCommandForPlayer);
|
||||
addCommandHandler("allcmd", simulateCommandForAllPlayers);
|
||||
|
||||
console.log("[Asshat.Developer]: Developer script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
/*
|
||||
addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
|
||||
let commandData = getCommand(command);
|
||||
|
||||
@@ -28,6 +29,7 @@ addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
|
||||
|
||||
commandData.handlerFunction(command, params, discordUser);
|
||||
});
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ function processPlayerDeath(client, position) {
|
||||
|
||||
function processPedSpawn(ped) {
|
||||
if(ped.type == ELEMENT_PLAYER) {
|
||||
setTimeout(processPlayerSpawn, 1000, ped);
|
||||
setTimeout(processPlayerSpawn, 500, ped);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ function processPlayerSpawn(ped) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getPlayerData(client).switchingCharacter) {
|
||||
if(!isPlayerSwitchingCharacter(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -289,9 +289,7 @@ function processPlayerSpawn(ped) {
|
||||
setPlayerHeading(client, tempSubAccount.spawnHeading);
|
||||
setPlayerInterior(client, tempSubAccount.interior);
|
||||
setPlayerVirtualWorld(client, tempSubAccount.dimension);
|
||||
setTimeout(function() {
|
||||
updatePlayerCash(client);
|
||||
}, 1000);
|
||||
}, 500);
|
||||
|
||||
updateAllPlayerNameTags();
|
||||
@@ -301,3 +299,9 @@ function processPlayerSpawn(ped) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
addEventHandler("OnPedSpawn", function(event, ped) {
|
||||
processPedSpawn(ped);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -13,6 +13,8 @@ function initHouseScript() {
|
||||
getServerData().houses = loadHousesFromDatabase();
|
||||
createAllHousePickups();
|
||||
createAllHouseBlips();
|
||||
|
||||
setAllHouseIndexes();
|
||||
console.log("[Asshat.House]: House script initialized successfully!");
|
||||
return true;
|
||||
}
|
||||
@@ -698,3 +700,11 @@ function exitHouse(client) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setAllHouseIndexes() {
|
||||
for(let i in getServerData().houses) {
|
||||
getServerData().houses[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -709,18 +709,19 @@ function takeJob(client, jobId) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function reloadAllJobsCommand(command, params, client) {
|
||||
for(let i in getServerData().jobs) {
|
||||
for(let j in getServerData().jobs[i].locations) {
|
||||
destroyElement(getServerData().jobs[i].locations[j].blip);
|
||||
destroyElement(getServerData().jobs[i].locations[j].pickup);
|
||||
}
|
||||
}
|
||||
forceAllPlayersToStopWorking();
|
||||
|
||||
//forceAllPlayersToStopWorking();
|
||||
getServerData().jobs = null;
|
||||
getServerData().jobs = loadJobsFromDatabase();
|
||||
createAllJobPickups();
|
||||
createAllJobBlips();
|
||||
|
||||
for(let i in getServerData().jobs) {
|
||||
for(let j in getServerData().jobs[i].locations) {
|
||||
deleteJobLocationPickup(i, j);
|
||||
deleteJobLocationBlip(i, j);
|
||||
createJobLocationPickup(i, j);
|
||||
createJobLocationBlip(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
messageAdminAction(`All server jobs have been reloaded by an admin!`);
|
||||
}
|
||||
@@ -753,6 +754,7 @@ function deleteJobLocationCommand(command, params, client) {
|
||||
|
||||
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
|
||||
|
||||
quickDatabaseQuery(`DELETE FROM job_loc WHERE job_loc_id = ${closestJobLocation.databaseId}`);
|
||||
deleteJobLocation(closestJobLocation);
|
||||
getJobData(closestJobLocation.job).locations.splice(getClosestJobLocation.index, 1);
|
||||
}
|
||||
@@ -1237,7 +1239,7 @@ function setAllJobDataIndexes() {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createJobLocation(job, position, interior, dimension) {
|
||||
let jobLocationData = serverClasses.jobLocationData(false);
|
||||
let jobLocationData = new serverClasses.jobLocationData(false);
|
||||
jobLocationData.position = position;
|
||||
jobLocationData.job = job;
|
||||
jobLocationData.interior = interior;
|
||||
@@ -1417,3 +1419,60 @@ function saveAllJobsToDatabase() {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function deleteJobLocationBlip(jobId, locationId) {
|
||||
if(getJobData(jobId).locations[locationId].blip != null) {
|
||||
removeFromWorld(getJobData(jobId).locations[locationId].blip);
|
||||
destroyElement(getJobData(jobId).locations[locationId].blip);
|
||||
getJobData(jobId).locations[locationId].blip = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function deleteJobLocationPickup(jobId, locationId) {
|
||||
if(getJobData(jobId).locations[locationId].pickup != null) {
|
||||
removeFromWorld(getJobData(jobId).locations[locationId].pickup);
|
||||
destroyElement(getJobData(jobId).locations[locationId].pickup);
|
||||
getJobData(jobId).locations[locationId].pickup = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createJobLocationPickup(jobId, locationId) {
|
||||
if(getJobData(jobId).pickupModel != -1) {
|
||||
let pickupModelId = getGameConfig().pickupModels[getServerGame()].job;
|
||||
|
||||
if(getJobData(jobId).pickupModel != 0) {
|
||||
pickupModelId = getJobData(jobId).pickupModel;
|
||||
}
|
||||
|
||||
getJobData(jobId).locations[locationId].pickup = gta.createPickup(pickupModelId, getJobData(jobId).locations[locationId].position);
|
||||
getJobData(jobId).locations[locationId].pickup.onAllDimensions = false;
|
||||
getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension;
|
||||
getJobData(jobId).locations[locationId].pickup.setData("ag.owner.type", AG_PICKUP_JOB, false);
|
||||
getJobData(jobId).locations[locationId].pickup.setData("ag.owner.id", jobId, false);
|
||||
getJobData(jobId).locations[locationId].pickup.setData("ag.label.type", AG_LABEL_JOB, true);
|
||||
addToWorld(getJobData(jobId).locations[locationId].pickup);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createJobLocationBlip(jobId, locationId) {
|
||||
if(getJobData(jobId).blipModel != -1) {
|
||||
let blipModelId = getGameConfig().blipSprites[getServerGame()].job;
|
||||
|
||||
if(getJobData(jobId).blipModel != 0) {
|
||||
blipModelId = getJobData(jobId).blipModel;
|
||||
}
|
||||
|
||||
getJobData(jobId).locations[locationId].blip = gta.createBlip(getJobData(jobId).locations[locationId].position, blipModelId, getColourByType("job"));
|
||||
getJobData(jobId).locations[locationId].pickup.onAllDimensions = false;
|
||||
getJobData(jobId).locations[locationId].pickup.dimension = getJobData(jobId).locations[locationId].dimension;
|
||||
addToWorld(getJobData(jobId).locations[locationId].pickup);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -406,7 +406,9 @@ function showCurrentBusStop(client) {
|
||||
function arrivedAtBusStop(client) {
|
||||
if(isLastStopOnBusRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
|
||||
respawnVehicle(getPlayerData(client).jobRouteVehicle);
|
||||
messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! Your bus has been returned to the bus depot.`, getColourByName("yellow"));
|
||||
messagePlayerNormal(client, `You finished the ${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} bus route! You earned $${getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your bus has been returned to the bus depot.`, getColourByName("yellow"));
|
||||
getPlayerCurrentSubAccount(client).cash += getBusRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout;
|
||||
updatePlayerCash(client);
|
||||
getPlayerData(client).jobRouteVehicle = false;
|
||||
getPlayerData(client).jobRoute = 0;
|
||||
getPlayerData(client).jobRouteStop = 0;
|
||||
|
||||
@@ -116,7 +116,9 @@ function showCurrentGarbageStop(client) {
|
||||
function arrivedAtGarbageStop(client) {
|
||||
if(isLastStopOnGarbageRoute(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute, getPlayerData(client).jobRouteStop)) {
|
||||
respawnVehicle(getPlayerData(client).jobRouteVehicle);
|
||||
messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! Your trashmaster has been returned to the garbage depot.`, getColourByName("yellow"));
|
||||
messagePlayerNormal(client, `You finished the ${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).name} garbage route! You earned $${getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout} and your trashmaster has been returned to the garbage depot.`, getColourByName("yellow"));
|
||||
getPlayerCurrentSubAccount(client).cash += getGarbageRouteData(getPlayerData(client).jobRouteIsland, getPlayerData(client).jobRoute).payout;
|
||||
updatePlayerCash(client);
|
||||
getPlayerData(client).jobRouteVehicle = false;
|
||||
getPlayerData(client).jobRoute = 0;
|
||||
getPlayerData(client).jobRouteStop = 0;
|
||||
|
||||
@@ -136,9 +136,14 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
setPlayerInterior(client, inHouse.entranceInterior);
|
||||
setTimeout(function() {
|
||||
fadeCamera(client, true, 1.0);
|
||||
setTimeout(function() {
|
||||
enableCityAmbienceForPlayer(client);
|
||||
clearPlayerOwnedPeds(client);
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
}, 1100);
|
||||
removeEntityData(client, "ag.inHouse");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -159,9 +164,14 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
setPlayerInterior(client, inBusiness.entranceInterior);
|
||||
setTimeout(function() {
|
||||
fadeCamera(client, true, 1.0);
|
||||
setTimeout(function() {
|
||||
enableCityAmbienceForPlayer(client);
|
||||
clearPlayerOwnedPeds(client);
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
}, 1100);
|
||||
removeEntityData(client, "ag.inBusiness");
|
||||
console.log(`[Asshat.Misc] ${getPlayerDisplayForConsole(client)} entered business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -184,6 +194,7 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
meActionToNearbyPlayers(client, "opens the door and enters the business");
|
||||
|
||||
fadeCamera(client, false, 1.0);
|
||||
disableCityAmbienceForPlayer(client);
|
||||
setTimeout(function() {
|
||||
setPlayerPosition(client, closestBusiness.exitPosition);
|
||||
setPlayerHeading(client, closestBusiness.exitRotation);
|
||||
@@ -218,6 +229,7 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
|
||||
|
||||
fadeCamera(client, false, 1.0);
|
||||
disableCityAmbienceForPlayer(client);
|
||||
setTimeout(function() {
|
||||
setPlayerPosition(client, closestHouse.exitPosition);
|
||||
setPlayerHeading(client, closestHouse.exitRotation);
|
||||
@@ -228,7 +240,6 @@ function enterExitPropertyCommand(command, params, client) {
|
||||
}, 1000);
|
||||
}, 1100);
|
||||
setEntityData(client, "ag.inHouse", closestHouseId);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,3 +315,9 @@ function getCharacterFullName(client) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function isPlayerSwitchingCharacter(client) {
|
||||
return getPlayerData(client).switchingCharacter;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -37,6 +37,7 @@ function initTimers() {
|
||||
serverTimers.updateTimeRuleTimer = setInterval(updateTimeRule, 1000);
|
||||
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
|
||||
serverTimers.vehicleRentTimer = setInterval(vehicleRentCheck, 60000);
|
||||
serverTimers.garbageCollectorTimer = setInterval(collectAllGarbage, 60000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1668,6 +1668,27 @@ function updatePlayerCash(client) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setPlayerCash(client, amount) {
|
||||
getPlayerCurrentSubAccount(client).cash = amount;
|
||||
updatePlayerCash(client);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function givePlayerCash(client, amount) {
|
||||
getPlayerCurrentSubAccount(client).cash += amount;
|
||||
updatePlayerCash(client);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function takePlayerCash(client, amount) {
|
||||
getPlayerCurrentSubAccount(client).cash -= amount;
|
||||
updatePlayerCash(client);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function clearChatBox(client) {
|
||||
//gta.messages.clear();
|
||||
for(let i = 0; i <= 20; i++) {
|
||||
@@ -1834,6 +1855,12 @@ async function waitUntil(condition) {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function resetClientStuff(client) {
|
||||
console.log(`[Asshat.Utilities] Resetting client data for ${getPlayerDisplayForConsole(client)}`);
|
||||
|
||||
if(!getPlayerData(client)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isPlayerOnJobRoute(client)) {
|
||||
stopJobRoute(client);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
// TYPE: Shared (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
"use strict";
|
||||
setErrorMode(RESOURCEERRORMODE_STRICT);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function toInteger(val) {
|
||||
|
||||
Reference in New Issue
Block a user