mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 02:08:55 +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
|
||||
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.
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ description 'ESX RP Chat'
|
||||
version '1.3.1'
|
||||
|
||||
server_scripts {
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'@es_extended/locale.lua',
|
||||
'locales/sv.lua',
|
||||
'locales/en.lua',
|
||||
|
||||
+8
-10
@@ -1,22 +1,20 @@
|
||||
RegisterNetEvent('esx_rpchat:sendProximityMessage')
|
||||
AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color)
|
||||
local source = PlayerId()
|
||||
local player = PlayerId()
|
||||
local target = GetPlayerFromServerId(playerId)
|
||||
|
||||
local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target)
|
||||
local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed)
|
||||
local playerPed, targetPed = PlayerPedId(), GetPlayerPed(target)
|
||||
local playerCoords, targetCoords = GetEntityCoords(playerPed), GetEntityCoords(targetPed)
|
||||
|
||||
if target == source then
|
||||
TriggerEvent('chat:addMessage', { args = { title, message }, color = color })
|
||||
elseif GetDistanceBetweenCoords(sourceCoords, targetCoords, true) < 20 then
|
||||
TriggerEvent('chat:addMessage', { args = { title, message }, color = color })
|
||||
if target == player or #(playerCoords - targetCoords) < 20 then
|
||||
TriggerEvent('chat:addMessage', {args = {title, message}, color = color})
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
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', '/do', _U('do_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', '/do', _U('do_help'), {{name = _U('generic_argument_name'), help = _U('generic_argument_help')}})
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
Config = {}
|
||||
Config.Locale = 'en'
|
||||
Config = {}
|
||||
|
||||
Config.EnableESXIdentity = false -- only turn this on if you are using esx_identity and want to use RP names
|
||||
Config.OnlyFirstname = false
|
||||
+1
-1
@@ -4,7 +4,7 @@ Locales['fi'] = {
|
||||
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
||||
['me_help'] = 'teet jotain',
|
||||
['me_prefix'] = 'me | %s',
|
||||
['do_help'] = 'roolipeliä tiedot', --TODO: check translation
|
||||
['do_help'] = 'roolipeliä tiedot',
|
||||
['do_prefix'] = 'do | %s',
|
||||
['generic_argument_name'] = 'viesti',
|
||||
['generic_argument_help'] = 'viestin sisältö',
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ Locales['fr'] = {
|
||||
['twt_prefix'] = '^0[^4Twitter^0] (^5@%s^0)',
|
||||
['me_help'] = 'action personnelle',
|
||||
['me_prefix'] = 'me | %s',
|
||||
['do_help'] = 'RP information', --TODO: check translation
|
||||
['do_help'] = 'RP information',
|
||||
['do_prefix'] = 'faire | %s',
|
||||
['generic_argument_name'] = 'message',
|
||||
['generic_argument_help'] = 'le message',
|
||||
|
||||
+38
-44
@@ -1,71 +1,65 @@
|
||||
AddEventHandler('es:invalidCommandHandler', function(source, command_args, user)
|
||||
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)
|
||||
|
||||
AddEventHandler('chatMessage', function(source, name, message)
|
||||
AddEventHandler('chatMessage', function(playerId, playerName, 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 } })
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
if xPlayer then playerName = xPlayer.getName() end
|
||||
TriggerClientEvent('chat:addMessage', -1, {args = {_U('ooc_prefix', playerName), message}, color = {128, 128, 128}})
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand('twt', function(source, args, rawCommand)
|
||||
if source == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
||||
return
|
||||
RegisterCommand('twt', function(playerId, args, rawCommand)
|
||||
if playerId == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from console!')
|
||||
else
|
||||
args = table.concat(args, ' ')
|
||||
local playerName = GetRealPlayerName(playerId)
|
||||
|
||||
TriggerClientEvent('chat:addMessage', -1, {args = {_U('twt_prefix', playerName), args}, color = {0, 153, 204}})
|
||||
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)
|
||||
|
||||
RegisterCommand('me', function(source, args, rawCommand)
|
||||
RegisterCommand('me', function(playerId, args, rawCommand)
|
||||
if source == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
||||
return
|
||||
print('esx_rpchat: you can\'t use this command from console!')
|
||||
else
|
||||
args = table.concat(args, ' ')
|
||||
local playerName = GetRealPlayerName(playerId)
|
||||
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', playerName), args, {255, 0, 0})
|
||||
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)
|
||||
|
||||
RegisterCommand('do', function(source, args, rawCommand)
|
||||
RegisterCommand('do', function(playerId, args, rawCommand)
|
||||
if source == 0 then
|
||||
print('esx_rpchat: you can\'t use this command from rcon!')
|
||||
return
|
||||
print('esx_rpchat: you can\'t use this command from console!')
|
||||
else
|
||||
args = table.concat(args, ' ')
|
||||
local playerName = GetRealPlayerName(playerId)
|
||||
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('do_prefix', playerName), args, {0, 0, 255})
|
||||
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)
|
||||
|
||||
function GetCharacterName(source)
|
||||
local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = GetPlayerIdentifiers(source)[1]
|
||||
})
|
||||
function GetRealPlayerName(playerId)
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
|
||||
if result[1] and result[1].firstname and result[1].lastname then
|
||||
if Config.OnlyFirstname then
|
||||
return result[1].firstname
|
||||
if xPlayer then
|
||||
if Config.EnableESXIdentity then
|
||||
if Config.OnlyFirstname then
|
||||
return xPlayer.get('firstName')
|
||||
else
|
||||
return xPlayer.getName()
|
||||
end
|
||||
else
|
||||
return ('%s %s'):format(result[1].firstname, result[1].lastname)
|
||||
return xPlayer.getName()
|
||||
end
|
||||
else
|
||||
return GetPlayerName(source)
|
||||
return GetPlayerName(playerId)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user