Raised This Month: $32 Target: $400
 8% 

How teleport the player more safer?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 08-14-2018 , 01:45   How teleport the player more safer?
Reply With Quote #1

TeleportEntity can teleport player to the typed location without player stacking check. As I udnerstand I must use TR_TraceRayFilterEx for fix teleport location.. If somebody did it before? Can u help?

Spoiler

Last edited by ZASTRELIS; 08-14-2018 at 06:40.
ZASTRELIS is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 08-14-2018 , 02:44   Re: How teleport the player more safer?
Reply With Quote #2

I think that we've origin[3] and must check it on all angels with direction in 64 units on 90, 180, 270 and origin[2]+120.0 for all end vectors are they impact collision.. is it true?

Last edited by ZASTRELIS; 08-14-2018 at 02:46.
ZASTRELIS is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 08-14-2018 , 03:17   Re: How teleport the player more safer?
Reply With Quote #3

To check if the teleport destination will result the player being stuck, you'd want to do a hull trace (which tests a bounding cube):

Code:
// this is where you want the player to be teleported to
float vecDesiredPosition[3];

// get the world size of the player for collision check
float vecMins[3], vecMaxs[3];
GetClientMins(client, vecMins);
GetClientMaxs(client, vecMaxs);

Handle trace = TR_TraceHullFilterEx(vecDesiredPosition, vecDesiredPosition, vecMins, vecMaxs,
		MASK_PLAYERSOLID, TeleportTraceFilter, client);

// valid is true if no collision was found
bool valid = !TR_DidHit(trace);
delete trace;
Code:
/** 
 * Return true if teleport should be stopped.  
 */
public bool TeleportTraceFilter(int entity, int contents, int client) {
	return entity > 0 && client != entity;
}
If the player would be stuck in that position, you'll want to use some sort of unstuck function. While they all also use hull traces find some position where the player won't be stuck, there's various ways to find viable candidates; you can take a look at the Stuck plugin or the function in my Halloween Tiny Unstuck plugin for reference.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 08-14-2018 at 04:35.
nosoop is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 08-14-2018 , 04:20   Re: How teleport the player more safer?
Reply With Quote #4

hmmm, GetClientMins instead.. GetPlayerMins, what is it?

Last edited by ZASTRELIS; 08-14-2018 at 04:29.
ZASTRELIS is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 08-14-2018 , 04:37   Re: How teleport the player more safer?
Reply With Quote #5

Quote:
Originally Posted by ZASTRELIS View Post
hmmm, GetClientMins instead.. GetPlayerMins, what is it?
A look at the API documentation would tell you the answer. Apologies for the confusion.

Had to tweak it from my TF2-specific plugin as I'm not sure if prescaled is supported in all games, and in the context of what I was working on I needed the default sizing.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 08-14-2018 at 04:40.
nosoop is offline
Reply



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 20:38.


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