AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Check if position vector is in bounds (https://forums.alliedmods.net/showthread.php?t=311313)

garewin 10-12-2018 19:57

Check if position vector is in bounds
 
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     {         new Float:forigin[3];         GetClientEyePosition(client, forigin);         new Float:fangles[3];         GetClientEyeAngles(client, fangles);         new Float: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);         new Float: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]--;     } } public bool:TraceRayFilter(ent, contents) {     return false; }

Edit: fixed it for now. The code i use right now is:
Spoiler


All times are GMT -4. The time now is 03:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.