roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
769 stars 119 forks source link

How to obtain the player's current position? #497

Closed YCcHxxt closed 3 months ago

YCcHxxt commented 3 months ago

I want to create a teleportation plugin similar to "kz", but regarding the issue of obtaining player positions, I have no idea where to start

TitaniumLithium commented 3 months ago
            var player = Utilities.GetPlayerFromUserid(id);
            var pawn = player.PlayerPawn.Get();
            Vector Position = new Vector(x,y,z);
            pawn.Teleport(Position)

Vector https://docs.cssharp.dev/api/CounterStrikeSharp.API.Modules.Utils.Vector.html CCSPlayerController https://docs.cssharp.dev/api/CounterStrikeSharp.API.Core.CCSPlayerController.html CCSPlayerPawn https://docs.cssharp.dev/api/CounterStrikeSharp.API.Core.CCSPlayerPawn.html Teleport https://docs.cssharp.dev/api/CounterStrikeSharp.API.Core.CBaseEntity.html#CounterStrikeSharp_API_Core_CBaseEntity_Teleport_CounterStrikeSharp_API_Modules_Utils_Vector_CounterStrikeSharp_API_Modules_Utils_QAngle_CounterStrikeSharp_API_Modules_UtilsVector

KillStr3aK commented 3 months ago

dont forget that for these kind of questions we have our discord available (or github discussions), this is not an issue