Skip to content

Commit

Permalink
Merge pull request #32 from zfbx/v7wip
Browse files Browse the repository at this point in the history
v7 features and refactoring
  • Loading branch information
zfbx authored Dec 8, 2021
2 parents ca70cfd + e8e62bd commit a1c2dec
Show file tree
Hide file tree
Showing 61 changed files with 1,531 additions and 1,743 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"SetEntityCoords"
],
"cSpell.words": [
"aceperms",
"alloc",
"bannedby",
"bantime",
Expand All @@ -37,12 +36,10 @@
"Dabbzz",
"Deutsch",
"discordinvite",
"enableaceperms",
"EXTRASUNNY",
"firstname",
"fivem",
"fxmanifest",
"guildid",
"injail",
"isdst",
"kickall",
Expand Down
1,111 changes: 437 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

35 changes: 0 additions & 35 deletions client.lua

This file was deleted.

25 changes: 25 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--[[
- This file is part of zdiscord.
- Copyright (C) 2021 Tony/zfbx
- source: <https://github.com/zfbx/zdiscord>
-
- This work is licensed under the Creative Commons
- Attribution-NonCommercial-ShareAlike 4.0 International License.
- To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
- or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
--]]

RegisterNetEvent(GetCurrentResourceName()..':kill', function()
SetEntityHealth(PlayerPedId(), 0)
end)

RegisterNetEvent(GetCurrentResourceName()..':teleport', function(x, y, z, withVehicle)
x = tonumber(x)
y = tonumber(y)
z = tonumber(z)
if (withVehicle) then
SetPedCoordsKeepVehicle(PlayerPedId(), x, y, z)
else
SetEntityCoords(PlayerPedId(), x, y, z);
end
end)
32 changes: 0 additions & 32 deletions commands/onlinecount.js

This file was deleted.

32 changes: 0 additions & 32 deletions commands/qb-reviveall.js

This file was deleted.

115 changes: 65 additions & 50 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,74 @@
/*
zdiscord - by Tony/zfbx - https://github.com/zfbx/zdiscord - License: GPLv3
zdiscord - by Tony/zfbx - https://github.com/zfbx/zdiscord - License: CC BY-NC-SA 4.0
Docs for this file available at https://zfbx.github.io/zdiscord/config or in docs/config.md
*/


// ESSENTIALS
const DiscordBotToken = "CHANGE";
const DiscordGuildId = "000000000000000000";
/** ******************************
* GENERAL CONFIGURATION SETTINGS
********************************/

const LanguageLocaleCode = "en";

// PUBLIC VALUES
const YourFiveMServerName = "My FiveM Server";
const FiveMServerName = "My FiveM Server";
const DiscordInviteLink = "https://discord.gg/fivem";
const YourFiveMServerIP = "127.0.0.1";
const FiveMServerIP = "127.0.0.1";


/** ********************
* DISCORD BOT SETTINGS
***********************/

const EnableDiscordBot = true;

// DISCORD BOT
const DiscordBotToken = "CHANGE";
const DiscordGuildId = "000000000000000000";

// STAFF CHAT
const EnableStaffChatForwarding = false;
const DiscordStaffChannelId = "000000000000000000";

// WHITELISTING / ALLOWLISTING
const EnableWhitelistChecking = "true";
const EnableWhitelistChecking = true;
const DiscordWhitelistRoleIds = "000000000000000000, 000000000000000000";

// SLASH COMMANDS / DISCORD PERMISSIONS
const EnableDiscordSlashCommands = "true";
const EnableDiscordSlashCommands = true;
const DiscordModRoleId = "000000000000000000";
const DiscordAdminRoleId = "000000000000000000";
const DiscordGodRoleId = "000000000000000000";

// DISCORD BOT STATUS
const EnableBotStatusMessages = "true";
const EnableBotStatusMessages = true;
const BotStatusMessages = [
"{servername}",
"{playercount} online",
];

// ACE PERMISSIONS
const EnableAutoAcePermissions = "false";
const EnableAutoAcePermissions = false;
const AutoAcePermissions = {
"group.god": DiscordGodRoleId,
"group.admin": DiscordAdminRoleId,
"group.mod": DiscordModRoleId,
// "example": "000000000000000000",
// "example2": [ "000000000000000000", "000000000000000000"],
};

// OTHER
const SaveScreenshotsToServer = "false";

// FUTURE (features potentially not yet released)
const EnableConnectingQueue = "false";
const ConnectingQueuePriorities = {
1: DiscordGodRoleId,
2: DiscordAdminRoleId,
3: DiscordModRoleId,
// 10: "000000000000000000",
// 20: [ "000000000000000000", "000000000000000000"],
};
const DiscordStaffChannelId = "000000000000000000";
const EnableUserPresenceUpdates = "false";
// Other
const SaveScreenshotsToServer = false;


/** ************************
* WEBHOOK LOGGING SETTINGS
**************************/

const EnableLoggingWebhooks = false;
const LoggingWebhookName = "zLogs";
// put "&" in front of the id if you're to ping a role
const LoggingAlertPingId = "&000000000000000000";
// example: "bank": "https://discord.com/webhook/...",
const LoggingWebhooks = {
"example": "",
"example": "https://discord.com/api/webhooks/000000000/sEcRRet-ToK3n_5tUfF_tH8t_YUo-S40u1d-n07-sHar3",
};


Expand All @@ -65,35 +77,38 @@ const LoggingWebhooks = {
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

module.exports = {
token: GetConvar("discord_token", DiscordBotToken),
guildid: GetConvar("discord_guild_id", DiscordGuildId),
lang: GetConvar("discord_lang", LanguageLocaleCode),
serverName: GetConvar("discord_server_name", YourFiveMServerName),
discordInvite: GetConvar("discord_invite", DiscordInviteLink),
serverIp: GetConvar("discord_server_ip", YourFiveMServerIP),
enableWhitelist: getConBool("discord_enable_whitelist", EnableWhitelistChecking),
whitelistRoles: getConList("discord_whitelist_roles", DiscordWhitelistRoleIds),
enableCommands: getConBool("discord_enable_commands", EnableDiscordSlashCommands),
modRole: GetConvar("discord_mod_role", DiscordModRoleId),
adminRole: GetConvar("discord_admin_role", DiscordAdminRoleId),
godRole: GetConvar("discord_god_role", DiscordGodRoleId),
enableStatus: getConBool("discord_enable_status", EnableBotStatusMessages),
statusMessages: BotStatusMessages,
enableaceperms: getConBool("discord_enable_ace_perms", EnableAutoAcePermissions),
aceperms: AutoAcePermissions,
saveScreenshots: getConBool("discord_save_screenshots", SaveScreenshotsToServer),
enableQueue: getConBool("discord_enable_connecting_queue", EnableConnectingQueue),
queuePrios: ConnectingQueuePriorities,
staffChannel: GetConvar("discord_staff_channel_id", DiscordStaffChannelId),
enableUserPresence: getConBool("discord_enable_user_presence", EnableUserPresenceUpdates),
logWebhooks: LoggingWebhooks,
EnableDiscordBot: getConBool("discord_enable_bot", EnableDiscordBot),
EnableStaffChatForwarding: getConBool("discord_enable_staff_chat", EnableStaffChatForwarding),
EnableLoggingWebhooks: getConBool("discord_enable_logging_webhooks", EnableLoggingWebhooks),
DiscordBotToken: GetConvar("discord_token", DiscordBotToken),
DiscordGuildId: GetConvar("discord_guild_id", DiscordGuildId),
LanguageLocaleCode: GetConvar("discord_lang", LanguageLocaleCode),
FiveMServerName: GetConvar("discord_server_name", FiveMServerName),
DiscordInviteLink: GetConvar("discord_invite", DiscordInviteLink),
FiveMServerIP: GetConvar("discord_server_ip", FiveMServerIP),
EnableWhitelistChecking: getConBool("discord_enable_whitelist", EnableWhitelistChecking),
DiscordWhitelistRoleIds: getConList("discord_whitelist_roles", DiscordWhitelistRoleIds),
EnableDiscordSlashCommands: getConBool("discord_enable_commands", EnableDiscordSlashCommands),
DiscordModRoleId: GetConvar("discord_mod_role", DiscordModRoleId),
DiscordAdminRoleId: GetConvar("discord_admin_role", DiscordAdminRoleId),
DiscordGodRoleId: GetConvar("discord_god_role", DiscordGodRoleId),
EnableBotStatusMessages: getConBool("discord_enable_status", EnableBotStatusMessages),
BotStatusMessages: BotStatusMessages,
EnableAutoAcePermissions: getConBool("discord_enable_ace_perms", EnableAutoAcePermissions),
AutoAcePermissions: AutoAcePermissions,
SaveScreenshotsToServer: getConBool("discord_save_screenshots", SaveScreenshotsToServer),
DiscordStaffChannelId: GetConvar("discord_staff_channel_id", DiscordStaffChannelId),
LoggingWebhooks: LoggingWebhooks,
LoggingAlertPingId: GetConvar("discord_logging_ping_id", LoggingAlertPingId),
LoggingWebhookName: GetConvar("discord_logging_name", LoggingWebhookName),
};

/** Returns convar or default value fixed to a true/false boolean
* @param {boolean|string|number} con - Convar name
* @param {boolean|string|number} def - Default fallback value
* @returns {boolean} - parsed bool */
function getConBool(con, def) {
if (typeof def == "boolean") def = def.toString();
const ret = GetConvar(con, def);
if (typeof ret == "boolean") return ret;
if (typeof ret == "string") return ["true", "on", "yes", "y", "1"].includes(ret.toLocaleLowerCase().trim());
Expand Down
Loading

0 comments on commit a1c2dec

Please sign in to comment.