├── README.md └── weleho_status ├── config.lua ├── fxmanifest.lua └── server.lua /README.md: -------------------------------------------------------------------------------- 1 | # Fivem Status Script by Weleho 2 | 3 | 1. Create Webhook to channel you want. 4 | 2. Configure config.lua and start script 5 | 3. Copy message id from deployed message and put that into config 6 | 4. Restart script and have fun! 7 | 8 | 9 | ![4eaf1218a7d5f8fd20dbce378668689314f7fd01](https://user-images.githubusercontent.com/57502552/120692273-3ce71f00-c4b0-11eb-8432-d40b116df141.png) 10 | ![034ed261abe112574622f0db26e42e4ddda1f49f](https://user-images.githubusercontent.com/57502552/120692288-41abd300-c4b0-11eb-99e0-14699b9ea56f.png) 11 | -------------------------------------------------------------------------------- /weleho_status/config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.Debug = false 4 | 5 | Config.Webhook = '' 6 | Config.ServerName = '' 7 | 8 | Config.MessageId = '' --Copy messageid from deployed message and restart script! 9 | 10 | Config.UpdateTime = 1000*60*1 -- 1 minute 11 | Config.Use24hClock = true -- false = 12h clock 12 | Config.JoinLink = 'https://cfx.re/join/' -- Make sure that JoinLink is URL, like: https://cfx.re/join/xp34mg, currenlty does not support Redm 13 | 14 | Config.EmbedColor = 3158326 15 | 16 | Config.Locale = 'en' 17 | 18 | Config.Locales = { 19 | ['fi'] = { 20 | ['date'] = 'Päivä', 21 | ['time'] = 'Aika', 22 | ['players'] = 'Pelaajia', 23 | ['connect'] = 'Yhdistä palvelimelle', 24 | }, 25 | ['en'] = { 26 | ['date'] = 'Date', 27 | ['time'] = 'Time', 28 | ['players'] = 'Players', 29 | ['connect'] = 'Connect to server', 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /weleho_status/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | games { 'rdr3', 'gta5' } 3 | rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' 4 | 5 | author 'Weleho' 6 | description 'Server Status' 7 | version '1.0.0' 8 | 9 | server_scripts { 10 | 'config.lua', 11 | 'server.lua' 12 | } 13 | -------------------------------------------------------------------------------- /weleho_status/server.lua: -------------------------------------------------------------------------------- 1 | local locales = Config.Locales[Config.Locale] 2 | 3 | Citizen.CreateThread(function() 4 | while true do 5 | if Config.MessageId ~= nil and Config.MessageId ~= '' then 6 | UpdateStatusMessage() 7 | else 8 | DeployStatusMessage() 9 | break 10 | end 11 | 12 | Citizen.Wait(Config.UpdateTime) 13 | end 14 | end) 15 | 16 | 17 | function DeployStatusMessage() 18 | local footer = nil 19 | 20 | if Config.Use24hClock then 21 | footer = os.date(locales['date']..': %d/%m/%Y | '..locales['time']..': %H:%M') 22 | else 23 | footer = os.date(locales['date']..': %d/%m/%Y | '..locales['time']..': %I:%M %p') 24 | end 25 | 26 | if Config.Debug then 27 | print('Deplying Status Message ['..footer..']') 28 | end 29 | 30 | local embed = { 31 | { 32 | ["color"] = Config.EmbedColor, 33 | ["title"] = "** Deploying Status Message!**", 34 | ["description"] = 'Copy this message id and put it into Config and restart script!', 35 | ["footer"] = { 36 | ["text"] = footer, 37 | }, 38 | } 39 | } 40 | 41 | PerformHttpRequest(Config.Webhook, function(err, text, headers) end, 'POST', json.encode({ 42 | embeds = embed, 43 | }), { ['Content-Type'] = 'application/json' }) 44 | end 45 | 46 | 47 | function UpdateStatusMessage() 48 | local players = #GetPlayers() 49 | local maxplayers = GetConvarInt('sv_maxclients', 0) 50 | local footer = nil 51 | 52 | if Config.Use24hClock then 53 | footer = os.date(locales['date']..': %d/%m/%Y | '..locales['time']..': %H:%M') 54 | else 55 | footer = os.date(locales['date']..': %d/%m/%Y | '..locales['time']..': %I:%M %p') 56 | end 57 | 58 | if Config.Debug then 59 | print('Updating Status Message ['..footer..']') 60 | end 61 | 62 | 63 | local message = json.encode({ 64 | embeds = { 65 | { 66 | 67 | ["color"] = Config.EmbedColor, 68 | ["title"] = '**'..Config.ServerName..'**', 69 | ["description"] = ':busts_in_silhouette: '..locales['players']..': `'..players..' / '..maxplayers..'`', 70 | ["footer"] = { 71 | ["text"] = footer, 72 | }, 73 | } 74 | }, 75 | 76 | components = { 77 | { 78 | ["type"] = 1, 79 | ["components"] = { 80 | { 81 | ["type"] = 2, 82 | ["label"] = locales['connect'], 83 | ["style"] = 5, 84 | ["url"] = Config.JoinLink, 85 | } 86 | }, 87 | } 88 | } 89 | }) 90 | 91 | PerformHttpRequest(Config.Webhook..'/messages/'..Config.MessageId, function(err, text, headers) 92 | if Config.Debug then 93 | print('[DEBUG] err=', err) 94 | print('[DEBUG] text=', text) 95 | end 96 | end, 'PATCH', message, { ['Content-Type'] = 'application/json' }) 97 | end 98 | 99 | 100 | 101 | --------------------------------------------------------------------------------