diff --git a/client/main.lua b/client/main.lua index a95c4007..3f57e522 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,11 +1,14 @@ RegisterNetEvent('esx_rpchat:sendProximityMessage') -AddEventHandler('esx_rpchat:sendProximityMessage', function(id, title, message, color) +AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color) local source = PlayerId() - local target = GetPlayerFromServerId(id) + local target = GetPlayerFromServerId(playerId) + + local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target) + local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed) if target == source then TriggerEvent('chat:addMessage', { args = { title, message }, color = color }) - elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(source)), GetEntityCoords(GetPlayerPed(target)), true) < 19 then + elseif GetDistanceBetweenCoords(sourceCoords, targetCoords, true) < 20 then TriggerEvent('chat:addMessage', { args = { title, message }, color = color }) end end) diff --git a/locales/cs.lua b/locales/cs.lua index f17d7419..112d386a 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -1,15 +1,12 @@ Locales['cs'] = { - ['ooc_help'] = 'poslat out of character zprávu', - ['ooc_prefix'] = 'OOC | %s', - ['twt_help'] = 'odeslat tweet', - ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', - ['me_help'] = 'osobní akce', - ['me_prefix'] = 'me | %s', - ['do_help'] = 'rP informace', - ['do_prefix'] = 'do | %s', - ['news_help'] = 'oznámit zprávy (nezneužívat)', - ['news_prefix'] = 'news | %s', - ['ooc_argument_name'] = 'zpráva', - ['ooc_argument_help'] = 'zpráva', - ['ooc_unknown_command'] = '^3%s^0 není platný příkaz!', + ['ooc_prefix'] = 'OOC | %s', + ['twt_help'] = 'odeslat tweet', + ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', + ['me_help'] = 'osobní akce', + ['me_prefix'] = 'me | %s', + ['do_help'] = 'RP informace', + ['do_prefix'] = 'do | %s', + ['generic_argument_name'] = 'zpráva', + ['generic_argument_help'] = 'zpráva', + ['generic_unknown_command'] = '^3%s^0 není platný příkaz!', } diff --git a/locales/en.lua b/locales/en.lua index e5bd70bf..fb7ad19a 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,15 +1,12 @@ Locales['en'] = { - ['ooc_help'] = 'type an out of character message', - ['ooc_prefix'] = 'OOC | %s', - ['twt_help'] = 'send a tweet', - ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', - ['me_help'] = 'personal action', - ['me_prefix'] = 'me | %s', - ['do_help'] = 'rP information', - ['do_prefix'] = 'do | %s', - ['news_help'] = 'announce news (do not abuse)', - ['news_prefix'] = 'news | %s', - ['ooc_argument_name'] = 'message', - ['ooc_argument_help'] = 'the message', - ['ooc_unknown_command'] = '^3%s^0 is not a valid command!', + ['ooc_prefix'] = 'OOC | %s', + ['twt_help'] = 'send a tweet', + ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', + ['me_help'] = 'personal action', + ['me_prefix'] = 'me | %s', + ['do_help'] = 'RP information', + ['do_prefix'] = 'do | %s', + ['generic_argument_name'] = 'message', + ['generic_argument_help'] = 'the message', + ['generic_unknown_command'] = '^3%s^0 is not a valid command!', } diff --git a/locales/fi.lua b/locales/fi.lua index bf4fb81a..92dbd9c7 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,15 +1,12 @@ Locales['fi'] = { - ['ooc_help'] = 'kirjota hahmon ulkopuolelle liittyvä viesti', - ['ooc_prefix'] = 'OOC | %s', - ['twt_help'] = 'lähetä twiitti', - ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', - ['me_help'] = 'teet jotain', - ['me_prefix'] = 'me | %s', - ['do_help'] = 'roolipeliä tiedot', --TODO: check translation - ['do_prefix'] = 'do | %s', - ['news_help'] = 'ilmoita uutinen (älä abuse)', - ['news_prefix'] = 'news | %s', - ['ooc_argument_name'] = 'viesti', - ['ooc_argument_help'] = 'viestin sisältö', - ['ooc_unknown_command'] = '^3%s^0 ei ole validi komento!', + ['ooc_prefix'] = 'OOC | %s', + ['twt_help'] = 'lähetä twiitti', + ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', + ['me_help'] = 'teet jotain', + ['me_prefix'] = 'me | %s', + ['do_help'] = 'roolipeliä tiedot', --TODO: check translation + ['do_prefix'] = 'do | %s', + ['generic_argument_name'] = 'viesti', + ['generic_argument_help'] = 'viestin sisältö', + ['generic_unknown_command'] = '^3%s^0 ei ole validi komento!', } diff --git a/locales/fr.lua b/locales/fr.lua index 108c6bad..d2d24632 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,15 +1,12 @@ Locales['fr'] = { - ['ooc_help'] = 'ecrit un message hors du personnage', - ['ooc_prefix'] = 'hrp | %s', - ['twt_help'] = 'envoie un tweet', - ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', - ['me_help'] = 'action personnelle', - ['me_prefix'] = 'me | %s', - ['do_help'] = 'rP information', --TODO: check translation - ['do_prefix'] = 'faire | %s', - ['news_help'] = 'annonce une information (ne pas en abuser)', - ['news_prefix'] = 'info | %s', - ['ooc_argument_name'] = 'message', - ['ooc_argument_help'] = 'le message', - ['ooc_unknown_command'] = '^3%s^0 n\'est pas une commande valide!', + ['ooc_prefix'] = 'hrp | %s', + ['twt_help'] = 'envoie un tweet', + ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', + ['me_help'] = 'action personnelle', + ['me_prefix'] = 'me | %s', + ['do_help'] = 'RP information', --TODO: check translation + ['do_prefix'] = 'faire | %s', + ['generic_argument_name'] = 'message', + ['generic_argument_help'] = 'le message', + ['generic_unknown_command'] = '^3%s^0 n\'est pas une commande valide!', } diff --git a/locales/sv.lua b/locales/sv.lua index 0d24eb7a..1c865a46 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -1,15 +1,12 @@ Locales['sv'] = { - ['ooc_help'] = 'skicka ett meddelande som inte kopplat till din karaktär', - ['ooc_prefix'] = 'OOC | %s', - ['twt_help'] = 'skicka en tweet', - ['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)', - ['me_help'] = 'skriv en händelse, t.ex \'visar körkort\'', - ['me_prefix'] = 'jag | %s', - ['do_help'] = 'rollspelinformation', --TODO: check translation - ['do_prefix'] = 'do | %s', - ['news_help'] = 'meddela en nyhet (missbruka inte)', - ['news_prefix'] = 'TV4 Stockholm', - ['ooc_argument_name'] = 'meddelande', - ['ooc_argument_help'] = 'det meddelandet du vill skicka', - ['ooc_unknown_command'] = '^3%s^0 är inte ett giltigt kommando!', + ['ooc_prefix'] = 'OOC | %s', + ['twt_help'] = 'skicka en tweet', + ['twt_prefix'] = '^5@%s^0', + ['me_help'] = 'skriv en händelse, t.ex \'visar körkort\'', + ['me_prefix'] = 'jag | %s', + ['do_help'] = 'något karaktären gör inom rollspel', + ['do_prefix'] = 'gör | %s', + ['generic_argument_name'] = 'meddelande', + ['generic_argument_help'] = 'det meddelandet du vill skicka', + ['generic_unknown_command'] = '^3%s^0 är inte ett giltigt kommando!', } diff --git a/server/main.lua b/server/main.lua index 34c8387d..f77f30dd 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,18 +3,14 @@ AddEventHandler('es:invalidCommandHandler', function(source, command_args, user) TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', _U('ooc_unknown_command', command_args[1]) } }) end) -RegisterCommand('ooc', function(source, args, rawCommand) - if source == 0 then - print('esx_rpchat: you can\'t use this command from rcon!') - return +AddEventHandler('chatMessage', function(source, name, message) + if string.sub(message, 1, string.len('/')) ~= '/' then + CancelEvent() + + if Config.EnableESXIdentity then name = GetCharacterName(source) end + TriggerClientEvent('chat:addMessage', -1, { args = { _U('ooc_prefix', name), message }, color = { 128, 128, 128 } }) end - - rawCommand = string.sub(rawCommand, 4) - local name = GetPlayerName(source) - if Config.EnableESXIdentity then name = GetCharacterName(source) end - - TriggerClientEvent('chat:addMessage', -1, { args = { _U('ooc_prefix', name), rawCommand }, color = { 128, 128, 128 } }) -end, false) +end) RegisterCommand('twt', function(source, args, rawCommand) if source == 0 then @@ -22,11 +18,12 @@ RegisterCommand('twt', function(source, args, rawCommand) return end - rawCommand = string.sub(rawCommand, 4) + args = table.concat(args, ' ') local name = GetPlayerName(source) if Config.EnableESXIdentity then name = GetCharacterName(source) end - TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', name), rawCommand }, color = { 0, 153, 204 } }) + TriggerClientEvent('chat:addMessage', -1, { args = { _U('twt_prefix', name), args }, color = { 0, 153, 204 } }) + print(('%s: %s'):format(name, args)) end, false) RegisterCommand('me', function(source, args, rawCommand) @@ -35,11 +32,12 @@ RegisterCommand('me', function(source, args, rawCommand) return end - rawCommand = string.sub(rawCommand, 3) + args = table.concat(args, ' ') local name = GetPlayerName(source) if Config.EnableESXIdentity then name = GetCharacterName(source) end - TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), rawCommand, { 255, 0, 0 }) + TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), args, { 255, 0, 0 }) + print(('%s: %s'):format(name, args)) end, false) RegisterCommand('do', function(source, args, rawCommand) @@ -48,30 +46,16 @@ RegisterCommand('do', function(source, args, rawCommand) return end - rawCommand = string.sub(rawCommand, 3) + args = table.concat(args, ' ') local name = GetPlayerName(source) if Config.EnableESXIdentity then name = GetCharacterName(source) end - TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', name), rawCommand, { 0, 0, 255 }) -end, false) - -RegisterCommand('news', function(source, args, rawCommand) - if source == 0 then - print('esx_rpchat: you can\'t use this command from rcon!') - return - end - - rawCommand = string.sub(rawCommand, 5) - local name = GetPlayerName(source) - if Config.EnableESXIdentity then name = GetCharacterName(source) end - - TriggerClientEvent('chat:addMessage', -1, { args = { _U('news_prefix', name), rawCommand }, color = { 249, 166, 0 } }) + TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', name), args, { 0, 0, 255 }) + print(('%s: %s'):format(name, args)) end, false) function GetCharacterName(source) - -- fetch identity in sync - local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', - { + local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', { ['@identifier'] = GetPlayerIdentifiers(source)[1] }) @@ -79,7 +63,7 @@ function GetCharacterName(source) if Config.OnlyFirstname then return result[1].firstname else - return result[1].firstname .. ' ' .. result[1].lastname + return ('%s %s'):format(result[1].firstname, result[1].lastname) end else return GetPlayerName(source)