mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +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)
|
TaskWarpPedIntoVehicle(ESX.PlayerData.ped, vehicle, -1)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
TriggerEvent('chat:addMessage', { args = { '^1SYSTEM', 'Invalid vehicle model.' } })
|
ESX.ShowNotification('Invalid vehicle model.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -124,14 +124,14 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
|
|||||||
if playerId == 0 then
|
if playerId == 0 then
|
||||||
print(('[^3WARNING^7] %s^7'):format(error))
|
print(('[^3WARNING^7] %s^7'):format(error))
|
||||||
else
|
else
|
||||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', error}})
|
xPlayer.showNotification(error)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
cb(xPlayer or false, args, function(msg)
|
cb(xPlayer or false, args, function(msg)
|
||||||
if playerId == 0 then
|
if playerId == 0 then
|
||||||
print(('[^3WARNING^7] %s^7'):format(msg))
|
print(('[^3WARNING^7] %s^7'):format(msg))
|
||||||
else
|
else
|
||||||
xPlayer.triggerEvent('chat:addMessage', {args = {'^1SYSTEM', msg}})
|
xPlayer.showNotification(msg)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -301,10 +301,11 @@ function loadESXPlayer(identifier, playerId, isNew)
|
|||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('chatMessage', function(playerId, author, message)
|
AddEventHandler('chatMessage', function(playerId, author, message)
|
||||||
|
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||||
if message:sub(1, 1) == '/' and playerId > 0 then
|
if message:sub(1, 1) == '/' and playerId > 0 then
|
||||||
CancelEvent()
|
CancelEvent()
|
||||||
local commandName = message:sub(1):gmatch("%w+")()
|
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
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ end)
|
|||||||
|
|
||||||
ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError)
|
ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError)
|
||||||
args.playerId.triggerEvent('esx_basicneeds:healPlayer')
|
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 = {
|
end, true, {help = 'Heal a player, or yourself - restores thirst, hunger and health.', validate = true, arguments = {
|
||||||
{name = 'playerId', help = 'the player id', type = 'player'}
|
{name = 'playerId', help = 'the player id', type = 'player'}
|
||||||
}})
|
}})
|
||||||
|
|||||||
Reference in New Issue
Block a user