natives.createChar: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
(Created page with "{{ScriptItem |endpoint = client |games = iv |type = function |name = natives.createChar |parameters = int pedType, int modelHash, Vec3 position, bool networked |parameter1 = int pedType The ped type (see Ped Defines) |parameter2 = int modelHash The model hash |parameter3 = Vec3 position The spawn position |parameter4 = bool networked Whether the ped is networked |usage = Create a ped |return1 = Ped |returnFail1 = void |exampleJS = addC...")
 
No edit summary
 
Line 10: Line 10:
|parameter4 = bool networked Whether the ped is networked
|parameter4 = bool networked Whether the ped is networked
|usage = Create a ped
|usage = Create a ped
|return1 = Ped
|return1 = void
|returnFail1 = void
|exampleJS = addCommandHandler("spawnped", function(command, params, client) {
|exampleJS = addCommandHandler("spawnped", function(command, params, client) {
     const hash = natives.getHashKey("M_Y_COP");
     const hash = natives.getHashKey("M_Y_COP");

Latest revision as of 19:53, 3 December 2025

Function Client Only icon-iv.png Online and Offline

Available since Client 1.0.0

void natives.createChar(int pedType, int modelHash, Vec3 position, bool networked)

The natives.createChar function is used to Create a ped.

Parameters

1) int pedType The ped type (see Ped Defines).
2) int modelHash The model hash.
3) Vec3 position The spawn position.
4) bool networked Whether the ped is networked.

Return

void This function doesn't return a value.

Notes

There aren't any notes for this function.

Examples

Example 1 - JavaScript:

addCommandHandler("spawnped", function(command, params, client) {

   const hash = natives.getHashKey("M_Y_COP");
   const pos = localPlayer.position;
   natives.requestModel(hash);
   if (natives.hasModelLoaded(hash)) {
       const ped = natives.createChar(1, hash, pos, true);
       natives.markModelAsNoLongerNeeded(hash);
   }

});

Compatibility

There isn't any compatibility information for this function.