Merge pull request #4 from thelindat/main

feat(esx_ambulancejob): Add support for esx_ambulancejob:revive server event through txAdmin console
This commit is contained in:
ESXCrackhead
2021-07-03 10:50:22 -05:00
committed by GitHub
+29 -14
View File
@@ -6,26 +6,41 @@ TriggerEvent('esx_society:registerSociety', 'ambulance', 'Ambulance', 'society_a
RegisterNetEvent('esx_ambulancejob:revive')
AddEventHandler('esx_ambulancejob:revive', function(playerId)
local xPlayer = ESX.GetPlayerFromId(source)
playerId = tonumber(playerId)
if source == '' and GetInvokingResource() == 'monitor' then -- txAdmin support
local xTarget = ESX.GetPlayerFromId(playerId)
if xTarget then
if deadPlayers[playerId] then
print(_U('revive_complete', xTarget.name))
xTarget.triggerEvent('esx_ambulancejob:revive')
else
print(_U('player_not_unconscious'))
end
else
print(_U('revive_fail_offline'))
end
else
local xPlayer = source and ESX.GetPlayerFromId(source)
if xPlayer and xPlayer.job.name == 'ambulance' then
local xTarget = ESX.GetPlayerFromId(playerId)
if xPlayer and xPlayer.job.name == 'ambulance' then
local xTarget = ESX.GetPlayerFromId(playerId)
if xTarget then
if deadPlayers[playerId] then
if Config.ReviveReward > 0 then
xPlayer.showNotification(_U('revive_complete_award', xTarget.name, Config.ReviveReward))
xPlayer.addMoney(Config.ReviveReward)
xTarget.triggerEvent('esx_ambulancejob:revive')
if xTarget then
if deadPlayers[playerId] then
if Config.ReviveReward > 0 then
xPlayer.showNotification(_U('revive_complete_award', xTarget.name, Config.ReviveReward))
xPlayer.addMoney(Config.ReviveReward)
xTarget.triggerEvent('esx_ambulancejob:revive')
else
xPlayer.showNotification(_U('revive_complete', xTarget.name))
xTarget.triggerEvent('esx_ambulancejob:revive')
end
else
xPlayer.showNotification(_U('revive_complete', xTarget.name))
xTarget.triggerEvent('esx_ambulancejob:revive')
xPlayer.showNotification(_U('player_not_unconscious'))
end
else
xPlayer.showNotification(_U('player_not_unconscious'))
xPlayer.showNotification(_U('revive_fail_offline'))
end
else
xPlayer.showNotification(_U('revive_fail_offline'))
end
end
end)