What happened?
i copy this code to add doors in a better way [GUIDE] Lock doors like a boss. How to use GTA's built-in door locking system, i just copy an paste the code in my own resource, and the only thing that i added was the DoorSystemSetOpenRatio " DoorSystemSetOpenRatio(doorId, -1.0, true, true)" and the door just keep opening and closing,
Expected result
door should keep open
Reproduction steps
create a Door with AddDoorToSystem
DoorSystemSetDoorState to unlocked
DoorSystemSetOpenRatio to -1.0.
PD: Added a video Desktop 12-1-2024 1-23-55
Importancy
Slight inconvenience
Area(s)
FiveM, OneSync, Natives
Specific version(s)
Fivem b2944 Canary
Additional information
--Client
RegisterNetEvent('ch_doorSystem:set')
AddEventHandler('ch_doorSystem:set', function(doorId, isLocked)
DoorSystemSetDoorState(doorId, isLocked and 1 or 0)
end)
RegisterNetEvent('ch_doorSystem:initialize', function(allDoors)
for doorId, door in pairs(allDoors) do
AddDoorToSystem(doorId, door.Model, door.Coordinates, false, true, true)
while not DoorSystemGetIsPhysicsLoaded(doorId) do
Wait(0)
end
DoorSystemSetDoorState(doorId, door.Locked and 1 or 0, true, true)
if not door.Locked then
DoorSystemSetOpenRatio(doorId, -1.0, true, true)
end
end
end)
-- Server
local Config = {}
Config.Doorss = {
[1] = {
Model = 961976194,
Coordinates = vector3(255.22825622559, 223.97601318359, 102.39321899414),
Locked = false,
},
}
local doorState = Config.Doorss
--
-- Commands
--
RegisterCommand('toggleDoor', function(source, args, rawCommand)
local doorId = tonumber(args[1])
if not doorId or not doorState[doorId] then
print("no Door")
return
end
doorState[doorId].Locked = not doorState[doorId].Locked
print(doorId, doorState[doorId].Locked)
TriggerClientEvent('ch_doorSystem:set', -1, doorId, doorState[doorId].Locked)
end)
--
-- Events
--
CreateThread(function()
Wait(500)
TriggerClientEvent('ch_doorSystem:initialize', -1, doorState)
end)