Player Teleport
Jump to navigation
Jump to search
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024
January 2024
This article is an orphan, meaning that few or no articles link to it.
You can help by
adding links to this article from other relevant articles.
January 2024
You can help by
January 2024
Add this to sdk_player.cpp, bind a key to 'teleport', and enjoy!
CON_COMMAND( teleport, "Teleportin Time") {
ToSDKPlayer(UTIL_GetCommandClient())->TryTeleport();
}
void CSDKPlayer::TryTeleport() {
// set up the vectors and traceline
trace_t tr;
Vector vecStart, vecStop, vecDir;
// get the angles
AngleVectors( this->EyeAngles(), &vecDir );
// get the vectors
vecStart = this->EyePosition();
vecStop = vecStart + vecDir * MAX_TRACE_LENGTH;
// do the traceline
UTIL_TraceLine( vecStart, vecStop, MASK_ALL, this, COLLISION_GROUP_NONE, &tr );
// Did we hit the floor?
if (tr.DidHitWorld()) {
Vector origin = tr.endpos;
bool teleOK = false;
// Is there room for a player?
for (int i = 0; i < 18 &&! teleOK; i++ ) {
UTIL_TraceHull( origin, origin,
VEC_HULL_MIN, VEC_HULL_MAX, MASK_PLAYERSOLID, this, COLLISION_GROUP_PLAYER_MOVEMENT, &tr );
if ( tr.startsolid )
origin.z += 1.0f;
else
teleOK = true;
}
if (teleOK)
this->SetAbsOrigin(origin);
}
}
Note from Ferdynater: Remember to define it in sdk_player.h You can define it under: virtual int FlashlightIsOn( void ); (add: virtual void TryTeleport( void );)