mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
feat: standardize notifications and get rid of chat messages
This commit is contained in:
@@ -257,7 +257,7 @@ AddEventHandler('esx:spawnVehicle', function(vehicle)
|
||||
TaskWarpPedIntoVehicle(ESX.PlayerData.ped, vehicle, -1)
|
||||
end)
|
||||
else
|
||||
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Invalid vehicle model.' } })
|
||||
ESX.ShowNotification('Invalid vehicle model.')
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -124,14 +124,14 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
|
||||
if playerId == 0 then
|
||||
print(('[^3WARNING^7] %s^7'):format(error))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', error}})
|
||||
xPlayer.showNotification(error)
|
||||
end
|
||||
else
|
||||
cb(xPlayer or false, args, function(msg)
|
||||
if playerId == 0 then
|
||||
print(('[^3WARNING^7] %s^7'):format(msg))
|
||||
else
|
||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', msg}})
|
||||
xPlayer.showNotification(msg)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -301,10 +301,11 @@ function loadESXPlayer(identifier, playerId, isNew)
|
||||
end
|
||||
|
||||
AddEventHandler('chatMessage', function(playerId, author, message)
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
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)}})
|
||||
xPlayer.showNotification(_U('commanderror_invalidcommand', commandName))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ end)
|
||||
|
||||
ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError)
|
||||
args.playerId.triggerEvent('esx_basicneeds:healPlayer')
|
||||
args.playerId.triggerEvent('chat:addMessage', {args = {'^5HEAL', 'You have been healed.'}})
|
||||
args.playerId.showNotification('You have been healed.')
|
||||
end, true, {help = 'Heal a player, or yourself - restores thirst, hunger and health.', validate = true, arguments = {
|
||||
{name = 'playerId', help = 'the player id', type = 'player'}
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user