RedM CreatePed Lua wrapper takes (hash, x, y, z, heading, networked, scriptHost, p7, p8) — NOT the GTAV (pedType, modelHash, ...) shape
Context
Spawning a networked ped in RedM Lua via CreatePed. The native docs for CREATE_PED (0xD49F9B0955C367DE) list the parameter shape as (pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed) — 8 args, pedType first.
The trap
Calling CreatePed(4, modelHash, x, y, z, heading, true, false) in RedM Lua (RDR3 client) returns 0 silently, even when:
- The model is loaded (
HasModelLoaded(model) == true) - The caller's player is within streaming range (verified 20m)
- The native is invoked from a host with
bScriptHostPed=true
No error, no log, just 0. With the correct shape it works on the first call.
The fix
In RedM Lua the runtime exposes CreatePed with the wrapper signature:
CreatePed(modelHash, x, y, z, heading, networked, scriptHostPed, p7, p8)
That is: modelHash first (no pedType slot), then position/heading, then networked, then scriptHostPed, plus two trailing args (purpose unconfirmed but false, false works in production).
Verified working call:
local guard = CreatePed(`mp_g_m_m_unicornwallgoons_01`,
x, y, z, heading,
true, -- networked
true, -- scriptHostPed
false, false)
-- guard is a valid networked Ped entity id
Same signature is used by nh-wagons/client/client.lua:150 and vorp_utils' PedAPI — both confirmed working in the wild.
Why
The pedType parameter is documented as "Unused. Peds get set to CIVMALE/CIVFEMALE/etc. no matter the value specified" — so the runtime wrapper omits it entirely rather than carry a dead arg. FiveM tutorials and the native ref both keep the GTAV-era 8-arg shape; copy-pasting from there into RedM silently produces zero peds.
Verified
Verified 2026-05-27 on FXServer 1.0.0.25770 with RedM client, model mp_g_m_m_unicornwallgoons_01 (hash 0xB6A13AB3). With the GTAV-shape call, three consecutive CreatePed calls all returned 0; switching to the wrapper-shape made the same three calls return valid entity ids (2479618, 2479874, 2480130) that pooled via GetGamePool('CPed') and rendered correctly to nearby players.
Linked natives
CREATE_PED(0xD49F9B0955C367DE)
Tags: createped, lua, wrapper, redm, gotcha, spawn
Category: uncategorized
Source: scandi_dynamic_events wagonrobbery bring-up
Created: 2026-05-27T20:14:16.192Z