Skip to content

Docs for events #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
34 changes: 29 additions & 5 deletions pysamp/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,35 @@ def is_valid(self) -> bool:
return is_valid_actor(self.id)

@event("OnActorStreamIn")
def on_stream_in(cls, actorid: int, forplayerid: int):
return (cls(actorid), Player(forplayerid))
def on_stream_in(cls, actor_id: int, for_player_id: int):
"""This event is called when an actor is streamed in by a player's
client.

:param Actor actor: The instance of the actor class.
:param Player for_player: The instance of the player class that streamed the
actor in.
:returns: No return value.

.. note:: This event can also be called by NPC.

Wraps: https://open.mp/docs/scripting/callbacks/OnActorStreamIn
"""
return (cls(actor_id), Player(for_player_id))

@event("OnActorStreamOut")
def on_stream_out(cls, actorid: int, forplayerid: int):
return (cls(actorid), Player(forplayerid))
def on_stream_out(cls, actor_id: int, for_player_id: int):
"""This event is called when an actor is streamed out by a
player's client.

:param Actor actor: The instance of the actor class.
:param Player for_player: The instance of the player class that streamed the
actor out.
:returns: No return value.

.. note:: This event can also be called by NPC.

Wraps: https://open.mp/docs/scripting/callbacks/OnActorStreamOut
"""
return (cls(actor_id), Player(for_player_id))

from pysamp.player import Player # noqa
from pysamp.player import Player # noqa
15 changes: 13 additions & 2 deletions pysamp/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,16 @@ def set_default_camera_col(disable: bool) -> bool:
return set_objects_default_camera_col(disable)

@event("OnObjectMoved")
def on_moved(cls, objectid: int):
return (cls(objectid),)
def on_moved(cls, object_id: int):
"""This event is called when an object stops moving after
:meth:`Object.move()`.

:param Object object: The insinstance of the object that was moved.
:returns: No return value.

.. note:: :meth:`set_position` does not work when used in this
event. To fix it, recreate the object.

Wraps: https://open.mp/docs/scripting/callbacks/OnObjectMoved
"""
return (cls(object_id),)
Loading