Advertisement
Guest User

blah blah blah streetcorps

a guest
Mar 29th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.09 KB | None | 0 0
  1. local vehshop = {
  2. opened = false,
  3. title = "Vehicle Shop",
  4. currentmenu = "main",
  5. lastmenu = nil,
  6. currentpos = nil,
  7. selectedbutton = 0,
  8. marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
  9. menu = {
  10. x = 0.9,
  11. y = 0.08,
  12. width = 0.2,
  13. height = 0.04,
  14. buttons = 10,
  15. from = 1,
  16. to = 10,
  17. scale = 0.4,
  18. font = 0,
  19. ["main"] = {
  20. title = "CATEGORIES",
  21. name = "main",
  22. buttons = {
  23. {name = "Vehicles", description = ""},
  24. {name = "Motorcycles", description = ""},
  25. }
  26. },
  27. ["vehicles"] = {
  28. title = "VEHICLES",
  29. name = "vehicles",
  30. buttons = {
  31. {name = "Compacts", description = ''},
  32. {name = "Coupes", description = ''},
  33. {name = "Sedans", description = ''},
  34. {name = "Sports", description = ''},
  35. {name = "Sports Classics", description = ''},
  36. {name = "Super", description = ''},
  37. {name = "Muscle", description = ''},
  38. {name = "Off-Road", description = ''},
  39. {name = "SUVs", description = ''},
  40. {name = "Vans", description = ''},
  41. {name = "Cycles", description = ''},
  42. }
  43. },
  44. ["compacts"] = {
  45. title = "compacts",
  46. name = "compacts",
  47. buttons = {
  48. {name = "Blista", costs = 15000, description = {}, model = "blista"},
  49. {name = "Brioso R/A", costs = 155000, description = {}, model = "brioso"},
  50. {name = "Dilettante", costs = 25000, description = {}, model = "Dilettante"},
  51. {name = "Issi", costs = 18000, description = {}, model = "issi2"},
  52. {name = "Panto", costs = 85000, description = {}, model = "panto"},
  53. {name = "Prairie", costs = 30000, description = {}, model = "prairie"},
  54. {name = "Rhapsody", costs = 120000, description = {}, model = "rhapsody"},
  55. }
  56. },
  57. ["coupes"] = {
  58. title = "coupes",
  59. name = "coupes",
  60. buttons = {
  61. {name = "Cognoscenti Cabrio", costs = 180000, description = {}, model = "cogcabrio"},
  62. {name = "Exemplar", costs = 200000, description = {}, model = "exemplar"},
  63. {name = "F620", costs = 80000, description = {}, model = "f620"},
  64. {name = "Felon", costs = 90000, description = {}, model = "felon"},
  65. {name = "Felon GT", costs = 95000, description = {}, model = "felon2"},
  66. {name = "Jackal", costs = 60000, description = {}, model = "jackal"},
  67. {name = "Oracle", costs = 80000, description = {}, model = "oracle"},
  68. {name = "Oracle XS", costs = 82000, description = {}, model = "oracle2"},
  69. {name = "Sentinel", costs = 90000, description = {}, model = "sentinel"},
  70. {name = "Sentinel XS", costs = 60000, description = {}, model = "sentinel2"},
  71. {name = "Windsor", costs = 800000, description = {}, model = "windsor"},
  72. {name = "Windsor Drop", costs = 850000, description = {}, model = "windsor2"},
  73. {name = "Zion", costs = 60000, description = {}, model = "zion"},
  74. {name = "Zion Cabrio", costs = 65000, description = {}, model = "zion2"},
  75. }
  76. },
  77. ["sports"] = {
  78. title = "sports",
  79. name = "sports",
  80. buttons = {
  81. {name = "9F", costs = 120000, description = {}, model = "ninef"},
  82. {name = "9F Cabrio", costs = 130000, description = {}, model = "ninef2"},
  83. {name = "Alpha", costs = 150000, description = {}, model = "alpha"},
  84. {name = "Banshee", costs = 105000, description = {}, model = "banshee"},
  85. {name = "Bestia GTS", costs = 610000, description = {}, model = "bestiagts"},
  86. {name = "Blista Compact", costs = 42000, description = {}, model = "blista"},
  87. {name = "Buffalo", costs = 35000, description = {}, model = "buffalo"},
  88. {name = "Buffalo S", costs = 96000, description = {}, model = "buffalo2"},
  89. {name = "Carbonizzare", costs = 195000, description = {}, model = "carbonizzare"},
  90. {name = "Comet", costs = 100000, description = {}, model = "comet2"},
  91. {name = "Coquette", costs = 138000, description = {}, model = "coquette"},
  92. {name = "Drift Tampa", costs = 995000, description = {}, model = "tampa2"},
  93. {name = "Feltzer", costs = 130000, description = {}, model = "feltzer2"},
  94. {name = "Furore GT", costs = 448000, description = {}, model = "furoregt"},
  95. {name = "Fusilade", costs = 36000, description = {}, model = "fusilade"},
  96. {name = "Jester", costs = 240000, description = {}, model = "jester"},
  97. {name = "Jester(Racecar)", costs = 350000, description = {}, model = "jester2"},
  98. {name = "Kuruma", costs = 95000, description = {}, model = "kuruma"},
  99. {name = "Lynx", costs = 1735000, description = {}, model = "lynx"},
  100. {name = "Massacro", costs = 275000, description = {}, model = "massacro"},
  101. {name = "Massacro(Racecar)", costs = 385000, description = {}, model = "massacro2"},
  102. {name = "Omnis", costs = 701000, description = {}, model = "omnis"},
  103. {name = "Penumbra", costs = 24000, description = {}, model = "penumbra"},
  104. {name = "Rapid GT", costs = 140000, description = {}, model = "rapidgt"},
  105. {name = "Rapid GT Convertible", costs = 150000, description = {}, model = "rapidgt2"},
  106. {name = "Schafter V12", costs = 140000, description = {}, model = "schafter3"},
  107. {name = "Sultan", costs = 12000, description = {}, model = "sultan"},
  108. {name = "Surano", costs = 110000, description = {}, model = "surano"},
  109. {name = "Tropos", costs = 816000, description = {}, model = "tropos"},
  110. {name = "Verkierer", costs = 695000, description = {}, model = "verlierer2"},
  111. }
  112. },
  113. ["sportsclassics"] = {
  114. title = "sports classics",
  115. name = "sportsclassics",
  116. buttons = {
  117. {name = "Casco", costs = 680000, description = {}, model = "casco"},
  118. {name = "Coquette Classic", costs = 665000, description = {}, model = "coquette2"},
  119. {name = "JB 700", costs = 350000, description = {}, model = "jb700"},
  120. {name = "Pigalle", costs = 400000, description = {}, model = "pigalle"},
  121. {name = "Stinger", costs = 850000, description = {}, model = "stinger"},
  122. {name = "Stinger GT", costs = 875000, description = {}, model = "stingergt"},
  123. {name = "Stirling GT", costs = 975000, description = {}, model = "feltzer3"},
  124. {name = "Z-Type", costs = 950000, description = {}, model = "ztype"},
  125. }
  126. },
  127. ["super"] = {
  128. title = "super",
  129. name = "super",
  130. buttons = {
  131. {name = "Adder", costs = 1000000, description = {}, model = "adder"},
  132. {name = "Banshee 900R", costs = 565000, description = {}, model = "banshee2"},
  133. {name = "Bullet", costs = 155000, description = {}, model = "bullet"},
  134. {name = "Cheetah", costs = 650000, description = {}, model = "cheetah"},
  135. {name = "Entity XF", costs = 795000, description = {}, model = "entityxf"},
  136. {name = "ETR1", costs = 199500, description = {}, model = "sheava"},
  137. {name = "FMJ", costs = 1750000, description = {}, model = "fmj"},
  138. {name = "Infernus", costs = 440000, description = {}, model = "infernus"},
  139. {name = "Osiris", costs = 1950000, description = {}, model = "osiris"},
  140. {name = "RE-7B", costs = 2475000, description = {}, model = "le7b"},
  141. {name = "Reaper", costs = 1595000, description = {}, model = "reaper"},
  142. {name = "Sultan RS", costs = 795000, description = {}, model = "sultanrs"},
  143. {name = "T20", costs = 2200000, description = {}, model = "t20"},
  144. {name = "Turismo R", costs = 500000, description = {}, model = "turismor"},
  145. {name = "Tyrus", costs = 2550000, description = {}, model = "tyrus"},
  146. {name = "Vacca", costs = 240000, description = {}, model = "vacca"},
  147. {name = "Voltic", costs = 150000, description = {}, model = "voltic"},
  148. {name = "X80 Proto", costs = 2700000, description = {}, model = "prototipo"},
  149. {name = "Zentorno", costs = 725000, description = {}, model = "zentorno"},
  150. }
  151. },
  152. ["muscle"] = {
  153. title = "muscle",
  154. name = "muscle",
  155. buttons = {
  156. {name = "Blade", costs = 160000, description = {}, model = "blade"},
  157. {name = "Buccaneer", costs = 29000, description = {}, model = "buccaneer"},
  158. {name = "Chino", costs = 225000, description = {}, model = "chino"},
  159. {name = "Coquette BlackFin", costs = 695000, description = {}, model = "coquette3"},
  160. {name = "Dominator", costs = 35000, description = {}, model = "dominator"},
  161. {name = "Dukes", costs = 62000, description = {}, model = "dukes"},
  162. {name = "Gauntlet", costs = 32000, description = {}, model = "gauntlet"},
  163. {name = "Hotknife", costs = 90000, description = {}, model = "hotknife"},
  164. {name = "Faction", costs = 36000, description = {}, model = "faction"},
  165. {name = "Nightshade", costs = 585000, description = {}, model = "nightshade"},
  166. {name = "Picador", costs = 9000, description = {}, model = "picador"},
  167. {name = "Sabre Turbo", costs = 15000, description = {}, model = "sabregt"},
  168. {name = "Tampa", costs = 375000, description = {}, model = "tampa"},
  169. {name = "Virgo", costs = 195000, description = {}, model = "virgo"},
  170. {name = "Vigero", costs = 21000, description = {}, model = "vigero"},
  171. }
  172. },
  173. ["offroad"] = {
  174. title = "off-road",
  175. name = "off-road",
  176. buttons = {
  177. {name = "Bifta", costs = 75000, description = {}, model = "bifta"},
  178. {name = "Blazer", costs = 8000, description = {}, model = "blazer"},
  179. {name = "Brawler", costs = 715000, description = {}, model = "brawler"},
  180. {name = "Bubsta 6x6", costs = 249000, description = {}, model = "dubsta3"},
  181. {name = "Dune Buggy", costs = 20000, description = {}, model = "dune"},
  182. {name = "Rebel", costs = 22000, description = {}, model = "rebel2"},
  183. {name = "Sandking", costs = 38000, description = {}, model = "sandking"},
  184. {name = "The Liberator", costs = 550000, description = {}, model = "monster"},
  185. {name = "Trophy Truck", costs = 550000, description = {}, model = "trophytruck"},
  186. }
  187. },
  188. ["suvs"] = {
  189. title = "suvs",
  190. name = "suvs",
  191. buttons = {
  192. {name = "Baller", costs = 90000, description = {}, model = "baller"},
  193. {name = "Cavalcade", costs = 60000, description = {}, model = "cavalcade"},
  194. {name = "Grabger", costs = 35000, description = {}, model = "granger"},
  195. {name = "Huntley S", costs = 195000, description = {}, model = "huntley"},
  196. {name = "Landstalker", costs = 58000, description = {}, model = "landstalker"},
  197. {name = "Radius", costs = 32000, description = {}, model = "radi"},
  198. {name = "Rocoto", costs = 85000, description = {}, model = "rocoto"},
  199. {name = "Seminole", costs = 30000, description = {}, model = "seminole"},
  200. {name = "XLS", costs = 253000, description = {}, model = "xls"},
  201. }
  202. },
  203. ["vans"] = {
  204. title = "vans",
  205. name = "vans",
  206. buttons = {
  207. {name = "Bison", costs = 30000, description = {}, model = "bison"},
  208. {name = "Bobcat XL", costs = 23000, description = {}, model = "bobcatxl"},
  209. {name = "Gang Burrito", costs = 65000, description = {}, model = "gburrito"},
  210. {name = "Journey", costs = 15000, description = {}, model = "journey"},
  211. {name = "Minivan", costs = 30000, description = {}, model = "minivan"},
  212. {name = "Paradise", costs = 25000, description = {}, model = "paradise"},
  213. {name = "Rumpo", costs = 13000, description = {}, model = "rumpo"},
  214. {name = "Surfer", costs = 11000, description = {}, model = "surfer"},
  215. {name = "Youga", costs = 16000, description = {}, model = "youga"},
  216. }
  217. },
  218. ["sedans"] = {
  219. title = "sedans",
  220. name = "sedans",
  221. buttons = {
  222. {name = "Asea", costs = 1000000, description = {}, model = "asea"},
  223. {name = "Asterope", costs = 1000000, description = {}, model = "asterope"},
  224. --{name = "Cognoscenti", costs = 1000000, description = {}, model = "cognoscenti"},
  225. --{name = "Cognoscenti(Armored)", costs = 1000000, description = {}, model = "cognoscenti2"},
  226. --{name = "Cognoscenti 55", costs = 1000000, description = {}, model = "cognoscenti3"},
  227. --{name = "Cognoscenti 55(Armored", costs = 1500000, description = {}, model = "ZENTORNO"},
  228. {name = "Fugitive", costs = 24000, description = {}, model = "fugitive"},
  229. {name = "Glendale", costs = 200000, description = {}, model = "glendale"},
  230. {name = "Ingot", costs = 9000, description = {}, model = "ingot"},
  231. {name = "Intruder", costs = 16000, description = {}, model = "intruder"},
  232. {name = "Premier", costs = 10000, description = {}, model = "premier"},
  233. {name = "Primo", costs = 9000, description = {}, model = "primo"},
  234. {name = "Primo Custom", costs = 9500, description = {}, model = "primo2"},
  235. {name = "Regina", costs = 8000, description = {}, model = "regina"},
  236. {name = "Schafter", costs = 65000, description = {}, model = "schafter2"},
  237. {name = "Stanier", costs = 10000, description = {}, model = "stanier"},
  238. {name = "Stratum", costs = 10000, description = {}, model = "stratum"},
  239. {name = "Stretch", costs = 30000, description = {}, model = "stretch"},
  240. {name = "Super Diamond", costs = 250000, description = {}, model = "superd"},
  241. {name = "Surge", costs = 38000, description = {}, model = "surge"},
  242. {name = "Tailgater", costs = 55000, description = {}, model = "tailgater"},
  243. {name = "Warrener", costs = 120000, description = {}, model = "warrener"},
  244. {name = "Washington", costs = 15000, description = {}, model = "washington"},
  245. }
  246. },
  247. ["motorcycles"] = {
  248. title = "MOTORCYCLES",
  249. name = "motorcycles",
  250. buttons = {
  251. {name = "Akuma", costs = 9000, description = {}, model = "AKUMA"},
  252. {name = "Bagger", costs = 5000, description = {}, model = "bagger"},
  253. {name = "Bati 801", costs = 15000, description = {}, model = "bati"},
  254. {name = "Bati 801RR", costs = 15000, description = {}, model = "bati2"},
  255. {name = "BF400", costs = 95000, description = {}, model = "bf400"},
  256. {name = "Carbon RS", costs = 40000, description = {}, model = "carbonrs"},
  257. {name = "Cliffhanger", costs = 225000, description = {}, model = "cliffhanger"},
  258. {name = "Daemon", costs = 5000, description = {}, model = "daemon"},
  259. {name = "Double T", costs = 12000, description = {}, model = "double"},
  260. {name = "Enduro", costs = 48000, description = {}, model = "enduro"},
  261. {name = "Faggio", costs = 4000, description = {}, model = "faggio2"},
  262. {name = "Gargoyle", costs = 120000, description = {}, model = "gargoyle"},
  263. {name = "Hakuchou", costs = 82000, description = {}, model = "hakuchou"},
  264. {name = "Hexer", costs = 15000, description = {}, model = "hexer"},
  265. {name = "Innovation", costs = 90000, description = {}, model = "innovation"},
  266. {name = "Lectro", costs = 700000, description = {}, model = "lectro"},
  267. {name = "Nemesis", costs = 12000, description = {}, model = "nemesis"},
  268. {name = "PCJ-600", costs = 9000, description = {}, model = "pcj"},
  269. {name = "Ruffian", costs = 9000, description = {}, model = "ruffian"},
  270. {name = "Sanchez", costs = 7000, description = {}, model = "sanchez"},
  271. {name = "Sovereign", costs = 90000, description = {}, model = "sovereign"},
  272. {name = "Thrust", costs = 75000, description = {}, model = "thrust"},
  273. {name = "Vader", costs = 9000, description = {}, model = "vader"},
  274. {name = "Vindicator", costs = 600000, description = {}, model = "vindicator"},
  275. }
  276. },
  277. }
  278. }
  279. local fakecar = {model = '', car = nil}
  280. local vehshop_locations = {
  281. {entering = {-33.803,-1102.322,25.422}, inside = {-46.56327,-1097.382,25.99875, 120.1953}, outside = {-31.849,-1090.648,25.998,322.345}},
  282. }
  283.  
  284. local vehshop_blips ={}
  285. local inrangeofvehshop = false
  286. local currentlocation = nil
  287. local boughtcar = false
  288.  
  289. local function LocalPed()
  290. return GetPlayerPed(-1)
  291. end
  292.  
  293. function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  294. SetTextFont(font)
  295. SetTextProportional(0)
  296. SetTextScale(scale, scale)
  297. SetTextColour(r, g, b, a)
  298. SetTextDropShadow(0, 0, 0, 0,255)
  299. SetTextEdge(1, 0, 0, 0, 255)
  300. SetTextDropShadow()
  301. SetTextOutline()
  302. SetTextCentre(centre)
  303. SetTextEntry("STRING")
  304. AddTextComponentString(text)
  305. DrawText(x , y)
  306. end
  307.  
  308. function IsPlayerInRangeOfVehshop()
  309. return inrangeofvehshop
  310. end
  311.  
  312. function ShowVehshopBlips(bool)
  313. if bool and #vehshop_blips == 0 then
  314. for station,pos in pairs(vehshop_locations) do
  315. local loc = pos
  316. pos = pos.entering
  317. local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
  318. -- 60 58 137
  319. SetBlipSprite(blip,326)
  320. BeginTextCommandSetBlipName("STRING")
  321. AddTextComponentString('Vehicle shop')
  322. EndTextCommandSetBlipName(blip)
  323. SetBlipAsShortRange(blip,true)
  324. SetBlipAsMissionCreatorBlip(blip,true)
  325. table.insert(vehshop_blips, {blip = blip, pos = loc})
  326. end
  327. Citizen.CreateThread(function()
  328. while #vehshop_blips > 0 do
  329. Citizen.Wait(0)
  330. local inrange = false
  331. for i,b in ipairs(vehshop_blips) do
  332. if IsPlayerWantedLevelGreater(GetPlayerIndex(),0) == false and vehshop.opened == false and IsPedInAnyVehicle(LocalPed(), true) == false and GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(LocalPed())) < 5 then
  333. DrawMarker(1,b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
  334. drawTxt('Press ~g~ENTER~s~ to buy ~b~vehicle',0,1,0.5,0.8,0.6,255,255,255,255)
  335. currentlocation = b
  336. inrange = true
  337. end
  338. end
  339. inrangeofvehshop = inrange
  340. end
  341. end)
  342. elseif bool == false and #vehshop_blips > 0 then
  343. for i,b in ipairs(vehshop_blips) do
  344. if DoesBlipExist(b.blip) then
  345. SetBlipAsMissionCreatorBlip(b.blip,false)
  346. Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
  347. end
  348. end
  349. vehshop_blips = {}
  350. end
  351. end
  352.  
  353. function f(n)
  354. return n + 0.0001
  355. end
  356.  
  357. function LocalPed()
  358. return GetPlayerPed(-1)
  359. end
  360.  
  361. function try(f, catch_f)
  362. local status, exception = pcall(f)
  363. if not status then
  364. catch_f(exception)
  365. end
  366. end
  367. function firstToUpper(str)
  368. return (str:gsub("^%l", string.upper))
  369. end
  370. --local veh = nil
  371. function OpenCreator()
  372. boughtcar = false
  373. local ped = LocalPed()
  374. local pos = currentlocation.pos.inside
  375. FreezeEntityPosition(ped,true)
  376. SetEntityVisible(ped,false)
  377. local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
  378. SetEntityCoords(ped,pos[1],pos[2],g)
  379. SetEntityHeading(ped,pos[4])
  380. vehshop.currentmenu = "main"
  381. vehshop.opened = true
  382. vehshop.selectedbutton = 0
  383. --[[Citizen.CreateThread(function()
  384. RequestModel(GetHashKey('t20'))
  385. while not HasModelLoaded(GetHashKey('t20')) do
  386. Citizen.Wait(0)
  387. end
  388. veh = CreateVehicle(GetHashKey('t20'),GetOffsetFromEntityInWorldCoords(ped,2.001,0,0),false,true)
  389. SetModelAsNoLongerNeeded(GetHashKey('t20'))
  390. SetEntityHeading(veh,pos[4])
  391. FreezeEntityPosition(veh,true)
  392. SetEntityCollision(veh,false,false)
  393. SetEntityInvincible(veh,true)
  394. end)]]
  395. end
  396. local vehicle_price = 0
  397. function CloseCreator()
  398. Citizen.CreateThread(function()
  399. local ped = LocalPed()
  400. if not boughtcar then
  401. local pos = currentlocation.pos.entering
  402. SetEntityCoords(ped,pos[1],pos[2],pos[3])
  403. FreezeEntityPosition(ped,false)
  404. SetEntityVisible(ped,true)
  405. else
  406. local veh = GetVehiclePedIsUsing(ped)
  407. local model = GetEntityModel(veh)
  408. local colors = table.pack(GetVehicleColours(veh))
  409. local extra_colors = table.pack(GetVehicleExtraColours(veh))
  410.  
  411. local mods = {}
  412. for i = 0,24 do
  413. mods[i] = GetVehicleMod(veh,i)
  414. end
  415. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(veh))
  416. local pos = currentlocation.pos.outside
  417.  
  418. FreezeEntityPosition(ped,false)
  419. RequestModel(model)
  420. while not HasModelLoaded(model) do
  421. Citizen.Wait(0)
  422. end
  423. personalvehicle = CreateVehicle(model,pos[1],pos[2],pos[3],pos[4],true,false)
  424. SetModelAsNoLongerNeeded(model)
  425. for i,mod in pairs(mods) do
  426. SetVehicleModKit(personalvehicle,0)
  427. SetVehicleMod(personalvehicle,i,mod)
  428. end
  429. SetVehicleOnGroundProperly(personalvehicle)
  430. SetVehicleHasBeenOwnedByPlayer(personalvehicle,true)
  431. local id = NetworkGetNetworkIdFromEntity(personalvehicle)
  432. SetNetworkIdCanMigrate(id, true)
  433. Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(personalvehicle))
  434. SetVehicleColours(personalvehicle,colors[1],colors[2])
  435. SetVehicleExtraColours(personalvehicle,extra_colors[1],extra_colors[2])
  436. --local blip = AddBlipForEntity(personalvehicle)
  437. --SetBlipSprite(blip,326)
  438. --BeginTextCommandSetBlipName("STRING")
  439. --AddTextComponentString('Personal vehicle')
  440. --EndTextCommandSetBlipName(blip)
  441. --personalvehicle_blip = blip
  442. TaskWarpPedIntoVehicle(GetPlayerPed(-1),personalvehicle,-1)
  443. SetEntityVisible(ped,true)
  444. TriggerEvent('BoughtPv',personalvehicle)
  445.  
  446. end
  447. vehshop.opened = false
  448. vehshop.menu.from = 1
  449. vehshop.menu.to = 10
  450. end)
  451. end
  452.  
  453. function drawMenuButton(button,x,y,selected)
  454. local menu = vehshop.menu
  455. SetTextFont(menu.font)
  456. SetTextProportional(0)
  457. SetTextScale(menu.scale, menu.scale)
  458. if selected then
  459. SetTextColour(0, 0, 0, 255)
  460. else
  461. SetTextColour(255, 255, 255, 255)
  462. end
  463. SetTextCentre(0)
  464. SetTextEntry("STRING")
  465. AddTextComponentString(button.name)
  466. if selected then
  467. DrawRect(x,y,menu.width,menu.height,255,255,255,255)
  468. else
  469. DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  470. end
  471. DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  472. end
  473.  
  474. function drawMenuInfo(text)
  475. local menu = vehshop.menu
  476. SetTextFont(menu.font)
  477. SetTextProportional(0)
  478. SetTextScale(0.45, 0.45)
  479. SetTextColour(255, 255, 255, 255)
  480. SetTextCentre(0)
  481. SetTextEntry("STRING")
  482. AddTextComponentString(text)
  483. DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
  484. DrawText(0.365, 0.934)
  485. end
  486.  
  487. function drawMenuRight(txt,x,y,selected)
  488. local menu = vehshop.menu
  489. SetTextFont(menu.font)
  490. SetTextProportional(0)
  491. SetTextScale(menu.scale, menu.scale)
  492. SetTextRightJustify(1)
  493. if selected then
  494. SetTextColour(0, 0, 0, 255)
  495. else
  496. SetTextColour(255, 255, 255, 255)
  497. end
  498. SetTextCentre(0)
  499. SetTextEntry("STRING")
  500. AddTextComponentString(txt)
  501. DrawText(x + menu.width/2 - 0.03, y - menu.height/2 + 0.0028)
  502. end
  503.  
  504. function drawMenuTitle(txt,x,y)
  505. local menu = vehshop.menu
  506. SetTextFont(2)
  507. SetTextProportional(0)
  508. SetTextScale(0.5, 0.5)
  509. SetTextColour(255, 255, 255, 255)
  510. SetTextEntry("STRING")
  511. AddTextComponentString(txt)
  512. DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  513. DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  514. end
  515. function tablelength(T)
  516. local count = 0
  517. for _ in pairs(T) do count = count + 1 end
  518. return count
  519. end
  520. function Notify(text)
  521. SetNotificationTextEntry('STRING')
  522. AddTextComponentString(text)
  523. DrawNotification(false, false)
  524. end
  525.  
  526. function DoesPlayerHaveVehicle(model,button,y,selected)
  527. local t = false
  528. --TODO:check if player own car
  529. if t then
  530. drawMenuRight("OWNED",vehshop.menu.x,y,selected)
  531. else
  532. drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
  533. end
  534. end
  535.  
  536. local backlock = false
  537. Citizen.CreateThread(function()
  538. while true do
  539. Citizen.Wait(0)
  540. if IsControlJustPressed(1,201) and IsPlayerInRangeOfVehshop() then
  541. if vehshop.opened then
  542. CloseCreator()
  543. else
  544. OpenCreator()
  545. end
  546. end
  547. if vehshop.opened then
  548. local ped = LocalPed()
  549. local menu = vehshop.menu[vehshop.currentmenu]
  550. drawTxt(vehshop.title,1,1,vehshop.menu.x,vehshop.menu.y,1.0, 255,255,255,255)
  551. drawMenuTitle(menu.title, vehshop.menu.x,vehshop.menu.y + 0.08)
  552. drawTxt(vehshop.selectedbutton.."/"..tablelength(menu.buttons),0,0,vehshop.menu.x + vehshop.menu.width/2 - 0.0385,vehshop.menu.y + 0.067,0.4, 255,255,255,255)
  553. local y = vehshop.menu.y + 0.12
  554. buttoncount = tablelength(menu.buttons)
  555. local selected = false
  556.  
  557. for i,button in pairs(menu.buttons) do
  558. if i >= vehshop.menu.from and i <= vehshop.menu.to then
  559.  
  560. if i == vehshop.selectedbutton then
  561. selected = true
  562. else
  563. selected = false
  564. end
  565. drawMenuButton(button,vehshop.menu.x,y,selected)
  566. if button.costs ~= nil then
  567. if vehshop.currentmenu == "compacts" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "super" or vehshop.currentmenu == "muscle" or vehshop.currentmenu == "offroad" or vehshop.currentmenu == "suvs" or vehshop.currentmenu == "vans" or vehshop.currentmenu == "industrial" or vehshop.currentmenu == "cycles" or vehshop.currentmenu == "motorcycles" then
  568. DoesPlayerHaveVehicle(button.model,button,y,selected)
  569. else
  570. drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
  571. end
  572. end
  573. y = y + 0.04
  574. if vehshop.currentmenu == "compacts" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "super" or vehshop.currentmenu == "muscle" or vehshop.currentmenu == "offroad" or vehshop.currentmenu == "suvs" or vehshop.currentmenu == "vans" or vehshop.currentmenu == "industrial" or vehshop.currentmenu == "cycles" or vehshop.currentmenu == "motorcycles" then
  575. if selected then
  576. if fakecar.model ~= button.model then
  577. if DoesEntityExist(fakecar.car) then
  578. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  579. end
  580. local pos = currentlocation.pos.inside
  581. local hash = GetHashKey(button.model)
  582. RequestModel(hash)
  583. while not HasModelLoaded(hash) do
  584. Citizen.Wait(0)
  585. drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
  586.  
  587. end
  588. local veh = CreateVehicle(hash,pos[1],pos[2],pos[3],pos[4],false,false)
  589. while not DoesEntityExist(veh) do
  590. Citizen.Wait(0)
  591. drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
  592. end
  593. FreezeEntityPosition(veh,true)
  594. SetEntityInvincible(veh,true)
  595. SetVehicleDoorsLocked(veh,4)
  596. --SetEntityCollision(veh,false,false)
  597. TaskWarpPedIntoVehicle(LocalPed(),veh,-1)
  598. for i = 0,24 do
  599. SetVehicleModKit(veh,0)
  600. RemoveVehicleMod(veh,i)
  601. end
  602. fakecar = { model = button.model, car = veh}
  603. end
  604. end
  605. end
  606. if selected and IsControlJustPressed(1,201) then
  607. ButtonSelected(button)
  608. end
  609. end
  610. end
  611. end
  612. if vehshop.opened then
  613. if IsControlJustPressed(1,202) then
  614. Back()
  615. end
  616. if IsControlJustReleased(1,202) then
  617. backlock = false
  618. end
  619. if IsControlJustPressed(1,188) then
  620. if vehshop.selectedbutton > 1 then
  621. vehshop.selectedbutton = vehshop.selectedbutton -1
  622. if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
  623. vehshop.menu.from = vehshop.menu.from -1
  624. vehshop.menu.to = vehshop.menu.to - 1
  625. end
  626. end
  627. end
  628. if IsControlJustPressed(1,187)then
  629. if vehshop.selectedbutton < buttoncount then
  630. vehshop.selectedbutton = vehshop.selectedbutton +1
  631. if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
  632. vehshop.menu.to = vehshop.menu.to + 1
  633. vehshop.menu.from = vehshop.menu.from + 1
  634. end
  635. end
  636. end
  637. end
  638.  
  639. end
  640. end)
  641.  
  642.  
  643. function round(num, idp)
  644. if idp and idp>0 then
  645. local mult = 10^idp
  646. return math.floor(num * mult + 0.5) / mult
  647. end
  648. return math.floor(num + 0.5)
  649. end
  650. function ButtonSelected(button)
  651. local ped = GetPlayerPed(-1)
  652. local this = vehshop.currentmenu
  653. local btn = button.name
  654. if this == "main" then
  655. if btn == "Vehicles" then
  656. OpenMenu('vehicles')
  657. elseif btn == "Motorcycles" then
  658. OpenMenu('motorcycles')
  659. end
  660. elseif this == "vehicles" then
  661. if btn == "Sports" then
  662. OpenMenu('sports')
  663. elseif btn == "Sedans" then
  664. OpenMenu('sedans')
  665. elseif btn == "Compacts" then
  666. OpenMenu('compacts')
  667. elseif btn == "Coupes" then
  668. OpenMenu('coupes')
  669. elseif btn == "Sports Classics" then
  670. OpenMenu("sportsclassics")
  671. elseif btn == "Super" then
  672. OpenMenu('super')
  673. elseif btn == "Muscle" then
  674. OpenMenu('muscle')
  675. elseif btn == "Off-Road" then
  676. OpenMenu('offroad')
  677. elseif btn == "SUVs" then
  678. OpenMenu('suvs')
  679. elseif btn == "Vans" then
  680. OpenMenu('vans')
  681. end
  682. elseif this == "compacts" or this == "coupes" or this == "sedans" or this == "sports" or this == "sportsclassics" or this == "super" or this == "muscle" or this == "offroad" or this == "suvs" or this == "vans" or this == "industrial" or this == "cycles" or this == "motorcycles" then
  683. TriggerServerEvent('CheckMoneyForVeh',button.model,button.costs)
  684. end
  685. end
  686. RegisterNetEvent('FinishMoneyCheckForVeh')
  687. AddEventHandler('FinishMoneyCheckForVeh', function()
  688. boughtcar = true
  689. CloseCreator()
  690. end)
  691.  
  692. function OpenMenu(menu)
  693. fakecar = {model = '', car = nil}
  694. vehshop.lastmenu = vehshop.currentmenu
  695. if menu == "vehicles" then
  696. vehshop.lastmenu = "main"
  697. elseif menu == "bikes" then
  698. vehshop.lastmenu = "main"
  699. elseif menu == 'race_create_objects' then
  700. vehshop.lastmenu = "main"
  701. elseif menu == "race_create_objects_spawn" then
  702. vehshop.lastmenu = "race_create_objects"
  703. end
  704. vehshop.menu.from = 1
  705. vehshop.menu.to = 10
  706. vehshop.selectedbutton = 0
  707. vehshop.currentmenu = menu
  708. end
  709.  
  710.  
  711. function Back()
  712. if backlock then
  713. return
  714. end
  715. backlock = true
  716. if vehshop.currentmenu == "main" then
  717. CloseCreator()
  718. elseif vehshop.currentmenu == "compacts" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "super" or vehshop.currentmenu == "muscle" or vehshop.currentmenu == "offroad" or vehshop.currentmenu == "suvs" or vehshop.currentmenu == "vans" or vehshop.currentmenu == "industrial" or vehshop.currentmenu == "cycles" or vehshop.currentmenu == "motorcycles" then
  719. if DoesEntityExist(fakecar.car) then
  720. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  721. end
  722. fakecar = {model = '', car = nil}
  723. OpenMenu(vehshop.lastmenu)
  724. else
  725. OpenMenu(vehshop.lastmenu)
  726. end
  727.  
  728. end
  729.  
  730. function stringstarts(String,Start)
  731. return string.sub(String,1,string.len(Start))==Start
  732. end
  733.  
  734. local firstspawn = 0
  735. AddEventHandler('playerSpawned', function(spawn)
  736. if firstspawn == 0 then
  737. RemoveIpl('v_carshowroom')
  738. RemoveIpl('shutter_open')
  739. RemoveIpl('shutter_closed')
  740. RemoveIpl('shr_int')
  741. RemoveIpl('csr_inMission')
  742. RequestIpl('v_carshowroom')
  743. RequestIpl('shr_int')
  744. --RequestIpl('csr_inMission')
  745. RequestIpl('shutter_closed')
  746. --326 car blip 227 225
  747. ShowVehshopBlips(true)
  748. firstspawn = 1
  749. end
  750. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement