Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- FiveM Scripts
- Copyright C 2018 Sighmir
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- at your option any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- ]]
- vRP = Proxy.getInterface("vRP")
- vRPg = Proxy.getInterface("vRP_garages")
- function deleteVehiclePedIsIn()
- local v = GetVehiclePedIsIn(GetPlayerPed(-1),false)
- SetVehicleHasBeenOwnedByPlayer(v,false)
- Citizen.InvokeNative(0xAD738C3085FE7E11, v, false, true) -- set not as mission entity
- SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(v))
- Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(v))
- end
- local vehshop = {
- opened = false,
- title = "Simeon Showroom",
- currentmenu = "main",
- lastmenu = nil,
- currentpos = nil,
- selectedbutton = 0,
- marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
- menu = {
- x = 0.1,
- y = 0.08,
- width = 0.2,
- height = 0.04,
- buttons = 10,
- from = 1,
- to = 10,
- scale = 0.4,
- font = 0,
- ["main"] = {
- title = "CATEGORIES",
- name = "main",
- buttons = {
- {name = "mercedes-benz", description = ''},
- {name = "bmw", description = ''},
- {name = "lamborghini", description = ''},
- {name = "audi", description = ''},
- {name = "porsche", description = ''},
- {name = "andet", description = ''},
- }
- },
- ["mercedes-benz"] = {
- title = "mercedes-benz",
- name = "mercedes-benz",
- buttons = {
- {name = "Mercedes-Benz G65 AMG", costs = 3000000, description = {}, model = "g65amg"},
- {name = "Mercedes-Benz CLS63S", costs = 2500000, description = {}, model = "CLS63S"},
- }
- },
- ["bmw"] = {
- title = "bmw",
- name = "bmw",
- buttons = {
- {name = "BMW i8", costs = 10000000, description = {}, model = "i8"},
- {name = "BMW M5 2019 Competiotion", costs = 4500000, description {}, model = "2019M5",
- }
- },
- ["lamborghini"] = {
- title = "lamborghini",
- name = "lamborghini",
- buttons = {
- {name = "Lamborghini Huracan Performante", costs = 5000000, description = {}, model = "18performante"},
- {name = "Lamborghini Urus", costs = 6500000, description = {}, model = "urus"},
- }
- },
- ["audi"] = {
- title = "audi",
- name = "audi",
- buttons = {
- {name = "Audi S5", costs = 2500000, description = {}, model = "sentinel"},
- {name = "Audi C7 RS6", costs = 3000000, description = {}, model = "rs6"},
- {name = "Audi R8", costs = 4500000, description = {}, model = "r8v10"},
- }
- },
- ["porsche"] = {
- title = "porsche",
- name = "porsche",
- buttons = {
- {name = "Porsche Cayenne", costs = 3500000, description = {}, model = "pct18"},
- {name = "Porsche Panamera", costs = 3500000, description = {}, model = "panamera18"},
- }
- },
- ["andet"] = {
- title = "andet",
- name = "andet",
- buttons = {
- {name = "Bugatti Veyron Limited Version", costs = 30000000, description = {}, model = "supersport"},
- {name = "Jeep Demon Hawk", costs = 2500000, description = {}, model = "demonhawk",
- {name = "Ferrari LaFerrari", costs = 1500000, description = {}, model = "aperta",
- {name = "Lamborghini ????", costs = 30000000, description = {}, model = "lamtmc",
- {name = "Peugeot RCZ 2016", costs = 500000, description {}, model = "rcz16",
- {name = "Range Rover ????", costs = 3000000, description {}, model = "rrst",
- {name = "Rolls Royce ????", costs = 5000000, description {}, model = "rculi",
- {name = "Rolls Royce CP", costs = 5500000, description {}, model = "RollsRoyceCP",
- {name = "Toyota Camry 2018", costs = 1000000, description {}, model = "camry18",
- {name = "Ferrari Spyder 250", costs = 30000000, description {}, model = "cali57",
- {name = "Ford ????", costs 1500000, description {}, model = "00f350dually",
- }
- },
- }
- }
- local fakecar = {model = '', car = nil}
- local vehshop_locations = {
- {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}},
- }
- local vehshop_blips ={}
- local inrangeofvehshop = false
- local currentlocation = nil
- local boughtcar = false
- function vehSR_drawTxt(text,font,centre,x,y,scale,r,g,b,a)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextCentre(centre)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x , y)
- end
- function vehSR_IsPlayerInRangeOfVehshop()
- return inrangeofvehshop
- end
- local firstspawn = 0
- AddEventHandler('playerSpawned', function(spawn)
- if firstspawn == 0 then
- --326 car blip 227 225
- vehSR_ShowVehshopBlips(true)
- firstspawn = 1
- end
- end)
- function vehSR_ShowVehshopBlips(bool)
- if bool and #vehshop_blips == 0 then
- for station,pos in pairs(vehshop_locations) do
- local loc = pos
- pos = pos.entering
- local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
- -- 60 58 137
- SetBlipSprite(blip,326)
- BeginTextCommandSetBlipName("STRING")
- AddTextComponentString("Simeon Showroom")
- EndTextCommandSetBlipName(blip)
- SetBlipAsShortRange(blip,true)
- SetBlipAsMissionCreatorBlip(blip,true)
- table.insert(vehshop_blips, {blip = blip, pos = loc})
- end
- Citizen.CreateThread(function()
- while #vehshop_blips > 0 do
- Citizen.Wait(0)
- local inrange = false
- for i,b in ipairs(vehshop_blips) do
- 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
- 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)
- vehSR_drawTxt("Tryk ~g~ENTER~s~ for at købe et ~b~køretøj",0,1,0.5,0.8,0.6,255,255,255,255)
- currentlocation = b
- inrange = true
- end
- end
- inrangeofvehshop = inrange
- end
- end)
- elseif bool == false and #vehshop_blips > 0 then
- for i,b in ipairs(vehshop_blips) do
- if DoesBlipExist(b.blip) then
- SetBlipAsMissionCreatorBlip(b.blip,false)
- Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
- end
- end
- vehshop_blips = {}
- end
- end
- function vehSR_f(n)
- return n + 0.0001
- end
- function vehSR_LocalPed()
- return GetPlayerPed(-1)
- end
- function vehSR_try(f, catch_f)
- local status, exception = pcall(f)
- if not status then
- catch_f(exception)
- end
- end
- function vehSR_firstToUpper(str)
- return (str:gsub("^%l", string.upper))
- end
- --local veh = nil
- function vehSR_OpenCreator()
- boughtcar = false
- local ped = vehSR_LocalPed()
- local pos = currentlocation.pos.inside
- FreezeEntityPosition(ped,true)
- SetEntityVisible(ped,false)
- local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
- SetEntityCoords(ped,pos[1],pos[2],g)
- SetEntityHeading(ped,pos[4])
- vehshop.currentmenu = "main"
- vehshop.opened = true
- vehshop.selectedbutton = 0
- end
- local vehicle_price = 0
- function vehSR_CloseCreator(vehicle,veh_type)
- Citizen.CreateThread(function()
- local ped = vehSR_LocalPed()
- if not boughtcar then
- local pos = currentlocation.pos.entering
- SetEntityCoords(ped,pos[1],pos[2],pos[3])
- FreezeEntityPosition(ped,false)
- SetEntityVisible(ped,true)
- else
- deleteVehiclePedIsIn()
- vRP.teleport({-44.21378326416,-1079.1402587891,26.67050743103})
- vRPg.spawnBoughtVehicle({veh_type, vehicle})
- SetEntityVisible(ped,true)
- FreezeEntityPosition(ped,false)
- end
- vehshop.opened = false
- vehshop.menu.from = 1
- vehshop.menu.to = 10
- end)
- end
- function vehSR_drawMenuButton(button,x,y,selected)
- local menu = vehshop.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(button.name)
- if selected then
- DrawRect(x,y,menu.width,menu.height,255,255,255,255)
- else
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- end
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function vehSR_drawMenuTitle(txt,x,y)
- local menu = vehshop.menu
- SetTextFont(2)
- SetTextProportional(0)
- SetTextScale(0.5, 0.5)
- SetTextColour(255, 255, 255, 255)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function vehSR_tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function vehSR_Notify(text)
- SetNotificationTextEntry('STRING')
- AddTextComponentString(text)
- DrawNotification(false, false)
- end
- function vehSR_drawMenuRight(txt,x,y,selected)
- local menu = vehshop.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawText(x + menu.width/2 - 0.06, y - menu.height/2 + 0.0028)
- end
- local backlock = false
- Citizen.CreateThread(function()
- local last_dir
- while true do
- Citizen.Wait(0)
- if IsControlJustPressed(1,201) and vehSR_IsPlayerInRangeOfVehshop() then
- if vehshop.opened then
- vehSR_CloseCreator("","")
- else
- vehSR_OpenCreator()
- end
- end
- if vehshop.opened then
- local ped = vehSR_LocalPed()
- local menu = vehshop.menu[vehshop.currentmenu]
- vehSR_drawTxt(vehshop.title,1,1,vehshop.menu.x,vehshop.menu.y,1.0, 255,255,255,255)
- vehSR_drawMenuTitle(menu.title, vehshop.menu.x,vehshop.menu.y + 0.08)
- 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)
- local y = vehshop.menu.y + 0.12
- buttoncount = vehSR_tablelength(menu.buttons)
- local selected = false
- for i,button in pairs(menu.buttons) do
- if i >= vehshop.menu.from and i <= vehshop.menu.to then
- if i == vehshop.selectedbutton then
- selected = true
- else
- selected = false
- end
- vehSR_drawMenuButton(button,vehshop.menu.x,y,selected)
- if button.costs ~= nil then
- 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" or vehshop.currentmenu == "mercedes-benz" or vehshop.currentmenu == "bmw" or vehshop.currentmenu == "lamborghini" or vehshop.currentmenu == "audi" or vehshop.currentmenu == "porsche" or vehshop.currentmenu == "andet" then
- vehSR_drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
- else
- vehSR_drawMenuButton(button,vehshop.menu.x,y,selected)
- end
- end
- y = y + 0.04
- 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" or vehshop.currentmenu == "mercedes-benz" or vehshop.currentmenu == "bmw" or vehshop.currentmenu == "lamborghini" or vehshop.currentmenu == "audi" or vehshop.currentmenu == "porsche" or vehshop.currentmenu == "andet" then
- if selected then
- if fakecar.model ~= button.model then
- if DoesEntityExist(fakecar.car) then
- Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
- end
- local pos = currentlocation.pos.inside
- local hash = GetHashKey(button.model)
- RequestModel(hash)
- local timer = 0
- while not HasModelLoaded(hash) and timer < 255 do
- Citizen.Wait(1)
- vehSR_drawTxt("Loader...",0,1,0.5,0.5,1.5,255,255-timer,255-timer,255)
- RequestModel(hash)
- timer = timer + 1
- end
- if timer < 255 then
- local veh = CreateVehicle(hash,pos[1],pos[2],pos[3],pos[4],false,false)
- while not DoesEntityExist(veh) do
- Citizen.Wait(1)
- vehSR_drawTxt("Loader...",0,1,0.5,0.5,1.5,255,255-timer,255-timer,255)
- end
- FreezeEntityPosition(veh,true)
- SetEntityInvincible(veh,true)
- SetVehicleDoorsLocked(veh,4)
- --SetEntityCollision(veh,false,false)
- TaskWarpPedIntoVehicle(vehSR_LocalPed(),veh,-1)
- for i = 0,24 do
- SetVehicleModKit(veh,0)
- RemoveVehicleMod(veh,i)
- end
- fakecar = { model = button.model, car = veh}
- else
- timer = 0
- while timer < 50 do
- Citizen.Wait(1)
- vehSR_drawTxt("Failed!",0,1,0.5,0.5,1.5,255,0,0,255)
- timer = timer + 1
- end
- if last_dir then
- if vehshop.selectedbutton < buttoncount then
- vehshop.selectedbutton = vehshop.selectedbutton +1
- if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
- vehshop.menu.to = vehshop.menu.to + 1
- vehshop.menu.from = vehshop.menu.from + 1
- end
- else
- last_dir = false
- vehshop.selectedbutton = vehshop.selectedbutton -1
- if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
- vehshop.menu.from = vehshop.menu.from -1
- vehshop.menu.to = vehshop.menu.to - 1
- end
- end
- else
- if vehshop.selectedbutton > 1 then
- vehshop.selectedbutton = vehshop.selectedbutton -1
- if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
- vehshop.menu.from = vehshop.menu.from -1
- vehshop.menu.to = vehshop.menu.to - 1
- end
- else
- last_dir = true
- vehshop.selectedbutton = vehshop.selectedbutton +1
- if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
- vehshop.menu.to = vehshop.menu.to + 1
- vehshop.menu.from = vehshop.menu.from + 1
- end
- end
- end
- end
- end
- end
- end
- if selected and IsControlJustPressed(1,201) then
- vehSR_ButtonSelected(button)
- end
- end
- end
- if IsControlJustPressed(1,202) then
- vehSR_Back()
- end
- if IsControlJustReleased(1,202) then
- backlock = false
- end
- if IsControlJustPressed(1,188) then
- last_dir = false
- if vehshop.selectedbutton > 1 then
- vehshop.selectedbutton = vehshop.selectedbutton -1
- if buttoncount > 10 and vehshop.selectedbutton < vehshop.menu.from then
- vehshop.menu.from = vehshop.menu.from -1
- vehshop.menu.to = vehshop.menu.to - 1
- end
- end
- end
- if IsControlJustPressed(1,187)then
- last_dir = true
- if vehshop.selectedbutton < buttoncount then
- vehshop.selectedbutton = vehshop.selectedbutton +1
- if buttoncount > 10 and vehshop.selectedbutton > vehshop.menu.to then
- vehshop.menu.to = vehshop.menu.to + 1
- vehshop.menu.from = vehshop.menu.from + 1
- end
- end
- end
- end
- end
- end)
- function vehSR_round(num, idp)
- if idp and idp>0 then
- local mult = 10^idp
- return math.floor(num * mult + 0.5) / mult
- end
- return math.floor(num + 0.5)
- end
- function vehSR_ButtonSelected(button)
- local ped = GetPlayerPed(-1)
- local this = vehshop.currentmenu
- local btn = button.name
- if this == "main" then
- if btn == "mercedes-benz" then
- vehSR_OpenMenu('mercedes-benz')
- elseif btn == "bmw" then
- vehSR_OpenMenu('bmw')
- elseif btn == "lamborghini" then
- vehSR_OpenMenu('lamborghini')
- elseif btn == "audi" then
- vehSR_OpenMenu('audi')
- elseif btn == "porsche" then
- vehSR_OpenMenu('porsche')
- elseif btn == "andet" then
- vehSR_OpenMenu('andet')
- end
- 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" or this == "mercedes-benz" or this == "bmw" or this == "lamborghini" or this == "audi" or this "porsche" or this "andet" then
- TriggerServerEvent('veh_SR:CheckMoneyForVeh',button.model,button.costs, "car")
- elseif this == "cycles" or this == "motorcycles" then
- TriggerServerEvent('veh_SR:CheckMoneyForVeh',button.model,button.costs, "bike")
- end
- end
- RegisterNetEvent('veh_SR:CloseMenu')
- AddEventHandler('veh_SR:CloseMenu', function(vehicle, veh_type)
- boughtcar = true
- vehSR_CloseCreator(vehicle,veh_type)
- end)
- function vehSR_OpenMenu(menu)
- fakecar = {model = '', car = nil}
- vehshop.lastmenu = vehshop.currentmenu
- if menu == "vehicles" then
- vehshop.lastmenu = "main"
- elseif menu == "bikes" then
- vehshop.lastmenu = "main"
- elseif menu == 'race_create_objects' then
- vehshop.lastmenu = "main"
- elseif menu == "race_create_objects_spawn" then
- vehshop.lastmenu = "race_create_objects"
- end
- vehshop.menu.from = 1
- vehshop.menu.to = 10
- vehshop.selectedbutton = 0
- vehshop.currentmenu = menu
- end
- function vehSR_Back()
- if backlock then
- return
- end
- backlock = true
- if vehshop.currentmenu == "main" then
- vehSR_CloseCreator("","")
- 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" or vehshop.currentmenu == "mercedes-benz" or vehshop.currentmenu == "bmw" or vehshop.currentmenu == "lamborghini" or vehshop.currentmenu == "audi" or vehshop.currentmenu == "porsche" or vehshop.currentmenu == "andet" then
- if DoesEntityExist(fakecar.car) then
- Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
- end
- fakecar = {model = '', car = nil}
- vehSR_OpenMenu(vehshop.lastmenu)
- else
- vehSR_OpenMenu(vehshop.lastmenu)
- end
- end
- function vehSR_stringstarts(String,Start)
- return string.sub(String,1,string.len(Start))==Start
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement