Huge command system overhaul

This commit is contained in:
Vortrex
2020-12-13 14:44:14 -06:00
parent f97775760b
commit 2ef292d799
19 changed files with 145 additions and 1587 deletions

View File

@@ -10,43 +10,12 @@
function initAccountScript() {
console.log("[Asshat.Account]: Initializing account script ...");
addAccountCommandHandlers();
console.log("[Asshat.Account]: Account script initialized!");
}
// ---------------------------------------------------------------------------
function addAccountCommandHandlers() {
console.log("[Asshat.Account]: Adding account command handlers ...");
let accountCommands = serverCommands.account;
for(let i in accountCommands) {
addCommandHandler(accountCommands[i].command, accountCommands[i].handlerFunction);
}
console.log("[Asshat.Account]: Account command handlers added!");
}
// ---------------------------------------------------------------------------
function loginCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isClientRegistered(client)) {
messageClientError(client, "Your name is not registered! Use /register to make an account.");
return false;
@@ -64,25 +33,6 @@ function loginCommand(command, params, client) {
// ---------------------------------------------------------------------------
function autoLoginByIPCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let flagValue = getAccountSettingsFlagValue("autoLoginIP");
if(getClientData(client).accountData.settings & flagValue) {
@@ -98,25 +48,6 @@ function autoLoginByIPCommand(command, params, client) {
// ---------------------------------------------------------------------------
function registerCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(isClientRegistered(client)) {
messageClientError(client, "Your name is already registered!");
return false;
@@ -136,25 +67,6 @@ function registerCommand(command, params, client) {
// ---------------------------------------------------------------------------
function changePasswordCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -181,104 +93,6 @@ function changePasswordCommand(command, params, client) {
// ---------------------------------------------------------------------------
function switchCharacterCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
getClientCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getClientCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
saveSubAccountToDatabase(getClientCurrentSubAccount(client));
client.despawnPlayer();
showConnectCameraToPlayer(client);
showCharacterSelectToClient(client);
}
// ---------------------------------------------------------------------------
function newCharacterCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let firstName = splitParams[0];
let lastName = splitParams[1];
checkNewCharacter(client, firstName, lastName, "01/01/1901", "Liberty City", getServerConfig().newCharacter.skin);
}
// ---------------------------------------------------------------------------
function useCharacterCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let characterId = toInteger(params) || 1;
selectCharacter(client, characterId-1);
}
// ---------------------------------------------------------------------------
function isClientLoggedIn(client) {
if(client.console) {
return true;

View File

@@ -20,23 +20,11 @@ const banType = {
function initBanScript() {
console.log("[Asshat.Ban]: Initializing ban script ...");
addBanCommandHandlers();
console.log("[Asshat.Ban]: Ban script initialized!");
}
// ---------------------------------------------------------------------------
function addBanCommandHandlers() {
console.log("[Asshat.Ban]: Adding ban command handlers ...");
let banCommands = getServerData().commands.ban;
for(let i in banCommands) {
addCommandHandler(banCommands[i].command, banCommands[i].handlerFunction);
}
console.log("[Asshat.Ban]: Bans command handlers added! ...");
}
// ---------------------------------------------------------------------------
function accountBanCommand(command, params, client, fromDiscord) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {

View File

@@ -12,25 +12,12 @@ function initBusinessScript() {
console.log("[Asshat.Business]: Initializing business script ...");
getServerData().businesses = loadBusinessesFromDatabase();
createAllBusinessPickups();
addBusinessCommandHandlers();
console.log("[Asshat.Business]: Business script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addBusinessCommandHandlers() {
console.log("[Asshat.Business]: Adding business commands!");
let businessCommands = serverCommands.business;
for(let i in businessCommands) {
addCommandHandler(businessCommands[i].command, businessCommands[i].handlerFunction);
}
console.log("[Asshat.Business]: Business commands added!");
return true;
}
// ---------------------------------------------------------------------------
function loadBusinessesFromDatabase() {
console.log("[Asshat.Business]: Loading businesses from database ...");
@@ -91,25 +78,6 @@ function loadBusinessLocationsFromDatabase(businessId) {
// ---------------------------------------------------------------------------
function createBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -127,25 +95,6 @@ function createBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function createBusinessLocationCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -186,25 +135,6 @@ function createBusiness(name, entrancePosition, interiorId, virtualWorld) {
// ---------------------------------------------------------------------------
function deleteBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -218,28 +148,6 @@ function deleteBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function deleteBusinessLocationCommand(command, params, client) {
messageClientError(client, "This command is under construction!");
return false;
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -253,25 +161,6 @@ function deleteBusinessLocationCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setBusinessNameCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -289,25 +178,6 @@ function setBusinessNameCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setBusinessOwnerCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -340,25 +210,6 @@ function setBusinessOwnerCommand(command, params, client) {
// ---------------------------------------------------------------------------
function lockBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -380,25 +231,6 @@ function lockBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setBusinessEntranceFeeCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -416,25 +248,6 @@ function setBusinessEntranceFeeCommand(command, params, client) {
// ---------------------------------------------------------------------------
function withdrawFromBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -461,25 +274,6 @@ function withdrawFromBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function depositIntoBusinessCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -504,25 +298,6 @@ function depositIntoBusinessCommand(command, params, client) {
// ---------------------------------------------------------------------------
function viewBusinessTillAmountCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
//if(areParamsEmpty(params)) {
// messageClientSyntax(client, getCommandSyntaxText(command));
// return false;

View File

@@ -10,25 +10,12 @@
function initChatScript() {
console.log("[Asshat.Chat]: Initializing chat script ...");
addChatCommandHandlers();
console.log("[Asshat.Chat]: Chat script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addChatCommandHandlers() {
console.log("[Asshat.Chat]: Adding chat command handlers ...");
let chatCommands = serverCommands.chat;
for(let i in chatCommands) {
addCommandHandler(chatCommands[i].command, chatCommands[i].handlerFunction);
}
console.log("[Asshat.Chat]: Chat command handlers added successfully!");
return true;
}
// ---------------------------------------------------------------------------
function meActionCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {

View File

@@ -11,25 +11,12 @@
function initClanScript() {
console.log("[Asshat.Clan]: Initializing clans script ...");
getServerData().clans = loadClansFromDatabase();
addClanCommandHandlers();
console.log("[Asshat.Clan]: Clan script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addClanCommandHandlers() {
console.log("[Asshat.Clan]: Adding clan command handlers ...");
let clanCommands = serverCommands.clan;
for(let i in clanCommands) {
addCommandHandler(clanCommands[i].command, clanCommands[i].handlerFunction);
}
console.log("[Asshat.Clan]: Clan command handlers added successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadClansFromDatabase() {
console.log("[Asshat.Clan]: Loading clans from database ...");
@@ -61,25 +48,6 @@ function loadClansFromDatabase() {
// ----------------------------------------------------------------------------
function createClanCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -98,25 +66,6 @@ function createClanCommand(command, params, client) {
// ----------------------------------------------------------------------------
function deleteClanCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
@@ -139,25 +88,6 @@ function deleteClanCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanOwnerCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "owner")) {
messageClientError(client, "You must be the clan owner to use this command!");
return false;
@@ -172,25 +102,6 @@ function setClanOwnerCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanTagCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "clanTag")) {
messageClientError(client, "You can not change the clan tag!");
return false;
@@ -205,25 +116,6 @@ function setClanTagCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanNameCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "clanName")) {
messageClientError(client, "You can not change the clan name!");
return false;
@@ -238,25 +130,6 @@ function setClanNameCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanMemberTagCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "memberTag")) {
messageClientError(client, "You can not change a clan member's tag!");
return false;
@@ -271,25 +144,6 @@ function setClanMemberTagCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanRankTagCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "rankTag")) {
messageClientError(client, "You can not change a clan ranks's tag!");
return false;
@@ -304,25 +158,6 @@ function setClanRankTagCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanMemberFlagsCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "memberFlags")) {
messageClientError(client, "You can not change a clan member's permissions!");
return false;
@@ -337,25 +172,6 @@ function setClanMemberFlagsCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanRankFlagsCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "rankFlags")) {
messageClientError(client, "You can not change a clan ranks's permissions!");
return false;
@@ -370,25 +186,6 @@ function setClanRankFlagsCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanMemberTitleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "memberFlags")) {
messageClientError(client, "You can not change a clan member's title!");
return false;
@@ -403,25 +200,6 @@ function setClanMemberTitleCommand(command, params, client) {
// ----------------------------------------------------------------------------
function setClanRankTitleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!doesClientHaveClanPermission(client, "rankTitle")) {
messageClientError(client, "You can not change a clan ranks's title!");
return false;

View File

@@ -15,24 +15,11 @@ let serverCommands = {};
function initCommandScript() {
console.log("[Asshat.Command]: Initializing commands script ...");
serverCommands = loadCommandData();
addCommandCommandHandlers();
console.log("[Asshat.Command]: Initialized commands script!");
}
// ---------------------------------------------------------------------------
function addCommandCommandHandlers() {
console.log("[Asshat.Clan]: Adding command command handlers ...");
let commandCommands = serverCommands.command;
for(let i in commandCommands) {
addCommandHandler(commandCommands[i].command, commandCommands[i].handlerFunction);
}
console.log("[Asshat.Command]: Command command handlers added successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadCommandData() {
let tempCommands = {
account: [
@@ -205,11 +192,14 @@ function getCommand(command) {
let commandGroups = getCommands()
for(let i in commandGroups) {
let commandGroup = commandGroups[i];
for(let j in commandGroup)
if(toLowerCase(commandGroup[j].command) == toLowerCase(command)) {
return commandGroup[j];
for(let j in commandGroup) {
if(toLowerCase(commandGroup[j].command) == toLowerCase(command)) {
return commandGroup[j];
}
}
}
return false;
}
// ---------------------------------------------------------------------------
@@ -251,128 +241,130 @@ function isCommandAllowedOnDiscord(command) {
// ---------------------------------------------------------------------------
function disableCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
}
params = toLowerCase(params);
removeCommandHandler(params);
messageClientSuccess(client, `[#FF9900]All server data saved to database!`);
if(!getCommand(params)) {
messageClientError(client, `The command [#CCCCCC]/${params} [#FFFFFF] does not exist!`);
return false;
}
getCommand(params).enabled = false;
messageClientSuccess(client, `Command [#CCCCCC]/${params} [#FFFFFF]has been disabled!`);
return true;
}
// ---------------------------------------------------------------------------
function enableCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
}
params = toLowerCase(params);
addCommandHandler(params, getCommand(params).handlerFunction);
messageClientSuccess(client, `[#FF9900]All server data saved to database!`);
if(!getCommand(params)) {
messageClientError(client, `The command [#CCCCCC]/${params} [#FFFFFF] does not exist!`);
return false;
}
getCommand(params).enabled = true;
messageClientSuccess(client, `Command [#CCCCCC]/${params} [#FFFFFF]has been enabled!`);
return true;
}
// ---------------------------------------------------------------------------
function disableAllCommandsByType(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
params = toLowerCase(params);
if(isNull(getServerData().commands[params])) {
messageClientError(client, "That command type does not exist!");
messageClientError(client, `Command type [#CCCCCC]${params} [#FFFFFF]does not exist!`);
return false;
}
for(let i in getServerData().commands[params]) {
removeCommandHandler(getServerData().commands[params][i].command);
getServerData().commands[params][i].enabled = false;
}
messageClientSuccess(client, `[#FF9900]All ${params} commands have been disabled!`);
messageClientSuccess(client, `[#FF9900]All [#CCCCCC]${params} [#FFFFFF]commands have been disabled!`);
return true;
}
// ---------------------------------------------------------------------------
function enableAllCommandsByType(command, params, client) {
if(getCommand(command).requireLogin) {
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
params = toLowerCase(params);
if(isNull(getServerData().commands[params])) {
messageClientError(client, `Command type [#CCCCCC]${params} [#FFFFFF]does not exist!`);
return false;
}
for(let i in getServerData().commands[params]) {
getServerData().commands[params][i].enabled = true;
}
messageClientSuccess(client, `[#FF9900]All [#CCCCCC]${params} [#FFFFFF]commands have been enabled!`);
return true;
}
// ---------------------------------------------------------------------------
addEventHandler("OnPlayerCommand", function(event, client, command, params) {
let commandData = getCommand(command);
if(!commandData) {
messageClientError(client, `The command [#CCCCCC]/${command} [#FFFFFF]does not exist! Use /help for commands and information.`);
return false;
}
if(!commandData.enabled) {
messageClientError(client, `The command [#CCCCCC]/${command} [#FFFFFF]is disabled!`);
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
messageClientError(client, `You must be logged in to use the [#CCCCCC]/${command} [#FFFFFF]command!`);
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
messageClientError(client, `The [#CCCCCC]/${command} [#FFFFFF] command isn't available on discord!`);
return false;
}
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
messageClientError(client, `You do not have permission to use the [#CCCCCC]/${command} [#FFFFFF]command!`);
return false;
}
params = toLowerCase(params);
let paramsDisplay = params;
if(areParamsEmpty(params)) {
paramsDisplay = ""
}
if(isNull(getServerData().commands[params])) {
messageClientError(client, "That command type does not exist!");
return false;
}
console.log(`[Asshat.Command] ${getClientDisplayForConsole(client)} used command: /${command} ${paramsDisplay}`);
commandData.handlerFunction(command, params, client);
});
for(let i in getServerData().commands[params]) {
let command = getServerData().commands[params][i].command;
addCommandHandler(command, getServerData().commands[params][i].handlerFunction);
}
messageClientSuccess(client, `[#FF9900]All ${params} commands have been enabled!`);
return true;
}
// ---------------------------------------------------------------------------

View File

@@ -158,23 +158,11 @@ let serverConfig = {
function initConfigScript() {
console.log("[Asshat.Config]: Initializing config script ...");
addConfigCommandHandlers();
console.log("[Asshat.Config]: Config script initialized!");
}
// ---------------------------------------------------------------------------
function addConfigCommandHandlers() {
console.log("[Asshat.Config]: Adding config command handlers ...");
let configCommands = serverCommands.config;
for(let i in configCommands) {
addCommandHandler(configCommands[i].command, configCommands[i].handlerFunction);
}
console.log("[Asshat.Config]: Config command handlers added!");
}
// ---------------------------------------------------------------------------
function loadServerConfig() {
let dbConnection = connectToDatabase();
if(dbConnection) {

View File

@@ -25,23 +25,11 @@ let persistentDatabaseConnection = null;
function initDatabaseScript() {
console.log("[Asshat.Database]: Initializing database script ...");
addDatabaseCommandHandlers()
console.log("[Asshat.Database]: Database script initialized successfully!");
}
// ----------------------------------------------------------------------------
function addDatabaseCommandHandlers() {
console.log("[Asshat.Database]: Adding database command handlers ...");
let databaseCommands = serverCommands.database;
for(let i in databaseCommands) {
addCommandHandler(databaseCommands[i].command, databaseCommands[i].handlerFunction);
}
console.log("[Asshat.Database]: Database command handlers added!");
}
// ----------------------------------------------------------------------------
function connectToDatabase() {
if(persistentDatabaseConnection == null) {
console.log("[Asshat.Database] Initializing database connection ...");
@@ -78,6 +66,9 @@ function queryDatabase(dbConnection, queryString) {
// ----------------------------------------------------------------------------
function escapeDatabaseString(dbConnection, unsafeString) {
if(!dbConnection) {
dbConnection = connectToDatabase();
}
return dbConnection.escapeString(unsafeString);
}
@@ -106,4 +97,17 @@ function fetchQueryAssoc(dbQuery) {
return dbQuery.fetchAssoc();
}
// ----------------------------------------------------------------------------
function quickDatabaseQuery(queryString) {
let dbConnection = connectToDatabase();
if(dbConnection) {
let dbQuery = queryDatabase(dbConnection, queryString);
if(dbQuery) {
dbQuery.free();
}
disconnectFromDatabase();
}
}
// ----------------------------------------------------------------------------

View File

@@ -10,25 +10,12 @@
function initDeveloperScript() {
console.log("[Asshat.Developer]: Initializing developer script ...");
addDeveloperCommandHandlers()
console.log("[Asshat.Developer]: Developer script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addDeveloperCommandHandlers() {
console.log("[Asshat.Developer]: Adding developer command handlers ...");
let developerCommands = serverCommands.developer;
for(let i in developerCommands) {
addCommandHandler(developerCommands[i].command, developerCommands[i].handlerFunction);
}
console.log("[Asshat.Developer]: Developer command handlers added!");
return true;
}
// ---------------------------------------------------------------------------
function executeServerCodeCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
@@ -105,24 +92,7 @@ function executeClientCodeCommand(command, params, client) {
// ---------------------------------------------------------------------------
function saveAllServerDataCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
messageClientInfo(client, `[#FF9900]Saving all server data to database ...`);
saveAllServerDataToDatabase();
@@ -133,24 +103,7 @@ function saveAllServerDataCommand(command, params, client) {
// ---------------------------------------------------------------------------
function restartGameModeCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
consoleCommand("refresh");
thisResource.restart();

View File

@@ -12,25 +12,12 @@
function initFactionScript() {
console.log("[Asshat.Faction]: Initializing faction script ...");
addFactionCommandHandlers();
console.log("[Asshat.Faction]: Faction script initialized!");
return true;
}
// ---------------------------------------------------------------------------
function addFactionCommandHandlers() {
console.log("[Asshat.Faction]: Adding faction command handlers ...");
let factionCommands = serverCommands.faction;
for(let i in factionCommands) {
addCommandHandler(factionCommands[i].command, factionCommands[i].handlerFunction);
}
console.log("[Asshat.Faction]: Faction command handlers added!");
return true;
}
// ---------------------------------------------------------------------------
function loadFactionsFromDatabase() {
console.log("[Asshat.Faction]: Loading factions from database ...");

View File

@@ -9,24 +9,7 @@
// ===========================================================================
function helpCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(areParamsEmpty(params)) {
showMainHelpMessage(client);

View File

@@ -12,25 +12,12 @@ function initHouseScript() {
console.log("[Asshat.House]: Initializing house script ...");
getServerData().houses = loadHousesFromDatabase();
createAllHousePickups();
addHouseCommandHandlers();
console.log("[Asshat.House]: House script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addHouseCommandHandlers() {
console.log("[Asshat.House]: Adding house commands!");
let houseCommands = serverCommands.house;
for(let i in houseCommands) {
addCommandHandler(houseCommands[i].command, houseCommands[i].handlerFunction);
}
console.log("[Asshat.House]: House commands added!");
return true;
}
// ---------------------------------------------------------------------------
function loadHousesFromDatabase() {
console.log("[Asshat.House]: Loading houses from database ...");
let tempHouses = [];

View File

@@ -14,12 +14,6 @@ function initItemScript() {
// ---------------------------------------------------------------------------
function addItemCommandHandlers() {
return true;
}
// ---------------------------------------------------------------------------
function loadItemsFromDatabase() {
let tempItems = [];
let dbConnection = connectToDatabase();

View File

@@ -12,7 +12,6 @@ function initJobScript() {
console.log("[Asshat.Job]: Initializing job script ...");
getServerData().jobs = loadJobsFromDatabase();
addJobCommandHandlers();
createAllJobPickups();
createAllJobBlips();
@@ -24,18 +23,6 @@ function initJobScript() {
// ---------------------------------------------------------------------------
function addJobCommandHandlers() {
console.log("[Asshat.Job]: Adding job command handlers ...");
let jobCommands = serverCommands.job;
for(let i in jobCommands) {
addCommandHandler(jobCommands[i].command, jobCommands[i].handlerFunction);
}
console.log("[Asshat.Job]: Job command handlers added successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadJobsFromDatabase() {
console.log("[Asshat.Job]: Loading jobs from database ...");
@@ -382,24 +369,6 @@ function startWorkingCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let closestJobLocation = getClosestJobLocation(client.player.position);
let jobData = getJobData(closestJobLocation.job);
@@ -435,24 +404,6 @@ function stopWorkingCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let closestJobLocation = getClosestJobLocation(client.player.position);
@@ -608,24 +559,6 @@ function stopWorking(client) {
// ---------------------------------------------------------------------------
function jobUniformCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let jobId = getClientCurrentSubAccount(client).job;
let uniforms = getJobData(jobId).uniforms;
@@ -659,24 +592,6 @@ function jobUniformCommand(command, params, client) {
// ---------------------------------------------------------------------------
function jobEquipmentCommand(command, params, client) {
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let jobId = getClientCurrentSubAccount(client).job;
let equipments = getJobData(jobId).equipment;
@@ -713,25 +628,7 @@ function quitJobCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
quitJob(client);
messageClientSuccess(client, "You are now unemployed!");
return true;
@@ -744,24 +641,7 @@ function jobRadioCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -773,24 +653,6 @@ function jobDepartmentRadioCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -828,24 +690,7 @@ function takeJob(client, jobId) {
// ---------------------------------------------------------------------------
function reloadAllJobsCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
for(let i in getServerData().jobs) {
for(let j in getServerData().jobs[i].locations) {

View File

@@ -13,24 +13,6 @@ function policeTazerCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -42,24 +24,6 @@ function policeCuffCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -71,24 +35,6 @@ function policeArrestCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -100,24 +46,6 @@ function policeSearchCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -129,24 +57,6 @@ function policeDragCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}
@@ -158,24 +68,6 @@ function policeDetainCommand(command, params, client) {
return false;
}
if(doesCommandRequireLogin(command)) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You are not logged in!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
return true;
}

View File

@@ -10,27 +10,14 @@
// ---------------------------------------------------------------------------
function initBusinessScript() {
function initMiscScript() {
console.log("[Asshat.Misc]: Initializing misc script ...");
addMiscCommandHandlers();
console.log("[Asshat.Misc]: Misc script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addMiscCommandHandlers() {
console.log("[Asshat.Misc]: Adding misc commands!");
let businessCommands = serverCommands.misc;
for(let i in businessCommands) {
addCommandHandler(businessCommands[i].command, businessCommands[i].handlerFunction);
}
console.log("[Asshat.Misc]: Misc commands added!");
return true;
}
// ---------------------------------------------------------------------------
function getPositionCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {

View File

@@ -9,16 +9,6 @@
// ===========================================================================
function initModerationScript() {
addModerationCommandHandlers();
}
// ---------------------------------------------------------------------------
function addModerationCommandHandlers() {
let moderationCommands = serverCommands.moderation;
for(let i in moderationCommands) {
addCommandHandler(moderationCommands[i].command, moderationCommands[i].handlerFunction);
}
}
// ---------------------------------------------------------------------------

View File

@@ -10,23 +10,11 @@
function initSubAccountScript() {
console.log("[Asshat.SubAccount]: Initializing account script ...");
addSubAccountCommandHandlers();
console.log("[Asshat.SubAccount]: Account script initialized!");
}
// ---------------------------------------------------------------------------
function addSubAccountCommandHandlers() {
console.log("[Asshat.SubAccount]: Adding sub account command handlers ...");
let subAccountCommands = serverCommands.subAccount;
for(let i in subAccountCommands) {
addCommandHandler(subAccountCommands[i].command, subAccountCommands[i].handlerFunction);
}
console.log("[Asshat.SubAccount]: Sub Account command handlers added!");
}
// ---------------------------------------------------------------------------
function loadSubAccountFromName(firstName, lastName) {
let dbConnection = connectToDatabase();
if(dbConnection) {
@@ -239,10 +227,48 @@ function selectCharacter(client, characterId = -1) {
setEntityData(client, "ag.spawned", true, true);
setEntityData(client, "ag.position", tempSubAccount.spawnPosition, true);
setEntityData(client, "ag.heading", tempSubAccount.spawnHeading, true);
if(isGTAIV()) {
triggerNetworkEvent("ag.iv.syncPosition", client, true);
spawnAllVehicles();
}
}
addNetworkHandler("ag.selectCharacter", selectCharacter);
addNetworkHandler("ag.selectCharacter", selectCharacter);
// ---------------------------------------------------------------------------
function switchCharacterCommand(command, params, client) {
getClientCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getClientCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
saveSubAccountToDatabase(getClientCurrentSubAccount(client));
client.despawnPlayer();
showConnectCameraToPlayer(client);
showCharacterSelectToClient(client);
}
// ---------------------------------------------------------------------------
function newCharacterCommand(command, params, client) {
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let splitParams = params.split(" ");
let firstName = splitParams[0];
let lastName = splitParams[1];
checkNewCharacter(client, firstName, lastName, "01/01/1901", "Liberty City", getServerConfig().newCharacter.skin);
}
// ---------------------------------------------------------------------------
function useCharacterCommand(command, params, client) {
if(areParamsEmpty(params)) {
messageClientSyntax(client, getCommandSyntaxText(command));
return false;
}
let characterId = toInteger(params) || 1;
selectCharacter(client, characterId-1);
}
// ---------------------------------------------------------------------------

View File

@@ -13,25 +13,12 @@ function initVehicleScript() {
console.log("[Asshat.Vehicle]: Initializing vehicle script ...");
getServerData().vehicles = loadVehiclesFromDatabase();
spawnAllVehicles();
addVehicleCommandHandlers();
console.log("[Asshat.Vehicle]: Vehicle script initialized successfully!");
return true;
}
// ---------------------------------------------------------------------------
function addVehicleCommandHandlers() {
console.log("[Asshat.Vehicle]: Adding vehicle command handlers ...");
let vehicleCommands = serverCommands.vehicle;
for(let i in vehicleCommands) {
addCommandHandler(vehicleCommands[i].command, vehicleCommands[i].handlerFunction);
}
console.log("[Asshat.Vehicle]: Vehicle command handlers added successfully!");
return true;
}
// ---------------------------------------------------------------------------
function loadVehiclesFromDatabase() {
console.log("[Asshat.Vehicle]: Loading vehicles from database ...");
let dbConnection = connectToDatabase();
@@ -137,25 +124,6 @@ function getVehicleData(vehicle) {
// ---------------------------------------------------------------------------
function createVehicleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let modelId = getVehicleModelIdFromParams(params);
if(!modelId) {
@@ -188,25 +156,6 @@ function createVehicleCommand(command, params, client) {
// ---------------------------------------------------------------------------
function createTemporaryVehicleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let modelId = getVehicleModelIdFromParams(params);
if(!modelId) {
@@ -232,25 +181,6 @@ function createTemporaryVehicleCommand(command, params, client) {
// ---------------------------------------------------------------------------
function vehicleLockCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
let vehicleData = getClosestVehicle(getPlayerPosition(client));
if(!getPlayerVehicle(client) && getVehiclePosition(vehicleData).distance(getPlayerPosition(client)) > getServerConfig().vehicleLockDistance) {
messageClientError(client, "You need to be in or near a vehicle!");
@@ -286,25 +216,6 @@ function vehicleLockCommand(command, params, client) {
// ---------------------------------------------------------------------------
function vehicleLightsCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!getPlayerVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -327,25 +238,6 @@ function vehicleLightsCommand(command, params, client) {
// ---------------------------------------------------------------------------
function vehicleEngineCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!getPlayerVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -373,25 +265,6 @@ function vehicleEngineCommand(command, params, client) {
// ---------------------------------------------------------------------------
function vehicleSirenCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!getPlayerVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -418,25 +291,6 @@ function vehicleSirenCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setVehicleColourCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!getPlayerVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -472,25 +326,6 @@ function setVehicleColourCommand(command, params, client) {
// ---------------------------------------------------------------------------
function vehicleRepairCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -520,25 +355,6 @@ function vehicleRepairCommand(command, params, client) {
// ---------------------------------------------------------------------------
function buyVehicleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -565,25 +381,6 @@ function buyVehicleCommand(command, params, client) {
// ---------------------------------------------------------------------------
function rentVehicleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -607,25 +404,6 @@ function rentVehicleCommand(command, params, client) {
// ---------------------------------------------------------------------------
function stopRentingVehicleCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
//getClientCurrentSubAccount(client).cash -= getVehicleData(vehicle).rentPrice;
let vehicle = getClientCurrentSubAccount(client).rentingVehicle;
stopRentingVehicle(client);
@@ -712,25 +490,6 @@ function getVehicleName(modelId) {
// ---------------------------------------------------------------------------
function setVehicleJobCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -760,25 +519,6 @@ function setVehicleJobCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setVehicleClanCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -801,25 +541,6 @@ function setVehicleClanCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setVehicleOwnerCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -842,25 +563,6 @@ function setVehicleOwnerCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setVehicleRentPriceCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -884,25 +586,6 @@ function setVehicleRentPriceCommand(command, params, client) {
// ---------------------------------------------------------------------------
function setVehicleBuyPriceCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -926,25 +609,6 @@ function setVehicleBuyPriceCommand(command, params, client) {
// ---------------------------------------------------------------------------
function removeVehicleOwnerCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -968,25 +632,6 @@ function removeVehicleOwnerCommand(command, params, client) {
// ---------------------------------------------------------------------------
function getVehicleInfoCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -1025,25 +670,6 @@ function getVehicleInfoCommand(command, params, client) {
// ---------------------------------------------------------------------------
function toggleVehicleSpawnLockCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
if(!isPlayerInAnyVehicle(client)) {
messageClientError(client, "You need to be in a vehicle!");
return false;
@@ -1065,25 +691,6 @@ function toggleVehicleSpawnLockCommand(command, params, client) {
// ---------------------------------------------------------------------------
function reloadAllVehiclesCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
for(let i in getServerData().vehicles) {
if(getServerData().vehicles[i].vehicle) {
deleteGameElement(getServerData().vehicles[i].vehicle);
@@ -1100,25 +707,6 @@ function reloadAllVehiclesCommand(command, params, client) {
// ---------------------------------------------------------------------------
function respawnAllVehiclesCommand(command, params, client) {
if(getCommand(command).requireLogin) {
if(!isClientLoggedIn(client)) {
messageClientError(client, "You must be logged in to use this command!");
return false;
}
}
if(isClientFromDiscord(client)) {
if(!isCommandAllowedOnDiscord(command)) {
messageClientError(client, "That command isn't available on discord!");
return false;
}
}
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
messageClientError(client, "You do not have permission to use this command!");
return false;
}
for(let i in getServerData().vehicles) {
if(getServerData().vehicles[i].vehicle) {
deleteGameElement(getServerData().vehicles[i].vehicle);