A person — player character or NPC — on the client.
var ped = LocalPlayer.ped();
ped.armour = 100;
ped.giveWeapon("WEAPON_PISTOL", 60, true);
if (ped.isInVehicle) ped.currentVehicle.repair();
Most setters here only take effect on a ped this client owns. For another
player's ped, call requestControl() first — or, better, do the work
server-side, since a client that can rewrite other players' peds is a
client that can cheat.
Static methods
staticcreate(model:Hash, position:Vector3, heading:Float = 0.0, networked:Bool = false, pedType:Int = 4):Ped
Spawns a ped, streaming its model in first.
Blocks the calling coroutine until the model is ready. Returns null
if the model is invalid or failed to load.
Parameters:
networked | Whether other players can see it. Local peds are cheaper and are the right choice for purely visual NPCs. |
|---|
Constructor
Variables
write onlyblockNonTemporaryEvents:Bool
Whether the ped reacts to gunfire, explosions and other events. Turning this off is the standard way to keep a shopkeeper from fleeing.
read onlycurrentVehicle:Vehicle
The vehicle the ped is sitting in, or null when on foot.
Note this reports the vehicle only once the ped is actually seated —
it stays null throughout the enter animation.
read onlyisDeadOrDying:Bool
Dead or in the dying animation. Prefer this over isDead, which only
flips once death has fully resolved.
Methods
giveWeapon(weapon:Hash, ammo:Int = 100, equip:Bool = true):Void
Gives the ped a weapon.
Parameters:
weapon | A weapon name ( |
|---|---|
equip | Whether to put it in the ped's hands immediately. |
playAnim(dict:String, name:String, flag:Int = 0, duration:Int = -1, blendIn:Float = 8.0, blendOut:Float = -8.0):Bool
Plays an animation, loading its dictionary first if needed.
Parameters:
flag | Animation flags; 1 loops, 2 holds the last frame, 49 loops while letting the ped move. |
|---|---|
duration | Milliseconds, or -1 to run until the flags say stop. |
Returns:
False if the dictionary failed to stream in.
inlinewalkTo(target:Vector3, speed:Float = 1.0, timeoutMs:Int = -1, stoppingRange:Float = 1.0):Void
Walks or runs the ped to a position. speed of 1.0 walks, 2.0 runs.
inlinewarpIntoVehicle(vehicle:Vehicle, seat:Int = -1):Void
Puts the ped straight into a seat, skipping the entry animation.