Native REDM RequestModel
--  RequestModel  0xFA28FE3A6246FC30  REQUEST_MODEL
RequestModel(
	model --[[ Hash ]], 
	p1 --[[ boolean ]]
)

Request a model to be loaded into memory.
 
 

Citizen.Invoke value:

0xFA28FE3A6246FC30

Parameters:

model:

Model is the hash code of the in game model you want to load. (GetHashKey)

p1:

Not sure. I don’t use it.

Returns:

Nothing.

Summary

Preloads the model for creating peds. This is a preloader.

Example

---  
--- Valentine auctions
ExtraSpawns = {  
[1] = {model="A_C_Cow"}
}
 -- Example 1: Unsafe --
model_hash = GetHashKey(ExtraSpawns.model) 
RequestModel(model_hash )

 -- Example 2: Safe --
model_hash = GetHashKey(ExtraSpawns.model) 
LoadModel(model_hash)
function LoadModel(model) 
    RequestModel(model)
    local emergency_break = 0
    while HasModelLoaded(model) == false or 0 do 
        Citizen.Wait(100)
        emergency_break = emergency_break +1
        if emergency_break > 20 then 
            break   -- no runaway loops here.
        end 
    end
end
    


Additional natives used in this example, or natives commonly used with this native.

Common Errors or Problems

Problem: My model doesn’t load and my ped is invisible. If the model doesn’t load the ped will be invisible. CreatePed will still create it, so in invisible creature will be running around. Solution preload the model using Example 2. Which tests and waits for the model to load before moving on to create the ped.

Problem: I run the code to wait for the model, and it checks to see if the model has loaded, and it just hangs in the loop. See Example 2 for how to include breakout test so your script doesn’t get stuck in a look waiting for the model to load.

Problem: My model loaded, my ped was created, but the ped is still invisible. See information about setting the ped to visible, and setting the peds outfit.

Credits and Disclaimers

The base of this data was taken from the redm/cfx fivem/rdr docs, or from the redm natives database hosted on vespura while it was active. We will be modifying the notes as needed, and building tutorials around the data so these pages will change as we work on it. This is a manual process, not an automated one, so updates will occur as we have time, the priority is releasing resources. Thanks for your patience.

Was the documentation useful?

0
RequestModel - Native

Do you understand the native?

You will be redirected

Related Examples and Posts

No posts found.

By MK

Dragon Codes