wadsonlucas

Untitled

Apr 14th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.00 KB | None | 0 0
  1.  
  2. vRP = Proxy.getInterface("vRP")
  3. vRPg = Proxy.getInterface("vRP_garages")
  4.  
  5. function deleteVehiclePedIsIn()
  6. local v = GetVehiclePedIsIn(GetPlayerPed(-1),false)
  7. SetVehicleHasBeenOwnedByPlayer(v,false)
  8. Citizen.InvokeNative(0xAD738C3085FE7E11, v, false, true) -- set not as mission entity
  9. SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(v))
  10. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(v))
  11. end
  12.  
  13. local vehshop = {
  14. opened = false,
  15. title = "Concessionária de Veiculos",
  16. currentmenu = "main",
  17. lastmenu = nil,
  18. currentpos = nil,
  19. selectedbutton = 0,
  20. marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
  21. menu = {
  22. x = 0.1,
  23. y = 0.08,
  24. width = 0.2,
  25. height = 0.04,
  26. buttons = 10,
  27. from = 1,
  28. to = 10,
  29. scale = 0.4,
  30. font = 0,
  31. ["main"] = {
  32. title = "Concessionária do Simeon",
  33. name = "main",
  34. buttons = {
  35. {name = "Carros", description = ""},
  36. {name = "Motos", description = ""},
  37. }
  38. },
  39. ["Carros"] = {
  40. title = "Carros",
  41. name = "Carros",
  42. buttons = {
  43. {name = "Importado", description = ''},
  44. {name = "coupes", description = ''},
  45. {name = "sedans", description = ''},
  46. {name = "sports", description = ''},
  47. {name = "sportsclassics", description = ''},
  48. {name = "supers", description = ''},
  49. {name = "muscle", description = ''},
  50. {name = "offroad", description = ''},
  51. {name = "suvs", description = ''},
  52. {name = "vans", description = ''},
  53. --{name = "cycles", description = ''},
  54. }
  55. },
  56. ["Importado"] = {
  57. title = "Importado",
  58. name = "Importado",
  59. buttons = {
  60. {name = "Audi S5", costs = 358000, description = {}, model = "sentinel"},
  61. {name = "BMW M4", costs = 345000, description = {}, model = "M4"},
  62. {name = "BMW Lumma 750", costs = 709000, description = {}, model = "lumma750"},
  63. {name = "Camry", costs = 180000, description = {}, model = "camry55"},
  64. {name = "Camaro", costs = 220000, description = {}, model = "zl12017"},
  65. {name = "Camaro ZL1", costs = 240000, description = {}, model = "czl1"},
  66. {name = "Corvette", costs = 400000, description = {}, model = "c7"},
  67. {name = "Lancer Evo", costs = 108000, description = {}, model = "kuruma"},
  68. {name = "Ferrari 812", costs = 395000, description = {}, model = "ferrari812"},
  69. {name = "Italia 458", costs = 1950000, description = {}, model = "italia458"},
  70. {name = "Lykan", costs = 12000000, description = {}, model = "lykan"},
  71. {name = "Lexus RC 350", costs = 100000, description = {}, model = "f620"},
  72. {name = "Jeep", costs = 60000, description = {}, model = "srt8"},
  73. {name = "Jetta", costs = 50000, description = {}, model = "oracle2"},
  74. {name = "BMW M4 Sport", costs = 276000, description = {}, model = "440i"},
  75. {name = "Mercedez AMG", costs = 114000, description = {}, model = "c63coupe"},
  76. {name = "Massacro", costs = 450000, description = {}, model = "massacro"},
  77. {name = "OpalaSS", costs = 40000, description = {}, model = "tampa"},
  78. {name = "Pajero", costs = 15000, description = {}, model = "pajero4"},
  79. {name = "Audi R8", costs = 315000, description = {}, model = "r8ppi"},
  80. {name = "Santa Fé", costs = 35000, description = {}, model = "santafe"},
  81. {name = "SLS AMG", costs = 1000000, description = {}, model = "slsamg"},
  82. {name = "Saveiro Cross", costs = 35000, description = {}, model = "cavalcade"},
  83. }
  84. },
  85. ["coupes"] = {
  86. title = "coupes",
  87. name = "coupes",
  88. buttons = {
  89. {name = "Cognoscenti Cabrio", costs = 180000, description = {}, model = "cogcabrio"},
  90. {name = "Exemplar", costs = 200000, description = {}, model = "exemplar"},
  91. {name = "F620", costs = 80000, description = {}, model = "f620"},
  92. {name = "Felon", costs = 90000, description = {}, model = "felon"},
  93. {name = "Felon GT", costs = 95000, description = {}, model = "felon2"},
  94. {name = "Jackal", costs = 60000, description = {}, model = "jackal"},
  95. {name = "Oracle", costs = 80000, description = {}, model = "oracle"},
  96. {name = "Oracle XS", costs = 82000, description = {}, model = "oracle2"},
  97. {name = "Sentinel", costs = 90000, description = {}, model = "sentinel"},
  98. {name = "Sentinel XS", costs = 60000, description = {}, model = "sentinel2"},
  99. {name = "Windsor", costs = 800000, description = {}, model = "windsor"},
  100. {name = "Windsor Drop", costs = 850000, description = {}, model = "windsor2"},
  101. {name = "Zion", costs = 60000, description = {}, model = "zion"},
  102. {name = "Zion Cabrio", costs = 65000, description = {}, model = "zion2"},
  103. }
  104. },
  105. ["sports"] = {
  106. title = "sports",
  107. name = "sports",
  108. buttons = {
  109. {name = "9F", costs = 120000, description = {}, model = "ninef"},
  110. {name = "9F Cabrio", costs = 130000, description = {}, model = "ninef2"},
  111. {name = "Alpha", costs = 150000, description = {}, model = "alpha"},
  112. {name = "Banshee", costs = 105000, description = {}, model = "banshee"},
  113. {name = "Bestia GTS", costs = 610000, description = {}, model = "bestiagts"},
  114. {name = "Blista Compact", costs = 42000, description = {}, model = "blista"},
  115. {name = "Buffalo", costs = 35000, description = {}, model = "buffalo"},
  116. {name = "Buffalo S", costs = 96000, description = {}, model = "buffalo2"},
  117. {name = "Carbonizzare", costs = 195000, description = {}, model = "carbonizzare"},
  118. {name = "Comet", costs = 100000, description = {}, model = "comet2"},
  119. {name = "Coquette", costs = 138000, description = {}, model = "coquette"},
  120. {name = "Drift Tampa", costs = 995000, description = {}, model = "tampa2"},
  121. {name = "Feltzer", costs = 130000, description = {}, model = "feltzer2"},
  122. {name = "Furore GT", costs = 448000, description = {}, model = "furoregt"},
  123. {name = "Fusilade", costs = 36000, description = {}, model = "fusilade"},
  124. {name = "Jester", costs = 240000, description = {}, model = "jester"},
  125. {name = "Jester(Racecar)", costs = 350000, description = {}, model = "jester2"},
  126. {name = "Kuruma", costs = 95000, description = {}, model = "kuruma"},
  127. {name = "Lynx", costs = 1735000, description = {}, model = "lynx"},
  128. {name = "Massacro", costs = 275000, description = {}, model = "massacro"},
  129. {name = "Massacro(Racecar)", costs = 385000, description = {}, model = "massacro2"},
  130. {name = "Omnis", costs = 701000, description = {}, model = "omnis"},
  131. {name = "Penumbra", costs = 24000, description = {}, model = "penumbra"},
  132. {name = "Rapid GT", costs = 140000, description = {}, model = "rapidgt"},
  133. {name = "Rapid GT Convertible", costs = 150000, description = {}, model = "rapidgt2"},
  134. {name = "Schafter V12", costs = 140000, description = {}, model = "schafter3"},
  135. {name = "Sultan", costs = 12000, description = {}, model = "sultan"},
  136. {name = "Surano", costs = 110000, description = {}, model = "surano"},
  137. {name = "Tropos", costs = 816000, description = {}, model = "tropos"},
  138. {name = "Verkierer", costs = 695000, description = {}, model = "verlierer2"},
  139. }
  140. },
  141. ["sportsclassics"] = {
  142. title = "sportsclassics",
  143. name = "sportsclassics",
  144. buttons = {
  145. {name = "Casco", costs = 680000, description = {}, model = "casco"},
  146. {name = "Coquette Classic", costs = 665000, description = {}, model = "coquette2"},
  147. {name = "JB 700", costs = 350000, description = {}, model = "jb700"},
  148. {name = "Pigalle", costs = 400000, description = {}, model = "pigalle"},
  149. {name = "Stinger", costs = 850000, description = {}, model = "stinger"},
  150. {name = "Stinger GT", costs = 875000, description = {}, model = "stingergt"},
  151. {name = "Stirling GT", costs = 975000, description = {}, model = "feltzer3"},
  152. {name = "Z-Type", costs = 950000, description = {}, model = "ztype"},
  153. }
  154. },
  155. ["supers"] = {
  156. title = "supers",
  157. name = "supers",
  158. buttons = {
  159. {name = "Adder", costs = 1000000, description = {}, model = "adder"},
  160. {name = "Banshee 900R", costs = 565000, description = {}, model = "banshee2"},
  161. {name = "Bullet", costs = 155000, description = {}, model = "bullet"},
  162. {name = "Entity XF", costs = 795000, description = {}, model = "entityxf"},
  163. {name = "ETR1", costs = 199500, description = {}, model = "sheava"},
  164. {name = "FMJ", costs = 1750000, description = {}, model = "fmj"},
  165. {name = "Infernus", costs = 440000, description = {}, model = "infernus"},
  166. {name = "Osiris", costs = 1950000, description = {}, model = "osiris"},
  167. {name = "RE-7B", costs = 2475000, description = {}, model = "le7b"},
  168. {name = "Reaper", costs = 1595000, description = {}, model = "reaper"},
  169. {name = "Sultan RS", costs = 795000, description = {}, model = "sultanrs"},
  170. {name = "T20", costs = 2200000, description = {}, model = "t20"},
  171. {name = "Turismo R", costs = 500000, description = {}, model = "turismor"},
  172. {name = "Tyrus", costs = 2550000, description = {}, model = "tyrus"},
  173. {name = "Vacca", costs = 240000, description = {}, model = "vacca"},
  174. {name = "Voltic", costs = 150000, description = {}, model = "voltic"},
  175. {name = "X80 Proto", costs = 2700000, description = {}, model = "prototipo"},
  176. {name = "Zentorno", costs = 725000, description = {}, model = "zentorno"},
  177. }
  178. },
  179. ["muscle"] = {
  180. title = "muscle",
  181. name = "muscle",
  182. buttons = {
  183. {name = "Blade", costs = 160000, description = {}, model = "blade"},
  184. {name = "Buccaneer", costs = 29000, description = {}, model = "buccaneer"},
  185. {name = "Chino", costs = 225000, description = {}, model = "chino"},
  186. {name = "Coquette BlackFin", costs = 695000, description = {}, model = "coquette3"},
  187. {name = "Dominator", costs = 35000, description = {}, model = "dominator"},
  188. {name = "Dukes", costs = 62000, description = {}, model = "dukes"},
  189. {name = "Gauntlet", costs = 32000, description = {}, model = "gauntlet"},
  190. {name = "Hotknife", costs = 90000, description = {}, model = "hotknife"},
  191. {name = "Faction", costs = 36000, description = {}, model = "faction"},
  192. {name = "Nightshade", costs = 585000, description = {}, model = "nightshade"},
  193. {name = "Picador", costs = 9000, description = {}, model = "picador"},
  194. {name = "Sabre Turbo", costs = 15000, description = {}, model = "sabregt"},
  195. {name = "Tampa", costs = 375000, description = {}, model = "tampa"},
  196. {name = "Virgo", costs = 195000, description = {}, model = "virgo"},
  197. {name = "Vigero", costs = 21000, description = {}, model = "vigero"},
  198. }
  199. },
  200. ["offroad"] = {
  201. title = "offroad",
  202. name = "offroad",
  203. buttons = {
  204. {name = "Bifta", costs = 75000, description = {}, model = "bifta"},
  205. {name = "Blazer", costs = 8000, description = {}, model = "blazer"},
  206. {name = "Brawler", costs = 715000, description = {}, model = "brawler"},
  207. {name = "Bubsta 6x6", costs = 249000, description = {}, model = "dubsta3"},
  208. {name = "Dune Buggy", costs = 20000, description = {}, model = "dune"},
  209. {name = "Rebel", costs = 22000, description = {}, model = "rebel2"},
  210. {name = "Sandking", costs = 38000, description = {}, model = "sandking"},
  211. {name = "The Liberator", costs = 550000, description = {}, model = "monster"},
  212. {name = "Trophy Truck", costs = 550000, description = {}, model = "trophytruck"},
  213. }
  214. },
  215. ["suvs"] = {
  216. title = "suvs",
  217. name = "suvs",
  218. buttons = {
  219. {name = "Baller", costs = 90000, description = {}, model = "baller"},
  220. {name = "Cavalcade", costs = 60000, description = {}, model = "cavalcade"},
  221. {name = "Grabger", costs = 35000, description = {}, model = "granger"},
  222. {name = "Huntley S", costs = 195000, description = {}, model = "huntley"},
  223. {name = "Landstalker", costs = 58000, description = {}, model = "landstalker"},
  224. {name = "Radius", costs = 32000, description = {}, model = "radi"},
  225. {name = "Rocoto", costs = 85000, description = {}, model = "rocoto"},
  226. {name = "Seminole", costs = 30000, description = {}, model = "seminole"},
  227. {name = "XLS", costs = 253000, description = {}, model = "xls"},
  228. }
  229. },
  230. ["vans"] = {
  231. title = "vans",
  232. name = "vans",
  233. buttons = {
  234. {name = "Bison", costs = 30000, description = {}, model = "bison"},
  235. {name = "Bobcat XL", costs = 23000, description = {}, model = "bobcatxl"},
  236. {name = "Gang Burrito", costs = 65000, description = {}, model = "gburrito"},
  237. {name = "Journey", costs = 15000, description = {}, model = "journey"},
  238. {name = "Minivan", costs = 30000, description = {}, model = "minivan"},
  239. {name = "Paradise", costs = 25000, description = {}, model = "paradise"},
  240. {name = "Rumpo", costs = 13000, description = {}, model = "rumpo"},
  241. {name = "Surfer", costs = 11000, description = {}, model = "surfer"},
  242. {name = "Youga", costs = 16000, description = {}, model = "youga"},
  243. }
  244. },
  245. ["sedans"] = {
  246. title = "sedans",
  247. name = "sedans",
  248. buttons = {
  249. {name = "Asea", costs = 1000000, description = {}, model = "asea"},
  250. {name = "Asterope", costs = 1000000, description = {}, model = "asterope"},
  251. {name = "Cognoscenti", costs = 1000000, description = {}, model = "cognoscenti"},
  252. {name = "Cognoscenti(Armored)", costs = 1000000, description = {}, model = "cognoscenti2"},
  253. {name = "Cognoscenti 55", costs = 1000000, description = {}, model = "cog55"},
  254. {name = "Cognoscenti 55(Armored", costs = 1500000, description = {}, model = "cog552"},
  255. {name = "Fugitive", costs = 24000, description = {}, model = "fugitive"},
  256. {name = "Glendale", costs = 200000, description = {}, model = "glendale"},
  257. {name = "Ingot", costs = 9000, description = {}, model = "ingot"},
  258. {name = "Intruder", costs = 16000, description = {}, model = "intruder"},
  259. {name = "Premier", costs = 10000, description = {}, model = "premier"},
  260. {name = "Primo", costs = 9000, description = {}, model = "primo"},
  261. {name = "Primo Custom", costs = 9500, description = {}, model = "primo2"},
  262. {name = "Regina", costs = 8000, description = {}, model = "regina"},
  263. {name = "Schafter", costs = 65000, description = {}, model = "schafter2"},
  264. {name = "Stanier", costs = 10000, description = {}, model = "stanier"},
  265. {name = "Stratum", costs = 10000, description = {}, model = "stratum"},
  266. {name = "Stretch", costs = 30000, description = {}, model = "stretch"},
  267. {name = "Super Diamond", costs = 250000, description = {}, model = "superd"},
  268. {name = "Surge", costs = 38000, description = {}, model = "surge"},
  269. {name = "Tailgater", costs = 55000, description = {}, model = "tailgater"},
  270. {name = "Warrener", costs = 120000, description = {}, model = "warrener"},
  271. {name = "Washington", costs = 15000, description = {}, model = "washington"},
  272. }
  273. },
  274. ["Motos"] = {
  275. title = "Motos",
  276. name = "Motos",
  277. buttons = {
  278. {name = "Akuma", costs = 9000, description = {}, model = "AKUMA"},
  279. {name = "Bros", costs = 10000, description = {}, model = "bros60"},
  280. {name = "Ducatti", costs = 35000, description = {}, model = "dm1200"},
  281. {name = "Gsxr", costs = 32000, description = {}, model = "gsxr"},
  282. {name = "Ninjah2", costs = 12000, description = {}, model = "nh2r"},
  283. {name = "Ninjah10", costs = 45000, description = {}, model = "zx10"},
  284. {name = "R6", costs = 30000, description = {}, model = "r6"},
  285. {name = "Zx10R", costs = 79000, description = {}, model = "zx10r"},
  286. {name = "Hayabusa", costs = 60000, description = {}, model = "hayabusa"},
  287. }
  288. },
  289. }
  290. }
  291. local fakecar = {model = '', car = nil}
  292. local vehshop_locations = {
  293. {entering = {-33.803,-1102.322,25.422}, inside = {-49.414443969727,-1110.2772216797,26.435815811157}, outside = {-62.949256896973,-1100.1599121094,26.270923614502}},
  294. }
  295.  
  296. local vehshop_blips ={}
  297. local inrangeofvehshop = false
  298. local currentlocation = nil
  299. local boughtcar = false
  300.  
  301. function vehSR_drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  302. SetTextFont(font)
  303. SetTextProportional(0)
  304. SetTextScale(scale, scale)
  305. SetTextColour(r, g, b, a)
  306. SetTextDropShadow(0, 0, 0, 0,255)
  307. SetTextEdge(1, 0, 0, 0, 255)
  308. SetTextDropShadow()
  309. SetTextOutline()
  310. SetTextCentre(centre)
  311. SetTextEntry("STRING")
  312. AddTextComponentString(text)
  313. DrawText(x , y)
  314. end
  315.  
  316. function vehSR_IsPlayerInRangeOfVehshop()
  317. return inrangeofvehshop
  318. end
  319.  
  320. local firstspawn = 0
  321. AddEventHandler('playerSpawned', function(spawn)
  322. if firstspawn == 0 then
  323. --326 car blip 227 225
  324. vehSR_ShowVehshopBlips(true)
  325. firstspawn = 1
  326. end
  327. end)
  328.  
  329. function vehSR_ShowVehshopBlips(bool)
  330. if bool and #vehshop_blips == 0 then
  331. for station,pos in pairs(vehshop_locations) do
  332. local loc = pos
  333. pos = pos.entering
  334. local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
  335. -- 60 58 137
  336. SetBlipSprite(blip,326)
  337. BeginTextCommandSetBlipName("STRING")
  338. AddTextComponentString("Simeon Showroom")
  339. EndTextCommandSetBlipName(blip)
  340. SetBlipAsShortRange(blip,true)
  341. SetBlipAsMissionCreatorBlip(blip,true)
  342. table.insert(vehshop_blips, {blip = blip, pos = loc})
  343. end
  344. Citizen.CreateThread(function()
  345. while #vehshop_blips > 0 do
  346. Citizen.Wait(0)
  347. local inrange = false
  348. for i,b in ipairs(vehshop_blips) do
  349. if IsPlayerWantedLevelGreater(GetPlayerIndex(),0) == false and vehshop.opened == false and IsPedInAnyVehicle(vehSR_LocalPed(), true) == false and GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(vehSR_LocalPed())) < 5 then
  350. 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)
  351. vehSR_drawTxt("Pressione ~g~ENTER~s~ para comprar ~b~veiculo",0,1,0.5,0.8,0.6,255,255,255,255)
  352. currentlocation = b
  353. inrange = true
  354. end
  355. end
  356. inrangeofvehshop = inrange
  357. end
  358. end)
  359. elseif bool == false and #vehshop_blips > 0 then
  360. for i,b in ipairs(vehshop_blips) do
  361. if DoesBlipExist(b.blip) then
  362. SetBlipAsMissionCreatorBlip(b.blip,false)
  363. Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
  364. end
  365. end
  366. vehshop_blips = {}
  367. end
  368. end
  369.  
  370. function vehSR_f(n)
  371. return n + 0.0001
  372. end
  373.  
  374. function vehSR_LocalPed()
  375. return GetPlayerPed(-1)
  376. end
  377.  
  378. function vehSR_try(f, catch_f)
  379. local status, exception = pcall(f)
  380. if not status then
  381. catch_f(exception)
  382. end
  383. end
  384. function vehSR_firstToUpper(str)
  385. return (str:gsub("^%l", string.upper))
  386. end
  387. --local veh = nil
  388. function vehSR_OpenCreator()
  389. boughtcar = false
  390. local ped = vehSR_LocalPed()
  391. local pos = currentlocation.pos.inside
  392. FreezeEntityPosition(ped,true)
  393. SetEntityVisible(ped,false)
  394. local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
  395. SetEntityCoords(ped,pos[1],pos[2],g)
  396. SetEntityHeading(ped,pos[4])
  397. vehshop.currentmenu = "main"
  398. vehshop.opened = true
  399. vehshop.selectedbutton = 0
  400. end
  401. local vehicle_price = 0
  402. function vehSR_CloseCreator(vehicle,veh_type)
  403. Citizen.CreateThread(function()
  404. local ped = vehSR_LocalPed()
  405. if not boughtcar then
  406. local pos = currentlocation.pos.entering
  407. SetEntityCoords(ped,pos[1],pos[2],pos[3])
  408. FreezeEntityPosition(ped,false)
  409. SetEntityVisible(ped,true)
  410. else
  411. deleteVehiclePedIsIn()
  412. vRP.teleport({-44.21378326416,-1079.1402587891,26.67050743103})
  413. vRPg.spawnBoughtVehicle({veh_type, vehicle})
  414. SetEntityVisible(ped,true)
  415. FreezeEntityPosition(ped,false)
  416. end
  417. vehshop.opened = false
  418. vehshop.menu.from = 1
  419. vehshop.menu.to = 10
  420. end)
  421. end
  422.  
  423. function vehSR_drawMenuButton(button,x,y,selected)
  424. local menu = vehshop.menu
  425. SetTextFont(menu.font)
  426. SetTextProportional(0)
  427. SetTextScale(menu.scale, menu.scale)
  428. if selected then
  429. SetTextColour(0, 0, 0, 255)
  430. else
  431. SetTextColour(255, 255, 255, 255)
  432. end
  433. SetTextCentre(0)
  434. SetTextEntry("STRING")
  435. AddTextComponentString(button.name)
  436. if selected then
  437. DrawRect(x,y,menu.width,menu.height,255,255,255,255)
  438. else
  439. DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  440. end
  441. DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  442. end
  443.  
  444. function vehSR_drawMenuTitle(txt,x,y)
  445. local menu = vehshop.menu
  446. SetTextFont(2)
  447. SetTextProportional(0)
  448. SetTextScale(0.5, 0.5)
  449. SetTextColour(255, 255, 255, 255)
  450. SetTextEntry("STRING")
  451. AddTextComponentString(txt)
  452. DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  453. DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  454. end
  455. function vehSR_tablelength(T)
  456. local count = 0
  457. for _ in pairs(T) do count = count + 1 end
  458. return count
  459. end
  460. function vehSR_Notify(text)
  461. SetNotificationTextEntry('STRING')
  462. AddTextComponentString(text)
  463. DrawNotification(false, false)
  464. end
  465.  
  466. function vehSR_drawMenuRight(txt,x,y,selected)
  467. local menu = vehshop.menu
  468. SetTextFont(menu.font)
  469. SetTextProportional(0)
  470. SetTextScale(menu.scale, menu.scale)
  471. if selected then
  472. SetTextColour(0, 0, 0, 255)
  473. else
  474. SetTextColour(255, 255, 255, 255)
  475. end
  476. SetTextCentre(0)
  477. SetTextEntry("STRING")
  478. AddTextComponentString(txt)
  479. DrawText(x + menu.width/2 - 0.06, y - menu.height/2 + 0.0028)
  480. end
  481. local backlock = false
  482. Citizen.CreateThread(function()
  483. local last_dir
  484. while true do
  485. Citizen.Wait(0)
  486. if IsControlJustPressed(1,201) and vehSR_IsPlayerInRangeOfVehshop() then
  487. if vehshop.opened then
  488. vehSR_CloseCreator("","")
  489. else
  490. vehSR_OpenCreator()
  491. end
  492. end
  493. if vehshop.opened then
  494. local ped = vehSR_LocalPed()
  495. local menu = vehshop.menu[vehshop.currentmenu]
  496. vehSR_drawTxt(vehshop.title,1,1,vehshop.menu.x,vehshop.menu.y,1.0, 255,255,255,255)
  497. vehSR_drawMenuTitle(menu.title, vehshop.menu.x,vehshop.menu.y + 0.08)
  498. vehSR_drawTxt(vehshop.selectedbutton.."/"..vehSR_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)
  499. local y = vehshop.menu.y + 0.12
  500. buttoncount = vehSR_tablelength(menu.buttons)
  501. local selected = false
  502.  
  503. for i,button in pairs(menu.buttons) do
  504. if i >= vehshop.menu.from and i <= vehshop.menu.to then
  505.  
  506. if i == vehshop.selectedbutton then
  507. selected = true
  508. else
  509. selected = false
  510. end
  511. vehSR_drawMenuButton(button,vehshop.menu.x,y,selected)
  512. if button.costs ~= nil then
  513. if vehshop.currentmenu == "Importado" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "supers" 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 == "Motos" then
  514. vehSR_drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
  515. else
  516. vehSR_drawMenuButton(button,vehshop.menu.x,y,selected)
  517. end
  518. end
  519. y = y + 0.04
  520. if vehshop.currentmenu == "Importado" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "supers" 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 == "Motos" then
  521. if selected then
  522. if fakecar.model ~= button.model then
  523. if DoesEntityExist(fakecar.car) then
  524. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  525. end
  526. local pos = currentlocation.pos.inside
  527. local hash = GetHashKey(button.model)
  528. RequestModel(hash)
  529. local timer = 0
  530. while not HasModelLoaded(hash) and timer < 255 do
  531. Citizen.Wait(1)
  532. vehSR_drawTxt("Carregando Aguarde!",0,1,0.5,0.5,1.5,255,255-timer,255-timer,255)
  533. RequestModel(hash)
  534. timer = timer + 1
  535. end
  536. if timer < 255 then
  537. local veh = CreateVehicle(hash,pos[1],pos[2],pos[3],pos[4],false,false)
  538. while not DoesEntityExist(veh) do
  539. Citizen.Wait(1)
  540. vehSR_drawTxt("Carregando Aguarde!",0,1,0.5,0.5,1.5,255,255-timer,255-timer,255)
  541. end
  542. FreezeEntityPosition(veh,true)
  543. SetEntityInvincible(veh,true)
  544. SetVehicleDoorsLocked(veh,4)
  545. --SetEntityCollision(veh,false,false)
  546. TaskWarpPedIntoVehicle(vehSR_LocalPed(),veh,-1)
  547. for i = 0,24 do
  548. SetVehicleModKit(veh,0)
  549. RemoveVehicleMod(veh,i)
  550. end
  551. fakecar = { model = button.model, car = veh}
  552. else
  553. timer = 0
  554. while timer < 50 do
  555. Citizen.Wait(1)
  556. vehSR_drawTxt("Erro, tentando novamente!",0,1,0.5,0.5,1.5,255,0,0,255)
  557. timer = timer + 1
  558. end
  559. if last_dir then
  560. if vehshop.selectedbutton < buttoncount then
  561. vehshop.selectedbutton = vehshop.selectedbutton +1
  562. if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
  563. vehshop.menu.to = vehshop.menu.to + 1
  564. vehshop.menu.from = vehshop.menu.from + 1
  565. end
  566. else
  567. last_dir = false
  568. vehshop.selectedbutton = vehshop.selectedbutton -1
  569. if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
  570. vehshop.menu.from = vehshop.menu.from -1
  571. vehshop.menu.to = vehshop.menu.to - 1
  572. end
  573. end
  574. else
  575. if vehshop.selectedbutton > 1 then
  576. vehshop.selectedbutton = vehshop.selectedbutton -1
  577. if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
  578. vehshop.menu.from = vehshop.menu.from -1
  579. vehshop.menu.to = vehshop.menu.to - 1
  580. end
  581. else
  582. last_dir = true
  583. vehshop.selectedbutton = vehshop.selectedbutton +1
  584. if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
  585. vehshop.menu.to = vehshop.menu.to + 1
  586. vehshop.menu.from = vehshop.menu.from + 1
  587. end
  588. end
  589. end
  590. end
  591. end
  592. end
  593. end
  594. if selected and IsControlJustPressed(1,201) then
  595. vehSR_ButtonSelected(button)
  596. end
  597. end
  598. end
  599. if IsControlJustPressed(1,202) then
  600. vehSR_Back()
  601. end
  602. if IsControlJustReleased(1,202) then
  603. backlock = false
  604. end
  605. if IsControlJustPressed(1,188) then
  606. last_dir = false
  607. if vehshop.selectedbutton > 1 then
  608. vehshop.selectedbutton = vehshop.selectedbutton -1
  609. if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
  610. vehshop.menu.from = vehshop.menu.from -1
  611. vehshop.menu.to = vehshop.menu.to - 1
  612. end
  613. end
  614. end
  615. if IsControlJustPressed(1,187)then
  616. last_dir = true
  617. if vehshop.selectedbutton < buttoncount then
  618. vehshop.selectedbutton = vehshop.selectedbutton +1
  619. if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
  620. vehshop.menu.to = vehshop.menu.to + 1
  621. vehshop.menu.from = vehshop.menu.from + 1
  622. end
  623. end
  624. end
  625. end
  626.  
  627. end
  628. end)
  629.  
  630.  
  631. function vehSR_round(num, idp)
  632. if idp and idp>0 then
  633. local mult = 10^idp
  634. return math.floor(num * mult + 0.5) / mult
  635. end
  636. return math.floor(num + 0.5)
  637. end
  638. function vehSR_ButtonSelected(button)
  639. local ped = GetPlayerPed(-1)
  640. local this = vehshop.currentmenu
  641. local btn = button.name
  642. if this == "main" then
  643. if btn == "Carros" then
  644. vehSR_OpenMenu('Carros')
  645. elseif btn == "Motos" then
  646. vehSR_OpenMenu('Motos')
  647. end
  648. elseif this == "Carros" then
  649. if btn == "sports" then
  650. vehSR_OpenMenu('sports')
  651. elseif btn == "sedans" then
  652. vehSR_OpenMenu('sedans')
  653. elseif btn == "Importado" then
  654. vehSR_OpenMenu('Importado')
  655. elseif btn == "coupes" then
  656. vehSR_OpenMenu('coupes')
  657. elseif btn == "sportsclassics" then
  658. vehSR_OpenMenu("sportsclassics")
  659. elseif btn == "supers" then
  660. vehSR_OpenMenu('supers')
  661. elseif btn == "muscle" then
  662. vehSR_OpenMenu('muscle')
  663. elseif btn == "offroad" then
  664. vehSR_OpenMenu('offroad')
  665. elseif btn == "suvs" then
  666. vehSR_OpenMenu('suvs')
  667. elseif btn == "vans" then
  668. vehSR_OpenMenu('vans')
  669. end
  670. elseif this == "Importado" or this == "coupes" or this == "sedans" or this == "sports" or this == "sportsclassics" or this == "supers" or this == "muscle" or this == "offroad" or this == "suvs" or this == "vans" or this == "industrial" then
  671. TriggerServerEvent('veh_SR:CheckMoneyForVeh',button.model,button.costs, "car")
  672. elseif this == "cycles" or this == "Motos" then
  673. TriggerServerEvent('veh_SR:CheckMoneyForVeh',button.model,button.costs, "bike")
  674. end
  675. end
  676.  
  677. RegisterNetEvent('veh_SR:CloseMenu')
  678. AddEventHandler('veh_SR:CloseMenu', function(vehicle, veh_type)
  679. boughtcar = true
  680. vehSR_CloseCreator(vehicle,veh_type)
  681. end)
  682.  
  683. function vehSR_OpenMenu(menu)
  684. fakecar = {model = '', car = nil}
  685. vehshop.lastmenu = vehshop.currentmenu
  686. if menu == "Carros" then
  687. vehshop.lastmenu = "main"
  688. elseif menu == "bikes" then
  689. vehshop.lastmenu = "main"
  690. elseif menu == 'race_create_objects' then
  691. vehshop.lastmenu = "main"
  692. elseif menu == "race_create_objects_spawn" then
  693. vehshop.lastmenu = "race_create_objects"
  694. end
  695. vehshop.menu.from = 1
  696. vehshop.menu.to = 10
  697. vehshop.selectedbutton = 0
  698. vehshop.currentmenu = menu
  699. end
  700.  
  701.  
  702. function vehSR_Back()
  703. if backlock then
  704. return
  705. end
  706. backlock = true
  707. if vehshop.currentmenu == "main" then
  708. vehSR_CloseCreator("","")
  709. elseif vehshop.currentmenu == "Importado" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "supers" 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 == "Motos" then
  710. if DoesEntityExist(fakecar.car) then
  711. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  712. end
  713. fakecar = {model = '', car = nil}
  714. vehSR_OpenMenu(vehshop.lastmenu)
  715. else
  716. vehSR_OpenMenu(vehshop.lastmenu)
  717. end
  718.  
  719. end
  720.  
  721. function vehSR_stringstarts(String,Start)
  722. return string.sub(String,1,string.len(Start))==Start
  723. end
Add Comment
Please, Sign In to add comment