From e0d561649b82274604a2e40c40dbfb3b50289927 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 9 Mar 2020 13:05:33 +0100 Subject: [PATCH] Added invalid command handler --- locales/br.lua | 1 + locales/cs.lua | 1 + locales/de.lua | 1 + locales/en.lua | 1 + locales/fi.lua | 1 + locales/fr.lua | 1 + locales/pl.lua | 1 + locales/sv.lua | 1 + server/main.lua | 8 ++++++++ 9 files changed, 16 insertions(+) diff --git a/locales/br.lua b/locales/br.lua index 7b115f96..c2b46a7b 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -93,6 +93,7 @@ Locales['br'] = { ['commanderror_invaliditem'] = 'item invalido', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'o ID do jogador', diff --git a/locales/cs.lua b/locales/cs.lua index b99bebf0..178bf89f 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -93,6 +93,7 @@ Locales['cs'] = { ['commanderror_invaliditem'] = 'invalid item name', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'player id', diff --git a/locales/de.lua b/locales/de.lua index 86247f0b..1b218200 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -93,6 +93,7 @@ Locales['de'] = { ['commanderror_invaliditem'] = 'invalid item name', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'player id', diff --git a/locales/en.lua b/locales/en.lua index e7a6549b..9c3efda4 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -93,6 +93,7 @@ Locales['en'] = { ['commanderror_invaliditem'] = 'invalid item name', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'player id', diff --git a/locales/fi.lua b/locales/fi.lua index cd3b3d6b..9831b26e 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -93,6 +93,7 @@ Locales['fi'] = { ['commanderror_invaliditem'] = 'invalid item name', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'player id', diff --git a/locales/fr.lua b/locales/fr.lua index 502e360c..78aa1bbe 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -93,6 +93,7 @@ Locales['fr'] = { ['commanderror_invaliditem'] = 'nom de l\'objet invalide', ['commanderror_invalidweapon'] = 'arme invalide', ['commanderror_console'] = 'cette commande ne peut pas être utilisée dans la console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'il n\'ya aucun joueur avec cet ID en jeu', ['commandgeneric_playerid'] = 'id joueur', diff --git a/locales/pl.lua b/locales/pl.lua index 3f727d5f..db4f89ae 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -93,6 +93,7 @@ Locales['pl'] = { ['commanderror_invaliditem'] = 'invalid item name', ['commanderror_invalidweapon'] = 'invalid weapon', ['commanderror_console'] = 'that command can not be run from console', + ['commanderror_invalidcommand'] = '^3%s^0 is not an valid command!', ['commanderror_invalidplayerid'] = 'there is no player online matching that server id', ['commandgeneric_playerid'] = 'player id', diff --git a/locales/sv.lua b/locales/sv.lua index df1f21db..b41a434e 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -93,6 +93,7 @@ Locales['sv'] = { ['commanderror_invaliditem'] = 'ej giltigt item', ['commanderror_invalidweapon'] = 'ej giltigt vapen', ['commanderror_console'] = 'detta kommando kan ej executas i konsol', + ['commanderror_invalidcommand'] = '^3%s^0 är inte ett giltigt kommando!', ['commanderror_invalidplayerid'] = 'det finns ingen spelare som matchar det angivna server id', ['commandgeneric_playerid'] = 'spelarid', diff --git a/server/main.lua b/server/main.lua index 9dc9e753..008bc784 100644 --- a/server/main.lua +++ b/server/main.lua @@ -193,6 +193,14 @@ function loadESXPlayer(identifier, playerId) end) end +AddEventHandler('chatMessage', function(playerId, author, message) + if message:sub(1, 1) == '/' and playerId > 0 then + CancelEvent() + local commandName = message:sub(1):gmatch("%w+")() + TriggerClientEvent('chat:addMessage', playerId, {args = {'^1SYSTEM', _U('commanderror_invalidcommand', commandName)}}) + end +end) + AddEventHandler('playerDropped', function(reason) local playerId = source local xPlayer = ESX.GetPlayerFromId(playerId)