From 8a8700ca57944767fc506cbcfffa7b70d1196505 Mon Sep 17 00:00:00 2001 From: Demetrio <15928886+0xDEMXN@users.noreply.github.com> Date: Tue, 9 May 2023 15:52:09 +0200 Subject: [PATCH] feat(server/interface): configurable txAdmin notifications override (#299) --- fxmanifest.lua | 3 +- locales/al.json | 7 ++++- locales/cs.json | 7 ++++- locales/de.json | 7 ++++- locales/en.json | 7 ++++- locales/es.json | 7 ++++- locales/et.json | 7 ++++- locales/fr.json | 7 ++++- locales/he.json | 7 ++++- locales/hr.json | 7 ++++- locales/hu.json | 7 ++++- locales/id.json | 7 ++++- locales/it.json | 13 +++++--- locales/lt.json | 7 ++++- locales/nl.json | 7 ++++- locales/no.json | 9 ++++-- locales/pl.json | 7 ++++- locales/pt-br.json | 7 ++++- locales/ru.json | 7 ++++- locales/sk.json | 7 ++++- locales/sl.json | 7 ++++- locales/sv.json | 7 ++++- locales/th.json | 7 ++++- locales/tr.json | 7 ++++- locales/zh-cn.json | 7 ++++- locales/zh-tw.json | 7 ++++- resource/interface/server/txadmin.lua | 44 +++++++++++++++++++++++++++ resource/shared.lua | 1 + 28 files changed, 201 insertions(+), 30 deletions(-) create mode 100644 resource/interface/server/txadmin.lua create mode 100644 resource/shared.lua diff --git a/fxmanifest.lua b/fxmanifest.lua index e6fd7d25c..f0c882fc8 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -33,6 +33,7 @@ files { shared_script 'resource/init.lua' shared_scripts { + 'imports/locale/shared.lua', 'resource/**/shared.lua', -- 'resource/**/shared/*.lua' } @@ -49,6 +50,6 @@ client_scripts { server_scripts { 'imports/callback/server.lua', 'resource/**/server.lua', - -- 'resource/**/server/*.lua' + 'resource/**/server/*.lua', } diff --git a/locales/al.json b/locales/al.json index ee207c85e..869acc033 100644 --- a/locales/al.json +++ b/locales/al.json @@ -5,5 +5,10 @@ "close": "Mbylle", "confirm": "Konfirmo", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/cs.json b/locales/cs.json index 614c3a5a4..52c52d32b 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -5,5 +5,10 @@ "close": "Zavřít", "confirm": "Potvrdit", "more": "Více..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/de.json b/locales/de.json index e6b82b109..6db70dc25 100644 --- a/locales/de.json +++ b/locales/de.json @@ -5,5 +5,10 @@ "close": "Schließen", "confirm": "Bestätigen", "more": "Mehr..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/en.json b/locales/en.json index 855d0f91d..c35d631d9 100644 --- a/locales/en.json +++ b/locales/en.json @@ -5,5 +5,10 @@ "close": "Close", "confirm": "Confirm", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/es.json b/locales/es.json index f3090948b..0d1ce8f7b 100644 --- a/locales/es.json +++ b/locales/es.json @@ -5,5 +5,10 @@ "close": "Cerrar", "confirm": "Confirmar", "more": "Más..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/et.json b/locales/et.json index 9e1f5f960..44cd582cc 100644 --- a/locales/et.json +++ b/locales/et.json @@ -5,5 +5,10 @@ "close": "Sulge", "confirm": "Kinnita", "more": "Rohkem..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/fr.json b/locales/fr.json index e5031e2b2..e03cd95a3 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -5,5 +5,10 @@ "close": "Fermer", "confirm": "Confirmer", "more": "Plus..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/he.json b/locales/he.json index b7addbc92..bb463bd58 100644 --- a/locales/he.json +++ b/locales/he.json @@ -5,5 +5,10 @@ "close": "סגירה", "confirm": "אישור", "more": "...עוד" - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/hr.json b/locales/hr.json index 35654a95c..e66dd8ba2 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -5,5 +5,10 @@ "close": "Zatvori", "confirm": "Potvrdi", "more": "Više..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/hu.json b/locales/hu.json index 7e75b54b6..32cec195d 100644 --- a/locales/hu.json +++ b/locales/hu.json @@ -5,5 +5,10 @@ "close": "Bezárás", "confirm": "Megerősít", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/id.json b/locales/id.json index 7be40f53a..c3748fbee 100644 --- a/locales/id.json +++ b/locales/id.json @@ -5,5 +5,10 @@ "close": "Tutup", "confirm": "Konfirmasi", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/it.json b/locales/it.json index 584b2f42d..8f883b2ae 100644 --- a/locales/it.json +++ b/locales/it.json @@ -2,8 +2,13 @@ "language": "Italiano", "ui": { "cancel": "Annulla", - "close": "Chiudere", - "confirm": "Confermare", - "more": "Di più..." - } + "close": "Chiudi", + "confirm": "Conferma", + "more": "Altro..." + }, + "txadmin_announcement": "Annuncio server da %s", + "txadmin_dm": "Messaggio diretto da %s", + "txadmin_warn": "Sei stato richiamato da %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Riavvio Programmato" } diff --git a/locales/lt.json b/locales/lt.json index 9e8e3cfba..ad6fc3e3e 100644 --- a/locales/lt.json +++ b/locales/lt.json @@ -5,5 +5,10 @@ "close": "Uždaryti", "confirm": "Patvirtinti", "more": "Daugiau..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/nl.json b/locales/nl.json index 57e515309..cdec229dd 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -5,5 +5,10 @@ "close": "Sluiten", "confirm": "Bevestig", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/no.json b/locales/no.json index f6299e5b3..7dd399069 100644 --- a/locales/no.json +++ b/locales/no.json @@ -5,5 +5,10 @@ "close": "Lukk", "confirm": "Bekreft", "more": "Mer..." - } - } \ No newline at end of file + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" + } diff --git a/locales/pl.json b/locales/pl.json index 1fa58493f..d235302f3 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -5,5 +5,10 @@ "close": "Zamknij", "confirm": "Potwierdź", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/pt-br.json b/locales/pt-br.json index 14125d1b5..2692c7509 100644 --- a/locales/pt-br.json +++ b/locales/pt-br.json @@ -5,5 +5,10 @@ "close": "Fechar", "confirm": "Confirmar", "more": "Mais..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/ru.json b/locales/ru.json index e23aed424..751f888f8 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -5,5 +5,10 @@ "close": "Закрыть", "confirm": "Подтвердить", "more": "Ещё..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/sk.json b/locales/sk.json index f4858805d..59d7e4fe5 100644 --- a/locales/sk.json +++ b/locales/sk.json @@ -5,5 +5,10 @@ "close": "Zavrieť", "confirm": "Potvrdiť", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/sl.json b/locales/sl.json index be0d22534..96d0c3de9 100644 --- a/locales/sl.json +++ b/locales/sl.json @@ -5,5 +5,10 @@ "close": "Zapri", "confirm": "Potrdi", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/sv.json b/locales/sv.json index 65054175f..4508a67bf 100644 --- a/locales/sv.json +++ b/locales/sv.json @@ -5,5 +5,10 @@ "close": "Stäng", "confirm": "Acceptera", "more": "Mer..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/th.json b/locales/th.json index 972b811ce..aa37dec8c 100644 --- a/locales/th.json +++ b/locales/th.json @@ -5,5 +5,10 @@ "close": "ปิด", "confirm": "ยืนยัน", "more": "เพิ่มเติม..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/tr.json b/locales/tr.json index 3b86a46e5..fc5328d89 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -5,5 +5,10 @@ "close": "Kapat", "confirm": "Onayla", "more": "Daha Fazla..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/zh-cn.json b/locales/zh-cn.json index 6d372ac83..27acbd826 100644 --- a/locales/zh-cn.json +++ b/locales/zh-cn.json @@ -5,5 +5,10 @@ "close": "关闭", "confirm": "确认", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/locales/zh-tw.json b/locales/zh-tw.json index e5483a9d7..2eb767f88 100644 --- a/locales/zh-tw.json +++ b/locales/zh-tw.json @@ -5,5 +5,10 @@ "close": "關閉", "confirm": "確認", "more": "More..." - } + }, + "txadmin_announcement": "Server announcement by %s", + "txadmin_dm": "Direct Message from %s", + "txadmin_warn": "You have been warned by %s", + "txadmin_warn_content": "%s \nAction ID: %s", + "txadmin_scheduledrestart": "Scheduled Restart" } diff --git a/resource/interface/server/txadmin.lua b/resource/interface/server/txadmin.lua new file mode 100644 index 000000000..cff60f54f --- /dev/null +++ b/resource/interface/server/txadmin.lua @@ -0,0 +1,44 @@ +if GetConvarInt('ox:txAdminNotifications', false) then + if GetConvar('txAdmin-hideDefaultAnnouncement', 'false') == 'true' then + AddEventHandler('txAdmin:events:announcement', function(eventData) + TriggerClientEvent('ox_lib:notify', -1, { + id = 'txAdmin:announcement', + title = locale('txadmin_announcement', eventData.author), + description = eventData.message, + duration = 5000 + }) + end) + end + + if GetConvar('txAdmin-hideDefaultDirectMessage', 'false') == 'true' then + AddEventHandler('txAdmin:events:playerDirectMessage', function(eventData) + TriggerClientEvent('ox_lib:notify', eventData.target, { + id = 'txAdmin:playerDirectMessage', + title = locale('txadmin_dm', eventData.author), + description = eventData.message, + duration = 5000 + }) + end) + end + + if GetConvar('txAdmin-hideDefaultWarning', 'false') == 'true' then + AddEventHandler('txAdmin:events:playerWarned', function(eventData) + TriggerClientEvent('ox_lib:alertDialog', eventData.target, { + header = locale('txadmin_warn', eventData.author), + content = locale('txadmin_warn_content', eventData.reason, eventData.actionId), + centered = true + }) + end) + end + + if GetConvar('txAdmin-hideDefaultScheduledRestartWarning', 'false') == 'true' then + AddEventHandler('txAdmin:events:scheduledRestart', function(eventData) + TriggerClientEvent('ox_lib:notify', -1, { + id = 'txAdmin:scheduledRestart', + title = locale('txadmin_scheduledrestart'), + description = eventData.translatedMessage, + duration = 5000 + }) + end) + end +end diff --git a/resource/shared.lua b/resource/shared.lua new file mode 100644 index 000000000..aa9ba6170 --- /dev/null +++ b/resource/shared.lua @@ -0,0 +1 @@ +lib.locale()