daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. ################################################################
  3. - Creator: Jyben
  4. - Date: 30/04/2017
  5. - Url: https://github.com/Jyben/emergency
  6. - Licence: Apache 2.0
  7. ################################################################
  8. --]]
  9.  
  10. local Keys = {
  11.     ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  12.     ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  13.     ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  14.     ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  15.     ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  16.     ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  17.     ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  18.     ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  19.     ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  20. }
  21.  
  22. local lang = 'en'
  23.  
  24. local txt = {
  25.   ['fr'] = {
  26.         ['inComa'] = '~r~Vous êtes dans le coma',
  27.         ['accident'] = 'Un accident s\'est produit',
  28.         ['murder'] = 'Tentative de meurtre',
  29.         ['ambIsComming'] = 'Une ~b~ambulance~s~ est en route !',
  30.         ['res'] = 'Vous avez été réanimé',
  31.         ['ko'] = 'Vous êtes KO !',
  32.         ['callAmb'] = 'Appuyez sur ~g~E~s~ pour appeler une ambulance',
  33.         ['respawn'] = 'Appuyez sur ~r~X~s~ pour respawn',
  34.         ['youCallAmb'] = 'Vous avez appelé une ~b~ambulance~s~'
  35.   },
  36.  
  37.     ['en'] = {
  38.         ['inComa'] = '~r~Jste v komatu',
  39.         ['accident'] = 'Doslo k nehode',
  40.         ['murder'] = 'Pokus o vrazdu.',
  41.         ['ko'] = 'Dostal jsi KO !'
  42.     }
  43. }
  44.  
  45. local isDead = false
  46. local isKO = false
  47. local emergencyComes = false
  48.  
  49. --[[
  50. ################################
  51.             THREADS
  52. ################################
  53. --]]
  54.  
  55. Citizen.CreateThread(function()
  56.   while true do
  57.     Citizen.Wait(1)
  58.     --NetworkResurrectLocalPlayer(357.757, -597.202, 28.6314, true, true, false)
  59.     local playerPed = GetPlayerPed(-1)
  60.     local playerID = PlayerId()
  61.     local currentPos = GetEntityCoords(playerPed, true)
  62.     local previousPos
  63.  
  64.     isDead = IsEntityDead(playerPed)
  65.  
  66.     if isKO and previousPos ~= currentPos then
  67.       isKO = false
  68.     end
  69.  
  70.     if (GetEntityHealth(playerPed) < 120 and not isDead and not isKO) then
  71.       if (IsPedInMeleeCombat(playerPed)) then
  72.         SetPlayerKO(playerID, playerPed)
  73.       end
  74.     end
  75.  
  76.     previousPos = currentPos
  77.   end
  78. end)
  79.  
  80. Citizen.CreateThread(function()
  81.     while true do
  82.         Citizen.Wait(0)
  83.     if IsEntityDead(PlayerPedId()) then
  84.             StartScreenEffect("DeathFailOut", 0, 0)
  85.         ShakeGameplayCam("DEATH_FAIL_IN_EFFECT_SHAKE", 1.0)
  86.         local scaleform = RequestScaleformMovie("MP_BIG_MESSAGE_FREEMODE")
  87.         while not(HasScaleformMovieLoaded(scaleform)) do
  88.             Citizen.Wait(0)
  89.         end
  90.         PushScaleformMovieFunction(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE")
  91.         BeginTextComponent("STRING")
  92.         AddTextComponentString(txt[lang]['inComa'])
  93.         EndTextComponent()
  94.         PopScaleformMovieFunctionVoid()
  95.         Citizen.Wait(500)
  96.         while IsEntityDead(PlayerPedId()) do
  97.             Citizen.Wait(0)
  98.             DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
  99.         end
  100.         StopScreenEffect("DeathFailOut")
  101.     end
  102. end)
  103.  
  104. --[[
  105. ################################
  106.             EVENTS
  107. ################################
  108. --]]
  109.  
  110. AddEventHandler("playerSpawned", function(spawn)
  111.     exports.spawnmanager:setAutoSpawn(false)
  112. end)
  113.  
  114. -- Triggered when player died by environment
  115. AddEventHandler('baseevents:onPlayerDied',
  116.   function(playerId, reasonID)
  117.     local reason = txt[lang]['accident']
  118.         OnPlayerDied(playerId, reasonID, reason)
  119.     end
  120. )
  121.  
  122. -- Triggered when player died by an another player
  123. AddEventHandler('baseevents:onPlayerKilled',
  124.   function(playerId, playerKill, reasonID)
  125.     local reason = txt[lang]['murder']
  126.         OnPlayerDied(playerId, reasonID, reason)
  127.     end
  128. )
  129.  
  130.  
  131. --[[
  132. ################################
  133.         BUSINESS METHODS
  134. ################################
  135. --]]
  136.  
  137. function SetPlayerKO(playerID, playerPed)
  138.   isKO = true
  139.   SendNotification(txt[lang]['ko'])
  140.   SetPedToRagdoll(playerPed, 6000, 6000, 0, 0, 0, 0)
  141. end
  142.  
  143. function SendNotification(message)
  144.   SetNotificationTextEntry('STRING')
  145.   AddTextComponentString(message)
  146.   DrawNotification(false, false)
  147. end
  148.  
  149.  
  150.  
  151.  
  152. --[[
  153. ################################
  154.         USEFUL METHODS
  155. ################################
  156. --]]
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top