Player Teleport
Jump to navigation
Jump to search
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); } }