forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
f64ba04bac
commit
db56161001
1 changed files with 235 additions and 1 deletions
|
@ -17,6 +17,38 @@ local function Debug(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Extrem starke Anti-Despawn Funktion
|
||||||
|
-- IMPORTANT: Move this function definition to the top, before it's called
|
||||||
|
local function PreventDespawn(vehicle)
|
||||||
|
if not DoesEntityExist(vehicle) then return false end
|
||||||
|
|
||||||
|
-- Grundlegende Persistenz
|
||||||
|
SetEntityAsMissionEntity(vehicle, true, true)
|
||||||
|
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
|
||||||
|
SetVehicleNeedsToBeHotwired(vehicle, false)
|
||||||
|
|
||||||
|
-- Zusätzliche Flags
|
||||||
|
SetEntityLoadCollisionFlag(vehicle, true)
|
||||||
|
SetVehicleIsStolen(vehicle, false)
|
||||||
|
SetVehicleIsWanted(vehicle, false)
|
||||||
|
|
||||||
|
-- Verhindere dass das Fahrzeug als "abandoned" markiert wird
|
||||||
|
if DecorIsRegisteredAsType("IgnoredByQuickSave", 2) then
|
||||||
|
DecorSetBool(vehicle, "IgnoredByQuickSave", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Setze Fahrzeug auf Boden
|
||||||
|
SetVehicleOnGroundProperly(vehicle)
|
||||||
|
|
||||||
|
-- Verhindere dass das Fahrzeug gelöscht wird
|
||||||
|
NetworkRegisterEntityAsNetworked(vehicle)
|
||||||
|
local netID = NetworkGetNetworkIdFromEntity(vehicle)
|
||||||
|
SetNetworkIdExistsOnAllMachines(netID, true)
|
||||||
|
SetNetworkIdCanMigrate(netID, true)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-- Function to check if player owns the vehicle
|
-- Function to check if player owns the vehicle
|
||||||
local function DoesPlayerOwnVehicle(plate)
|
local function DoesPlayerOwnVehicle(plate)
|
||||||
local playerData = QBCore.Functions.GetPlayerData()
|
local playerData = QBCore.Functions.GetPlayerData()
|
||||||
|
@ -70,7 +102,206 @@ local function IsVehicleClassAllowed(vehicle)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Rest of your functions remain the same...
|
-- Funktion um Fahrzeugmods zu erhalten
|
||||||
|
local function GetVehicleMods(vehicle)
|
||||||
|
local mods = {}
|
||||||
|
|
||||||
|
-- Basis Mods
|
||||||
|
for i = 0, 49 do
|
||||||
|
mods[tostring(i)] = GetVehicleMod(vehicle, i)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Extras
|
||||||
|
mods.extras = {}
|
||||||
|
for i = 1, 12 do
|
||||||
|
if DoesExtraExist(vehicle, i) then
|
||||||
|
mods.extras[tostring(i)] = IsVehicleExtraTurnedOn(vehicle, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Farben
|
||||||
|
local primaryColor, secondaryColor = GetVehicleColours(vehicle)
|
||||||
|
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
|
||||||
|
|
||||||
|
mods.colors = {
|
||||||
|
primary = primaryColor,
|
||||||
|
secondary = secondaryColor,
|
||||||
|
pearlescent = pearlescentColor,
|
||||||
|
wheels = wheelColor
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Custom Farben
|
||||||
|
local hasCustomPrimaryColor = GetIsVehiclePrimaryColourCustom(vehicle)
|
||||||
|
if hasCustomPrimaryColor then
|
||||||
|
local r, g, b = GetVehicleCustomPrimaryColour(vehicle)
|
||||||
|
mods.customPrimaryColor = {r = r, g = g, b = b}
|
||||||
|
end
|
||||||
|
|
||||||
|
local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle)
|
||||||
|
if hasCustomSecondaryColor then
|
||||||
|
local r, g, b = GetVehicleCustomSecondaryColour(vehicle)
|
||||||
|
mods.customSecondaryColor = {r = r, g = g, b = b}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Neon
|
||||||
|
mods.neon = {
|
||||||
|
left = IsVehicleNeonLightEnabled(vehicle, 0),
|
||||||
|
right = IsVehicleNeonLightEnabled(vehicle, 1),
|
||||||
|
front = IsVehicleNeonLightEnabled(vehicle, 2),
|
||||||
|
back = IsVehicleNeonLightEnabled(vehicle, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
local r, g, b = GetVehicleNeonLightsColour(vehicle)
|
||||||
|
mods.neonColor = {r = r, g = g, b = b}
|
||||||
|
|
||||||
|
-- Xenon
|
||||||
|
mods.xenonColor = GetVehicleXenonLightsColour(vehicle)
|
||||||
|
mods.xenonEnabled = IsToggleModOn(vehicle, 22)
|
||||||
|
|
||||||
|
-- Livery
|
||||||
|
mods.livery = GetVehicleLivery(vehicle)
|
||||||
|
|
||||||
|
-- Fenster Tint
|
||||||
|
mods.windowTint = GetVehicleWindowTint(vehicle)
|
||||||
|
|
||||||
|
-- Rad Typ
|
||||||
|
mods.wheelType = GetVehicleWheelType(vehicle)
|
||||||
|
|
||||||
|
-- Rauch Farbe
|
||||||
|
local r, g, b = GetVehicleTyreSmokeColor(vehicle)
|
||||||
|
mods.tyreSmokeColor = {r = r, g = g, b = b}
|
||||||
|
|
||||||
|
-- Dashboard & Interior Farbe
|
||||||
|
mods.dashboardColor = GetVehicleDashboardColour(vehicle)
|
||||||
|
mods.interiorColor = GetVehicleInteriorColour(vehicle)
|
||||||
|
|
||||||
|
-- Toggles
|
||||||
|
mods.bulletProofTires = not GetVehicleTyresCanBurst(vehicle)
|
||||||
|
mods.turbo = IsToggleModOn(vehicle, 18)
|
||||||
|
mods.xeonHeadlights = IsToggleModOn(vehicle, 22)
|
||||||
|
|
||||||
|
return mods
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Funktion um Fahrzeugmods zu setzen
|
||||||
|
local function SetVehicleMods(vehicle, mods)
|
||||||
|
if not mods then return end
|
||||||
|
|
||||||
|
-- Setze Modkit
|
||||||
|
SetVehicleModKit(vehicle, 0)
|
||||||
|
|
||||||
|
-- Rad Typ zuerst setzen
|
||||||
|
if mods.wheelType then
|
||||||
|
SetVehicleWheelType(vehicle, mods.wheelType)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Basis Mods
|
||||||
|
for i = 0, 49 do
|
||||||
|
if mods[tostring(i)] ~= nil then
|
||||||
|
SetVehicleMod(vehicle, i, mods[tostring(i)], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Extras
|
||||||
|
if mods.extras then
|
||||||
|
for i = 1, 12 do
|
||||||
|
if mods.extras[tostring(i)] ~= nil then
|
||||||
|
SetVehicleExtra(vehicle, i, not mods.extras[tostring(i)])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Farben
|
||||||
|
if mods.colors then
|
||||||
|
SetVehicleColours(vehicle, mods.colors.primary or 0, mods.colors.secondary or 0)
|
||||||
|
SetVehicleExtraColours(vehicle, mods.colors.pearlescent or 0, mods.colors.wheels or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Custom Farben
|
||||||
|
if mods.customPrimaryColor then
|
||||||
|
SetVehicleCustomPrimaryColour(vehicle, mods.customPrimaryColor.r, mods.customPrimaryColor.g, mods.customPrimaryColor.b)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mods.customSecondaryColor then
|
||||||
|
SetVehicleCustomSecondaryColour(vehicle, mods.customSecondaryColor.r, mods.customSecondaryColor.g, mods.customSecondaryColor.b)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Neon
|
||||||
|
if mods.neon then
|
||||||
|
SetVehicleNeonLightEnabled(vehicle, 0, mods.neon.left or false)
|
||||||
|
SetVehicleNeonLightEnabled(vehicle, 1, mods.neon.right or false)
|
||||||
|
SetVehicleNeonLightEnabled(vehicle, 2, mods.neon.front or false)
|
||||||
|
SetVehicleNeonLightEnabled(vehicle, 3, mods.neon.back or false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mods.neonColor then
|
||||||
|
SetVehicleNeonLightsColour(vehicle, mods.neonColor.r, mods.neonColor.g, mods.neonColor.b)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Xenon
|
||||||
|
if mods.xenonEnabled then
|
||||||
|
ToggleVehicleMod(vehicle, 22, true)
|
||||||
|
if mods.xenonColor then
|
||||||
|
SetVehicleXenonLightsColour(vehicle, mods.xenonColor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Livery
|
||||||
|
if mods.livery then
|
||||||
|
SetVehicleLivery(vehicle, mods.livery)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fenster Tint
|
||||||
|
if mods.windowTint then
|
||||||
|
SetVehicleWindowTint(vehicle, mods.windowTint)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Rauch Farbe
|
||||||
|
if mods.tyreSmokeColor then
|
||||||
|
ToggleVehicleMod(vehicle, 20, true) -- Aktiviere Rauch
|
||||||
|
SetVehicleTyreSmokeColor(vehicle, mods.tyreSmokeColor.r, mods.tyreSmokeColor.g, mods.tyreSmokeColor.b)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Dashboard & Interior Farbe
|
||||||
|
if mods.dashboardColor then
|
||||||
|
SetVehicleDashboardColour(vehicle, mods.dashboardColor)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mods.interiorColor then
|
||||||
|
SetVehicleInteriorColour(vehicle, mods.interiorColor)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Toggles
|
||||||
|
if mods.bulletProofTires ~= nil then
|
||||||
|
SetVehicleTyresCanBurst(vehicle, not mods.bulletProofTires)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mods.turbo ~= nil then
|
||||||
|
ToggleVehicleMod(vehicle, 18, mods.turbo)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Setze Felgen nochmal explizit
|
||||||
|
if mods["23"] ~= nil then -- Vorderräder
|
||||||
|
SetVehicleMod(vehicle, 23, mods["23"], false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if mods["24"] ~= nil then -- Hinterräder
|
||||||
|
SetVehicleMod(vehicle, 24, mods["24"], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Hilfsfunktion um Fahrzeug anhand Kennzeichen zu finden
|
||||||
|
function GetVehicleByPlate(plate)
|
||||||
|
local vehicles = GetGamePool('CVehicle')
|
||||||
|
for _, vehicle in pairs(vehicles) do
|
||||||
|
if QBCore.Functions.GetPlate(vehicle) == plate then
|
||||||
|
return vehicle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- AFTER ALL FUNCTIONS ARE DEFINED, THEN ADD EVENT HANDLERS AND THREADS
|
||||||
|
|
||||||
-- Event Handler für Fahrzeug betreten (nur Fahrersitz)
|
-- Event Handler für Fahrzeug betreten (nur Fahrersitz)
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
|
@ -128,6 +359,9 @@ CreateThread(function()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Rest of your code (threads, event handlers, etc.)
|
||||||
|
|
||||||
|
|
||||||
-- Kontinuierliche Despawn-Verhinderung für alle getrackten Fahrzeuge
|
-- Kontinuierliche Despawn-Verhinderung für alle getrackten Fahrzeuge
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue