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

@:value({ pedType : 4, networked : false, heading : 0.0 })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

new(handle:Int)

Wraps a handle. No existence check — use Entity.fromHandle for that.

Variables

armour:Int

Body armour, 0–100 by default. Separate from health.

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.

write onlycanRagdoll:Bool

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 onlycurrentWeapon:Int

The equipped weapon's hash, or 0 when unarmed.

write onlydiesWhenInjured:Bool

read onlyisArmed:Bool

read onlyisDeadOrDying:Bool

Dead or in the dying animation. Prefer this over isDead, which only flips once death has fully resolved.

read onlyisInAnyVehicle:Bool

read onlyisInVehicle:Bool

Kept for symmetry with currentVehicle; identical to isInAnyVehicle.

read onlyisPlayer:Bool

Whether this ped is controlled by a player rather than the AI.

read onlyisRagdoll:Bool

read onlyisShooting:Bool

read onlylastVehicle:Vehicle

The last vehicle the ped was in, even after getting out.

read onlyseat:Null<Int>

The seat the ped occupies, or null when not in a vehicle. See VehicleSeat.

Methods

@:value({ immediately : false })inlineclearTasks(immediately:Bool = false):Void

@:value({ timeoutMs : 20000, speed : 2.0, seat : -1 })inlineenterVehicle(vehicle:Vehicle, seat:Int = -1, speed:Float = 2.0, timeoutMs:Int = 20000):Void

inlineequipWeapon(weapon:Hash):Void

@:value({ equip : true, ammo : 100 })giveWeapon(weapon:Hash, ammo:Int = 100, equip:Bool = true):Void

Gives the ped a weapon.

Parameters:

weapon

A weapon name ("WEAPON_PISTOL") or a pre-hashed value.

equip

Whether to put it in the ped's hands immediately.

inlineisPlayingAnim(dict:String, name:String):Bool

@:value({ flags : 0 })inlineleaveVehicle(flags:Int = 0):Void

makeStatic():Void

Makes the ped ignore the world and stand still — useful for static NPCs.

@:value({ blendOut : -8.0, blendIn : 8.0, duration : -1, flag : 0 })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.

inlinerandomiseOutfit():Void

inlineremoveAllWeapons():Void

inlineremoveWeapon(weapon:Hash):Void

inlinesetAmmo(weapon:Hash, ammo:Int):Void

@:value({ palette : 0 })inlinesetComponent(componentId:Int, drawable:Int, texture:Int, palette:Int = 0):Void

@:value({ stoppingRange : 1.0, timeoutMs : -1, speed : 1.0 })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.

@:value({ seat : -1 })inlinewarpIntoVehicle(vehicle:Vehicle, seat:Int = -1):Void

Puts the ped straight into a seat, skipping the entry animation.

Inherited Variables

Defined by Entity

alpha:Int

Opacity from 0 (invisible) to 255.

read onlyattachedTo:Entity

The entity this one is attached to, or null.

write onlycollision:Bool

read onlyexists:Bool

read onlyforwardVector:Vector3

The unit vector the entity faces.

write onlyfrozen:Bool

Whether the entity is pinned in place. Write-only — the game exposes no getter.

finalhandle:Int

The raw game handle.

read onlyhasControl:Bool

Whether this client currently owns the entity. Only the owner may modify a networked entity and have the change replicate.

heading:Float

Yaw only, in degrees — 0 faces north.

health:Int

read onlyheightAboveGround:Float

write onlyinvincible:Bool

read onlyisAttached:Bool

read onlyisDead:Bool

read onlyisNetworked:Bool

read onlymaxHealth:Int

read onlymodel:Int

The model hash this entity was created from.

read onlynetId:Int

The network ID, stable across all clients — the value to send in events. Returns 0 for a purely local entity.

write onlyoutline:Bool

Draws the game's selection outline around the entity.

rotation:Vector3

Rotation in degrees as (pitch, roll, yaw).

read onlyspeed:Float

Current speed in metres per second. Multiply by 3.6 for km/h, 2.237 for mph.

read onlystate:StateBag

The entity's replicated state bag. Reads work on any client; writes only replicate from the server.

read onlytype:EntityType

visible:Bool

Inherited Methods

Defined by Entity

@:value({ collision : false, bone : 0 })attachTo(target:Entity, offset:Vector3, rotation:Vector3, bone:Int = 0, collision:Bool = false):Void

Attaches this entity to target, offset from one of its bones.

Parameters:

bone

Bone index on the target; 0 attaches to its origin.

collision

Whether the two keep colliding with each other.

delete():Void

Deletes the entity.

Requires ownership: on a networked entity this silently does nothing unless requestControl() succeeded first.

@:value({ collision : true, keepVelocity : true })inlinedetach(keepVelocity:Bool = true, collision:Bool = true):Void

inlinedistanceTo(point:Vector3):Float

inlinedistanceToEntity(other:Entity):Float

@:value({ flags : 17 })inlinehasClearLineOfSightTo(other:Entity, flags:Int = 17):Bool

Whether nothing solid sits between this entity and other.

inlinemarkAsNoLongerNeeded():Void

Releases the entity back to the game, which may then despawn it.

inlineoffsetInWorldCoords(offset:Vector3):Vector3

Converts a position expressed in the entity's own frame into world space.

@:value({ timeoutMs : 1000 })requestControl(timeoutMs:Int = 1000):Bool

Asks the server for ownership and waits for it, returning whether it was granted before timeoutMs elapsed.

Every write to a networked entity you don't own is silently reverted by its real owner, so call this first:

if (vehicle.requestControl()) vehicle.repair();

Must be called from inside a coroutine. Ownership can be lost again at any moment, so keep the work that follows short.

@:value({ grabFromOtherScript : true })inlinesetAsMission(grabFromOtherScript:Bool = true):Void

Claims the entity for this script, so the game's population manager won't clean it up while you're using it.

teleport(position:Vector3, ?heading:Float):Void

Moves the entity without the game's usual "find a valid spot" fixups — no ground snapping, no pushing out of collision. Use it when you have already worked out exactly where the entity belongs.

toString():String

inlineworldToLocal(worldPosition:Vector3):Vector3

The inverse of offsetInWorldCoords: world space into the entity's frame.