Guest User

Untitled

a guest
Jun 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.15 KB | None | 0 0
  1. --[[
  2. FiveM Scripts
  3. Copyright C 2018 Sighmir
  4.  
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published
  7. by the Free Software Foundation, either version 3 of the License, or
  8. at your option any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU Affero General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ]]
  18.  
  19. --[[Proxy/Tunnel]]--
  20.  
  21. vRPgt = {}
  22. Tunnel.bindInterface("vRP_garages",vRPgt)
  23. Proxy.addInterface("vRP_garages",vRPgt)
  24. vRP = Proxy.getInterface("vRP")
  25.  
  26. --[[Local/Global]]--
  27.  
  28. GVEHICLES = {}
  29. local inrangeofgarage = false
  30. local currentlocation = nil
  31.  
  32. local garages = {
  33. {name="Garage", colour=3, id=357, marker=27, x=215.124, y=-791.377, z=29.946, h=0.0, hidden=false}, -- Centrum P-Plads
  34. {name="Garage", colour=3, id=357, marker=27, x=-334.685, y=289.773, z=84.905, h=0.0, hidden=false}, -- Tequilala ved P-Plads
  35. {name="Garage", colour=3, id=357, marker=27, x=-55.272, y=-1838.71, z=25.638, h=0.0, hidden=false}, -- Gang P-Plads
  36. {name="Garage", colour=3, id=357, marker=27, x=126.434, y=6610.04, z=30.880, h=0.0, hidden=false}, -- Paleto Bay P-Plads
  37. {name="Garage", colour=3, id=357, marker=27, x=-2035.372, y=-470.555, z=10.466, h=0.0, hidden=false}, -- Strand P-Plads
  38. {name="Garage", colour=3, id=357, marker=27, x=-976.59875488281, y=-2702.88671875, z=12.9, h=0.0, hidden=false}, -- Lufthavn
  39. {name="Garage", colour=3, id=357, marker=27, x=291.60162353516, y=-336.40170288086, z=44.219876098633, h=0.0, hidden=false}, -- Retssal-garage
  40. {name="Garage", colour=3, id=357, marker=27, x=2006.6551, y=3055.0170, z=46.1497, h=0.0, hidden=false}, --Yellow Jack P-Plads
  41. {name="Garage", colour=3, id=357, marker=27, x=-1063.9470214844, y=-1419.7119140625, z=4.545440788269, h=0.0, hidden=false}, --Vestlig P-Plads
  42. {name="Garage", colour=3, id=357, marker=27, x=436.12869262695, y=-1021.3997192383, z=27.8041456604, h=0.0, hidden=true, hiddend=true}, -- Garage PD
  43. {name="Garage", colour=3, id=357, marker=27, x=-463.47357177734, y=6037.0473632813, z=30.340528488159, h=0.0, hidden=true}, -- Paleto PD
  44. {name="Garage", colour=3, id=357, marker=27, x=460.80130004883, y=-1157.5744628906, z=28.291790008545, h=0.0, hidden=true}, -- P-Plads ved Politistation
  45. {name="Garage", colour=3, id=357, marker=27, x=1189.2893066406, y=-3230.6276855469, z=5.0287690162659, h=0.0, hidden=true}, -- Lastbiljob
  46. {name="Garage", colour=3, id=357, marker=27, x=2661.7719726563, y=2848.2077636719, z=38.47466583252, h=0.0, hidden=true}, -- P-Plads ved minearbejder
  47. {name="Garage", colour=3, id=357, marker=27, x=-796.51721191406, y=303.63195800781, z=84.800401306152, h=0.0, hidden=true}, -- P-Plads Penthouse lejligheder
  48. {name="Garage", colour=3, id=357, marker=27, x=180.84309387207, y=2821.6760253906, z=43.489575958252, h=0.0, hidden=true}, -- P-Plads et sted i Sandyshores.
  49. {name="Garage", colour=3, id=357, marker=27, x=1137.5103759766, y=-1606.0947265625, z=33.692562103271, h=0.0, hidden=true}, -- Ambulance garage
  50. {name="Garage", colour=3, id=357, marker=27, x=-50.634475708008, y=-1117.4621582031, z=25.572351837158, h=0.0, hidden=false}, -- Bilbutik garage
  51. {name="Garage", colour=3, id=357, marker=27, x=-456.49612426758, y=-1698.6625976563, z=18.100004592896, h=0.0, hidden=true}, -- Skraldemandsjob
  52. {name="Garage", colour=3, id=357, marker=27, x=902.69830322266, y=-184.05155944824, z=73.05, h=0.0, hidden=true}, -- Taxa job
  53. {name="Garage", colour=3, id=357, marker=27, x=-576.91052246094, y=5250.8061523438, z=69.46715087891, h=0.0, hidden=true}, -- Træhugger job
  54. {name="Garage", colour=3, id=357, marker=27, x=1862.4067382813, y=2567.0131835938, z=44.7, h=0.0, hidden=true}, -- Fængsel
  55. {name="Garage", colour=3, id=357, marker=27, x=1866.0242919922, y=3698.72265625, z=32.68, h=0.0, hidden=true}, -- PD i Sandy Shores
  56. {name="Garage", colour=3, id=357, marker=27, x=1702.9000244141, y=3597.0493164063, z=35.43, h=232.65390014648, hidden=true}, -- Sandy Shores
  57. {name="Garage", colour=3, id=357, marker=27, x=-1767.4169921875, y=-1151.4920654297, z=12.270, h=0.0, hidden=true}, -- Civil båd/tivoli
  58. {name="Garage", colour=3, id=357, marker=27, x=977.68688964844, y=-3002.0490722656, z=-40.603710174561, h=0.0, hidden=true}, -- Mekaniker garage
  59. {name="Garage", colour=3, id=357, marker=27, x=611.44940185547, y=-2778.1608886719, z=5.156, h=0.0, hidden=true}, -- Fisker job
  60. {name="Garage", colour=3, id=357, marker=27, x=328.68539428711, y=-1471.995727539, z=28.8124168396, h=0.0, hidden=true}, -- Hospitals garage
  61. {name="Garage", colour=3, id=357, marker=27, x=-372.33316040039, y=38.681262969971, z=159.96463012695, h=0.0, hidden=true}, -- Tuning Garage (Midtby)
  62.  
  63. -- Gruppering / specielle huse garager
  64. {name="Garage", colour=3, id=357, marker=27, x=-814.5706, y=160.5650, z=69.7000, h=0.0, hidden=true}, -- Rockford Hills 3
  65. {name="Garage", colour=3, id=357, marker=27, x=12.7956, y=548.4217, z=174.8835, h=0.0, hidden=true}, -- Whispymound Drive 3671
  66. {name="Garage", colour=3, id=357, marker=27, x=1393.4357, y=1117.334, z=113.8976, h=0.0, hidden=true}, -- La Torre
  67. {name="Garage", colour=3, id=357, marker=27, x=970.2740, y=-138.7984, z=73.4351, h=0.0, hidden=true}, -- The Lost MC
  68. {name="Garage", colour=3, id=357, marker=27, x=1943.619140625, y=3828.4538574219, z=30.540386962891, h=0.0, hidden=true}, -- Uno Por Ciento
  69. {name="Garage", colour=3, id=357, marker=27, x=-103.9112, y=-607.6959, z=35.0732, h=0.0, hidden=true}, -- RoadRunners
  70. {name="Garage", colour=3, id=357, marker=27, x=-24.4812, y=-1439.1867, z=29.7531, h=0.0, hidden=true}, -- The Family
  71. {name="Garage", colour=3, id=357, marker=27, x=-188.45788574219, y=132.79644775391, z=29.7531, h=11.176334381104, hidden=true}, -- House
  72. {name="Garage", colour=3, id=357, marker=27, x=1979.2723, y=3807.3410, z=30.1578, h=0.0, hidden=true}, -- Trevors campingvogn
  73. {name="Garage", colour=3, id=357, marker=27, x=-82.44026184082, y=-810.80102539063, z=36.332328796387, h=0.0, hidden=true}, -- Gambino
  74. {name="Garage", colour=3, id=357, marker=27, x=-564.26446533203, y=-906.42944335938, z=22.262148284912, h=0.0, hidden=true}, -- origin News
  75. }
  76.  
  77. vehicles = {}
  78. garageSelected = { {x=nil, y=nil, z=nil, h=nil}, }
  79. selectedPage = 0
  80.  
  81. lang_string = {
  82. menu1 = "Opdater Garage",
  83. menu2 = "Tag et Køretøj",
  84. menu3 = "Luk",
  85. menu4 = "Køretøj",
  86. menu5 = "Options",
  87. menu6 = "Tag ud",
  88. menu7 = "Tilbage",
  89. menu8 = "Tryk ~g~E~s~ For at åbne menuen",
  90. menu9 = "Sell",
  91. menu10 = "~g~E~s~ to sell the vehicle at 50% of the purchase price",
  92. menu11 = "Update the vehicle",
  93. menu12 = "Næste",
  94. state1 = "Out",
  95. state2 = "In",
  96. text1 = "Området er fyldt",
  97. text2 = "Detter Køretøj er ikke i din garage",
  98. text3 = "Køretøj ude",
  99. text4 = "Du ejer ikke dette Køretøj",
  100. text5 = "Køretøj gemt",
  101. text6 = "intet Køretøj til stede",
  102. text7 = "Vehicle sold",
  103. text8 = "Vehicle bought, good drive",
  104. text9 = "Insufficient funds",
  105. text10 = "Vehicle updated"
  106. }
  107. --[[Functions]]--
  108.  
  109. function vRPgt.spawnGarageVehicle(vtype, name, vehicle_plate, vehicle_colorprimary, vehicle_colorsecondary, vehicle_pearlescentcolor, vehicle_wheelcolor, vehicle_plateindex, vehicle_neoncolor1, vehicle_neoncolor2, vehicle_neoncolor3, vehicle_windowtint, vehicle_wheeltype, vehicle_mods0, vehicle_mods1, vehicle_mods2, vehicle_mods3, vehicle_mods4, vehicle_mods5, vehicle_mods6, vehicle_mods7, vehicle_mods8, vehicle_mods9, vehicle_mods10, vehicle_mods11, vehicle_mods12, vehicle_mods13, vehicle_mods14, vehicle_mods15, vehicle_mods16, vehicle_turbo, vehicle_tiresmoke, vehicle_xenon, vehicle_mods23, vehicle_mods24, vehicle_neon0, vehicle_neon1, vehicle_neon2, vehicle_neon3, vehicle_bulletproof, vehicle_smokecolor1, vehicle_smokecolor2, vehicle_smokecolor3, vehicle_modvariation) -- vtype is the vehicle type (one vehicle per type allowed at the same time)
  110.  
  111. local vehicle = vehicles[vtype]
  112. if vehicle and not IsVehicleDriveable(vehicle[3]) then -- precheck if vehicle is undriveable
  113. -- despawn vehicle
  114. SetVehicleHasBeenOwnedByPlayer(vehicle[3],false)
  115. Citizen.InvokeNative(0xAD738C3085FE7E11, vehicle[3], false, true) -- set not as mission entity
  116. SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(vehicle[3]))
  117. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicle[3]))
  118. TriggerEvent("vrp_garages:setVehicle", vtype, nil)
  119. end
  120.  
  121. vehicle = vehicles[vtype]
  122. if vehicle == nil then
  123. -- load vehicle model
  124. local mhash = GetHashKey(name)
  125.  
  126. local i = 0
  127. while not HasModelLoaded(mhash) and i < 10000 do
  128. RequestModel(mhash)
  129. Citizen.Wait(10)
  130. i = i+1
  131. end
  132.  
  133. -- spawn car
  134. if HasModelLoaded(mhash) then
  135. local x,y,z = vRP.getPosition({})
  136. local nveh = CreateVehicle(mhash, x,y,z+0.5, GetEntityHeading(GetPlayerPed(-1)), true, false) -- added player heading
  137. SetVehicleOnGroundProperly(nveh)
  138. SetEntityInvincible(nveh,false)
  139. SetPedIntoVehicle(GetPlayerPed(-1),nveh,-1) -- put player inside
  140. SetVehicleNumberPlateText(nveh, "GT" .. vRP.getRegistrationNumber({}))
  141. Citizen.InvokeNative(0xAD738C3085FE7E11, nveh, true, true) -- set as mission entity
  142. SetVehicleHasBeenOwnedByPlayer(nveh,true)
  143. vehicle_migration = false
  144. if not vehicle_migration then
  145. local nid = NetworkGetNetworkIdFromEntity(nveh)
  146. SetNetworkIdCanMigrate(nid,false)
  147. end
  148.  
  149. TriggerEvent("vrp_garages:setVehicle", vtype, {vtype,name,nveh})
  150.  
  151. SetModelAsNoLongerNeeded(mhash)
  152.  
  153. --grabbing customization
  154. local plate = plate
  155. local primarycolor = tonumber(vehicle_colorprimary)
  156. local secondarycolor = tonumber(vehicle_colorsecondary)
  157. local pearlescentcolor = vehicle_pearlescentcolor
  158. local wheelcolor = vehicle_wheelcolor
  159. local plateindex = tonumber(vehicle_plateindex)
  160. local neoncolor = {vehicle_neoncolor1,vehicle_neoncolor2,vehicle_neoncolor3}
  161. local windowtint = vehicle_windowtint
  162. local wheeltype = tonumber(vehicle_wheeltype)
  163. local mods0 = tonumber(vehicle_mods0)
  164. local mods1 = tonumber(vehicle_mods1)
  165. local mods2 = tonumber(vehicle_mods2)
  166. local mods3 = tonumber(vehicle_mods3)
  167. local mods4 = tonumber(vehicle_mods4)
  168. local mods5 = tonumber(vehicle_mods5)
  169. local mods6 = tonumber(vehicle_mods6)
  170. local mods7 = tonumber(vehicle_mods7)
  171. local mods8 = tonumber(vehicle_mods8)
  172. local mods9 = tonumber(vehicle_mods9)
  173. local mods10 = tonumber(vehicle_mods10)
  174. local mods11 = tonumber(vehicle_mods11)
  175. local mods12 = tonumber(vehicle_mods12)
  176. local mods13 = tonumber(vehicle_mods13)
  177. local mods14 = tonumber(vehicle_mods14)
  178. local mods15 = tonumber(vehicle_mods15)
  179. local mods16 = tonumber(vehicle_mods16)
  180. local turbo = vehicle_turbo
  181. local tiresmoke = vehicle_tiresmoke
  182. local xenon = vehicle_xenon
  183. local mods23 = tonumber(vehicle_mods23)
  184. local mods24 = tonumber(vehicle_mods24)
  185. local neon0 = vehicle_neon0
  186. local neon1 = vehicle_neon1
  187. local neon2 = vehicle_neon2
  188. local neon3 = vehicle_neon3
  189. local bulletproof = vehicle_bulletproof
  190. local smokecolor1 = vehicle_smokecolor1
  191. local smokecolor2 = vehicle_smokecolor2
  192. local smokecolor3 = vehicle_smokecolor3
  193. local variation = vehicle_modvariation
  194.  
  195. --setting customization
  196. SetVehicleColours(nveh, primarycolor, secondarycolor)
  197. SetVehicleExtraColours(nveh, tonumber(pearlescentcolor), tonumber(wheelcolor))
  198. SetVehicleNumberPlateTextIndex(nveh,plateindex)
  199. SetVehicleNeonLightsColour(nveh,tonumber(neoncolor[1]),tonumber(neoncolor[2]),tonumber(neoncolor[3]))
  200. SetVehicleTyreSmokeColor(nveh,tonumber(smokecolor1),tonumber(smokecolor2),tonumber(smokecolor3))
  201. SetVehicleModKit(nveh,0)
  202. SetVehicleMod(nveh, 0, mods0)
  203. SetVehicleMod(nveh, 1, mods1)
  204. SetVehicleMod(nveh, 2, mods2)
  205. SetVehicleMod(nveh, 3, mods3)
  206. SetVehicleMod(nveh, 4, mods4)
  207. SetVehicleMod(nveh, 5, mods5)
  208. SetVehicleMod(nveh, 6, mods6)
  209. SetVehicleMod(nveh, 7, mods7)
  210. SetVehicleMod(nveh, 8, mods8)
  211. SetVehicleMod(nveh, 9, mods9)
  212. SetVehicleMod(nveh, 10, mods10)
  213. SetVehicleMod(nveh, 11, mods11)
  214. SetVehicleMod(nveh, 12, mods12)
  215. SetVehicleMod(nveh, 13, mods13)
  216. SetVehicleMod(nveh, 14, mods14)
  217. SetVehicleMod(nveh, 15, mods15)
  218. SetVehicleMod(nveh, 16, mods16)
  219. if turbo == "on" then
  220. ToggleVehicleMod(nveh, 18, true)
  221. else
  222. ToggleVehicleMod(nveh, 18, false)
  223. end
  224. if tiresmoke == "on" then
  225. ToggleVehicleMod(nveh, 20, true)
  226. else
  227. ToggleVehicleMod(nveh, 20, false)
  228. end
  229. if xenon == "on" then
  230. ToggleVehicleMod(nveh, 22, true)
  231. else
  232. ToggleVehicleMod(nveh, 22, false)
  233. end
  234. SetVehicleWheelType(nveh, tonumber(wheeltype))
  235. SetVehicleMod(nveh, 23, mods23)
  236. SetVehicleMod(nveh, 24, mods24)
  237. if neon0 == "on" then
  238. SetVehicleNeonLightEnabled(nveh,0, true)
  239. else
  240. SetVehicleNeonLightEnabled(nveh,0, false)
  241. end
  242. if neon1 == "on" then
  243. SetVehicleNeonLightEnabled(nveh,1, true)
  244. else
  245. SetVehicleNeonLightEnabled(nveh,1, false)
  246. end
  247. if neon2 == "on" then
  248. SetVehicleNeonLightEnabled(nveh,2, true)
  249. else
  250. SetVehicleNeonLightEnabled(nveh,2, false)
  251. end
  252. if neon3 == "on" then
  253. SetVehicleNeonLightEnabled(nveh,3, true)
  254. else
  255. SetVehicleNeonLightEnabled(nveh,3, false)
  256. end
  257. if bulletproof == "on" then
  258. SetVehicleTyresCanBurst(nveh, false)
  259. else
  260. SetVehicleTyresCanBurst(nveh, true)
  261. end
  262. --if variation == "on" then
  263. -- SetVehicleModVariation(nveh,23)
  264. --else
  265. -- SetVehicleModVariation(nveh,23, false)
  266. --end
  267. SetVehicleWindowTint(nveh,tonumber(windowtint))
  268. end
  269. else
  270. vRP.notify({"Du kan kun have et "..vtype.." Køretøj ude."})
  271. end
  272. end
  273.  
  274. function vRPgt.spawnBoughtVehicle(vtype, name)
  275.  
  276. local vehicle = vehicles[vtype]
  277. if vehicle then -- precheck if vehicle is undriveable
  278. -- despawn vehicle
  279. SetVehicleHasBeenOwnedByPlayer(vehicle[3],false)
  280. Citizen.InvokeNative(0xAD738C3085FE7E11, vehicle[3], false, true) -- set not as mission entity
  281. SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(vehicle[3]))
  282. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicle[3]))
  283. TriggerEvent("vrp_garages:setVehicle", vtype, nil)
  284. end
  285.  
  286. vehicle = vehicles[vtype]
  287. if vehicle == nil then
  288. -- load vehicle model
  289. local mhash = GetHashKey(name)
  290.  
  291. local i = 0
  292. while not HasModelLoaded(mhash) and i < 10000 do
  293. RequestModel(mhash)
  294. Citizen.Wait(10)
  295. i = i+1
  296. end
  297.  
  298. -- spawn car
  299. if HasModelLoaded(mhash) then
  300. local x,y,z = vRP.getPosition({})
  301. local nveh = CreateVehicle(mhash, x,y,z+0.5, GetEntityHeading(GetPlayerPed(-1)), true, false) -- added player heading
  302. SetVehicleOnGroundProperly(nveh)
  303. SetEntityInvincible(nveh,false)
  304. SetPedIntoVehicle(GetPlayerPed(-1),nveh,-1) -- put player inside
  305. SetVehicleNumberPlateText(nveh, "GT" .. vRP.getRegistrationNumber({}))
  306. Citizen.InvokeNative(0xAD738C3085FE7E11, nveh, true, true) -- set as mission entity
  307. SetVehicleHasBeenOwnedByPlayer(nveh,true)
  308. vehicle_migration = false
  309. if not vehicle_migration then
  310. local nid = NetworkGetNetworkIdFromEntity(nveh)
  311. SetNetworkIdCanMigrate(nid,false)
  312. end
  313.  
  314. TriggerEvent("vrp_garages:setVehicle", vtype, {vtype,name,nveh})
  315.  
  316. SetModelAsNoLongerNeeded(mhash)
  317. end
  318. else
  319. vRP.notify({"Du kan kun have et "..vtype.." Køretøj ude."})
  320. end
  321. end
  322.  
  323. function vRPgt.despawnGarageVehicle(vtype,max_range)
  324. local vehicle = vehicles[vtype]
  325. if vehicle then
  326. local x,y,z = table.unpack(GetEntityCoords(vehicle[3],true))
  327. local px,py,pz = vRP.getPosition()
  328.  
  329. if GetDistanceBetweenCoords(x,y,z,px,py,pz,true) < max_range then -- check distance with the vehicule
  330. -- remove vehicle
  331. SetVehicleHasBeenOwnedByPlayer(vehicle[3],false)
  332. Citizen.InvokeNative(0xAD738C3085FE7E11, vehicle[3], false, true) -- set not as mission entity
  333. SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(vehicle[3]))
  334. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicle[3]))
  335. TriggerEvent("vrp_garages:setVehicle", vtype, nil)
  336. vRP.notify({"~g~Køretøj gemt."})
  337. else
  338. vRP.notify({"~r~Du er for langt væk fra dit Køretøj."})
  339. end
  340. else
  341. vRP.notify({"~r~Du har ikke et Køretøj ude."})
  342. end
  343. end
  344.  
  345. function MenuGarage()
  346. ped = GetPlayerPed(-1)
  347. selectedPage = 0
  348. MenuTitle = "Garage"
  349. ClearMenu()
  350. Menu.addButton(lang_string.menu1,"CloseMenu",nil)
  351. Menu.addButton(lang_string.menu2,"ListVehicle",selectedPage)
  352. Menu.addButton(lang_string.menu3,"CloseMenu",nil)
  353. end
  354.  
  355. function StoreVehicle()
  356. Citizen.CreateThread(function()
  357. local ped = GetPlayerPed(-1)
  358. local caissei = GetVehiclePedIsIn(GetPlayerPed(-1), false)
  359. SetEntityAsMissionEntity(caissei, true, true)
  360. local plate = GetVehicleNumberPlateText(caissei)
  361. local vtype = "car"
  362. if IsThisModelABike(GetEntityModel(caissei)) then
  363. vtype = "bike"
  364. end
  365. if DoesEntityExist(caissei) then
  366. --TriggerServerEvent('ply_garages:CheckForVeh', plate, vehicles[vtype][2], vtype)
  367. local damage = GetVehicleBodyHealth(caissei)
  368. if damage < 980 or not AreAllVehicleWindowsIntact(caissei) or IsVehicleDoorDamaged(caissei,0) or IsVehicleDoorDamaged(caissei,1) or IsVehicleDoorDamaged(caissei,2) or IsVehicleDoorDamaged(caissei,3) then
  369. TriggerEvent("pNotify:SendNotification",{text = "Dit køretøj er skadet, reparer det før du parkerer",type = "info",timeout = (2000),layout = "bottomCenter",queue = "info",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
  370. else
  371. TriggerServerEvent('ply_garages:CheckForVeh', plate, vehicles[vtype][2], vtype)
  372. -- remove vehicle
  373. end
  374. else
  375. drawNotification(lang_string.text6)
  376. end
  377. end)
  378. end
  379.  
  380. function ListVehicle(page)
  381. ped = GetPlayerPed(-1)
  382. selectedPage = page
  383. MenuTitle = lang_string.menu4
  384. ClearMenu()
  385. local count = 0
  386. for ind, value in pairs(GVEHICLES) do
  387. if ((count >= (page*10)) and (count < ((page*10)+10))) then
  388. Menu.addButton(tostring(value.vehicle_name), "OptionVehicle", value.vehicle_name)
  389. end
  390. count = count + 1
  391. end
  392. Menu.addButton(lang_string.menu12,"ListVehicle",page+1)
  393. if page == 0 then
  394. Menu.addButton(lang_string.menu7,"MenuGarage",nil)
  395. else
  396. Menu.addButton(lang_string.menu7,"ListVehicle",page-1)
  397. end
  398. end
  399.  
  400. function OptionVehicle(vehID)
  401. local vehID = vehID
  402. MenuTitle = "Options"
  403. ClearMenu()
  404. Menu.addButton(lang_string.menu6, "SpawnVehicle", vehID)
  405. Menu.addButton(lang_string.menu7, "ListVehicle", selectedPage)
  406. end
  407.  
  408. function SpawnVehicle(vehID)
  409. local vehID = vehID
  410. TriggerServerEvent('ply_garages:CheckForSpawnVeh', vehID)
  411. CloseMenu()
  412. end
  413.  
  414.  
  415. function drawNotification(text)
  416. SetNotificationTextEntry("STRING")
  417. AddTextComponentString(text)
  418. DrawNotification(false, false)
  419. end
  420.  
  421. function CloseMenu()
  422. Menu.hidden = true
  423. TriggerServerEvent("ply_garages:CheckGarageForVeh")
  424. end
  425.  
  426. function LocalPed()
  427. return GetPlayerPed(-1)
  428. end
  429.  
  430. function IsPlayerInRangeOfGarage()
  431. return inrangeofgarage
  432. end
  433.  
  434. function Chat(debugg)
  435. TriggerEvent("chatMessage", '', { 0, 0x99, 255 }, tostring(debugg))
  436. end
  437.  
  438. function ply_drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  439. SetTextFont(font)
  440. SetTextProportional(0)
  441. SetTextScale(scale, scale)
  442. SetTextColour(r, g, b, a)
  443. SetTextDropShadow(0, 0, 0, 0,255)
  444. SetTextEdge(1, 0, 0, 0, 255)
  445. SetTextDropShadow()
  446. SetTextOutline()
  447. SetTextCentre(centre)
  448. SetTextEntry("STRING")
  449. AddTextComponentString(text)
  450. DrawText(x , y)
  451. end
  452.  
  453.  
  454. function DrawText3DSP(x,y,z, text)
  455. local onScreen,_x,_y=World3dToScreen2d(x,y,z)
  456. local px,py,pz=table.unpack(GetGameplayCamCoords())
  457.  
  458. SetTextScale(0.35, 0.35)
  459. SetTextFont(4)
  460. SetTextProportional(1)
  461. SetTextColour(255, 255, 255, 215)
  462. SetTextEntry("STRING")
  463. SetTextCentre(1)
  464. AddTextComponentString(text)
  465. DrawText(_x,_y)
  466. local factor = (string.len(text)) / 370
  467. DrawRect(_x,_y+0.0125, 0.015+ factor, 0.03, 41, 11, 41, 68)
  468. end
  469.  
  470. --[[Citizen]]--
  471.  
  472. Citizen.CreateThread(function()
  473. while true do
  474. Citizen.Wait(0)
  475. for _, garage in pairs(garages) do
  476. DrawMarker(27, garage.x, garage.y, garage.z, 0, 0, 0, 0, 0, 0, 3.001, 3.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 50)
  477. if GetDistanceBetweenCoords(garage.x, garage.y, garage.z, GetEntityCoords(LocalPed())) < 3 and IsPedInAnyVehicle(LocalPed(), true) == false then
  478. -- ply_drawTxt(lang_string.menu8,0,1,0.5,0.8,0.6,255,255,255,255)
  479. DrawText3DSP(garage.x, garage.y, garage.z,lang_string.menu8)
  480. if IsControlJustPressed(1, 86) then
  481. garageSelected.x = garage.x
  482. garageSelected.y = garage.y
  483. garageSelected.z = garage.z
  484. MenuGarage()
  485. Menu.hidden = not Menu.hidden
  486. end
  487. Menu.renderGUI()
  488. end
  489. end
  490. end
  491. end)
  492.  
  493. Citizen.CreateThread(function()
  494. while true do
  495. Citizen.Wait(0)
  496. for _, garage in pairs(garages) do
  497. DrawMarker(27, garage.x, garage.y, garage.z, 0, 0, 0, 0, 0, 0, 3.001, 3.0001, 0.5001, 0, 155, 255, 200, 0, 1, 0, 50)
  498. if GetDistanceBetweenCoords(garage.x, garage.y, garage.z, GetEntityCoords(LocalPed())) < 3 and IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
  499. DrawText3DSP(garage.x, garage.y, garage.z, "Tryk ~g~E~w~ for at opvevare køretøjet.")
  500. --elseif GetDistanceBetweenCoords(garage.x, garage.y, garage.z, GetEntityCoords(LocalPed())) < 3 then
  501. -- DrawText3Ds(garage.x, garage.y, garage.z, "Stig ud af dit fucking køretøj.")
  502. if IsControlJustPressed(1, 38) then
  503. garageSelected.x = garage.x
  504. garageSelected.y = garage.y
  505. garageSelected.z = garage.z
  506. StoreVehicle()
  507. end
  508. end
  509. end
  510. end
  511. end)
  512.  
  513.  
  514.  
  515. Citizen.CreateThread(function()
  516. while true do
  517. local near = false
  518. Citizen.Wait(0)
  519. for _, garage in pairs(garages) do
  520. if (GetDistanceBetweenCoords(garage.x, garage.y, garage.z, GetEntityCoords(LocalPed())) < 3 and near ~= true) then
  521. near = true
  522. end
  523. end
  524. if near == false then
  525. Menu.hidden = true
  526. end
  527. end
  528. end)
  529.  
  530. Citizen.CreateThread(function()
  531. for _, item in pairs(garages) do
  532. if not item.hidden then
  533. item.blip = AddBlipForCoord(item.x, item.y, item.z)
  534. SetBlipSprite(item.blip, item.id)
  535. SetBlipAsShortRange(item.blip, true)
  536. SetBlipColour(item.blip, item.colour)
  537. SetBlipScale(item.blip, 0.8)
  538. BeginTextCommandSetBlipName("STRING")
  539. AddTextComponentString(item.name)
  540. EndTextCommandSetBlipName(item.blip)
  541. end
  542. end
  543. end)
  544. --[[Events]]--
  545.  
  546. RegisterNetEvent('vrp_garages:setVehicle')
  547. AddEventHandler('vrp_garages:setVehicle', function(vtype, vehicle)
  548. vehicles[vtype] = vehicle
  549. end)
  550.  
  551. RegisterNetEvent('ply_garages:addAptGarage')
  552. AddEventHandler('ply_garages:addAptGarage', function(gx,gy,gz,gh)
  553. local alreadyExists = false
  554. for _, garage in pairs(garages) do
  555. if garage.x == gx and garage.y == gy then
  556. alreadyExists = true
  557. end
  558. end
  559. if not alreadyExists then
  560. table.insert(garages, #garages + 1, {name="Apartment Garage", colour=3, id=357, x=gx, y=gy, z=gz, h=gh})
  561. end
  562. end)
  563.  
  564. RegisterNetEvent('ply_garages:getVehicles')
  565. AddEventHandler("ply_garages:getVehicles", function(THEVEHICLES)
  566. GVEHICLES = {}
  567. GVEHICLES = THEVEHICLES
  568. end)
  569.  
  570. AddEventHandler("playerSpawned", function()
  571. TriggerServerEvent("ply_garages:CheckGarageForVeh")
  572. TriggerServerEvent("ply_garages:CheckForAptGarages")
  573. end)
Add Comment
Please, Sign In to add comment