Player Teleport: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Thunder4ik (talk | contribs) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{Multiple issues| | |||
{{Dead end|date=January 2024}} | |||
{{Orphan|date=January 2024}} | |||
}} | |||
Add this to sdk_player.cpp, bind a key to 'teleport', and enjoy! | Add this to sdk_player.cpp, bind a key to 'teleport', and enjoy! | ||
<pre> | <pre> | ||
| Line 41: | Line 46: | ||
} | } | ||
</pre> | </pre> | ||
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 );) | |||
[[Category:Snippets]] | [[Category:Snippets]] | ||
Latest revision as of 10:08, 21 January 2024
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 );)