Hello, I'm working on a plugin that teleports the user 750 units in front of him.
The teleport itself works, but it can teleport the user out of bounds.
Is there any way to check if the target teleport position is inside the map bounds, and if not, teleport him to the farthest in-bounds point?
The code I'm using right now:
Code:
public cod_class_skill_used(client)//forward to mod engine{if(ma_klase[client] && ilosc_teleportow_gracza[client] > 0)//check if the player has a class tag and enough remaining teleports{newFloat:forigin[3];
GetClientEyePosition(client, forigin);
newFloat:fangles[3];
GetClientEyeAngles(client, fangles);
newFloat:iorigin[3], Float:iangles[3], Float:ivector[3];
TR_TraceRayFilter(forigin, fangles, MASK_NPCWORLDSTATIC, RayType_Infinite, TraceRayFilter, client);
TR_GetEndPosition(iorigin);
MakeVectorFromPoints(forigin, iorigin, ivector);
ivector[2] = 0.0;
NormalizeVector(ivector, ivector);
ScaleVector(ivector, 750.0);
GetVectorAngles(ivector, iangles);
newFloat:tpVector[3];
tpVector[0] = forigin[0] + ivector[0];
tpVector[1] = forigin[1] + ivector[1];
tpVector[2] = forigin[2] + ivector[2] - 30; // to offset the eye position
TeleportEntity(client, tpVector, iangles, NULL_VECTOR);
ilosc_teleportow_gracza[client]--;
}}publicbool:TraceRayFilter(ent, contents){returnfalse;
}
Edit: fixed it for now. The code i use right now is: