daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function OnPlayerDied(playerId, reasonID, reason)
  2.     local pos = GetEntityCoords(GetPlayerPed(-1))
  3.     local isDocConnected = nil
  4.  
  5.     TriggerServerEvent('es_em:sv_getDocConnected')
  6.  
  7.     Citizen.CreateThread(
  8.         function()
  9.             while isDocConnected == nil do
  10.                 Citizen.Wait(1)
  11.  
  12.                 RegisterNetEvent('es_em:cl_getDocConnected')
  13.                 AddEventHandler('es_em:cl_getDocConnected',
  14.                     function(cb)
  15.                         isDocConnected = cb
  16.                         if isDocConnected then
  17.                             SendNotification(txt[lang]['callAmb'])
  18.                         end
  19.                     end
  20.                 )
  21.             end
  22.         end
  23.     )
  24.  
  25.     SendNotification(txt[lang]['respawn'])
  26.  
  27.     Citizen.CreateThread(
  28.         function()
  29.             local emergencyCalled = false
  30.             local notifReceivedAt = nil
  31.  
  32.             while not isRes do
  33.                 Citizen.Wait(1)
  34.  
  35.                 if (IsControlJustReleased(1, Keys['E'])) and not emergencyCalled then
  36.                     if not isDocConnected then
  37.                         ResPlayer()
  38.                     else
  39.                         notifReceivedAt = GetGameTimer()
  40.                         SendNotification(txt[lang]['youCallAmb'])
  41.                         TriggerServerEvent('es_em:sendEmergency', reason, GetPlayerServerId(PlayerId()), pos.x, pos.y, pos.z)
  42.                     end
  43.  
  44.                     emergencyCalled = true
  45.                 elseif (IsControlJustReleased(1, Keys['X'])) then
  46.                     ResPlayer()
  47.                 end
  48.  
  49.                 if (GetTimeDifference(GetGameTimer(), notifReceivedAt) > 15000) and not emergencyComes and emergencyCalled then
  50.                     SendNotification(txt[lang]['callAmb'])
  51.                     emergencyCalled = false
  52.                 end
  53.  
  54.             end
  55.  
  56.             isDocConnected = nil
  57.             isRes = false
  58.             emergencyComes = false
  59.     end)
  60. end
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top