Removed mysql database usage

This commit is contained in:
ElPumpo
2020-01-15 10:47:02 +01:00
parent edc8bf4dd9
commit 7fc962a83c
7 changed files with 50 additions and 60 deletions
+38 -44
View File
@@ -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