Advertisement
Guest User

Untitled

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