fixing and adding things
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
local Config = Config
|
||||
|
||||
local currentPattern = nil
|
||||
local parkMode = false
|
||||
local lastFrontPattern = nil -- track last front pattern (Wail/Yelp/Stage2)
|
||||
|
||||
-- Utility: enable/disable extras
|
||||
local function setExtras(veh, extraList, state)
|
||||
for _, extra in pairs(extraList) do
|
||||
if DoesExtraExist(veh, extra) then
|
||||
SetVehicleExtra(veh, extra, not state)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Turn off all configured extras
|
||||
local function clearAllPatterns(veh)
|
||||
for _, list in pairs(Config.Extras) do
|
||||
setExtras(veh, list, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- Apply a single pattern
|
||||
local function activatePattern(veh, name)
|
||||
clearAllPatterns(veh)
|
||||
setExtras(veh, Config.Extras[name], true)
|
||||
currentPattern = name
|
||||
|
||||
-- Only Wail/Yelp/Stage2 affect front tracking
|
||||
if name == "Wail" or name == "Yelp" or name == "Stage2" then
|
||||
lastFrontPattern = name
|
||||
end
|
||||
end
|
||||
|
||||
-- Toggle Park Mode (front only)
|
||||
local function enablePark(veh)
|
||||
if parkMode then return end
|
||||
-- Only enable park if last front pattern was Wail or Yelp
|
||||
if lastFrontPattern == "Wail" or lastFrontPattern == "Yelp" then
|
||||
parkMode = true
|
||||
clearAllPatterns(veh)
|
||||
setExtras(veh, Config.Extras.Park, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function disablePark()
|
||||
parkMode = false
|
||||
end
|
||||
|
||||
-- Check if vehicle is allowed
|
||||
local function isAllowedVehicle(veh)
|
||||
local model = GetEntityModel(veh)
|
||||
for _, allowed in ipairs(Config.AllowedVehicles) do
|
||||
if model == GetHashKey(allowed) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- MAIN THREAD
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0) -- instant input
|
||||
|
||||
local ped = PlayerPedId()
|
||||
local veh = GetVehiclePedIsIn(ped, false)
|
||||
|
||||
if veh ~= 0 and isAllowedVehicle(veh) then
|
||||
|
||||
-- Prevent extras from repairing damage
|
||||
SetVehicleAutoRepairDisabled(veh, true)
|
||||
|
||||
-- If vehicle is in park mode and starts moving, revert to Wail
|
||||
if parkMode and GetEntitySpeed(veh) > 0.5 then -- >0.5 m/s threshold
|
||||
disablePark()
|
||||
activatePattern(veh, "Wail")
|
||||
end
|
||||
|
||||
-- Button 1 → Wail
|
||||
if IsControlJustPressed(0, Config.Keys.Wail) then
|
||||
disablePark()
|
||||
activatePattern(veh, "Wail")
|
||||
end
|
||||
|
||||
-- Button 2 → Yelp
|
||||
if IsControlJustPressed(0, Config.Keys.Yelp) then
|
||||
disablePark()
|
||||
activatePattern(veh, "Yelp")
|
||||
end
|
||||
|
||||
-- Button 4 → Stage2
|
||||
if IsControlJustPressed(0, Config.Keys.Stage2) then
|
||||
disablePark()
|
||||
activatePattern(veh, "Stage2")
|
||||
end
|
||||
|
||||
-- Left Arrow → Left TA
|
||||
if IsControlJustPressed(0, Config.Keys.TA_Left) then
|
||||
if parkMode then
|
||||
-- Rear-only change in park
|
||||
clearAllPatterns(veh)
|
||||
setExtras(veh, Config.Extras.TA_Left, true)
|
||||
else
|
||||
activatePattern(veh, "TA_Left")
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
-- OUTSIDE VEHICLE → enable park mode if last front pattern was Wail/Yelp
|
||||
if not parkMode then
|
||||
local lastVeh = GetPlayersLastVehicle()
|
||||
if lastVeh ~= 0 and isAllowedVehicle(lastVeh) then
|
||||
enablePark(lastVeh)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user