Raised This Month: $57 Target: $400

Solved Check if position vector is in bounds

Post New Thread Reply   
Thread Tools Display Modes
Author Message
New Member
Join Date: Oct 2018
Old 10-12-2018 , 20:57   Check if position vector is in bounds
Reply With Quote #1

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:

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:

Last edited by garewin; 10-13-2018 at 07:31. Reason: fixed
garewin is offline

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 06:00.

Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode