**Here i will explain how to add the export to the esx_basicneeds /heal
command
The file we will edit is: esx_basicneeds/server/main.lua
Since we don’t have the second player id available we need to change the code for the revive command to get the information we need.
First we need to change getting the player to getting the player id.
{name = 'playerId', help = 'The player id', type = 'player'}
By default it will return a player but we need the id so we change it to this:
{name = 'playerId', help = 'The player id', type = 'playerId'}
But since we now have the player id and not the player we need to get the player to revive them.
For that we add this line of code:
tPlayer = ESX.GetPlayerFromId(args.playerId)
Good so now we have the player id and the player we want to revive.
To revive the player we need to change this
args.playerId.triggerEvent('esx_basicneeds:healPlayer')
to this:
tPlayer.triggerEvent('esx_basicneeds:healPlayer')
This is because we changed the player to the player id.
Now that the player has been revived we will make the log to show in discord.
We add the export right below the revive function.
exports.JD_logs:createLog({
EmbedMessage = "**"..GetPlayerName(xPlayer.source).."** healed **".. GetPlayerName(tPlayer.source).."**",
color = "#FFFFFF",
player_id = xPlayer.source,
player_2_id = tPlayer.source,
channel = "heal",
})
The Embed message will show: Player_A healed Player_B
SO TO SUM UP THE CODE WE HAVE CHANGED HERE IS A BEFORE AND AFTER:
Before:
ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError)
args.playerId.triggerEvent('esx_basicneeds:healPlayer')
args.playerId.triggerEvent('chat:addMessage', {'^5HEAL', 'You got healed.')))}
end, true, {help = 'Heal someone.', validate = true, arguments = {
{name = 'playerId', help = 'player id', type = 'player'}
}})
After:
ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError)
tPlayer = ESX.GetPlayerFromId(args.playerId)
tPlayer.triggerEvent('esx_basicneeds:healPlayer')
tPlayer.triggerEvent('chat:addMessage', {'^5HEAL', 'You got healed.')))}
exports.JD_logs:createLog({
EmbedMessage = "**"..GetPlayerName(xPlayer.source).."** healed **".. GetPlayerName(tPlayer.source).."**",
color = "#FFFFFF",
player_id = xPlayer.source,
player_2_id = tPlayer.source,
channel = "heal",
})
end, true, {help = 'Heal someone.', validate = true, arguments = {
{name = 'playerId', help = 'player id', type = 'playerId'}
}})