Comment racing cmds (not finished)

This commit is contained in:
Vortrex
2022-04-26 10:21:54 -05:00
parent 0bbb9a8a80
commit 59a38e4fa3

View File

@@ -7,15 +7,8 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
let serverCommands = [];
// ===========================================================================
function initCommandScript() { function initCommandScript() {
logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ..."); logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ...");
serverCommands = loadCommands();
cacheAllCommandsAliases(serverCommands);
addAllCommandHandlers();
logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!"); logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!");
} }
@@ -396,16 +389,17 @@ function loadCommands() {
//new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"), //new CommandData("npcrespawn", respawnNPCCommand, "", getStaffFlagValue("ManageNPCs"), true, false, "Respawns the nearest NPC"),
], ],
race: [ race: [
new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"), // Unfinished!
new CommandData("delrace", deleteRaceCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes a race by name"), //new CommandData("addrace", createRaceCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race"),
new CommandData("addracecp", createRaceCheckPointCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race checkpoint"), //new CommandData("delrace", deleteRaceCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes a race by name"),
new CommandData("addracestart", createRaceStartPositionCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a starting position for a race"), //new CommandData("addracecp", createRaceCheckPointCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a race checkpoint"),
new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"), //new CommandData("addracestart", createRaceStartPositionCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Creates a starting position for a race"),
new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"), //new CommandData("delracestart", deleteRaceStartPositionCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest starting position for a race"),
new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"), //new CommandData("delracecp", deleteRaceCheckPointCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Deletes the closest race checkpoint"),
new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"), //new CommandData("racename", setRaceNameCommand, "<name>", getStaffFlagValue("ManageRaces"), true, false, "Sets a race's name"),
new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"), //new CommandData("startrace", startRaceCommand, "", getStaffFlagValue("None"), true, false, "Starts a race"),
new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"), //new CommandData("stoprace", stopRaceCommand, "", getStaffFlagValue("None"), true, false, "Stops racing (forfeits if in an active race)"),
//new CommandData("stopAllRacesCommand", stopAllRacesCommand, "", getStaffFlagValue("ManageRaces"), true, false, "Stops a race"),
], ],
radio: [ radio: [
new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"), new CommandData("radiostation", playStreamingRadioCommand, "<radio station id>", getStaffFlagValue("None"), true, false, "Plays a radio station in your vehicle, house, or business (depending on which one you're in)"),
@@ -494,7 +488,7 @@ function loadCommands() {
new CommandData("oldcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false), new CommandData("oldcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("lastcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false), new CommandData("lastcar", getLastVehicleInfoCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("unlock", vehicleLockCommand, "", getStaffFlagValue("None"), true, false), //new CommandData("unlock", vehicleLockCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("engine", vehicleEngineCommand, "", getStaffFlagValue("None"), true, false), new CommandData("engine", vehicleEngineCommand, "", getStaffFlagValue("None"), true, false),
new CommandData("siren", vehicleSirenCommand, "", getStaffFlagValue("None"), true, false), new CommandData("siren", vehicleSirenCommand, "", getStaffFlagValue("None"), true, false),
@@ -547,10 +541,11 @@ function loadCommands() {
function addAllCommandHandlers() { function addAllCommandHandlers() {
let commandCount = 0; let commandCount = 0;
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${serverCommands[i][j].command}`); for(let j in commands[i]) {
addCommandHandler(serverCommands[i][j].command, processPlayerCommand); logToConsole(LOG_DEBUG, `[VRR.Command] Adding command handler for ${i} - ${commands[i][j].command}`);
addCommandHandler(commands[i][j].command, processPlayerCommand);
commandCount++; commandCount++;
} }
} }
@@ -583,7 +578,7 @@ function getCommandData(command) {
// =========================================================================== // ===========================================================================
function getCommands() { function getCommands() {
return serverCommands; return getServerData().commands;
} }
// =========================================================================== // ===========================================================================
@@ -785,9 +780,10 @@ addCommandHandler("cmd", function(command, params, client) {
// =========================================================================== // ===========================================================================
function listAllCommands() { function listAllCommands() {
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
logToConsole(LOG_DEBUG, serverCommands[i][j].command); for(let j in commands[i]) {
logToConsole(LOG_DEBUG, commands[i][j].command);
} }
} }
} }
@@ -796,9 +792,10 @@ function listAllCommands() {
function getAllCommandsInSingleArray() { function getAllCommandsInSingleArray() {
let tempCommands = []; let tempCommands = [];
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
tempCommands.push(serverCommands[i][j].command); for(let j in commands[i]) {
tempCommands.push(commands[i][j].command);
} }
} }
@@ -809,9 +806,10 @@ function getAllCommandsInSingleArray() {
function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") { function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
let tempCommands = []; let tempCommands = [];
for(let i in serverCommands[groupName]) { let commands = getCommands();
if(getCommandRequiredPermissions(serverCommands[groupName][i].command) == 0) { for(let i in commands[groupName]) {
tempCommands.push(serverCommands[groupName][i].command); if(getCommandRequiredPermissions(commands[groupName][i].command) == 0) {
tempCommands.push(commands[groupName][i].command);
} }
} }
@@ -822,11 +820,12 @@ function getAllCommandsInGroupInSingleArray(groupName, staffFlag = "None") {
function getAllCommandsForStaffFlagInSingleArray(staffFlagName) { function getAllCommandsForStaffFlagInSingleArray(staffFlagName) {
let tempCommands = []; let tempCommands = [];
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
if(getCommandRequiredPermissions(serverCommands[i][j].command) != 0) { for(let j in commands[i]) {
if(hasBitFlag(getCommandRequiredPermissions(serverCommands[i][j].command), getStaffFlagValue(staffFlagName))) { if(getCommandRequiredPermissions(commands[i][j].command) != 0) {
tempCommands.push(serverCommands[i][j].command); if(hasBitFlag(getCommandRequiredPermissions(commands[i][j].command), getStaffFlagValue(staffFlagName))) {
tempCommands.push(commands[i][j].command);
} }
} }
} }
@@ -848,13 +847,14 @@ function doesCommandExist(command) {
// =========================================================================== // ===========================================================================
function cacheAllCommandsAliases() { function cacheAllCommandsAliases() {
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
for(let k in serverCommands) { for(let j in commands[i]) {
for(let m in serverCommands[k]) { for(let k in commands) {
if(serverCommands[i][j].handlerFunction == serverCommands[k][m].handlerFunction) { for(let m in commands[k]) {
serverCommands[i][j].aliases.push(serverCommands[k][m]); if(commands[i][j].handlerFunction == commands[k][m].handlerFunction) {
serverCommands[k][m].aliases.push(serverCommands[i][j]); commands[i][j].aliases.push(commands[k][m]);
commands[k][m].aliases.push(commands[i][j]);
} }
} }
} }
@@ -904,10 +904,11 @@ function getParam(params, delimiter, index) {
// =========================================================================== // ===========================================================================
function getCommandFromParams(params) { function getCommandFromParams(params) {
for(let i in serverCommands) { let commands = getCommands();
for(let j in serverCommands[i]) { for(let i in commands) {
if(toLowerCase(serverCommands[i][j].command).indexOf(toLowerCase(params)) != -1) { for(let j in commands[i]) {
return serverCommands[i][j]; if(toLowerCase(commands[i][j].command).indexOf(toLowerCase(params)) != -1) {
return commands[i][j];
} }
} }
} }