Besides reworking how it checks if the garage is locked or not, you could instead just set the garages to unlocked when someone leaves. The chances that someone is in one when someone leaves are pretty small.
Script is awesome, only issue is somehow it get locked bugged alot, only way to fix is with restart, any fixes?
Yo nice work for this script, it works , but is it possible to add a sql options to save modification, it will be awesome than es_carshop custom thing .
Thanks a LOT for your script! I was trying to find out how to use vehicles mods functions.
Very nice job
how do i make it so that they pay for upgrades i dont want people getting free upgrades, whenever i change the prices from saying 0 to my own price and i go to ls customs when i open the customs menu it dissapears and my car stays stuck in there and i can walk thru it. please me me
Did you ever figure out how to make people pay?
Any idea how to hide a menu completely if no tuning parts are available? For example if no spoilers are available, then hide the spoilers menu.
Do you mean when you go into lscustoms?
Iāve gone through mine and changed all the prices from free but i need to figure out how to take the $$$ from peoples accounts. Also if anyone knows where i can get a list of parts so i can add the missing upgrades to it that would be appreciated.
Hi, nice work for your job guy.
I have a little issue, iāve install this ressource, everything was working well, i had to re-install fiveM and now LSC are not on the map?
Iāve search and i dont know why it doesnt.
Do you have an idea?
Hey good job man with this script BUT itās possible i want pay this Los Custom i donāt want this free x) and SAVE this vĆ©hiculeā¦
For those wondering, yes there is a way to save customization. You need to loop through all the mods (1 - 24), tyresmoke ect and save their value into a new SQL datatable. (Set all to default of -1, for tyresmoke set to 255,255,255)
Once you get those saved into the database you need to call them back whenever you spawn a personal vehicle (remember to do SetVehicleModKit(veh, 0) whenever adding mods)
I added in the ability to save mods into my server, but it took me 12+ hours because of all the things i had to change. It is possible, just takes time.
I am going to try and share my way of saving the mods to the database.
Do not think this is going to work for you as I might have missed something but this should help get people on the right track.
Good Luck.
EDIT:
For those who are lazy, like me, here is a rar with all the files. Save Mods.rar (51.1 KB) be sure to import the sql, and everything WILL BE IN ENGLISH
CODE FLOW:
-
buying car from modified shop (remember to replace the vehshop_s.lua file with the one from garages) inserts purchased car into user_vehmod table.
-
Adding new trye smoke color tells server to update column
-
changing mods at lscustoms changes mod data, when removed from shop tells server to update user_vehmods table with mod changes. (1-24)
-
Spawning your vehicle in from garage tells server to get all mods from user_vehmods
-
Client attaches mods to car on spawn.
DEPENDENCIES:
dump.sql (2.8 KB) (Creates vehmod table for storing mod data)
Garage V3.0 - [Click]
es_freeroam (Before CouchDB move) - es_freeroam-master.zip (36.6 KB)
BEFORE YOU START
Install es_freeroam FIRST.
Make sure to follow Garages instructions and replace all files it asks, and make sure to create the sql tables it needs.
Double check all spacing after pasting!
in LSCustoms.lue - line 1478 - Replace (Tells garage/sever.lua to save to database)
function DriveOutOfGarage(pos)
SetStreamedTextureDictAsNoLongerNeeded("mpmissmarkers256")
lsc.inside = false
local ped = LocalPed()
local veh = GetVehiclePedIsUsing(ped)
local plate = GetVehicleNumberPlateText(veh)
local colors = table.pack(GetVehicleColours(veh))
local extra_colors = table.pack(GetVehicleExtraColours(veh))
TriggerServerEvent('UpdateVeh', plate, colors[1], colors[2], extra_colors[1], extra_colors[2], mods)
SetEntityCoords(veh,pos.x,pos.y,pos.z)
SetEntityHeading(veh,pos.heading)
lsc.menu["frontbumper"].buttons = {}
lsc.menu["rearbumper"].buttons = {}
lsc.menu["exhaust"].buttons = {}
lsc.menu["fenders"].buttons = {}
lsc.menu["hood"].buttons = {}
lsc.menu["rollcage"].buttons = {}
lsc.menu["roof"].buttons = {}
lsc.menu["skirts"].buttons = {}
lsc.menu["spoiler"].buttons = {}
lsc.menu["grille"].buttons = {}
lsc.menu["main"].buttons = {}
lsc.menu["bumpers"].buttons = {}
lsc.menu["chassis"].buttons = {}
table.sort(lsc)
table.sort(lsc.menu)
lsc.menu.from = 1
lsc.menu.to = 10
lsc.selectedbutton = 0
SetVehicleOnGroundProperly(veh)
SetVehicleHasBeenOwnedByPlayer(veh,true)
local id = NetworkGetNetworkIdFromEntity(veh)
SetNetworkIdCanMigrate(id, true)
Citizen.InvokeNative(0x629BFA74418D6239,Citizen.PointerValueIntInitialized(veh))
SetPlayerInvincible(GetPlayerIndex(),false)
SetEntityInvincible(veh,false)
SetEntityCollision(veh,true,true)
FreezeEntityPosition(veh, false)
SetVehicleDoorsLocked(veh,0)
TriggerServerEvent('lockGarage',false,lsc.currentgarage)
lsc.currentgarage = 0
end
in LSCustoms.lue - line 2134 - Replace - (tells garage/server.lua to save tyre smoke)
elseif string.find(button.name:lower(),'smoke') then
SetVehicleModKit(car,0)
ToggleVehicleMod(car,20,true)
SetVehicleTyreSmokeColor(car,button.color[1],button.color[2],button.color[3])
local plate = GetVehicleNumberPlateText(car)
TriggerServerEvent('VehUpdateTyreSmoke', plate, button.color[1], button.color[2], button.color[3])
IN FILE - Garages/Server.Lua - Add (Tells server to listen for these events)
RegisterServerEvent('VehUpdateTyreSmoke')
- Replace UpdateVeh with (adds saving mods to the DB with the built in function)
AddEventHandler('UpdateVeh', function(plate, primarycolor, secondarycolor, pearlescentcolor, wheelcolor, mods)
TriggerEvent('es:getPlayerFromId', source, function(user)
local mods = mods
local player = user.identifier
local name = name
local price = price
local vehicle = vehicle
local plate = plate
local state = "Removed"
local primarycolor = primarycolor
local secondarycolor = secondarycolor
local pearlescentcolor = pearlescentcolor
local wheelcolor = wheelcolor
local executed_query = MySQL:executeQuery("Update user_vehicle Set vehicle_colorprimary='@primarycolor', vehicle_colorsecondary='@secondarycolor', vehicle_pearlescentcolor='@pearlescentcolor', vehicle_wheelcolor='@wheelcolor' where vehicle_plate='@plate'",
{['@username'] = player, ['@name'] = name, ['@vehicle'] = vehicle, ['@price'] = price, ['@plate'] = plate, ['@state'] = state, ['@primarycolor'] = primarycolor, ['@secondarycolor'] = secondarycolor, ['@pearlescentcolor'] = pearlescentcolor, ['@wheelcolor'] = wheelcolor})
for i,t in pairs(mods) do
print('Attempting to update mods')
if t.mod ~= nil then
print("Mod#: "..i.." Value: " .. t.mod)
local executed_query = MySQL:executeQuery("update user_vehmods set mod"..i.."='"..t.mod.."' where plate='"..plate.."'" )
end
end
end)
end)
- Add (Tells sever to update tyre column in mods table)
AddEventHandler('VehUpdateTyreSmoke', function(plate, colorR, colorG, colorB)
local cr = colorR
local cg = colorG
local cb = colorB
local plate = plate
local executed_query = MySQL:executeQuery("update user_vehmods set tyresmoke='"..cr..","..cg..","..cb.."' where plate='"..plate.."'" )
end)
- Replace CheckForSpawnVeh (Passes mods to client)
AddEventHandler('garages:CheckForSpawnVeh', function(veh_id)
TriggerEvent('es:getPlayerFromId', source, function(user)
local veh_id = veh_id
local player = user.identifier
local executed_query = MySQL:executeQuery("SELECT * FROM user_vehicle WHERE identifier = '@username' AND ID = '@ID'",{['@username'] = player, ['@ID'] = veh_id})
local result = MySQL:getResults(executed_query, {'vehicle_model', 'vehicle_plate', 'vehicle_state', 'vehicle_colorprimary', 'vehicle_colorsecondary', 'vehicle_pearlescentcolor', 'vehicle_wheelcolor' }, "identifier")
if(result)then
for k,v in ipairs(result)do
vehicle = v.vehicle_model
plate = v.vehicle_plate
state = v.vehicle_state
primarycolor = v.vehicle_colorprimary
secondarycolor = v.vehicle_colorsecondary
pearlescentcolor = v.vehicle_pearlescentcolor
wheelcolor = v.vehicle_wheelcolor
local vehicle = vehicle
local plate = plate
local state = state
local primarycolor = primarycolor
local secondarycolor = secondarycolor
local pearlescentcolor = pearlescentcolor
local wheelcolor = wheelcolor
end
end
local executed_query = MySQL:executeQuery("SELECT * FROM user_vehmods WHERE plate = '"..plate.."'")
local result = MySQL:getResults(executed_query, {'plate', 'tyresmoke','mod0', 'mod1','mod2','mod3','mod4','mod5','mod6','mod7','mod8','mod9','mod10','mod11','mod12','mod13','mod14','mod15','mod16','mod17','mod18','mod19','mod20','mod21','mod22','mod23','mod24' }, "ID")
local tyrecolor = nil
print("FINDING SMOKE RESULT")
print (result)
local mods = {}
if(result)then
print("HAVE RESULT")
for k,v in ipairs(result)do
print("RESULT#: "..k.." VALUE: "..v)
tyre = v.tyresmoke
table.insert(mods, v.mod0)
table.insert(mods, v.mod1)
table.insert(mods, v.mod2)
table.insert(mods, v.mod3)
table.insert(mods, v.mod4)
table.insert(mods, v.mod5)
table.insert(mods, v.mod6)
table.insert(mods, v.mod7)
table.insert(mods, v.mod8)
table.insert(mods, v.mod9)
table.insert(mods, v.mod10)
table.insert(mods, v.mod11)
table.insert(mods, v.mod12)
table.insert(mods, v.mod13)
table.insert(mods, v.mod14)
table.insert(mods, v.mod15)
table.insert(mods, v.mod16)
table.insert(mods, v.mod17)
table.insert(mods, v.mod18)
table.insert(mods, v.mod19)
table.insert(mods, v.mod20)
table.insert(mods, v.mod21)
table.insert(mods, v.mod22)
table.insert(mods, v.mod23)
table.insert(mods, v.mod24)
tyrecolor = tyre
end
end
TriggerClientEvent('garages:SpawnVehicle', source, vehicle, plate, state, primarycolor, secondarycolor, pearlescentcolor, wheelcolor, tyrecolor, mods)
end)
end)
- IN FILE - Garages/Client.Lua - Replace SpawnVehicle (Gets mods from server, and adds)
AddEventHandler('garages:SpawnVehicle', function(vehicle, plate, state, primarycolor, secondarycolor, pearlescentcolor, wheelcolor, tyrecolor, mods)
local tyrecolors = tyrecolor
local tyre = {}
local localmods = mods
for word in string.gmatch(tyrecolors, '([^,]+)') do
table.insert(tyre, word)
end
local car = GetHashKey(vehicle)
local plate = plate
local state = state
local primarycolor = tonumber(primarycolor)
local secondarycolor = tonumber(secondarycolor)
local pearlescentcolor = tonumber(pearlescentcolor)
local wheelcolor = tonumber(wheelcolor)
Citizen.CreateThread(function()
Citizen.Wait(3000)
local caisseo = GetClosestVehicle(215.124, -791.377, 30.836, 3.000, 0, 70)
if DoesEntityExist(caisseo) then
drawNotification("Something is blocking the area.")
else
if state == "Removed" then
drawNotification("This vehicle is not in the garage.")
else
RequestModel(car)
while not HasModelLoaded(car) do
Citizen.Wait(0)
end
veh = CreateVehicle(car, 215.124, -791.377, 30.836, 0.0, true, false)
for k, v in pairs(localmods) do
local t = k - 1
SetVehicleModKit(veh,0)
SetVehicleMod(veh, tonumber(t), tonumber(v))
end
ToggleVehicleMod(veh,20,true)
SetVehicleTyreSmokeColor(veh,tonumber(tyre[1]), tonumber(tyre[2]), tonumber(tyre[3]))
SetVehicleNumberPlateText(veh, plate)
SetVehicleOnGroundProperly(veh)
SetVehicleHasBeenOwnedByPlayer(veh,true)
print(GetVehicleOwner(veh))
local id = NetworkGetNetworkIdFromEntity(veh)
SetNetworkIdCanMigrate(id, true)
SetVehicleColours(veh, primarycolor, secondarycolor)
SetVehicleExtraColours(veh, pearlescentcolor, wheelcolor)
SetEntityInvincible(veh, false)
drawNotification("Vehicle Retrieved.")
TriggerServerEvent('garages:SetVehOut', vehicle, plate)
TriggerServerEvent("garages:CheckGarageForVeh")
end
end
end)
end)
IN FILE es_freeroam (Garages Dependence)/vehshop_s.lua - Replace BuyForVeh (Tells the server to add your car to the mod database)
AddEventHandler('BuyForVeh', function(name, vehicle, price, plate, primarycolor, secondarycolor, pearlescentcolor, wheelcolor)
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.identifier
local name = name
local price = price
local vehicle = vehicle
local plate = plate
local state = "Removed"
local primarycolor = primarycolor
local secondarycolor = secondarycolor
local pearlescentcolor = pearlescentcolor
local wheelcolor = wheelcolor
local executed_query = MySQL:executeQuery("INSERT INTO user_vehicle (`identifier`, `vehicle_name`, `vehicle_model`, `vehicle_price`, `vehicle_plate`, `vehicle_state`, `vehicle_colorprimary`, `vehicle_colorsecondary`, `vehicle_pearlescentcolor`, `vehicle_wheelcolor`) VALUES ('@username', '@name', '@vehicle', '@price', '@plate', '@state', '@primarycolor', '@secondarycolor', '@pearlescentcolor', '@wheelcolor')",
{['@username'] = player, ['@name'] = name, ['@vehicle'] = vehicle, ['@price'] = price, ['@plate'] = plate, ['@state'] = state, ['@primarycolor'] = primarycolor, ['@secondarycolor'] = secondarycolor, ['@pearlescentcolor'] = pearlescentcolor, ['@wheelcolor'] = wheelcolor})
local executed_query = MySQL:executeQuery("INSERT INTO user_vehmods set plate='"..plate.."'" )
end)
end)
That is freaking amazing dude, thanks for sharing that.
- Is it on purpose though, that it doesnāt save headlights and neon-lights? Because I saw in the code, that there was no entries for that.
Either way, it works, and have been testing around with alot of cars, all comes out as saved
yea i didnāt get around to adding it yet, i just did it a couple days ago
Alright no worries man, you did a great job no matter what - People canāt expect to get everything everytime, just wanted to ask and see ^^
I did everything like you but once the car in the garage, I can not get it out
Working perfect thanks for share <3
Try using the rar at the top of the comment and see if that works for you
can u store more then 1 car whit this ? just wondering