diff --git a/scripts/server/class.js b/scripts/server/class.js index a5efabc3..026074ef 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -1018,7 +1018,7 @@ class VehicleData { }; /** - * @class Representing a command's data. Loaded and saved in the database + * @class Representing a command's data. */ class CommandData { enable() { @@ -1033,7 +1033,7 @@ class CommandData { this.enabled = !this.enabled; } - constructor(command, handlerFunction, syntaxString, requiredStaffFlags, requireLogin, allowOnDiscord, helpDescription) { + constructor(command, handlerFunction, syntaxString = "", requiredStaffFlags = 0, requireLogin = true, allowOnDiscord = false, helpDescription = "") { this.command = command; this.handlerFunction = handlerFunction; this.syntaxString = syntaxString; @@ -1486,6 +1486,10 @@ class NPCData { this.armour = 100; this.currentAction = VRR_NPCACTION_NONE; this.triggers = []; + this.typeFlags = 0; + this.heedThreats = false; + this.threats = 0; + this.invincible = false; this.bodyParts = { hair: [0,0], @@ -1529,6 +1533,10 @@ class NPCData { this.fightStyle = toInteger(dbAssoc["npc_fightstyle"]); this.health = toInteger(dbAssoc["npc_health"]); this.armour = toInteger(dbAssoc["npc_armour"]); + this.typeFlags = toInteger(dbAssoc["npc_type_flags"]); + this.heedThreats = intToBool(dbAssoc["npc_headthreats"]); + this.threats = toInteger(dbAssoc["npc_threats"]); + this.invincible = intToBool(dbAssoc["npc_invincible"]); this.bodyParts = { hair: [toInteger(dbAssoc["npc_hd_part_hair_model"]) || 0, toInteger(dbAssoc["npc_hd_part_hair_texture"]) || 0], diff --git a/scripts/server/command.js b/scripts/server/command.js index eecd5a96..aa982f0a 100644 --- a/scripts/server/command.js +++ b/scripts/server/command.js @@ -11,25 +11,11 @@ let serverCommands = []; // =========================================================================== -let builtInCommands = [ - "refresh", - "restart", - "stop", - "start", - "reconnect", - "setname", - "connect", - "disconnect", - "say", - "dumpdoc", -]; - -// =========================================================================== - function initCommandScript() { logToConsole(LOG_INFO, "[VRR.Command]: Initializing commands script ..."); serverCommands = loadCommands(); - //addAllCommandHandlers(); + cacheAllCommandsAliases(serverCommands); + addAllCommandHandlers(); logToConsole(LOG_INFO, "[VRR.Command]: Initialized commands script!"); } @@ -38,499 +24,507 @@ function initCommandScript() { function loadCommands() { let tempCommands = { accent: [ - commandData("accent", setAccentCommand, "", getStaffFlagValue("None"), false, false, "Sets your character's accent"), - commandData("accents", listAccentsCommand, "", getStaffFlagValue("None"), false, false, "Shows a list of all available accents"), - commandData("accentlist", listAccentsCommand, "", getStaffFlagValue("None"), false, false, "Shows a list of all available accents"), + new CommandData("accent", setAccentCommand, "", getStaffFlagValue("None"), false, false, "Sets your character's accent"), + new CommandData("accents", listAccentsCommand, "", getStaffFlagValue("None"), false, false, "Shows a list of all available accents"), + new CommandData("accentlist", listAccentsCommand, "", getStaffFlagValue("None"), false, false, "Shows a list of all available accents"), ], account: [ - commandData("login", loginCommand, "", getStaffFlagValue("None"), false, false, "Login to an account"), - commandData("register", registerCommand, "", getStaffFlagValue("None"), false, false, "Creates an account"), - commandData("changepass", changeAccountPasswordCommand, " ", getStaffFlagValue("None"), true, false, "Change an account password"), - commandData("iplogin", toggleAutoLoginByIPCommand, "", getStaffFlagValue("None"), true, false, "Toggle whether to automatically login if you join with the same IP as your last join"), - commandData("autolastchar", toggleAutoSelectLastCharacterCommand, "", getStaffFlagValue("None"), true, false, "Toggle whether to automatically spawn with the last character you played as"), - commandData("gui", toggleAccountGUICommand, "", getStaffFlagValue("None"), false, false, "Toggle whether to use GUI. If GUI is disabled on the server, it won't show even if you have GUI enabled."), - commandData("2fa", toggleAccountTwoFactorAuthCommand, "", getStaffFlagValue("None"), true, false, "Set up and use two-factor authentication."), - commandData("setemail", setAccountEmailCommand, "", getStaffFlagValue("None"), true, false, "Sets your email. To reset your password, you must have a valid email set and verified."), - commandData("verifyemail", verifyAccountEmailCommand, "", getStaffFlagValue("None"), true, false, "Confirms/verifies your email."), - //commandData("setdiscord", setAccountDiscordCommand, "", getStaffFlagValue("None"), true, false, "Set up the integration for discord. Allows you to see info and use in-game commands on discord."), - commandData("notips", toggleNoRandomTipsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off random tips"), - commandData("loginalert", toggleAccountLoginAttemptNotificationsCommand, "", getStaffFlagValue("None"), true, false, "Turn on and off email notifications for attempts to login to your account"), - commandData("scrolllines", setAccountChatScrollLinesCommand, "", getStaffFlagValue("None"), true, false, "Sets how many chatbox lines to scroll at a time when using pageup/pagedown"), - commandData("chatautohide", setAccountChatAutoHideDelayCommand, "