Jump to content

fivem - resources Adding logs to: ESX Revive

  • jd_logsv3

JokeDevil
 Share

Recommended Posts

  • Lead Developer

Here i will explain how to add the export to the esx_ambulancejob revive command

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_ambulancejob:revive')

to this:

tPlayer.triggerEvent('esx_ambulancejob:revive')

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_logsV3:createLog({ 
	EmbedMessage = "**"..GetPlayerName(xPlayer.source).."** has revived **".. GetPlayerName(tPlayer.source).."**", 
	player_id = xPlayer.source, 
	player_2_id = tPlayer.source, 
	channel = "revive", 
})

The Embed message will show: Player_A has revived Player_B

SO TO SUM UP THE CODE WE HAVE CHANGED HERE IS A BEFORE AND AFTER:

Before:

ESX.RegisterCommand('revive', 'admin', function(xPlayer, args, showError) 
	args.playerId.triggerEvent('esx_ambulancejob:revive') 
end, true, {help = _U('revive_help'), validate = true, arguments = { 
	{name = 'playerId', help = 'The player id', type = 'player'} 
}})

After:

ESX.RegisterCommand('revive', 'admin', function(xPlayer, args, showError)
	tPlayer = ESX.GetPlayerFromId(args.playerId) 
	tPlayer.triggerEvent('esx_ambulancejob:revive')
	exports.JD_logs:createLog({ 
		EmbedMessage = "**"..GetPlayerName(xPlayer.source).."** has revived **".. GetPlayerName(tPlayer.source).."**", 
		player_id = xPlayer.source, 
		player_2_id = tPlayer.source, 
		channel = "revive", 
	}) 
end, true, {help = _U('revive_help'), validate = true, arguments = { 
	{name = 'playerId', help = 'The player id', type = 'playerId'} 
}})

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • General Statistics

    37
    Total Topics
    64
    Total Posts
    473
    Total Members
    26
    Most Online
    DJgaming
    Newest Member
    DJgaming
    Joined


×
×
  • Create New...