Ped spawnPed(Hash pedModel, float coordX, float coordY, float coordZ)
{
STREAMING::REQUEST_MODEL(pedModel, true);
while (!STREAMING::HAS_MODEL_LOADED(pedModel)) WAIT(0);
Ped pedSpawn = PED::CREATE_PED(pedModel, coordX, coordY, coordZ, 0, 1, 1, 1, 1);
PED::_SET_RANDOM_OUTFIT_VARIATION(pedSpawn, 1);
ENTITY::PLACE_ENTITY_ON_GROUND_PROPERLY(pedSpawn, 1);
ENTITY::FREEZE_ENTITY_POSITION(pedSpawn, 0);
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(pedModel);
return pedSpawn;
}
I do it like this.
So you can do something like this for example, this should spawn Charles next to you:
Vector3 plCoords = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true, false);
Ped myPed = spawnPed(MISC::GET_HASH_KEY("CS_charlessmith"), plCoords.x + 2, plCoords.y, plCoords.z);