AddDoorToSystem
DocsAddDoorToSystem(doorHash, modelHash, x, y, z, p5, scriptDoor, isLocal)Description
p5 only set to true in single player native scripts. Door hashes normally look like PROP_[int]_DOOR_[int] for interior doors and PROP_BUILDING_[int]_DOOR_[int] exterior doors but you can just make up your own hash if you want.
If scriptDoor is true, register the door on the script handler host (note: there's a hardcap on the number of script IDs that can be added to the system at a given time). If scriptDoor and isLocal are both false, the door is considered to be in a "Persists w/o netobj" state.
A simple "localized" door-system (with hundreds/thousands of doors) can be created by setting p5, p6, and p7 to false and using EventHandlers to synchronize the states to: DOOR_SYSTEM_SET_DOOR_STATE, DOOR_SYSTEM_SET_OPEN_RATIO, DOOR_SYSTEM_SET_HOLD_OPEN, etc.
Parameters
| Name | Type | Description |
|---|---|---|
doorHash | Hash | A (unique) door system identifier |
modelHash | Hash | Entity model hash |
x | float | The X coordinate of the door object |
y | float | The Y coordinate of the door object |
z | float | The Z coordinate of the door object |
p5 | BOOL | — |
scriptDoor | BOOL | false; relies upon getNetworkGameScriptHandler. |
isLocal | BOOL | On true disables the creation `CRequestDoorEvent's` in [DOOR_SYSTEM_SET_DOOR_STATE](#\_0x6BAB9442830C7F53). |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Load Model HashmodelHash
modelHashModels must be loaded before use. This snippet handles requesting and releasing properly.
-- Properly load a model before spawning/using it
local modelName = "prop_barrel_01a" -- change to your model
local modelHash = GetHashKey(modelName)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Wait(0)
end
print("Model loaded: " .. modelName .. " (" .. modelHash .. ")")
-- Release when done:
-- SetModelAsNoLongerNeeded(modelHash)Returns
voidThis native does not return a value.