Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.35 KB | None | 0 0
  1. local emergencycall=0
  2. local callPos=0
  3. local senderPosP
  4. local senderPosEMS
  5. local senderPosFire
  6. local callerBlipP
  7. local callerBlipEMS
  8. local callerBlipFire
  9. local pCallQ=0
  10. local emsCallQ=0
  11. local fireCallQ=0
  12.  
  13. --911 Dispatcher
  14. CreateThread(function()
  15.     while true do
  16.         Wait(0)
  17.         if(emergencycall==1) then
  18.             if IsGameKeyboardKeyJustPressed(79) then
  19.                 emergencycall=0
  20.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Contacting the Police department...")
  21.                 Wait(5000)
  22.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1The Police department dispatched units to your current location...")
  23.                 Wait(2000)
  24.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...[call ended]")
  25.                 TriggerServerEvent('911callService', 1)
  26.             end
  27.             if IsGameKeyboardKeyJustPressed(80) then
  28.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Contacting EMS services...")
  29.                 emergencycall=0
  30.                 Wait(5000)
  31.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1EMS dispatched units to your current location...")
  32.                 Wait(2000)
  33.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...[call ended]")
  34.                 TriggerServerEvent('911callService', 2)
  35.             end
  36.             if IsGameKeyboardKeyJustPressed(81) then
  37.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Contacting the Fire department...")
  38.                 emergencycall=0
  39.                 Wait(5000)
  40.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1The Fire department dispatched units to your current location...")
  41.                 Wait(2000)
  42.                 TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...[call ended]")
  43.                 TriggerServerEvent('911callService', 3)
  44.             end
  45.         end
  46.     end
  47. end)
  48.  
  49. AddEventHandler('911Call', function(amount)
  50.     CreateThread(function()
  51.         TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1911, What's your emergency?...")
  52.         TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Dial 1 ^5(NumPad1) ^1to contact the Police department...")
  53.         TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Dial 2 ^5(NumPad2) ^1to contact EMS services...")
  54.         TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Dial 3 ^5(NumPad3) ^1to contact the Fire department.")
  55.         emergencycall=1
  56.         Wait(15000)
  57.         if(emergencycall==1) then TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Sir, are you still on the line?...")
  58.         else return
  59.         end
  60.         Wait(15000)
  61.         if(emergencycall==1) then TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...Sorry, someone else might need the line...")
  62.         else return
  63.         end
  64.         TriggerEvent('chatMessage', '911', { 0, 0x99, 255 }, "^1...(call ended)")
  65.         emergencycall=0
  66.     end)
  67. end)
  68.  
  69. AddEventHandler('911callPolice', function(senderid)
  70.     CreateThread(function()
  71.         local sender = GetPlayerByServerId(tonumber(senderid))
  72.         senderPosP = table.pack(GetCharCoordinates(sender.ped, _f, _f, _f))
  73.         if(IsCharModel(GetPlayerPed(), GetHashKey("M_Y_COP", _r)) or IsCharModel(GetPlayerPed(), GetHashKey("M_Y_COP_TRAFFIC", _r)) or IsCharModel(GetPlayerPed(), GetHashKey("M_Y_STROOPER", _r)) or IsCharModel(GetPlayerPed(), GetHashKey("M_M_FBI", _r)) or IsCharModel(GetPlayerPed(), GetHashKey("M_M_FATCOP_01", _r))) then
  74.             pCallQ=1
  75.         end
  76.     end)
  77. end)
  78.  
  79. CreateThread(function()
  80.     while true do
  81.         Wait(0)
  82.         if(pCallQ==1) then
  83.             ShowText("~b~911 call in progress. Press ~g~E ~b~to accept it or ~r~N ~b~to deny it", 500)
  84.             if IsGameKeyboardKeyJustPressed(18) then
  85.                 RequestAnims("cop_wander_radio")
  86.                 while not HaveAnimsLoaded("cop_wander_radio") do Wait(0) end
  87.                 TaskPlayAnimSecondaryUpperBody(GetPlayerPed(), "walk_answer_radio_a", "cop_wander_radio", 9.9, 0, 0, 0, 1, -2)
  88.                 callerBlipP = AddBlipForCoord(senderPosP[1], senderPosP[2], senderPosP[3], _i)
  89.                 ChangeBlipSprite(callerBlipP, 33)
  90.                 ChangeBlipColour(callerBlipP, 3)
  91.                 SetBlipAsShortRange(callerBlipP, true)
  92.                 SetRoute(callerBlipP, true)
  93.                 EnableGpsInVehicle(GetCarCharIsUsing(GetPlayerPed(), _i), true)
  94.                 callPos=1
  95.                 ShowText("~b~Call accepted. Proceed to destination.", 10000)
  96.                 pCallQ=0
  97.                 Wait(5000)
  98.                 ClearCharTasks(GetPlayerPed())
  99.             elseif IsGameKeyboardKeyJustPressed(49) then
  100.                 RequestAnims("cop_wander_radio")
  101.                 while not HaveAnimsLoaded("cop_wander_radio") do Wait(0) end
  102.                 TaskPlayAnimSecondaryUpperBody(GetPlayerPed(), "walk_answer_radio_a", "cop_wander_radio", 9.9, 0, 0, 0, 1, -2)
  103.                 pCallQ=0
  104.                 ShowText("~r~Call denied.", 7000)
  105.                 Wait(5000)
  106.                 ClearCharTasks(GetPlayerPed())
  107.             end
  108.         end
  109.     end
  110. end)
  111.  
  112. AddEventHandler('911callEMS', function(senderid)
  113.     CreateThread(function()
  114.         local sender = GetPlayerByServerId(tonumber(senderid))
  115.         senderPosEMS = table.pack(GetCharCoordinates(sender.ped, _f, _f, _f))
  116.         if(IsCharModel(GetPlayerPed(), GetHashKey("M_Y_PMEDIC", _r))) then
  117.             emsCallQ=1
  118.         end
  119.     end)
  120. end)
  121.  
  122. CreateThread(function()
  123.     while true do
  124.         Wait(0)
  125.         if(emsCallQ==1) then
  126.             ShowText("~b~911 call in progress. Press ~g~E ~b~to accept it or ~r~N ~b~to deny it", 500)
  127.             if IsGameKeyboardKeyJustPressed(18) then
  128.                 callerBlipEMS = AddBlipForCoord(senderPosEMS[1], senderPosEMS[2], senderPosEMS[3], _i)
  129.                 ChangeBlipSprite(callerBlipEMS, 33)
  130.                 ChangeBlipColour(callerBlipEMS, 1)
  131.                 SetBlipAsShortRange(callerBlipEMS, true)
  132.                 SetRoute(callerBlipEMS, true)
  133.                 EnableGpsInVehicle(GetCarCharIsUsing(GetPlayerPed(), _i), true)
  134.                 callPos=2
  135.                 ShowText("~b~Call accepted. Proceed to destination.", 10000)
  136.                 emsCallQ=0
  137.             elseif IsGameKeyboardKeyJustPressed(49) then
  138.                 emsCallQ=0
  139.                 ShowText("~r~Call denied.", 7000)
  140.             end
  141.         end
  142.     end
  143. end)
  144.  
  145. AddEventHandler('911callFire', function(senderid)
  146.     CreateThread(function()
  147.         local sender = GetPlayerByServerId(tonumber(senderid))
  148.         senderPosFire = table.pack(GetCharCoordinates(sender.ped, _f, _f, _f))
  149.         if(IsCharModel(GetPlayerPed(), GetHashKey("M_Y_FIREMAN", _r)) or IsCharModel(GetPlayerPed(), GetHashKey("M_M_FIRECHIEF", _r))) then
  150.             fireCallQ=1
  151.         end
  152.     end)
  153. end)
  154.  
  155. CreateThread(function()
  156.     while true do
  157.         Wait(0)
  158.         if(fireCallQ==1) then
  159.             ShowText("~b~911 call in progress. Press ~g~E ~b~to accept it or ~r~N ~b~to deny it", 500)
  160.             if IsGameKeyboardKeyJustPressed(18) then
  161.                 callerBlipFire = AddBlipForCoord(senderPosFire[1], senderPosFire[2], senderPosFire[3], _i)
  162.                 ChangeBlipSprite(callerBlipFire, 33)
  163.                 ChangeBlipColour(callerBlipFire, 6)
  164.                 SetBlipAsShortRange(callerBlipFire, true)
  165.                 SetRoute(callerBlipFire, true)
  166.                 EnableGpsInVehicle(GetCarCharIsUsing(GetPlayerPed(), _i), true)
  167.                 callPos=3
  168.                 ShowText("~b~Call accepted. Proceed to destination.", 10000)
  169.                 fireCallQ=0
  170.             elseif IsGameKeyboardKeyJustPressed(49) then
  171.                 fireCallQ=0
  172.                 ShowText("~r~Call denied.", 7000)
  173.             end
  174.         end
  175.     end
  176. end)
  177.  
  178. AddEventHandler('trigger911CallPolice', function()
  179. CreateThread(function()
  180. TriggerServerEvent('911callService', 1)
  181. end)
  182. end)
  183.  
  184. AddEventHandler('trigger911CallEMS', function()
  185. CreateThread(function()
  186. TriggerServerEvent('911callService', 2)
  187. end)
  188. end)
  189.  
  190. AddEventHandler('trigger911CallFire', function()
  191. CreateThread(function()
  192. TriggerServerEvent('911callService', 3)
  193. end)
  194. end)
  195.  
  196. --[[CreateThread(function()
  197.     while true do
  198.         Wait(0)
  199.         if(callPos==1) then
  200.             if(IsPlayerNearCoords(callerBlipP[1], callerBlipP[2], callerBlipP[3], 10.0)) then
  201.                 ShowText("~r~You arrived to the scene!", 7000)
  202.                 Wait(7000)
  203.                 RemoveBlip(callerBlipP)
  204.                 callPos=0
  205.             end
  206.         end
  207.     end
  208. end)
  209.  
  210. CreateThread(function()
  211.     while true do
  212.         Wait(0)
  213.         if(callPos==2) then
  214.             if(IsPlayerNearCoords(callerBlipEMS[1], callerBlipEMS[2], callerBlipEMS[3], 10.0)) then
  215.                 ShowText("~r~You arrived to the scene!", 7000)
  216.                 Wait(7000)
  217.                 RemoveBlip(callerBlipEMS)
  218.                 callPos=0
  219.             end
  220.         end
  221.     end
  222. end)
  223.  
  224. CreateThread(function()
  225.     while true do
  226.         Wait(0)
  227.         if(callPos==3) then
  228.             if(IsPlayerNearCoords(callerBlipFire[1], callerBlipFire[2], callerBlipFire[3], 10.0)) then
  229.                 ShowText("~r~You arrived to the scene!", 7000)
  230.                 Wait(7000)
  231.                 RemoveBlip(callerBlipFire)
  232.                 callPos=0
  233.             end
  234.         end
  235.     end
  236. end)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement