Advertisement
Guest User

client

a guest
Sep 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.94 KB | None | 0 0
  1. vRP = Proxy.getInterface("vRP")
  2. vRPserver = Tunnel.getInterface("vRP","vRP_trucker")
  3. vRPtruckS = Tunnel.getInterface("vRP_trucker","vRP_trucker")
  4. vRPtruckC = {}
  5. Tunnel.bindInterface("vRP_trucker",vRPtruckC)
  6. Proxy.addInterface("vRP_trucker",vRPtruckC)
  7. x, y, z = 1202.7896728516,-3201.7028808594,6.0280437469482
  8. loadingBay = {1050.1638183594,-3208.58203125,5.8984785079956}
  9.  
  10.  
  11.  
  12. theTrailer = nil
  13. incircle = false
  14. incircle2 = false
  15. inJob = false
  16. hasTruck = nil
  17. trailerBlip = nil
  18. jobBlip = nil
  19. trucks = {}
  20. trailers = {}
  21. jobDetails = {}
  22. lBay = nil
  23. leftBay = true
  24.  
  25. function trucker_drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  26. SetTextFont(font)
  27. SetTextProportional(0)
  28. SetTextScale(scale, scale)
  29. SetTextColour(r, g, b, a)
  30. SetTextDropShadow(0, 0, 0, 0,255)
  31. SetTextEdge(1, 0, 0, 0, 255)
  32. SetTextDropShadow()
  33. SetTextOutline()
  34. SetTextCentre(centre)
  35. SetTextEntry("STRING")
  36. AddTextComponentString(text)
  37. DrawText(x, y)
  38. end
  39.  
  40. function DrawText3D(x,y,z, text, scl, font)
  41. local onScreen,_x,_y=World3dToScreen2d(x,y,z)
  42. local px,py,pz=table.unpack(GetGameplayCamCoords())
  43. local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
  44.  
  45. local scale = (1/dist)*scl
  46. local fov = (1/GetGameplayCamFov())*100
  47. local scale = scale*fov
  48.  
  49. if onScreen then
  50. SetTextScale(0.0*scale, 1.1*scale)
  51. SetTextFont(font)
  52. SetTextProportional(1)
  53. -- SetTextScale(0.0, 0.55)
  54. SetTextColour(255, 255, 255, 255)
  55. SetTextDropshadow(0, 0, 0, 0, 255)
  56. SetTextEdge(2, 0, 0, 0, 150)
  57. SetTextDropShadow()
  58. SetTextOutline()
  59. SetTextEntry("STRING")
  60. SetTextCentre(1)
  61. AddTextComponentString(text)
  62. DrawText(_x,_y)
  63. end
  64. end
  65.  
  66. AddEventHandler("playerSpawned",function()
  67. vRPtruckS.getTrucks({}, function(truckz, trailerz)
  68. trucks = truckz
  69. trailers = trailerz
  70. end)
  71. end)
  72.  
  73. function round(x)
  74. return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
  75. end
  76.  
  77. function vRPtruckC.getDeliveryDistance(theX, theY, theZ)
  78. return round(Vdist(x, y, z, theX, theY, theZ))
  79. end
  80.  
  81. function vRPtruckC.saveDeliveryDetails(theJob)
  82. jobDetails = theJob
  83. inJob = true
  84. end
  85.  
  86. function vRPtruckC.spawnTrailer(theBay, bayLoc)
  87. bayX, bayY, bayZ = bayLoc[1], bayLoc[2], bayLoc[3]
  88. local vehicle = GetHashKey(trailers[math.random(1, #trailers)])
  89. RequestModel(vehicle)
  90.  
  91. while not HasModelLoaded(vehicle) do
  92. Wait(1)
  93. end
  94. theTrailer = CreateVehicle(vehicle, bayX, bayY, bayZ, 55.0, true, false)
  95. SetVehicleOnGroundProperly(theTrailer)
  96. SetEntityAsMissionEntity( theTrailer, true, true )
  97. trailerBlip = AddBlipForEntity(theTrailer)
  98. SetBlipSprite(trailerBlip, 11)
  99. SetBlipColour(trailerBlip, 2)
  100. lBay = theBay
  101. leftBay = false
  102. end
  103.  
  104. Citizen.CreateThread(function()
  105. while true do
  106. Citizen.Wait(1)
  107. local pos = GetEntityCoords(GetPlayerPed(-1), true)
  108. if(theTrailer) and (leftBay == false)then
  109. local trailerCoords = GetEntityCoords(theTrailer)
  110. if(GetDistanceBetweenCoords(trailerCoords.x, trailerCoords.y, trailerCoords.z, loadingBay[1], loadingBay[2], loadingBay[3]) > 10)then
  111. leftBay = true
  112. vRPtruckS.updateBayStats({lBay, 1})
  113. lBay = nil
  114. end
  115. end
  116. if(inJob == true) then
  117. if(theTrailer ~= nil)then
  118. if not (IsEntityDead(theTrailer)) then
  119. local ok = GetVehiclePedIsIn(GetPlayerPed(-1), false)
  120. local ok2, vtype, name = vRP.getNearestOwnedVehicle({7})
  121. if (ok) then
  122. isInVehicle = false
  123. for i, v in pairs(trucks) do
  124. if (GetHashKey(v) == GetEntityModel(ok)) and (ok2) and (IsEntityAttached(theTrailer)) then
  125. isInVehicle = true
  126. if(trailerBlip ~= nil)then
  127. RemoveBlip(trailerBlip)
  128. trailerBlip = nil
  129. end
  130. if (jobBlip == nil)then
  131. jobBlip = AddBlipForCoord(jobDetails[2], jobDetails[3], jobDetails[4])
  132. SetBlipRoute(jobBlip, true)
  133. end
  134. end
  135. end
  136. else
  137. trucker_drawTxt("~r~[EMPRESA] ~w~Voce precisa pegar a ~r~Carga ~w~para terminar a Entrega!",1,1,0.5,0.9,0.8,255,255,255,255)
  138. end
  139. if(isInVehicle == false)then
  140. trucker_drawTxt("~r~[EMPRESA] ~w~Voce precisa pegar a ~r~Carga ~w~para terminar a Entrega!",1,1,0.5,0.9,0.8,255,255,255,255)
  141. elseif(isInVehicle == true)then
  142. if not IsEntityAttached(theTrailer) then
  143. trailerBlip = AddBlipForEntity(theTrailer)
  144. SetBlipSprite(trailerBlip, 479)
  145. SetBlipColour(trailerBlip, 2)
  146. trucker_drawTxt("~r~[EMPRESA] ~w~Voce precisa pegar a ~r~Carga ~w~para terminar a Entrega!",1,1,0.5,0.9,0.8,255,255,255,255)
  147. else
  148. destinationType = jobDetails[5]
  149. destinationName = jobDetails[1]
  150. distanceLeft = tonumber(string.format("%0.4f", round(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, jobDetails[2], jobDetails[3], jobDetails[4]))))
  151. trucker_drawTxt("~r~Destino: ~w~"..destinationName,1,1,0.5,0.85,0.8,255,255,255,255)
  152. trucker_drawTxt("~r~Carga: ~w~"..destinationType,1,1,0.5,0.90,0.8,255,255,255,255)
  153. trucker_drawTxt("~r~Dano a Carga: ~w~"..GetEntityHealth(theTrailer).." ~w~de Vida",4,1,0.5,0.95,0.5,255,255,255,255)
  154. trucker_drawTxt("",1,1,0.5,0.90,0.8,255,255,255,255)
  155. end
  156. end
  157. else
  158. finishJob()
  159. vRP.notify({"~w~[EMPRESA] ~r~A Entrega foi Cancelada!"})
  160. if(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x, y, z) > 40.0)then
  161. vRPtruckS.payTrailerFine({})
  162. end
  163. end
  164. end
  165. end
  166. end
  167. end)
  168.  
  169. function finishJob()
  170. hasTruck = nil
  171. inJob = false
  172. jobDetails = {}
  173. if(jobBlip ~= nil)then
  174. RemoveBlip(jobBlip)
  175. jobBlip = nil
  176. end
  177. if(trailerBlip ~= nil)then
  178. RemoveBlip(trailerBlip)
  179. trailerBlip = nil
  180. end
  181. if(theTrailer ~= nil)then
  182. Citizen.InvokeNative(0xEA386986E786A54F , Citizen.PointerValueIntInitialized(theTrailer))
  183. theTrailer = nil
  184. end
  185. end
  186.  
  187. CreateThread(function()
  188. while true do
  189. Citizen.Wait(1)
  190. local pos = GetEntityCoords(GetPlayerPed(-1), true)
  191. if(inJob == true)then
  192. x3, y3, z3 = jobDetails[2], jobDetails[3], jobDetails[4]
  193. if(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x3, y3, z3) < 40.0)then
  194. destinationName = jobDetails[1]
  195. DrawText3D(x3, y3, z3+0.4, "~r~"..destinationName, 2.0, 1)
  196. DrawMarker(39, x3, y3, z3-0.5, 0, 0, 0, 0, 0, 0, 1.3, 1.3, 1.3, 0, 205, 255, 255, 0, 0, 0, true)
  197. end
  198. if(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x3, y3, z3) < 5)then
  199. incircle2 = true
  200. if (incircle2 == true) then
  201. vRPtruckS.finishTruckingDelivery({jobDetails[6]})
  202. finishJob()
  203. end
  204. elseif(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x3, y3, z3) > 5)then
  205. incircle2 = false
  206. end
  207. end
  208.  
  209. if(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x, y, z) < 40.0)then
  210. DrawText3D(x,y,z+0.4, "~r~Empresa de Caminhao", 2.0, 1)
  211. DrawText3D(x,y,z+0.15, "~w~Transporte de Mercadorias Importadas", 1, 7)
  212. DrawMarker(39, x, y, z-0.5, 0, 0, 0, 0, 0, 0, 1.3, 1.3, 1.3, 0, 205, 255, 255, 0, 0, 0, true)
  213. if(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x, y, z) < 5)then
  214. incircle = true
  215. if (incircle == true) then
  216. if(hasTruck == nil)then
  217. local ok, vtype, name = vRP.getNearestOwnedVehicle({7})
  218. if (ok) then
  219. for i, v in pairs(trucks) do
  220. if (v == name) then
  221. hasTruck = 1
  222. end
  223. end
  224. end
  225. end
  226. if (hasTruck == 1) then
  227. if(inJob == false)then
  228. trucker_drawTxt("~r~[EMPRESA] ~w~Pressione ~r~[E] ~w~para acessar o Menu de Entrega!",1,1,0.5,0.8,0.8,255,255,255,255)
  229. else
  230. trucker_drawTxt("~r~[EMPRESA] ~w~Voce ja tem uma Entrega Pendente!",1,1,0.5,0.74,0.8,255,255,255,255)
  231. end
  232. if(IsControlJustReleased(1, 51)) and (inJob == false)then
  233. TriggerServerEvent('openTruckerJobs')
  234. end
  235. else
  236. trucker_drawTxt("~r~[EMPRESA] ~w~Voce precisa de um ~r~Caminhao ~w~para fazer uma Entrega!",1,1,0.5,0.8,0.8,255,255,255,255)
  237. end
  238. end
  239. elseif(GetDistanceBetweenCoords(pos.x, pos.y, pos.z, x, y, z) > 5)then
  240. incircle = false
  241. hasTruck = nil
  242. end
  243. end
  244. end
  245. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement