Advertisement
Guest User

server.lua

a guest
Sep 19th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. local Tunnel = module("vrp", "lib/Tunnel")
  2. local Proxy = module("vrp", "lib/Proxy")
  3. MySQL = module("vrp_mysql", "MySQL")
  4.  
  5. vRP = Proxy.getInterface("vRP")
  6. vRPclient = Tunnel.getInterface("vRP","vRP_trucker")
  7. vRPCtruck = Tunnel.getInterface("vRP_trucker","vRP_trucker")
  8.  
  9. vRPtruck = {}
  10. Tunnel.bindInterface("vRP_trucker",vRPtruck)
  11. Proxy.addInterface("vRP_trucker",vRPtruck)
  12.  
  13. x, y, z = 1202.7896728516,-3201.7028808594,6.0280437469482
  14.  
  15. trailerCoords = {
  16. [1] = {1050.1638183594,-3208.58203125,5.8984785079956},
  17. [2] = {1034.6558837891,-3208.58203125,5.9022426605225},
  18. [3] = {1021.7258300781,-3208.58203125,5.9001793861389},
  19. [4] = {1009.5572509766,-3208.58203125,5.9014225006104},
  20. [5] = {997.87097167969,-3208.58203125,5.9010539054871}
  21. }
  22.  
  23. trucks = {"daftruck", "kamaztrucker", "mantrucker", "mercedestrucker", "scaniatrucker", "volvotrucker"}
  24. trailers = {"TANKER", "TRAILERS", "TRAILERS2"}
  25. activeDeliveries = {}
  26.  
  27. unloadLocations = {
  28. {"Posto Shell", 186.87092590332,6614.294921875,31.82873916626, "Gasolina", 9102}, --Blaine
  29. {"Fazenda", 2015.2478027344,4979.3334960938,41.288940429688, "Fertilizadores", 7728}, --Ferma
  30. {"Fishing Triton", 3806.3562011718,4457.3383789062,4.3696641921998, "Partes de Barco", 7909}, --Iesirea inspre mare partea dreapta
  31. {"Los Santos", -577.99694824218,5325.5283203125,70.263298034668, "Pecas de Motor", 7835}, -- Blaine cherestea
  32. {"Golden Fish", 1309.264038086,4328.076171875,38.1669921875, "Redes de Pesca", 6936}, -- Pescarie lacul din mijloc
  33. {"Secret Army", -2069.2082519532,3386.5070800782,31.282091140748, "Uranio", 6234}, -- Blaine cherestea
  34. {"Construtora Brasil", 870.50927734375,2343.2783203125,51.687889099122, "Tijolos", 4904}, -- Aproape de armata
  35. {"Secrets Guns", 2482.4860839844,-443.32431030274,92.992576599122, "Arma", 3299}, -- facilitate secreta los santos dreapta
  36. {"Aeroporto", 1744.2651367188,3289.7778320312,41.102840423584, "Pecas de Aeronaves", 6028}, -- aeroport trevor
  37. {"Pet Shop", 562.17309570312,2722.1853027344,42.060230255126, "Comidas de Animais", 5237}, -- petshop xtremezone
  38. {"Shopping", -2318.4116210938,280.80227661132,169.467086792, "Produtos", 3627}, -- mall Xtremezone
  39. {"Fabrica de Cimento", 1215.9357910156,1877.8912353516,78.845520019532, "Pedras", 4526}, -- Fabrica de ciment la iesire din los santos
  40. {"Fazenda", -50.683254241944,1874.984008789,196.8624572754, "Fertilizadores", 4366}, -- Langa Poacher
  41. {"Fazenda", -64.300018310546,6275.9194335938,31.35410118103, "Aves", 8763}, -- Langa Poacher
  42. {"Ferragem", 2672.3757324218,3518.2490234375,52.712032318116, "Ferramentas", 6564}, -- Paralel cu Human Labs
  43. {"Bayer", 849.52270507812,2201.7373046875,51.490081787116, "Pesticidas", 4761}, -- Langa constructia din mijloc
  44. {"Ferragem", 2333.0327148438,3137.6437988282,48.178939819336, "Pecas", 6081}, --
  45. {"Industria Brasileira de Reciclagem", -1921.7559814454,2045.240234375,140.73533630372, "Garrafas", 4932}, -- Podgorie
  46. {"Posto Ipiranga", 2563.6311035156,419.98919677734,108.45681762696, "Gasolina", 3863} --Benzinarie
  47. }
  48.  
  49. deliveryDistances = {}
  50.  
  51. deliveryCompany = {"ACI SRL", "ACC", "BrasilAcres", "BrasilGoodies", "GlobeBR", "Renar Logistik", "S.A.L S.R.L", "TE Logistica", "Tesouro Brasileiro", "Tradeaux"}
  52.  
  53.  
  54. AddEventHandler("vRP:playerSpawn",function(user_id,source,first_spawn)
  55. vRPclient.addBlip(source,{x, y, z, 67, 2, "Empresa de Caminhao"})
  56. end)
  57.  
  58. function vRPtruck.getTrucks()
  59. return trucks, trailers
  60. end
  61.  
  62. function vRPtruck.finishTruckingDelivery(distance)
  63. thePlayer = source
  64. local user_id = vRP.getUserId({thePlayer})
  65. deliveryMoney = math.ceil(distance*1.00)
  66. vRPclient.notify(thePlayer, {"~r~[EMPRESA] ~w~Voce entregou a Carga, seu Pagamento de ~r~R$"..deliveryMoney.." ~w~foi entregue"})
  67. vRP.giveBankMoney({user_id, deliveryMoney})
  68. end
  69.  
  70. function vRPtruck.payTrailerFine()
  71. thePlayer = source
  72. local user_id = vRP.getUserId({thePlayer})
  73. if(vRP.tryFullPayment({user_id, 5000})) then
  74. vRPclient.notify(thePlayer, {"~r~[EMPRESA] ~w~Voce bateu o ~r~Caminhao! ~w~Tomou o Prejuizo de ~r~R$5000"})
  75. end
  76. end
  77.  
  78. function vRPtruck.updateBayStats(theBay, stats)
  79. trailerCoords[theBay][4] = stats
  80. end
  81.  
  82. local function takeDeliveryJob(thePlayer, theDelivery)
  83. lBay = 0
  84. for i, v in pairs(trailerCoords) do
  85. if(v[4] == 1)then
  86. lBay = i
  87. trailerCoords[lBay][4] = 0
  88. break
  89. end
  90. end
  91. if(lBay ~= 0)then
  92. vRPCtruck.spawnTrailer(thePlayer, {lBay, trailerCoords[lBay]})
  93. local user_id = vRP.getUserId({thePlayer})
  94. activeDeliveries[user_id] = unloadLocations[theDelivery]
  95. vRPCtruck.saveDeliveryDetails(thePlayer, {activeDeliveries[user_id]})
  96. vRP.closeMenu({thePlayer})
  97. vRPclient.notify(thePlayer, {"~r~[EMPRESA] ~w~Va para ~r~"..activeDeliveries[user_id][1].." ~w~para Entregar ~r~"..activeDeliveries[user_id][5]})
  98. else
  99. vRPclient.notify(thePlayer, {"~r~[EMPRESA] ~w~Nao ha mais ~r~Entregas, ~w~volte mais Tarde!"})
  100. return
  101. end
  102. end
  103.  
  104. trucker_menu = {name="Empresa de Caminhao",css={top="75px", header_color="rgba(0,125,255,0.75)"}}
  105.  
  106. RegisterServerEvent("openTruckerJobs")
  107. AddEventHandler("openTruckerJobs", function()
  108. thePlayer = source
  109. local user_id = vRP.getUserId({thePlayer})
  110. for i, v in ipairs(unloadLocations) do
  111. deliveryName = tostring(v[1])
  112. dX, dY, dZ = v[2], v[3], v[4]
  113. deliveryType = v[5]
  114. deliveryDistance = v[6]
  115. deliveryMoney = math.ceil(deliveryDistance*1)
  116. theCompany = deliveryCompany[math.random(1, #deliveryCompany)]
  117. trucker_menu[deliveryName] = {function() takeDeliveryJob(thePlayer, i) end, "Empresa: <font color='yellow'>"..theCompany.."</font><br>Carga: <font color='red'>"..deliveryType.."</font><br>Distancia: <font color='red'>"..(deliveryDistance/1000).." KM</font><br>Pagamento: <font color='green'>R$"..deliveryMoney.."</font>"}
  118. end
  119. vRP.openMenu({thePlayer,trucker_menu})
  120. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement