diff --git a/src/core/modules/players/players_entity.cpp b/src/core/modules/players/players_entity.cpp index c1e062266..e4beceb62 100644 --- a/src/core/modules/players/players_entity.cpp +++ b/src/core/modules/players/players_entity.cpp @@ -39,6 +39,7 @@ // >> EXTERNALS // ============================================================================ extern IServerGameClients *servergameclients; +extern IServerTools *servertools; // ============================================================================ @@ -81,6 +82,15 @@ bool PlayerMixin::IsWeapon() return false; } +void PlayerMixin::SnapToPosition(Vector *pOrigin, QAngle *pAngles) +{ + servertools->SnapPlayerToPosition( + (pOrigin ? *pOrigin : GetOrigin()) + GetViewOffset(), + pAngles ? *pAngles : GetViewAngle(), + (IClientEntity *)GetEdict()->GetIServerEntity() + ); +} + // CBasePlayer float PlayerMixin::GetSpeed() { diff --git a/src/core/modules/players/players_entity.h b/src/core/modules/players/players_entity.h index 97a863e3f..045f3c50e 100644 --- a/src/core/modules/players/players_entity.h +++ b/src/core/modules/players/players_entity.h @@ -72,6 +72,8 @@ class PlayerMixin: public CBaseEntityWrapper bool IsPlayer(); bool IsWeapon(); + void SnapToPosition(Vector *pOrigin = NULL, QAngle *pAngles = NULL); + // CBasePlayer // TODO: Return for some of these the proper entity class instead of a handle/index // E. g. BaseEntity, Entity, Weapon, Player, etc. diff --git a/src/core/modules/players/players_wrap.cpp b/src/core/modules/players/players_wrap.cpp index 978d22554..33011720e 100644 --- a/src/core/modules/players/players_wrap.cpp +++ b/src/core/modules/players/players_wrap.cpp @@ -384,6 +384,16 @@ void export_player_wrapper(scope _players) ":rtype: bool" ); + _PlayerMixin.def( + "snap_to_position", + &PlayerMixin::SnapToPosition, + "Teleports the player at the given position and angles.\n\n" + ":param Vector origin:\n" + " The coordinates to teleport the player at.\n" + ":param QAngle angles:\n" + " The angles to set the player's view to.", + ("self", arg("origin")=object(), arg("angles")=object())); + _PlayerMixin.add_property( "speed", &PlayerMixin::GetSpeed,