Adds new timer

This commit is contained in:
nearbyplayer
2017-08-21 09:26:32 -04:00
parent fdad0691cd
commit f48f934102
6 changed files with 198 additions and 9 deletions
+127 -5
View File
@@ -118,12 +118,117 @@ function StartRespawnTimer()
StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end)
end
end)
end
function RespawnTimer()
local timer = Config.RespawnDelayAfterRPDeath
local allowRespawn = Config.RespawnDelayAfterRPDeath/2
local enoughMoney = false
local money = 0
if IsDead and Config.ShowDeathTimer then
ESX.TriggerServerCallback('esx_ambulancejob:getBankMoney', function(money)
if money >= Config.EarlyRespawnFineAmount then
enoughMoney = true
else
enoughMoney = false
end
end)
Citizen.CreateThread(function()
while timer > 0 and IsDead do
raw_seconds = timer/1000
raw_minutes = raw_seconds/60
minutes = stringsplit(raw_minutes, ".")[1]
seconds = stringsplit(raw_seconds-(minutes*60), ".")[1]
if Config.EarlyRespawn and Config.EarlyRespawnFine and enoughMoney then
SetTextFont(4)
SetTextProportional(0)
SetTextScale(0.0, 0.5)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(_U('please_wait') .. minutes .. _U('minutes') .. seconds .. _U('seconds_fine') .. Config.EarlyRespawnFineAmount .. _U('press_respawn_fine'))
SetTextCentre(true)
DrawText(0.5, 0.8)
timer = timer - 15
Citizen.Wait(0)
if IsControlPressed(0, Keys['E']) then
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(0)
end
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeathRemoveMoney', function()
TriggerServerEvent('esx_ambulancejob:removeAccountMoney', source)
TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos)
RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos)
StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end
else
SetTextFont(4)
SetTextProportional(0)
SetTextScale(0.0, 0.5)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(_U('please_wait') .. minutes .. _U('minutes') .. seconds .. _U('seconds'))
SetTextCentre(true)
DrawText(0.5, 0.8)
timer = timer - 15
Citizen.Wait(0)
end
end
while timer <= 0 and IsDead do
SetTextFont(4)
SetTextProportional(0)
SetTextScale(0.0, 0.5)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(_U('press_respawn'))
SetTextCentre(true)
DrawText(0.5, 0.8)
Citizen.Wait(0)
if IsControlPressed(0, Keys['E']) then
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(0)
end
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function()
TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos)
RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos)
--StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end
end
end)
end
end
function TeleportFadeEffect(entity, coords)
@@ -531,10 +636,14 @@ AddEventHandler('esx_ambulancejob:onPlayerDeath', function()
IsDead = true
StartRespawnTimer()
StartRespawnToHospitalMenuTimer()
if Config.ShowDeathTimer == true then
RespawnTimer()
else
StartRespawnTimer()
StartRespawnToHospitalMenuTimer()
StartScreenEffect('DeathFailOut', 0, false)
end
StartScreenEffect('DeathFailOut', 0, false)
end)
RegisterNetEvent('esx_ambulancejob:revive')
@@ -745,3 +854,16 @@ Citizen.CreateThread(function()
EnableMpDlcMaps(true)
RequestIpl('Coroner_Int_on') -- Morgue
end)
-- String string
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
+4
View File
@@ -7,6 +7,10 @@ Config.RemoveWeaponsAfterRPDeath = true
Config.RemoveCashAfterRPDeath = true
Config.RemoveItemsAfterRPDeath = true
Config.EnablePlayerManagement = false
Config.ShowDeathTimer = true
Config.EarlyRespawn = true
Config.EarlyRespawnFine = true
Config.EarlyRespawnFineAmount = 500
Config.Locale = 'fr'
Config.Zones = {
+8
View File
@@ -35,4 +35,12 @@ Locales['br'] = {
-- Death
['respawn_at_hospital'] = 'você quer ser transportado para o hospital?',
['yes'] = 'sim',
['please_wait'] = 'por favor, espere ~b~',
['minutes'] = ' minutos ',
['seconds_fine'] = ' segundos ~w~para respawn | Respawn agora para ~g~$',
['seconds'] = ' segundos ~w~para respawn.',
['press_respawn_fine'] = '~w~ [Pressione ~b~E~w~]',
['press_respawn'] = 'pressione [~b~E~w~] para respawn.',
-- Revive
['revive_help'] = 'reviver um jogador',
}
+8
View File
@@ -35,4 +35,12 @@ Locales['en'] = {
-- Death
['respawn_at_hospital'] = 'do you want to be transported to the hospital?',
['yes'] = 'yes',
['please_wait'] = 'please wait ~b~',
['minutes'] = ' minutes ',
['seconds_fine'] = ' seconds ~w~to respawn | Respawn now for ~g~$',
['seconds'] = ' seconds ~w~to respawn.',
['press_respawn_fine'] = '~w~ [Press ~b~E~w~]',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
-- Revive
['revive_help'] = 'revive a player',
}
+8
View File
@@ -35,4 +35,12 @@ Locales['fr'] = {
-- Death
['respawn_at_hospital'] = 'voulez-vous être transporté à l\'hôpital ?',
['yes'] = 'oui',
['please_wait'] = 's\'il vous plaît, attendez ~b~',
['minutes'] = ' minutes ',
['seconds_fine'] = ' secondes ~w~to réapparaître | Réapparaître maintenant pour ~g~$',
['seconds'] = ' secondes ~w~pour réapparaître.',
['press_respawn_fine'] = '~w~ [Presse ~b~E~w~]',
['press_respawn'] = 'appuyez [~b~E~w~] sur pour réapparaître.',
-- Revive
['revive_help'] = 'relancer un joueur',
}
+43 -4
View File
@@ -34,6 +34,45 @@ ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(
end)
ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeathRemoveMoney', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
if Config.RemoveCashAfterRPDeath then
xPlayer.set('money', 0)
xPlayer.setAccountMoney('black_money', 0)
end
if Config.EarlyRespawn and Config.EarlyRespawnFine then
xPlayer.removeAccountMoney('bank', Config.EarlyRespawnFineAmount)
end
if Config.RemoveItemsAfterRPDeath then
for i=1, #xPlayer.inventory, 1 do
if xPlayer.inventory[i].count > 0 then
xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0)
end
end
end
if Config.RemoveWeaponsAfterRPDeath then
for i=1, #xPlayer.loadout, 1 do
xPlayer.removeWeapon(xPlayer.loadout[i].name)
end
end
cb()
end)
ESX.RegisterServerCallback('esx_ambulancejob:getBankMoney', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local money = xPlayer.getAccount('bank').money
cb(money)
end)
TriggerEvent('esx_phone:registerCallback', function(source, phoneNumber, message, anon)
local xPlayer = ESX.GetPlayerFromId(source)
@@ -48,11 +87,11 @@ TriggerEvent('esx_phone:registerCallback', function(source, phoneNumber, message
end
end
end
end)
TriggerEvent('es:addGroupCommand', 'respawn', 'admin', function(source, args, user)
TriggerEvent('es:addGroupCommand', 'revive', 'admin', function(source, args, user)
if args[2] ~= nil then
TriggerClientEvent('esx_ambulancejob:revive', tonumber(args[2]))
else
@@ -61,4 +100,4 @@ TriggerEvent('es:addGroupCommand', 'respawn', 'admin', function(source, args, us
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
end, {help = 'Respawn', params = {{name = 'id'}}})
end, {help = _U('revive_help'), params = {{name = 'id'}}})