Actor

class pysamp.actor.Actor(id: int)

Bases: object

A class that represents actors, also known as NPC’s.

These ‘actors’ are like NPCs, however they have limited functionality. They do not take up server player slots.

Read more about actors here: https://open.mp/docs/scripting/functions/CreateActor

apply_animation(animation_library: str, animation_name: str, delta: float, loop: bool, lock_x: bool, lock_y: bool, freeze: bool, time: int) bool

Set an animation on the actor.

clear_animations() bool

Clear the animations that are in use by the actor, if any.

classmethod create(modelid: int, x: float, y: float, z: float, rotation: float) Optional[Actor]

Create a new actor.

Parameters
  • modelid (int) – The model of the actor.

  • x (float) – The model of the actor.

  • y (float) – The model of the actor.

  • z (float) – The model of the actor.

  • rotation (float) – The model of the actor.

Returns

An Actor object. Will return None if the actor limit is reached of 1000 actors.

destroy() bool

Remove a created actor from the world.

get_facing_angle() float

Get the actor’s facing angle.

get_health() float

Get how much health the actor has.

get_id() int
get_position() Tuple[float, float, float]

Gets the current world coordinates of where the actor is located.

get_virtual_world() int

Get which virtual world ID the actor is in.

is_invulnerable() bool

See if the actor is invulnerable to damage.

is_valid() bool

Check if the actor is valid.

classmethod on_stream_in(actorid: int, forplayerid: int)
classmethod on_stream_out(actorid: int, forplayerid: int)
set_facing_angle(angle: float) bool

Set the actor’s facing angle.

set_health(health: float) bool

Set the health of the actor.

set_invulnerable(invulnerable: bool = True) bool

Set the actor to be invlunerable to damage.

set_position(position: Tuple[float, float, float]) bool

Set a new position for the actor.

streamed_in(for_player: Player) bool

Check if a player has streamed in the actor.

virtual_world(virtual_world: int) bool

Set the actor to a specific virtual world id.