Skip to content

Commit

Permalink
feat: standardize notifications and get rid of chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
m3ftwz committed Feb 18, 2022
1 parent 084dc23 commit 1edf290
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [esx]/es_extended/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions [esx]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion [esx]/es_extended/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion [esx_addons]/esx_basicneeds/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
}})
Expand Down

0 comments on commit 1edf290

Please sign in to comment.