Object

class pysamp.object.Object(id: int)

Bases: object

Class that creates and handles global objects.

To create a new object, check Object.create().

For player objects, check out pysamp.PlayerObject.

Objects are world objects represented by what object they are (model), and where they are created. They can be moved, rotated and customized with non-default textures.

It is recommended to use a streamer if you need more than 1000 objects. SA-MP has a limit if approximately 1000 objects. Bypassing this limit will cause all objects to disappear.

For a list of models, you can utilize tools like here: https://dev.prineside.com/en/gtasa_samp_model_id/

classmethod create(model: int, x: float, y: float, z: float, rotation_x: float, rotation_y: float, rotation_z: float, draw_distance: float) Object

Create a new object.

Returns

An instance of an Object.

destroy() bool

Destroy the object.

This removes the object from the world, and will no longer be available. It’s occupied object id gets free’d up.

get_model() int

Get the model of the object.

get_position() Tuple[float, float, float]

Retrieve the coordinates for where the object is right now.

get_rotation() Tuple[float, float, float]

Get the rotation the object currently have.

is_moving() bool

Check if the object is currently moving.

is_valid() bool

Check if the object exists.

move(x: float, y: float, z: float, speed: float, rotation_x: float = - 1000.0, rotation_y: float = - 1000.0, rotation_z: float = - 1000.0) int

Move and rotate the object to given values.

Rotation values should be -1000 if you don’t want to modify the object rotation.

Returns the time in seconds it takes to move the object.

classmethod on_moved(objectid: int)
static set_default_camera_col(disable: bool) bool

Set whether all object should by default ignore colission.

Please note that this is a static method as it is affecting all objects. You call it like this:

# Disable camera colission by default on all objects:
Object.set_default_camera_col(True)
set_material(material_index: int, model_id: int, txd_name: str, texture_name: str, material_color: int = 0) bool

Change the object materials.

The material can be from another object model in the game.

Note

Vertex lighting of the object will disappear if material color is changed.

Warning

You MUST use ARGB color format, not RGBA.

set_material_text(text: str, material_index: int = 0, material_size: int = 90, font_face: str = 'Arial', font_size: int = 24, bold: bool = True, font_color: int = 4294967295, back_color: int = 0, text_alignment: int = 0) bool

Change the material text of the object.

Example of usage:

if "/text" in cmdtext:
    object = Object(19353, 0, 0, 10, 0.0, 0.0, 90.0)
    object.set_material_text(
        "Here is text!",  # desired text
        0,  # material index
        OBJECT_MATERIAL_SIZE_256x128,  # material size
        "Arial",  # font face
        28,  # font size
        False,  # bold?
        0xFFFF8200,  # font color (ARGB format)
        0xFF000000,  # background color (ARGB format)
        OBJECT_MATERIAL_TEXT_ALIGN_CENTER  # alignment
    )
# write "Here is text!" on the object, with orange font color
# and black background

Note

Text does not update after 16 calls on the same object.

Warning

The color format is ARGB opposed to how RGBA format.

set_no_camera_collision() bool

Disable camera collision on the object.

Makes the camera freely pass through it.

Note

This only works outside the map boundaries (past -3000/3000 on the X and Y axis).

set_postition(x: float, y: float, z: float) bool

Set a new position for the object using world coordinates.

For rotation, check out Object.set_rotation.

set_rotation(rotation_x: float, rotation_y: float, rotation_z: float) bool

Set the new rotation the object should have.

stop() bool

Stop moving the object.