mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Removed mysql database usage
This commit is contained in:
@@ -27,7 +27,7 @@ git clone https://github.com/ESX-Org/esx_rpchat [esx]/esx_rpchat
|
|||||||
### License
|
### License
|
||||||
esx_rpchat - RP chat for ESX
|
esx_rpchat - RP chat for ESX
|
||||||
|
|
||||||
Copyright (C) 2015-2018 Jérémie N'gadi
|
Copyright (C) 2015-2020 Jérémie N'gadi
|
||||||
|
|
||||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ description 'ESX RP Chat'
|
|||||||
version '1.3.1'
|
version '1.3.1'
|
||||||
|
|
||||||
server_scripts {
|
server_scripts {
|
||||||
'@mysql-async/lib/MySQL.lua',
|
|
||||||
'@es_extended/locale.lua',
|
'@es_extended/locale.lua',
|
||||||
'locales/sv.lua',
|
'locales/sv.lua',
|
||||||
'locales/en.lua',
|
'locales/en.lua',
|
||||||
|
|||||||
+8
-10
@@ -1,22 +1,20 @@
|
|||||||
RegisterNetEvent('esx_rpchat:sendProximityMessage')
|
RegisterNetEvent('esx_rpchat:sendProximityMessage')
|
||||||
AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color)
|
AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color)
|
||||||
local source = PlayerId()
|
local player = PlayerId()
|
||||||
local target = GetPlayerFromServerId(playerId)
|
local target = GetPlayerFromServerId(playerId)
|
||||||
|
|
||||||
local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target)
|
local playerPed, targetPed = PlayerPedId(), GetPlayerPed(target)
|
||||||
local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed)
|
local playerCoords, targetCoords = GetEntityCoords(playerPed), GetEntityCoords(targetPed)
|
||||||
|
|
||||||
if target == source then
|
if target == player or #(playerCoords - targetCoords) < 20 then
|
||||||
TriggerEvent('chat:addMessage', { args = { title, message }, color = color })
|
TriggerEvent('chat:addMessage', {args = {title, message}, color = color})
|
||||||
elseif GetDistanceBetweenCoords(sourceCoords, targetCoords, true) < 20 then
|
|
||||||
TriggerEvent('chat:addMessage', { args = { title, message }, color = color })
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
TriggerEvent('chat:addSuggestion', '/twt', _U('twt_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
|
TriggerEvent('chat:addSuggestion', '/twt', _U('twt_help'), {{name = _U('generic_argument_name'), help = _U('generic_argument_help')}})
|
||||||
TriggerEvent('chat:addSuggestion', '/me', _U('me_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
|
TriggerEvent('chat:addSuggestion', '/me', _U('me_help'), {{name = _U('generic_argument_name'), help = _U('generic_argument_help')}})
|
||||||
TriggerEvent('chat:addSuggestion', '/do', _U('do_help'), { { name = _U('generic_argument_name'), help = _U('generic_argument_help') } } )
|
TriggerEvent('chat:addSuggestion', '/do', _U('do_help'), {{name = _U('generic_argument_name'), help = _U('generic_argument_help')}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
Config = {}
|
Config = {}
|
||||||
Config.Locale = 'en'
|
|
||||||
|
|
||||||
Config.EnableESXIdentity = false -- only turn this on if you are using esx_identity and want to use RP names
|
Config.EnableESXIdentity = false -- only turn this on if you are using esx_identity and want to use RP names
|
||||||
Config.OnlyFirstname = false
|
Config.OnlyFirstname = false
|
||||||
+1
-1
@@ -4,7 +4,7 @@ Locales['fi'] = {
|
|||||||
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
||||||
['me_help'] = 'teet jotain',
|
['me_help'] = 'teet jotain',
|
||||||
['me_prefix'] = 'me | %s',
|
['me_prefix'] = 'me | %s',
|
||||||
['do_help'] = 'roolipeliä tiedot', --TODO: check translation
|
['do_help'] = 'roolipeliä tiedot',
|
||||||
['do_prefix'] = 'do | %s',
|
['do_prefix'] = 'do | %s',
|
||||||
['generic_argument_name'] = 'viesti',
|
['generic_argument_name'] = 'viesti',
|
||||||
['generic_argument_help'] = 'viestin sisältö',
|
['generic_argument_help'] = 'viestin sisältö',
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ Locales['fr'] = {
|
|||||||
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
||||||
['me_help'] = 'action personnelle',
|
['me_help'] = 'action personnelle',
|
||||||
['me_prefix'] = 'me | %s',
|
['me_prefix'] = 'me | %s',
|
||||||
['do_help'] = 'RP information', --TODO: check translation
|
['do_help'] = 'RP information',
|
||||||
['do_prefix'] = 'faire | %s',
|
['do_prefix'] = 'faire | %s',
|
||||||
['generic_argument_name'] = 'message',
|
['generic_argument_name'] = 'message',
|
||||||
['generic_argument_help'] = 'le message',
|
['generic_argument_help'] = 'le message',
|
||||||
|
|||||||
+38
-44
@@ -1,71 +1,65 @@
|
|||||||
AddEventHandler('es:invalidCommandHandler', function(source, command_args, user)
|
AddEventHandler('es:invalidCommandHandler', function(source, command_args, user)
|
||||||
CancelEvent()
|
CancelEvent()
|
||||||
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', _U('unknown_command', command_args[1]) } })
|
TriggerClientEvent('chat:addMessage', source, {args = {'^1SYSTEM', _U('unknown_command', command_args[1])}})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('chatMessage', function(source, name, message)
|
AddEventHandler('chatMessage', function(playerId, playerName, message)
|
||||||
if string.sub(message, 1, string.len('/')) ~= '/' then
|
if string.sub(message, 1, string.len('/')) ~= '/' then
|
||||||
CancelEvent()
|
CancelEvent()
|
||||||
|
|
||||||
if Config.EnableESXIdentity then name = GetCharacterName(source) end
|
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||||
TriggerClientEvent('chat:addMessage', -1, { args = { _U('ooc_prefix', name), message }, color = { 128, 128, 128 } })
|
if xPlayer then playerName = xPlayer.getName() end
|
||||||
|
TriggerClientEvent('chat:addMessage', -1, {args = {_U('ooc_prefix', playerName), message}, color = {128, 128, 128}})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterCommand('twt', function(source, args, rawCommand)
|
RegisterCommand('twt', function(playerId, args, rawCommand)
|
||||||
if source == 0 then
|
if playerId == 0 then
|
||||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
print('esx_rpchat: you can\'t use this command from console!')
|
||||||
return
|
else
|
||||||
|
args = table.concat(args, ' ')
|
||||||
|
local playerName = GetRealPlayerName(playerId)
|
||||||
|
|
||||||
|
TriggerClientEvent('chat:addMessage', -1, {args = {_U('twt_prefix', playerName), args}, color = {0, 153, 204}})
|
||||||
end
|
end
|
||||||
|
|
||||||
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), args }, color = { 0, 153, 204 } })
|
|
||||||
--print(('%s: %s'):format(name, args))
|
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
RegisterCommand('me', function(source, args, rawCommand)
|
RegisterCommand('me', function(playerId, args, rawCommand)
|
||||||
if source == 0 then
|
if source == 0 then
|
||||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
print('esx_rpchat: you can\'t use this command from console!')
|
||||||
return
|
else
|
||||||
|
args = table.concat(args, ' ')
|
||||||
|
local playerName = GetRealPlayerName(playerId)
|
||||||
|
|
||||||
|
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', playerName), args, {255, 0, 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
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), args, { 255, 0, 0 })
|
|
||||||
--print(('%s: %s'):format(name, args))
|
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
RegisterCommand('do', function(source, args, rawCommand)
|
RegisterCommand('do', function(playerId, args, rawCommand)
|
||||||
if source == 0 then
|
if source == 0 then
|
||||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
print('esx_rpchat: you can\'t use this command from console!')
|
||||||
return
|
else
|
||||||
|
args = table.concat(args, ' ')
|
||||||
|
local playerName = GetRealPlayerName(playerId)
|
||||||
|
|
||||||
|
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', playerName), args, {0, 0, 255})
|
||||||
end
|
end
|
||||||
|
|
||||||
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), args, { 0, 0, 255 })
|
|
||||||
--print(('%s: %s'):format(name, args))
|
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
function GetCharacterName(source)
|
function GetRealPlayerName(playerId)
|
||||||
local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {
|
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||||
['@identifier'] = GetPlayerIdentifiers(source)[1]
|
|
||||||
})
|
|
||||||
|
|
||||||
if result[1] and result[1].firstname and result[1].lastname then
|
if xPlayer then
|
||||||
if Config.OnlyFirstname then
|
if Config.EnableESXIdentity then
|
||||||
return result[1].firstname
|
if Config.OnlyFirstname then
|
||||||
|
return xPlayer.get('firstName')
|
||||||
|
else
|
||||||
|
return xPlayer.getName()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return ('%s %s'):format(result[1].firstname, result[1].lastname)
|
return xPlayer.getName()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return GetPlayerName(source)
|
return GetPlayerName(playerId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user