A ped on the server.

Server-side peds are mostly read-only: the game logic that drives them runs on the client that owns them. Position, seating and weapons can be set from here; animations, tasks and health cannot, and have to be asked of the owning client via an event.

var ped = player.ped;
if (ped != null && ped.isInVehicle) {
    trace('${player.name} is driving ${ped.currentVehicle.plate}');
}

Static methods

@:value({ pedType : 4, heading : 0.0 })staticcreate(model:Hash, position:Vector3, heading:Float = 0.0, pedType:Int = 4):Ped

Spawns a ped.

Blocks the calling coroutine until the ped is networked: a server-created entity is orphaned, with no network ID, until a client comes into scope for it. Returns null if that does not happen within the timeout.

Constructor

new(handle:Int)

Variables

armour:Int

read onlycauseOfDeath:Int

The weapon hash that killed this ped, or 0.

read onlycurrentVehicle:Vehicle

The vehicle the ped is sitting in, or null.

read onlyisInVehicle:Bool

read onlyisPlayer:Bool

read onlypedMaxHealth:Int

Maximum health, which for peds is tracked separately from Entity.maxHealth.

read onlyseat:Null<Int>

The seat index the ped occupies, or null when on foot.

Methods

inlineclearTasks():Void

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

inlineremoveAllWeapons():Void

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

Puts the ped straight into a seat. -1 is the driver's.

Inherited Variables

Defined by Entity

read onlyattachedTo:Entity

The entity this one is attached to, or null.

read onlycreatorResource:String

The resource that created the entity, if any.

read onlyexists:Bool

frozen:Bool

finalhandle:Int

The server-side entity handle.

heading:Float

read onlyhealth:Int

Current health. Read-only on the server — health is simulated by the owning client, so setting it means sending that client an event.

read onlymaxHealth:Int

read onlymodel:Int

read onlynetId:Int

The network ID — the entity reference to send to clients — or 0 if the entity has none yet.

Guarded, because the underlying native raises rather than returning a sentinel:

script error in native ...: Tried to access invalid entity: 131333

An entity the server just created is orphaned until a client comes into scope for it: it has a handle, but no network ID and no owner. A stale handle behaves the same way. Both cases read as 0 here instead of taking down the handler that asked.

The existence check alone is not sufficient — the native has been reported to raise even when DoesEntityExist says otherwise — so the call itself is also caught.

read onlyowner:Int

The server ID of the client that currently owns this entity, or -1 when nobody does.

Ownership decides which client simulates the entity, and therefore who must be told to change its health, tasks or physics.

rotation:Vector3

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

routingBucket:Int

The routing bucket this entity lives in.

Buckets are the server's instancing mechanism: entities and players in different buckets can't see or interact with each other at all. Bucket 0 is the default world.

read onlyspeed:Float

Speed in metres per second.

read onlystate:StateBag

The entity's replicated state bag.

read onlytype:EntityType

Inherited Methods

Defined by Entity

delete():Void

Deletes the entity. Unlike on the client this always works — the server is authoritative and doesn't need to negotiate ownership first.

inlinedistanceTo(point:Vector3):Float

inlinedistanceToEntity(other:Entity):Float

toString():String

@:value({ timeoutMs : 5000 })waitUntilNetworked(timeoutMs:Int = 5000):Bool

Blocks until the entity is registered on the server and has a network ID, returning whether it got one before timeoutMs elapsed.

Server-created entities do not exist immediately — they stay orphaned until a client is in scope. Anything that needs the network ID (sending it to a client, writing a state bag) has to wait for this first, which is what the create helpers do for you.

Returns false if no client ever comes into scope, or if the model was not valid for the entity type.