Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.15 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 = 17500, description = {}, model = "brioso"},
  50.                 {name = "Dilettante", costs = 20000, description = {}, model = "Dilettante"},
  51.                 {name = "Issi", costs = 25000, description = {}, model = "issi2"},
  52.                 {name = "Panto", costs = 10000, description = {}, model = "panto"},
  53.                 {name = "Prairie", costs = 35000, description = {}, model = "prairie"},
  54.                 {name = "Rhapsody", costs = 30000, description = {}, model = "rhapsody"},
  55.             }
  56.         },
  57.         ["coupes"] = {
  58.             title = "coupes",
  59.             name = "coupes",
  60.             buttons = {
  61.                 {name = "Cognoscenti Cabrio", costs = 115000, description = {}, model = "cogcabrio"},
  62.                 {name = "Exemplar", costs = 100000, description = {}, model = "exemplar"},
  63.                 {name = "F620", costs = 100000, description = {}, model = "f620"},
  64.                 {name = "Felon", costs = 90000, description = {}, model = "felon"},
  65.                 {name = "Felon GT", costs = 120000, description = {}, model = "felon2"},
  66.                 {name = "Jackal", costs = 75000, description = {}, model = "jackal"},
  67.                 {name = "Oracle", costs = 85000, description = {}, model = "oracle"},
  68.                 {name = "Oracle XS", costs = 80000, description = {}, model = "oracle2"},
  69.                 {name = "Sentinel", costs = 120000, description = {}, model = "sentinel"},
  70.                 {name = "Sentinel XS", costs = 110000, description = {}, model = "sentinel2"},
  71.                 {name = "Windsor", costs = 800000, description = {}, model = "windsor"},
  72.                 {name = "Windsor Drop", costs = 150000, description = {}, model = "windsor2"},
  73.                 {name = "Zion", costs = 130000, description = {}, model = "zion"},
  74.                 {name = "Zion Cabrio", costs = 140000, description = {}, model = "zion2"},
  75.             }
  76.         },
  77.         ["sports"] = {
  78.             title = "sports",
  79.             name = "sports",
  80.             buttons = {
  81.                 {name = "9F", costs = 400000, description = {}, model = "ninef"},
  82.                 {name = "9F Cabrio", costs = 375000, description = {}, model = "ninef2"},
  83.                 {name = "Alpha", costs = 175000, description = {}, model = "alpha"},
  84.                 {name = "Banshee", costs = 200000, description = {}, model = "banshee"},
  85.                 {name = "Bestia GTS", costs = 300000, description = {}, model = "bestiagts"},
  86.                 {name = "Blista Compact", costs = 35000, description = {}, model = "blista"},
  87.                 {name = "Buffalo", costs = 150000, description = {}, model = "buffalo"},
  88.                 {name = "Buffalo S", costs = 160000, description = {}, model = "buffalo2"},
  89.                 {name = "Carbonizzare", costs = 400000, description = {}, model = "carbonizzare"},
  90.                 {name = "Comet", costs = 300000, description = {}, model = "comet2"},
  91.                 {name = "Coquette", costs = 500000, description = {}, model = "coquette"},
  92.                 {name = "Drift Tampa", costs = 250000, description = {}, model = "tampa2"},
  93.                 {name = "Feltzer", costs = 400000, description = {}, model = "feltzer2"},
  94.                 {name = "Furore GT", costs = 325000, description = {}, model = "furoregt"},
  95.                 {name = "Fusilade", costs = 150000, description = {}, model = "fusilade"},
  96.                 {name = "Jester", costs = 450000, description = {}, model = "jester"},
  97.                 {name = "Jester(Racecar)", costs = 500000, description = {}, model = "jester2"},
  98.                 {name = "Kuruma", costs = 125000, description = {}, model = "kuruma"},
  99.                 {name = "Lynx", costs = 175000, description = {}, model = "lynx"},
  100.                 {name = "Massacro", costs = 275000, description = {}, model = "massacro"},
  101.                 {name = "Massacro(Racecar)", costs = 350000, description = {}, model = "massacro2"},
  102.                 {name = "Omnis", costs = 80000, description = {}, model = "omnis"},
  103.                 {name = "Penumbra", costs = 225000, description = {}, model = "penumbra"},
  104.                 {name = "Rapid GT", costs = 300000, description = {}, model = "rapidgt"},
  105.                 {name = "Rapid GT Convertible", costs = 350000, description = {}, model = "rapidgt2"},
  106.                 {name = "Schafter V12", costs = 150000, description = {}, model = "schafter3"},
  107.                 {name = "Sultan", costs = 50000, description = {}, model = "sultan"},
  108.                 {name = "Surano", costs = 275000, description = {}, model = "surano"},
  109.                 {name = "Tropos", costs = 100000, description = {}, model = "tropos"},
  110.                 {name = "Verkierer", costs = 200000, description = {}, model = "verlierer2"},
  111.             }
  112.         },
  113.         ["sportsclassics"] = {
  114.             title = "sports classics",
  115.             name = "sportsclassics",
  116.             buttons = {
  117.                 {name = "Casco", costs = 75000, description = {}, model = "casco"},
  118.                 {name = "Coquette Classic", costs = 150000, description = {}, model = "coquette2"},
  119.                 {name = "JB 700", costs = 200000, description = {}, model = "jb700"},
  120.                 {name = "Pigalle", costs = 50000, description = {}, model = "pigalle"},
  121.                 {name = "Stinger", costs = 225000, description = {}, model = "stinger"},
  122.                 {name = "Stinger GT", costs = 250000, description = {}, model = "stingergt"},
  123.                 {name = "Stirling GT", costs = 300000, description = {}, model = "feltzer3"},
  124.                 {name = "Z-Type", costs = 150000, description = {}, model = "ztype"},
  125.             }
  126.         },
  127.         ["super"] = {
  128.             title = "super",
  129.             name = "super",
  130.             buttons = {
  131.                 {name = "Adder", costs = 950000, description = {}, model = "adder"},
  132.                 {name = "Banshee 900R", costs = 550000, description = {}, model = "banshee2"},
  133.                 {name = "Bullet", costs = 750000, description = {}, model = "bullet"},
  134.                 {name = "Cheetah", costs = 1000000, description = {}, model = "cheetah"},
  135.                 {name = "Entity XF", costs = 1250000, description = {}, model = "entityxf"},
  136.                 {name = "ETR1", costs = 850000, description = {}, model = "sheava"},
  137.                 {name = "FMJ", costs = 1350000, description = {}, model = "fmj"},
  138.                 {name = "Infernus", costs = 750000, description = {}, model = "infernus"},
  139.                 {name = "Osiris", costs = 1000000, description = {}, model = "osiris"},
  140.                 {name = "RE-7B", costs = 1500000, description = {}, model = "le7b"},
  141.                 {name = "Reaper", costs = 1300000, description = {}, model = "reaper"},
  142.                 {name = "Sultan RS", costs = 350000, description = {}, model = "sultanrs"},
  143.                 {name = "T20", costs = 1250000, description = {}, model = "t20"},
  144.                 {name = "Turismo R", costs = 1500000, description = {}, model = "turismor"},
  145.                 {name = "Tyrus", costs = 1700000, description = {}, model = "tyrus"},
  146.                 {name = "Vacca", costs = 850000, description = {}, model = "vacca"},
  147.                 {name = "Voltic", costs = 550000, description = {}, model = "voltic"},
  148.                 {name = "X80 Proto", costs = 1750000, description = {}, model = "prototipo"},
  149.                 {name = "Zentorno", costs = 1750000, description = {}, model = "zentorno"},
  150.             }
  151.         },
  152.         ["muscle"] = {
  153.             title = "muscle",
  154.             name = "muscle",
  155.             buttons = {
  156.                 {name = "Blade", costs = 50000, description = {}, model = "blade"},
  157.                 {name = "Buccaneer", costs = 50000, description = {}, model = "buccaneer"},
  158.                 {name = "Chino", costs = 75000, description = {}, model = "chino"},
  159.                 {name = "Coquette BlackFin", costs = 125000, description = {}, model = "coquette3"},
  160.                 {name = "Dominator", costs = 60000, description = {}, model = "dominator"},
  161.                 {name = "Dukes", costs = 45000, description = {}, model = "dukes"},
  162.                 {name = "Gauntlet", costs = 85000, description = {}, model = "gauntlet"},
  163.                 {name = "Hotknife", costs = 100000, description = {}, model = "hotknife"},
  164.                 {name = "Faction", costs = 75000, description = {}, model = "faction"},
  165.                 {name = "Nightshade", costs = 200000, description = {}, model = "nightshade"},
  166.                 {name = "Picador", costs = 40000, description = {}, model = "picador"},
  167.                 {name = "Sabre Turbo", costs = 75000, description = {}, model = "sabregt"},
  168.                 {name = "Tampa", costs = 150000, description = {}, model = "tampa"},
  169.                 {name = "Virgo", costs = 100000, description = {}, model = "virgo"},
  170.                 {name = "Vigero", costs = 75000, description = {}, model = "vigero"},
  171.             }
  172.         },
  173.         ["offroad"] = {
  174.             title = "off-road",
  175.             name = "off-road",
  176.             buttons = {
  177.                 {name = "Bifta", costs = 45000, description = {}, model = "bifta"},
  178.                 {name = "Blazer", costs = 15000, description = {}, model = "blazer"},
  179.                 {name = "Brawler", costs = 250000, description = {}, model = "brawler"},
  180.                 {name = "Bubsta 6x6", costs = 375000, description = {}, model = "dubsta3"},
  181.                 {name = "Dune Buggy", costs = 75000, description = {}, model = "dune"},
  182.                 {name = "Rebel", costs = 90000, description = {}, model = "rebel2"},
  183.                 {name = "Sandking", costs = 150000, description = {}, model = "sandking"},
  184.                 {name = "Trophy Truck", costs = 175000, description = {}, model = "trophytruck"},
  185.             }
  186.         },
  187.         ["suvs"] = {
  188.             title = "suvs",
  189.             name = "suvs",
  190.             buttons = {
  191.                 {name = "Baller", costs = 50000, description = {}, model = "baller"},
  192.                 {name = "Cavalcade", costs = 60000, description = {}, model = "cavalcade"},
  193.                 {name = "Grabger", costs = 75000, description = {}, model = "granger"},
  194.                 {name = "Huntley S", costs = 80000, description = {}, model = "huntley"},
  195.                 {name = "Landstalker", costs = 50000, description = {}, model = "landstalker"},
  196.                 {name = "Radius", costs = 45000, description = {}, model = "radi"},
  197.                 {name = "Rocoto", costs = 60000, description = {}, model = "rocoto"},
  198.                 {name = "Seminole", costs = 50000, description = {}, model = "seminole"},
  199.                 {name = "XLS", costs = 55000, description = {}, model = "xls"},
  200.             }
  201.         },
  202.         ["vans"] = {
  203.             title = "vans",
  204.             name = "vans",
  205.             buttons = {
  206.                 {name = "Bison", costs = 65000, description = {}, model = "bison"},
  207.                 {name = "Bobcat XL", costs = 50000, description = {}, model = "bobcatxl"},
  208.                 {name = "Gang Burrito", costs = 65000, description = {}, model = "gburrito"},
  209.                 {name = "Journey", costs = 45000, description = {}, model = "journey"},
  210.                 {name = "Minivan", costs = 40000, description = {}, model = "minivan"},
  211.                 {name = "Paradise", costs = 50000, description = {}, model = "paradise"},
  212.                 {name = "Rumpo", costs = 50000, description = {}, model = "rumpo"},
  213.                 {name = "Surfer", costs = 35000, description = {}, model = "surfer"},
  214.                 {name = "Youga", costs = 65000, description = {}, model = "youga"},
  215.             }
  216.         },
  217.         ["sedans"] = {
  218.             title = "sedans",
  219.             name = "sedans",
  220.             buttons = {
  221.                 {name = "Asea", costs = 25000, description = {}, model = "asea"},
  222.                 {name = "Asterope", costs = 30000, description = {}, model = "asterope"},
  223.                 --{name = "Cognoscenti", costs = 1000000, description = {}, model = "cognoscenti"},
  224.                 --{name = "Cognoscenti(Armored)", costs = 1000000, description = {}, model = "cognoscenti2"},
  225.                 --{name = "Cognoscenti 55", costs = 1000000, description = {}, model = "cognoscenti3"},
  226.                 --{name = "Cognoscenti 55(Armored", costs = 1500000, description = {}, model = "ZENTORNO"},
  227.                 {name = "Fugitive", costs = 50000, description = {}, model = "fugitive"},
  228.                 {name = "Glendale", costs = 15000, description = {}, model = "glendale"},
  229.                 {name = "Ingot", costs = 10000, description = {}, model = "ingot"},
  230.                 {name = "Intruder", costs = 25000, description = {}, model = "intruder"},
  231.                 {name = "Premier", costs = 20000, description = {}, model = "premier"},
  232.                 {name = "Primo", costs = 18000, description = {}, model = "primo"},
  233.                 {name = "Primo Custom", costs = 22500, description = {}, model = "primo2"},
  234.                 {name = "Regina", costs = 17500, description = {}, model = "regina"},
  235.                 {name = "Schafter", costs = 45000, description = {}, model = "schafter2"},
  236.                 {name = "Stanier", costs = 30000, description = {}, model = "stanier"},
  237.                 {name = "Stratum", costs = 23000, description = {}, model = "stratum"},
  238.                 {name = "Stretch", costs = 350000, description = {}, model = "stretch"},
  239.                 {name = "Super Diamond", costs = 125000, description = {}, model = "superd"},
  240.                 {name = "Surge", costs = 45000, description = {}, model = "surge"},
  241.                 {name = "Tailgater", costs = 50000, description = {}, model = "tailgater"},
  242.                 {name = "Warrener", costs = 25000, description = {}, model = "warrener"},
  243.                 {name = "Washington", costs = 15000, description = {}, model = "washington"},
  244.             }
  245.         },
  246.         ["motorcycles"] = {
  247.             title = "MOTORCYCLES",
  248.             name = "motorcycles",
  249.             buttons = {
  250.                 {name = "Akuma", costs = 50000, description = {}, model = "AKUMA"},
  251.                 {name = "Bagger", costs = 25000, description = {}, model = "bagger"},
  252.                 {name = "Bati 801", costs = 35000, description = {}, model = "bati"},
  253.                 {name = "Bati 801RR", costs = 35000, description = {}, model = "bati2"},
  254.                 {name = "BF400", costs = 65000, description = {}, model = "bf400"},
  255.                 {name = "Carbon RS", costs = 90000, description = {}, model = "carbonrs"},
  256.                 {name = "Cliffhanger", costs = 85000, description = {}, model = "cliffhanger"},
  257.                 {name = "Daemon", costs = 100000, description = {}, model = "daemon"},
  258.                 {name = "Double T", costs = 115000, description = {}, model = "double"},
  259.                 {name = "Enduro", costs = 50000, description = {}, model = "enduro"},
  260.                 {name = "Faggio", costs = 6000, description = {}, model = "faggio2"},
  261.                 {name = "Gargoyle", costs = 40000, description = {}, model = "gargoyle"},
  262.                 {name = "Hakuchou", costs = 150000, description = {}, model = "hakuchou"},
  263.                 {name = "Hexer", costs = 35000, description = {}, model = "hexer"},
  264.                 {name = "Innovation", costs = 65000, description = {}, model = "innovation"},
  265.                 {name = "Lectro", costs = 60000, description = {}, model = "lectro"},
  266.                 {name = "Nemesis", costs = 100000, description = {}, model = "nemesis"},
  267.                 {name = "PCJ-600", costs = 75000, description = {}, model = "pcj"},
  268.                 {name = "Ruffian", costs = 50000, description = {}, model = "ruffian"},
  269.                 {name = "Sanchez", costs = 15000, description = {}, model = "sanchez"},
  270.                 {name = "Sovereign", costs = 90000, description = {}, model = "sovereign"},
  271.                 {name = "Thrust", costs = 175000, description = {}, model = "thrust"},
  272.                 {name = "Vader", costs = 65000, description = {}, model = "vader"},
  273.                 {name = "Vindicator", costs = 200000, description = {}, model = "vindicator"},
  274.             }
  275.         },
  276.     }
  277. }
  278. local fakecar = {model = '', car = nil}
  279. local vehshop_locations = {
  280. {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}},
  281. }
  282.  
  283. local vehshop_blips ={}
  284. local inrangeofvehshop = false
  285. local currentlocation = nil
  286. local boughtcar = false
  287.  
  288. local function LocalPed()
  289. return GetPlayerPed(-1)
  290. end
  291.  
  292. function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  293.     SetTextFont(font)
  294.     SetTextProportional(0)
  295.     SetTextScale(scale, scale)
  296.     SetTextColour(r, g, b, a)
  297.     SetTextDropShadow(0, 0, 0, 0,255)
  298.     SetTextEdge(1, 0, 0, 0, 255)
  299.     SetTextDropShadow()
  300.     SetTextOutline()
  301.     SetTextCentre(centre)
  302.     SetTextEntry("STRING")
  303.     AddTextComponentString(text)
  304.     DrawText(x , y)
  305. end
  306.  
  307. function IsPlayerInRangeOfVehshop()
  308. return inrangeofvehshop
  309. end
  310.  
  311. function ShowVehshopBlips(bool)
  312.     if bool and #vehshop_blips == 0 then
  313.         for station,pos in pairs(vehshop_locations) do
  314.             local loc = pos
  315.             pos = pos.entering
  316.             local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
  317.             -- 60 58 137
  318.             SetBlipSprite(blip,326)
  319.             BeginTextCommandSetBlipName("STRING")
  320.             AddTextComponentString('Vehicle shop')
  321.             EndTextCommandSetBlipName(blip)
  322.             SetBlipAsShortRange(blip,true)
  323.             SetBlipAsMissionCreatorBlip(blip,true)
  324.             table.insert(vehshop_blips, {blip = blip, pos = loc})
  325.         end
  326.         Citizen.CreateThread(function()
  327.             while #vehshop_blips > 0 do
  328.                 Citizen.Wait(0)
  329.                 local inrange = false
  330.                 for i,b in ipairs(vehshop_blips) do
  331.                     if IsPlayerWantedLevelGreater(GetPlayerIndex(),0) == false and vehshop.opened == false and IsPedInAnyVehicle(LocalPed(), true) == false and  GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(LocalPed())) < 5 then
  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.                         drawTxt('Press ~g~ENTER~s~ to buy ~b~vehicle',0,1,0.5,0.8,0.6,255,255,255,255)
  334.                         currentlocation = b
  335.                         inrange = true
  336.                     end
  337.                 end
  338.                 inrangeofvehshop = inrange
  339.             end
  340.         end)
  341.     elseif bool == false and #vehshop_blips > 0 then
  342.         for i,b in ipairs(vehshop_blips) do
  343.             if DoesBlipExist(b.blip) then
  344.                 SetBlipAsMissionCreatorBlip(b.blip,false)
  345.                 Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
  346.             end
  347.         end
  348.         vehshop_blips = {}
  349.     end
  350. end
  351.  
  352. function f(n)
  353. return n + 0.0001
  354. end
  355.  
  356. function LocalPed()
  357. return GetPlayerPed(-1)
  358. end
  359.  
  360. function try(f, catch_f)
  361. local status, exception = pcall(f)
  362. if not status then
  363. catch_f(exception)
  364. end
  365. end
  366. function firstToUpper(str)
  367.     return (str:gsub("^%l", string.upper))
  368. end
  369. --local veh = nil
  370. function OpenCreator()
  371.     boughtcar = false
  372.     local ped = LocalPed()
  373.     local pos = currentlocation.pos.inside
  374.     FreezeEntityPosition(ped,true)
  375.     SetEntityVisible(ped,false)
  376.     local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
  377.     SetEntityCoords(ped,pos[1],pos[2],g)
  378.     SetEntityHeading(ped,pos[4])
  379.     vehshop.currentmenu = "main"
  380.     vehshop.opened = true
  381.     vehshop.selectedbutton = 0
  382.     --[[Citizen.CreateThread(function()
  383.         RequestModel(GetHashKey('t20'))
  384.         while not HasModelLoaded(GetHashKey('t20')) do
  385.             Citizen.Wait(0)
  386.         end
  387.         veh = CreateVehicle(GetHashKey('t20'),GetOffsetFromEntityInWorldCoords(ped,2.001,0,0),false,true)
  388.         SetModelAsNoLongerNeeded(GetHashKey('t20'))
  389.         SetEntityHeading(veh,pos[4])
  390.         FreezeEntityPosition(veh,true)
  391.         SetEntityCollision(veh,false,false)
  392.         SetEntityInvincible(veh,true)
  393.     end)]]
  394. end
  395. local vehicle_price = 0
  396. function CloseCreator()
  397.     Citizen.CreateThread(function()
  398.         local ped = LocalPed()
  399.         if not boughtcar then
  400.             local pos = currentlocation.pos.entering
  401.             SetEntityCoords(ped,pos[1],pos[2],pos[3])
  402.             FreezeEntityPosition(ped,false)
  403.             SetEntityVisible(ped,true)
  404.         else
  405.             local veh = GetVehiclePedIsUsing(ped)
  406.             local model = GetEntityModel(veh)
  407.             local colors = table.pack(GetVehicleColours(veh))
  408.             local extra_colors = table.pack(GetVehicleExtraColours(veh))
  409.  
  410.             local mods = {}
  411.             for i = 0,24 do
  412.                 mods[i] = GetVehicleMod(veh,i)
  413.             end
  414.             Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(veh))
  415.             local pos = currentlocation.pos.outside
  416.  
  417.             FreezeEntityPosition(ped,false)
  418.             RequestModel(model)
  419.             while not HasModelLoaded(model) do
  420.                 Citizen.Wait(0)
  421.             end
  422.             personalvehicle = CreateVehicle(model,pos[1],pos[2],pos[3],pos[4],true,false)
  423.             SetModelAsNoLongerNeeded(model)
  424.             for i,mod in pairs(mods) do
  425.                 SetVehicleModKit(personalvehicle,0)
  426.                 SetVehicleMod(personalvehicle,i,mod)
  427.             end
  428.             SetVehicleOnGroundProperly(personalvehicle)
  429.             SetVehicleHasBeenOwnedByPlayer(personalvehicle,true)
  430.             local id = NetworkGetNetworkIdFromEntity(personalvehicle)
  431.             SetNetworkIdCanMigrate(id, true)
  432.             Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(personalvehicle))
  433.             SetVehicleColours(personalvehicle,colors[1],colors[2])
  434.             SetVehicleExtraColours(personalvehicle,extra_colors[1],extra_colors[2])
  435.             --local blip = AddBlipForEntity(personalvehicle)
  436.             --SetBlipSprite(blip,326)
  437.             --BeginTextCommandSetBlipName("STRING")
  438.             --AddTextComponentString('Personal vehicle')
  439.             --EndTextCommandSetBlipName(blip)
  440.             --personalvehicle_blip = blip
  441.             TaskWarpPedIntoVehicle(GetPlayerPed(-1),personalvehicle,-1)
  442.             SetEntityVisible(ped,true)
  443.  
  444.  
  445.         end
  446.         vehshop.opened = false
  447.         vehshop.menu.from = 1
  448.         vehshop.menu.to = 10
  449.     end)
  450. end
  451.  
  452. function drawMenuButton(button,x,y,selected)
  453.     local menu = vehshop.menu
  454.     SetTextFont(menu.font)
  455.     SetTextProportional(0)
  456.     SetTextScale(menu.scale, menu.scale)
  457.     if selected then
  458.         SetTextColour(0, 0, 0, 255)
  459.     else
  460.         SetTextColour(255, 255, 255, 255)
  461.     end
  462.     SetTextCentre(0)
  463.     SetTextEntry("STRING")
  464.     AddTextComponentString(button.name)
  465.     if selected then
  466.         DrawRect(x,y,menu.width,menu.height,255,255,255,255)
  467.     else
  468.         DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  469.     end
  470.     DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  471. end
  472.  
  473. function drawMenuInfo(text)
  474.     local menu = vehshop.menu
  475.     SetTextFont(menu.font)
  476.     SetTextProportional(0)
  477.     SetTextScale(0.45, 0.45)
  478.     SetTextColour(255, 255, 255, 255)
  479.     SetTextCentre(0)
  480.     SetTextEntry("STRING")
  481.     AddTextComponentString(text)
  482.     DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
  483.     DrawText(0.365, 0.934)
  484. end
  485.  
  486. function drawMenuRight(txt,x,y,selected)
  487.     local menu = vehshop.menu
  488.     SetTextFont(menu.font)
  489.     SetTextProportional(0)
  490.     SetTextScale(menu.scale, menu.scale)
  491.     SetTextRightJustify(1)
  492.     if selected then
  493.         SetTextColour(0, 0, 0, 255)
  494.     else
  495.         SetTextColour(255, 255, 255, 255)
  496.     end
  497.     SetTextCentre(0)
  498.     SetTextEntry("STRING")
  499.     AddTextComponentString(txt)
  500.     DrawText(x + menu.width/2 - 0.03, y - menu.height/2 + 0.0028)
  501. end
  502.  
  503. function drawMenuTitle(txt,x,y)
  504. local menu = vehshop.menu
  505.     SetTextFont(2)
  506.     SetTextProportional(0)
  507.     SetTextScale(0.5, 0.5)
  508.     SetTextColour(255, 255, 255, 255)
  509.     SetTextEntry("STRING")
  510.     AddTextComponentString(txt)
  511.     DrawRect(x,y,menu.width,menu.height,0,0,0,150)
  512.     DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
  513. end
  514. function tablelength(T)
  515.   local count = 0
  516.   for _ in pairs(T) do count = count + 1 end
  517.   return count
  518. end
  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()
  688.     boughtcar = true
  689.     CloseCreator()
  690. end)
  691.  
  692. function OpenMenu(menu)
  693.     fakecar = {model = '', car = nil}
  694.     vehshop.lastmenu = vehshop.currentmenu
  695.     if menu == "vehicles" then
  696.         vehshop.lastmenu = "main"
  697.     elseif menu == "bikes"  then
  698.         vehshop.lastmenu = "main"
  699.     elseif menu == 'race_create_objects' then
  700.         vehshop.lastmenu = "main"
  701.     elseif menu == "race_create_objects_spawn" then
  702.         vehshop.lastmenu = "race_create_objects"
  703.     end
  704.     vehshop.menu.from = 1
  705.     vehshop.menu.to = 10
  706.     vehshop.selectedbutton = 0
  707.     vehshop.currentmenu = menu
  708. end
  709.  
  710.  
  711. function Back()
  712.     if backlock then
  713.         return
  714.     end
  715.     backlock = true
  716.     if vehshop.currentmenu == "main" then
  717.         CloseCreator()
  718.     elseif vehshop.currentmenu == "compacts" or vehshop.currentmenu == "coupes" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "sports" or vehshop.currentmenu == "sportsclassics" or vehshop.currentmenu == "super" or vehshop.currentmenu == "muscle" or vehshop.currentmenu == "offroad" or vehshop.currentmenu == "suvs" or vehshop.currentmenu == "vans" or vehshop.currentmenu == "industrial" or vehshop.currentmenu == "cycles" or vehshop.currentmenu == "motorcycles" then
  719.         if DoesEntityExist(fakecar.car) then
  720.             Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
  721.         end
  722.         fakecar = {model = '', car = nil}
  723.         OpenMenu(vehshop.lastmenu)
  724.     else
  725.         OpenMenu(vehshop.lastmenu)
  726.     end
  727.  
  728. end
  729.  
  730. function stringstarts(String,Start)
  731.    return string.sub(String,1,string.len(Start))==Start
  732. end
  733.  
  734. local firstspawn = 0
  735. AddEventHandler('playerSpawned', function(spawn)
  736. if firstspawn == 0 then
  737.     --326 car blip 227 225
  738.     ShowVehshopBlips(true)
  739.     firstspawn = 1
  740. end
  741. end)
  742.  
  743. RegisterNetEvent('vehshop:spawnVehicle')
  744. AddEventHandler('vehshop:spawnVehicle', function(v)
  745.     local car = GetHashKey(v)
  746.     local playerPed = GetPlayerPed(-1)
  747.     if playerPed and playerPed ~= -1 then
  748.         RequestModel(car)
  749.         while not HasModelLoaded(car) do
  750.                 Citizen.Wait(0)
  751.         end
  752.         local playerCoords = GetEntityCoords(playerPed)
  753.  
  754.         veh = CreateVehicle(car, playerCoords, 0.0, true, false)
  755.         TaskWarpPedIntoVehicle(playerPed, veh, -1)
  756.         SetEntityInvincible(veh, true)
  757.     end
  758. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement