Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.20 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 = {448.24,-1017.99,28.5621}, inside = {448.24,-1017.99,28.5621}, outside = {448.24,-1017.99,28.5621}},
  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('Concessionnaire')
  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.                     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)
  333.                     if 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      
  334.                         drawTxt('Appuyer sur ~g~Entrée~s~ pour accéder au menu d\'achat',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(veh)
  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 vehicle = veh
  407.             local veh = GetVehiclePedIsUsing(ped)
  408.             local model = GetEntityModel(veh)
  409.             local colors = table.pack(GetVehicleColours(veh))
  410.             local extra_colors = table.pack(GetVehicleExtraColours(veh))
  411.  
  412.             local mods = {}
  413.             for i = 0,24 do
  414.                 mods[i] = GetVehicleMod(veh,i)
  415.             end
  416.             Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(veh))
  417.             local pos = currentlocation.pos.outside
  418.  
  419.             FreezeEntityPosition(ped,false)
  420.             RequestModel(model)
  421.             while not HasModelLoaded(model) do
  422.                 Citizen.Wait(0)
  423.             end
  424.             personalvehicle = CreateVehicle(model,pos[1],pos[2],pos[3],pos[4],true,false)
  425.             SetModelAsNoLongerNeeded(model)
  426.             for i,mod in pairs(mods) do
  427.                 SetVehicleModKit(personalvehicle,0)
  428.                 SetVehicleMod(personalvehicle,i,mod)
  429.             end
  430.             SetVehicleOnGroundProperly(personalvehicle)
  431.             local plate = GetVehicleNumberPlateText(personalvehicle)
  432.             SetVehicleHasBeenOwnedByPlayer(personalvehicle,true)
  433.             local id = NetworkGetNetworkIdFromEntity(personalvehicle)
  434.             SetNetworkIdCanMigrate(id, true)
  435.             Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(personalvehicle))
  436.             SetVehicleColours(personalvehicle,colors[1],colors[2])
  437.             SetVehicleExtraColours(personalvehicle,extra_colors[1],extra_colors[2])
  438.             TaskWarpPedIntoVehicle(GetPlayerPed(-1),personalvehicle,-1)
  439.             SetEntityVisible(ped,true)         
  440.             local primaryColor = colors[1]
  441.             local secondaryColor = colors[2]
  442.             TriggerServerEvent('BuyForVeh', vehicle, plate, primaryColor, secondaryColor)
  443.         end
  444.         vehshop.opened = false
  445.         vehshop.menu.from = 1
  446.         vehshop.menu.to = 10
  447.     end)
  448. end
  449.  
  450. function drawMenuButton(button,x,y,selected)
  451.     local menu = vehshop.menu
  452.     SetTextFont(menu.font)
  453.     SetTextProportional(0)
  454.     SetTextScale(menu.scale, menu.scale)
  455.     if selected then
  456.         SetTextColour(0, 0, 0, 255)
  457.     else
  458.         SetTextColour(255, 255, 255, 255)
  459.     end
  460.     SetTextCentre(0)
  461.     SetTextEntry("STRING")
  462.     AddTextComponentString(button.name)
  463.     if selected then
  464.         DrawRect(x,y,menu.width,menu.height,255,255,255,255)
  465.     else
  466.         DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  467.     end
  468.     DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  469. end
  470.  
  471. function drawMenuInfo(text)
  472.     local menu = vehshop.menu
  473.     SetTextFont(menu.font)
  474.     SetTextProportional(0)
  475.     SetTextScale(0.45, 0.45)
  476.     SetTextColour(255, 255, 255, 255)
  477.     SetTextCentre(0)
  478.     SetTextEntry("STRING")
  479.     AddTextComponentString(text)
  480.     DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
  481.     DrawText(0.365, 0.934)
  482. end
  483.  
  484. function drawMenuRight(txt,x,y,selected)
  485.     local menu = vehshop.menu
  486.     SetTextFont(menu.font)
  487.     SetTextProportional(0)
  488.     SetTextScale(menu.scale, menu.scale)
  489.     SetTextRightJustify(1)
  490.     if selected then
  491.         SetTextColour(0, 0, 0, 255)
  492.     else
  493.         SetTextColour(255, 255, 255, 255)
  494.     end
  495.     SetTextCentre(0)
  496.     SetTextEntry("STRING")
  497.     AddTextComponentString(txt)
  498.     DrawText(x + menu.width/2 - 0.03, y - menu.height/2 + 0.0028)
  499. end
  500.  
  501. function drawMenuTitle(txt,x,y)
  502. local menu = vehshop.menu
  503.     SetTextFont(2)
  504.     SetTextProportional(0)
  505.     SetTextScale(0.5, 0.5)
  506.     SetTextColour(255, 255, 255, 255)
  507.     SetTextEntry("STRING")
  508.     AddTextComponentString(txt)
  509.     DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  510.     DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  511. end
  512.  
  513. function tablelength(T)
  514.   local count = 0
  515.   for _ in pairs(T) do count = count + 1 end
  516.   return count
  517. end
  518.  
  519. function Notify(text)
  520.     SetNotificationTextEntry('STRING')
  521.     AddTextComponentString(text)
  522.     DrawNotification(false, false)
  523. end
  524.  
  525. function DoesPlayerHaveVehicle(model,button,y,selected)
  526.         local t = false
  527.         --TODO:check if player own car
  528.         if t then
  529.             drawMenuRight("OWNED",vehshop.menu.x,y,selected)
  530.         else
  531.             drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
  532.         end
  533. end
  534.  
  535. local backlock = false
  536. Citizen.CreateThread(function()
  537.     while true do
  538.         Citizen.Wait(0)
  539.         if IsControlJustPressed(1,201) and IsPlayerInRangeOfVehshop() then
  540.             if vehshop.opened then
  541.                 CloseCreator()
  542.             else
  543.                 OpenCreator()
  544.             end
  545.         end
  546.         if vehshop.opened then
  547.             local ped = LocalPed()
  548.             local menu = vehshop.menu[vehshop.currentmenu]
  549.             drawTxt(vehshop.title,1,1,vehshop.menu.x,vehshop.menu.y,1.0, 255,255,255,255)
  550.             drawMenuTitle(menu.title, vehshop.menu.x,vehshop.menu.y + 0.08)
  551.             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)
  552.             local y = vehshop.menu.y + 0.12
  553.             buttoncount = tablelength(menu.buttons)
  554.             local selected = false
  555.  
  556.             for i,button in pairs(menu.buttons) do
  557.                 if i >= vehshop.menu.from and i <= vehshop.menu.to then
  558.  
  559.                     if i == vehshop.selectedbutton then
  560.                         selected = true
  561.                     else
  562.                         selected = false
  563.                     end
  564.                     drawMenuButton(button,vehshop.menu.x,y,selected)
  565.                     if button.costs ~= nil then
  566.                         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
  567.                             DoesPlayerHaveVehicle(button.model,button,y,selected)
  568.                         else
  569.                         drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
  570.                         end
  571.                     end
  572.                     y = y + 0.04
  573.                     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
  574.                         if selected then
  575.                             if fakecar.model ~= button.model then
  576.                                 if DoesEntityExist(fakecar.car) then
  577.                                     Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  578.                                 end
  579.                                 local pos = currentlocation.pos.inside
  580.                                 local hash = GetHashKey(button.model)
  581.                                 RequestModel(hash)
  582.                                 while not HasModelLoaded(hash) do
  583.                                     Citizen.Wait(0)
  584.                                     drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
  585.  
  586.                                 end
  587.                                 local veh = CreateVehicle(hash,pos[1],pos[2],pos[3],pos[4],false,false)
  588.                                 while not DoesEntityExist(veh) do
  589.                                     Citizen.Wait(0)
  590.                                     drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
  591.                                 end
  592.                                 FreezeEntityPosition(veh,true)
  593.                                 SetEntityInvincible(veh,true)
  594.                                 SetVehicleDoorsLocked(veh,4)
  595.                                 --SetEntityCollision(veh,false,false)
  596.                                 TaskWarpPedIntoVehicle(LocalPed(),veh,-1)
  597.                                 for i = 0,24 do
  598.                                     SetVehicleModKit(veh,0)
  599.                                     RemoveVehicleMod(veh,i)
  600.                                 end
  601.                                 fakecar = { model = button.model, car = veh}
  602.                             end
  603.                         end
  604.                     end
  605.                     if selected and IsControlJustPressed(1,201) then
  606.                         ButtonSelected(button)
  607.                     end
  608.                 end
  609.             end
  610.         end
  611.         if vehshop.opened then
  612.             if IsControlJustPressed(1,202) then
  613.                 Back()
  614.             end
  615.             if IsControlJustReleased(1,202) then
  616.                 backlock = false
  617.             end
  618.             if IsControlJustPressed(1,188) then
  619.                 if vehshop.selectedbutton > 1 then
  620.                     vehshop.selectedbutton = vehshop.selectedbutton -1
  621.                     if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
  622.                         vehshop.menu.from = vehshop.menu.from -1
  623.                         vehshop.menu.to = vehshop.menu.to - 1
  624.                     end
  625.                 end
  626.             end
  627.             if IsControlJustPressed(1,187)then
  628.                 if vehshop.selectedbutton < buttoncount then
  629.                     vehshop.selectedbutton = vehshop.selectedbutton +1
  630.                     if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
  631.                         vehshop.menu.to = vehshop.menu.to + 1
  632.                         vehshop.menu.from = vehshop.menu.from + 1
  633.                     end
  634.                 end
  635.             end
  636.         end
  637.  
  638.     end
  639. end)
  640.  
  641.  
  642. function round(num, idp)
  643.   if idp and idp>0 then
  644.     local mult = 10^idp
  645.     return math.floor(num * mult + 0.5) / mult
  646.   end
  647.   return math.floor(num + 0.5)
  648. end
  649. function ButtonSelected(button)
  650.     local ped = GetPlayerPed(-1)
  651.     local this = vehshop.currentmenu
  652.     local btn = button.name
  653.     if this == "main" then
  654.         if btn == "Vehicles" then
  655.             OpenMenu('vehicles')
  656.         elseif btn == "Motorcycles" then
  657.             OpenMenu('motorcycles')
  658.         end
  659.     elseif this == "vehicles" then
  660.         if btn == "Sports" then
  661.             OpenMenu('sports')
  662.         elseif btn == "Sedans" then
  663.             OpenMenu('sedans')
  664.         elseif btn == "Compacts" then
  665.             OpenMenu('compacts')
  666.         elseif btn == "Coupes" then
  667.             OpenMenu('coupes')
  668.         elseif btn == "Sports Classics" then
  669.             OpenMenu("sportsclassics")
  670.         elseif btn == "Super" then
  671.             OpenMenu('super')
  672.         elseif btn == "Muscle" then
  673.             OpenMenu('muscle')
  674.         elseif btn == "Off-Road" then
  675.             OpenMenu('offroad')
  676.         elseif btn == "SUVs" then
  677.             OpenMenu('suvs')
  678.         elseif btn == "Vans" then
  679.             OpenMenu('vans')
  680.         end
  681.     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
  682.         TriggerServerEvent('CheckMoneyForVeh',button.model,button.costs)
  683.     end
  684. end
  685.  
  686. RegisterNetEvent('FinishMoneyCheckForVeh')
  687. AddEventHandler('FinishMoneyCheckForVeh', function(vehicle)
  688.     local vehicle = vehicle
  689.     boughtcar = true
  690.     CloseCreator(vehicle)
  691. end)
  692.  
  693. function OpenMenu(menu)
  694.     fakecar = {model = '', car = nil}
  695.     vehshop.lastmenu = vehshop.currentmenu
  696.     if menu == "vehicles" then
  697.         vehshop.lastmenu = "main"
  698.     elseif menu == "bikes"  then
  699.         vehshop.lastmenu = "main"
  700.     elseif menu == 'race_create_objects' then
  701.         vehshop.lastmenu = "main"
  702.     elseif menu == "race_create_objects_spawn" then
  703.         vehshop.lastmenu = "race_create_objects"
  704.     end
  705.     vehshop.menu.from = 1
  706.     vehshop.menu.to = 10
  707.     vehshop.selectedbutton = 0
  708.     vehshop.currentmenu = menu
  709. end
  710.  
  711.  
  712. function Back()
  713.     if backlock then
  714.         return
  715.     end
  716.     backlock = true
  717.     if vehshop.currentmenu == "main" then
  718.         CloseCreator()
  719.     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
  720.         if DoesEntityExist(fakecar.car) then
  721.             Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  722.         end
  723.         fakecar = {model = '', car = nil}
  724.         OpenMenu(vehshop.lastmenu)
  725.     else
  726.         OpenMenu(vehshop.lastmenu)
  727.     end
  728.  
  729. end
  730.  
  731. function stringstarts(String,Start)
  732.    return string.sub(String,1,string.len(Start))==Start
  733. end
  734.  
  735. local firstspawn = 0
  736. AddEventHandler('playerSpawned', function(spawn)
  737. if firstspawn == 0 then
  738.     --326 car blip 227 225
  739.     ShowVehshopBlips(true)
  740.     firstspawn = 1
  741. end
  742. end)
  743.  
  744. RegisterNetEvent('vehshop:spawnVehicle')
  745. AddEventHandler('vehshop:spawnVehicle', function(v)
  746.     local car = GetHashKey(v)
  747.     local playerPed = GetPlayerPed(-1)
  748.     if playerPed and playerPed ~= -1 then
  749.         RequestModel(car)
  750.         while not HasModelLoaded(car) do
  751.                 Citizen.Wait(0)
  752.         end
  753.         local playerCoords = GetEntityCoords(playerPed)
  754.  
  755.         veh = CreateVehicle(car, playerCoords, 0.0, true, false)
  756.         TaskWarpPedIntoVehicle(playerPed, veh, -1)
  757.         SetEntityInvincible(veh, true)
  758.     end
  759. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement