Advertisement
Guest User

Untitled

a guest
May 19th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. local robbing = false
  2. local bank = ""
  3. local secondsRemaining = 0
  4.  
  5. function DisplayHelpText(str)
  6.     SetTextComponentFormat("STRING")
  7.     AddTextComponentString(str)
  8.     DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  9. end
  10.  
  11. function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline)
  12.     SetTextFont(0)
  13.     SetTextProportional(0)
  14.     SetTextScale(scale, scale)
  15.     SetTextColour(r, g, b, a)
  16.     SetTextDropShadow(0, 0, 0, 0,255)
  17.     SetTextEdge(1, 0, 0, 0, 255)
  18.     SetTextDropShadow()
  19.     if(outline)then
  20.         SetTextOutline()
  21.     end
  22.     SetTextEntry("STRING")
  23.     AddTextComponentString(text)
  24.     DrawText(x - width/2, y - height/2 + 0.005)
  25. end
  26.  
  27. local banks = {
  28.     ["fleeca"] = {
  29.         position = { ['x'] = 147.04908752441, ['y'] = -1044.9448242188, ['z'] = 29.36802482605 },
  30.         reward = 50000,
  31.         nameofbank = "Fleeca Bank (Centrum)",
  32.         lastrobbed = 0
  33.     },
  34.     ["fleeca2"] = {
  35.         position = { ['x'] = -2957.6674804688, ['y'] = 481.45776367188, ['z'] = 15.697026252747 },
  36.         reward = 20000,
  37.         nameofbank = "Fleeca Bank (Motorvejen)",
  38.         lastrobbed = 0
  39.     },
  40.     ["blainecounty"] = {
  41.         position = { ['x'] = -107.06505584717, ['y'] = 6474.8012695313, ['z'] = 31.62670135498 },
  42.         reward = 20000,
  43.         nameofbank = "Blaine County Savings",
  44.         lastrobbed = 0
  45.     }
  46.     --,
  47.     --["fleeca3"] = {
  48.     --  position = { ['x'] = 265.418426513672, ['y'] = 213.640502929688, ['z'] = 101.683471679688 },
  49.     --  reward = 100000,
  50.     --  nameofbank = "Fleeca Mainbank",
  51.     --  lastrobbed = 0
  52.     --}
  53. }
  54.  
  55. RegisterNetEvent('es_bank:currentlyrobbing')
  56. AddEventHandler('es_bank:currentlyrobbing', function(robb)
  57.     robbing = true
  58.     bank = robb
  59.     secondsRemaining = 1800 -- Remember to change value.
  60. end)
  61.  
  62. RegisterNetEvent('es_bank:toofarlocal')
  63. AddEventHandler('es_bank:toofarlocal', function(robb)
  64.     robbing = false
  65.     TriggerEvent('chatMessage', 'SYSTEM', {255, 0, 0}, "Heist failed, robbers got away with nothing.")
  66.     robbingName = ""
  67.     secondsRemaining = 0
  68.     incircle = false
  69. end)
  70.  
  71.  
  72. RegisterNetEvent('es_bank:robberycomplete')
  73. AddEventHandler('es_bank:robberycomplete', function(robb)
  74.     robbing = false
  75.     TriggerEvent('chatMessage', 'SYSTEM', {255, 0, 0}, "Heist done, you recieved: ^2" .. banks[bank].reward)
  76.     bank = ""
  77.     secondsRemaining = 0
  78.     incircle = false
  79. end)
  80.  
  81. Citizen.CreateThread(function()
  82.     while true do
  83.         if robbing then
  84.             Citizen.Wait(1000)
  85.             if(secondsRemaining > 0)then
  86.                 secondsRemaining = secondsRemaining - 1
  87.             end
  88.         end
  89.  
  90.         Citizen.Wait(0)
  91.     end
  92. end)
  93.  
  94. -- I disabled this, because I already got banking icons on the map --
  95.  
  96. -- Citizen.CreateThread(function()
  97.     -- for k,v in pairs(banks)do
  98.         -- local ve = v.position
  99.  
  100.         -- local blip = AddBlipForCoord(ve.x, ve.y, ve.z)
  101.         -- SetBlipSprite(blip, 500)
  102.         -- SetBlipScale(blip, 0.8)
  103.         -- SetBlipAsShortRange(blip, true)
  104.         -- BeginTextCommandSetBlipName("STRING")
  105.         -- AddTextComponentString("Bank")
  106.         -- EndTextCommandSetBlipName(blip)
  107.     -- end
  108. -- end)
  109.  
  110. incircle = false
  111.  
  112. Citizen.CreateThread(function()
  113.     while true do
  114.         local pos = GetEntityCoords(GetPlayerPed(-1), true)
  115.  
  116.         for k,v in pairs(banks)do
  117.             local pos2 = v.position
  118.  
  119.             if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then
  120.                 if not robbing then
  121.                     DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0)
  122.                    
  123.                     if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then
  124.                         if (incircle == false) then
  125.                             DisplayHelpText("Press ~INPUT_DROP_AMMO~ to rob ~b~" .. v.nameofbank .. "~w~, but the cops will be alerted!")
  126.                         end
  127.                         incircle = true
  128.                         if(IsControlJustReleased(1, 57))then
  129.                             TriggerServerEvent('es_bank:rob', k)
  130.                         end
  131.                     elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then
  132.                         incircle = false
  133.                     end
  134.                 end
  135.             end
  136.         end
  137.  
  138.         if robbing then
  139.            
  140.             drawTxt(0.66, 1.44, 1.0,1.0,0.4, "Robbing Bank: ~r~" .. secondsRemaining .. "~w~ seconds left", 255, 255, 255, 255)
  141.            
  142.             local pos2 = banks[bank].position
  143.            
  144.             if(IsPlayerDead(PlayerId())) then
  145.                     if(alreadyDead == false) then
  146.                         TriggerServerEvent('es_bank:toofar', bank)
  147.                         alreadyDead = true
  148.                     end
  149.                 else
  150.                     alreadyDead = false
  151.                 end
  152.            
  153.             if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 33)then
  154.                 TriggerServerEvent('es_bank:toofar', bank)
  155.             end
  156.         end
  157.  
  158.         Citizen.Wait(0)
  159.     end
  160. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement