try this
{entering = {904.7940,-184.5603,73.9992}, inside = 904.7940,-184.5603,73.9992,322.345}, outside = {904.7940,-184.5603,73.9992,322.345}},
1 Like
Hello, really nice script i use it everyday ! Any idea how to add a “if namejob = “Cop” then” function to this script to allow only one specified job to open the menu ?
1 Like
yeah please insert to permission job please
m8, you found out? it would be nice.
Why is the vehshop_lua is empty? There aren’t anything in the file.
Why is the vehshop_server.lua is empty? I did something wrong? I’m in the CP but it’s didn’t do anything.
Here’s the script
local vehshop = {
opened = false,
title = "Job Garage",
currentmenu = "main",
lastmenu = nil,
currentpos = nil,
selectedbutton = 0,
marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
menu = {
x = 0.11,
y = 0.25,
width = 0.2,
height = 0.04,
buttons = 10,
from = 1,
to = 10,
scale = 0.4,
font = 0,
["main"] = {
title = "CATEGORIES",
name = "main",
buttons = {
{name = "Vehicles", description = ""},
}
},
["vehicles"] = {
title = "VEHICLES",
name = "vehicles",
buttons = {
{name = "Vehicle-Minor", description = ''},
{name = "Vehicle-WineMakers", description = ''},
{name = "Vehicle-Farmer", description = ''},
{name = "Vehicle-Tanker", description = ''},
{name = "Vehicle-Taxi", description = ''},
}
},
["Vehicle-Minor"] = {
title = "Vehicle-Minor",
name = "Vehicle-Minor",
buttons = {
{name = "Camion", costs = 0, description = {}, model = "Rubble"},
}
},
["Vehicle-WineMakers"] = {
title = "Vehicle-WineMakers",
name = "Vehicle-WineMakers",
buttons = {
{name = "Camion", costs = 0, description = {}, model = "Mule"},
}
},
["Vehicle-Farmer"] = {
title = "Vehicle-Farmer",
name = "Vehicle-Farmer",
buttons = {
{name = "Camion", costs = 0, description = {}, model = "Pounder"},
}
},
["Vehicle-Tanker"] = {
title = "Vehicle-Tanker",
name = "Vehicle-Tanker",
buttons = {
{name = "Camion", costs = 0, description = {}, model = "Benson"},
}
},
["Vehicle-Taxi"] = {
title = "Vehicle-Taxi",
name = "Vehicle-Taxi",
buttons = {
{name = "Taxi", costs = 0, description = {}, model = "Taxi"},
}
},
}
}
local fakecar = {model = '', car = nil}
local vehshop_locations = {
{entering = {904.7940,-184.5603,73.9992}, inside = 904.7940,-184.5603,73.9992,322.345}, outside = {904.7940,-184.5603,73.9992,322.345}},
}
local vehshop_blips ={}
local inrangeofvehshop = false
local currentlocation = nil
local boughtcar = false
local function LocalPed()
return GetPlayerPed(-1)
end
function 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 IsPlayerInRangeOfVehshop()
return inrangeofvehshop
end
function 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,357)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Job Garage')
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(LocalPed(), true) == false and GetDistanceBetweenCoords(b.pos.entering[1],b.pos.entering[2],b.pos.entering[3],GetEntityCoords(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)
drawTxt('Press ~g~ENTER~s~ to access vehicle menu',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 f(n)
return n + 0.0001
end
function LocalPed()
return GetPlayerPed(-1)
end
function try(f, catch_f)
local status, exception = pcall(f)
if not status then
catch_f(exception)
end
end
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
--local veh = nil
function OpenCreator()
boughtcar = false
local ped = 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
--[[Citizen.CreateThread(function()
RequestModel(GetHashKey('t20'))
while not HasModelLoaded(GetHashKey('t20')) do
Citizen.Wait(0)
end
veh = CreateVehicle(GetHashKey('t20'),GetOffsetFromEntityInWorldCoords(ped,2.001,0,0),false,true)
SetModelAsNoLongerNeeded(GetHashKey('t20'))
SetEntityHeading(veh,pos[4])
FreezeEntityPosition(veh,true)
SetEntityCollision(veh,false,false)
SetEntityInvincible(veh,true)
end)]]
end
local vehicle_price = 0
function CloseCreator()
Citizen.CreateThread(function()
local ped = 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
local veh = GetVehiclePedIsUsing(ped)
local model = GetEntityModel(veh)
local colors = table.pack(GetVehicleColours(veh))
local extra_colors = table.pack(GetVehicleExtraColours(veh))
local mods = {}
for i = 0,24 do
mods[i] = GetVehicleMod(veh,i)
end
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(veh))
local pos = currentlocation.pos.outside
FreezeEntityPosition(ped,false)
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
personalvehicle = CreateVehicle(model,pos[1],pos[2],pos[3],pos[4],true,false)
SetModelAsNoLongerNeeded(model)
for i,mod in pairs(mods) do
SetVehicleModKit(personalvehicle,0)
SetVehicleMod(personalvehicle,i,mod)
end
SetVehicleOnGroundProperly(personalvehicle)
SetVehicleHasBeenOwnedByPlayer(personalvehicle,true)
local id = NetworkGetNetworkIdFromEntity(personalvehicle)
SetNetworkIdCanMigrate(id, true)
Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(personalvehicle))
SetVehicleColours(personalvehicle,colors[1],colors[2])
SetVehicleExtraColours(personalvehicle,extra_colors[1],extra_colors[2])
--local blip = AddBlipForEntity(personalvehicle)
--SetBlipSprite(blip,326)
--BeginTextCommandSetBlipName("STRING")
--AddTextComponentString('Personal vehicle')
--EndTextCommandSetBlipName(blip)
--personalvehicle_blip = blip
TaskWarpPedIntoVehicle(GetPlayerPed(-1),personalvehicle,-1)
SetEntityVisible(ped,true)
end
vehshop.opened = false
vehshop.menu.from = 1
vehshop.menu.to = 10
end)
end
function 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 drawMenuInfo(text)
local menu = vehshop.menu
SetTextFont(menu.font)
SetTextProportional(0)
SetTextScale(0.45, 0.45)
SetTextColour(255, 255, 255, 255)
SetTextCentre(0)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
DrawText(0.365, 0.934)
end
function drawMenuRight(txt,x,y,selected)
local menu = vehshop.menu
SetTextFont(menu.font)
SetTextProportional(0)
SetTextScale(menu.scale, menu.scale)
SetTextRightJustify(1)
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.03, y - menu.height/2 + 0.0028)
end
function 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 tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
function Notify(text)
SetNotificationTextEntry('STRING')
AddTextComponentString(text)
DrawNotification(false, false)
end
function DoesPlayerHaveVehicle(model,button,y,selected)
local t = false
--TODO:check if player own car
if t then
drawMenuRight("OWNED",vehshop.menu.x,y,selected)
else
drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
end
end
local backlock = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(1,201) and IsPlayerInRangeOfVehshop() then
if vehshop.opened then
CloseCreator()
else
OpenCreator()
end
end
if vehshop.opened then
local ped = LocalPed()
local menu = vehshop.menu[vehshop.currentmenu]
drawTxt(vehshop.title,1,1,vehshop.menu.x,vehshop.menu.y,1.0, 255,255,255,255)
drawMenuTitle(menu.title, vehshop.menu.x,vehshop.menu.y + 0.08)
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)
local y = vehshop.menu.y + 0.12
buttoncount = 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
drawMenuButton(button,vehshop.menu.x,y,selected)
if button.costs ~= nil then
if vehshop.currentmenu == "Vehicle-Minor" or vehshop.currentmenu == "Vehicle-WineMakers" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "Vehicle-Farmer" or vehshop.currentmenu == "Vehicle-Tanker" or vehshop.currentmenu == "Vehicle-Taxi" 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
DoesPlayerHaveVehicle(button.model,button,y,selected)
else
drawMenuRight(button.costs.."$",vehshop.menu.x,y,selected)
end
end
y = y + 0.04
if vehshop.currentmenu == "Vehicle-Minor" or vehshop.currentmenu == "Vehicle-WineMakers" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "Vehicle-Farmer" or vehshop.currentmenu == "Vehicle-Tanker" or vehshop.currentmenu == "Vehicle-Taxi" 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
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)
while not HasModelLoaded(hash) do
Citizen.Wait(0)
drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
end
local veh = CreateVehicle(hash,pos[1],pos[2],pos[3],pos[4],false,false)
while not DoesEntityExist(veh) do
Citizen.Wait(0)
drawTxt("~b~Loading...",0,1,0.5,0.5,1.5,255,255,255,255)
end
FreezeEntityPosition(veh,true)
SetEntityInvincible(veh,true)
SetVehicleDoorsLocked(veh,4)
--SetEntityCollision(veh,false,false)
TaskWarpPedIntoVehicle(LocalPed(),veh,-1)
for i = 0,24 do
SetVehicleModKit(veh,0)
RemoveVehicleMod(veh,i)
end
fakecar = { model = button.model, car = veh}
end
end
end
if selected and IsControlJustPressed(1,201) then
ButtonSelected(button)
end
end
end
end
if vehshop.opened then
if IsControlJustPressed(1,202) then
Back()
end
if IsControlJustReleased(1,202) then
backlock = false
end
if IsControlJustPressed(1,188) then
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
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 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 ButtonSelected(button)
local ped = GetPlayerPed(-1)
local this = vehshop.currentmenu
local btn = button.name
if this == "main" then
if btn == "Vehicles" then
OpenMenu('vehicles')
elseif btn == "Motorcycles" then
OpenMenu('motorcycles')
end
elseif this == "vehicles" then
if btn == "Vehicle-Farmer" then
OpenMenu('Vehicle-Farmer')
elseif btn == "Sedans" then
OpenMenu('sedans')
elseif btn == "Vehicle-Minor" then
OpenMenu('Vehicle-Minor')
elseif btn == "Vehicle-WineMakers" then
OpenMenu('Vehicle-WineMakers')
elseif btn == "Vehicle-Tanker" then
OpenMenu("Vehicle-Tanker")
elseif btn == "Vehicle-Taxi" then
OpenMenu('Vehicle-Taxi')
elseif btn == "Muscle" then
OpenMenu('muscle')
elseif btn == "Off-Road" then
OpenMenu('offroad')
elseif btn == "SUVs" then
OpenMenu('suvs')
elseif btn == "Vans" then
OpenMenu('vans')
end
elseif this == "Vehicle-Minor" or this == "Vehicle-WineMakers" or this == "sedans" or this == "Vehicle-Farmer" or this == "Vehicle-Tanker" or this == "Vehicle-Taxi" or this == "muscle" or this == "offroad" or this == "suvs" or this == "vans" or this == "industrial" or this == "cycles" or this == "motorcycles" then
--if playermoney >= button.costs then
vehicle_price = 0--button.costs
boughtcar = true
CloseCreator()
--else
-- Notify('~r~Not enough money')
--end
end
end
function 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 Back()
if backlock then
return
end
backlock = true
if vehshop.currentmenu == "main" then
CloseCreator()
elseif vehshop.currentmenu == "Vehicle-Minor" or vehshop.currentmenu == "Vehicle-WineMakers" or vehshop.currentmenu == "sedans" or vehshop.currentmenu == "Vehicle-Farmer" or vehshop.currentmenu == "Vehicle-Tanker" or vehshop.currentmenu == "Vehicle-Taxi" 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
if DoesEntityExist(fakecar.car) then
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car))
end
fakecar = {model = '', car = nil}
OpenMenu(vehshop.lastmenu)
else
OpenMenu(vehshop.lastmenu)
end
end
function stringstarts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
local firstspawn = 0
AddEventHandler('playerSpawned', function(spawn)
if firstspawn == 0 then
RemoveIpl('v_carshowroom')
RemoveIpl('shutter_open')
RemoveIpl('shutter_closed')
RemoveIpl('shr_int')
RemoveIpl('csr_inMission')
RequestIpl('v_carshowroom')
RequestIpl('shr_int')
--RequestIpl('csr_inMission')
RequestIpl('shutter_closed')
--326 car blip 227 225
ShowVehshopBlips(true)
firstspawn = 1
end
end)
Hello just trying to make post 20 characters but what does this do?
its not working
started him not showing up… no marker to enter at all
does this works with eden garage 2?
Not working ?