Skip to content
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

Docs for events #140

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions pysamp/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,31 @@ 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 int actor_id: The ID of the actor.
:param int for_player_id: The ID of the player that streamed the
actor in.
:returns: No return value.

.. note:: This event can also be called by NPC.
"""
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 int actor_id: The ID of the actor.
:param int for_player_id: The ID of the player that streamed the
actor out.
:returns: No return value.

.. note:: This event can also be called by NPC.
"""
return (cls(actor_id), Player(for_player_id))

from pysamp.player import Player # noqa
from pysamp.player import Player # noqa
13 changes: 11 additions & 2 deletions pysamp/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,14 @@ 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 int object_id: The ID 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.
"""
return (cls(object_id),)
Loading