Skip to content

Commit

Permalink
fix: revert base entity teleport changes, add warning to player contr…
Browse files Browse the repository at this point in the history
…oller (roflmuffin#688)
  • Loading branch information
roflmuffin authored Nov 27, 2024
1 parent b2046b2 commit 6349c11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 4 additions & 8 deletions managed/CounterStrikeSharp.API/Core/Model/CBaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@ public partial class CBaseEntity
public void Teleport(Vector? position = null, QAngle? angles = null, Vector? velocity = null)
{
Guard.IsValidEntity(this);

if (position == null && angles == null && velocity == null)
throw new ArgumentNullException("No valid argument");

nint _position = position?.Handle ?? 0;
nint _angles = angles?.Handle ?? 0;
nint _velocity = velocity?.Handle ?? 0;
nint _handle = Handle;

if (this is CCSPlayerController player && player.PlayerPawn.Value is CCSPlayerPawn playerPawn)
{
_handle = playerPawn.Handle;
}

VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(_handle, GameData.GetOffset("CBaseEntity_Teleport"))(_handle, _position, _angles, _velocity);
VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(_handle, GameData.GetOffset("CBaseEntity_Teleport"))(_handle, _position,
_angles, _velocity);
}

/// <exception cref="InvalidOperationException">Entity is not valid</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,11 @@ public VoiceFlags VoiceFlags
NativeAPI.SetClientVoiceFlags(Handle, (Byte)value);
}
}

[Obsolete(
"You are trying to call Teleport on a non-physical player. Maybe you mean Pawn? (See: https://docs.cssharp.dev/docs/guides/referencing-players.html#controllers--pawns)")]
public new void Teleport(Vector? position = null, QAngle? angles = null, Vector? velocity = null)
{
base.Teleport(position, angles, velocity);
}
}

0 comments on commit 6349c11

Please sign in to comment.