requestModel
Load a GTA5 model (prop, ped, vehicle) and wait until it's ready. Accepts a hash or a name.
Load a GTA5 model (prop, ped, vehicle) and wait until it's ready. Accepts a hash or a name.
lib.requestModel(model, timeout?) loads a GTA5 model and blocks until it's ready. It accepts a
hash or a name, validates the model exists, and returns the loaded hash — no RequestModel +
while not HasModelLoaded loop.
local model = lib.requestModel(`prop_chair_01`)
local prop = CreateObject(model, coords.x, coords.y, coords.z, true, false, false)
SetModelAsNoLongerNeeded(model)modelnumber | stringrequiredModel hash or name. A string is hashed via joaat.
timeoutnumberoptionalMax wait in ms. Default 30000.
Returns the loaded model hash (number). Throws immediately if the model is invalid / unknown to
the CD image, or after the timeout if it never loads.
local pedModel = lib.requestModel('a_m_y_business_01', 5000)
local ped = CreatePed(4, pedModel, coords.x, coords.y, coords.z, 0.0, true, false)
SetModelAsNoLongerNeeded(pedModel)Always release the model with SetModelAsNoLongerNeeded(model) once the entity is spawned — otherwise
streaming keeps it in memory for the whole session. A backtick hash (`prop_chair_01`) is cleaner
than a string (it skips the runtime joaat). An invalid model throws right away with no timeout, so
wrap it in pcall when the model comes from user input. Call it inside a CreateThread — it yields.