Raised This Month: $51 Target: $400
 12% 

Entity teleportation..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
I'mSane
Member
Join Date: Apr 2010
Location: SPb, Russia
Old 11-28-2010 , 16:02   Entity teleportation..
Reply With Quote #1

When I'm trying to teleport an entity when playing, entity teleports exactly to my player. But when I'm a spectator, it works properly and entity teleports to the point when I aim. Here's code:

PHP Code:
decl Float:vecOrigin[3], Float:vecAngles[3], Float:vecPos[3];  
GetClientAbsOrigin(clientvecOrigin); 
GetClientEyeAngles(clientvecAngles); 
new 
Handle:trace TR_TraceRayFilterEx(vecOriginvecAnglesCONTENTS_SOLID|CONTENTS_MOVEABLERayType_InfiniteTraceEntityFilterPlayersent);  
if(
TR_DidHit(trace)) 
{  
    
TR_GetEndPosition(vecPostrace); 

CloseHandle(trace); 
TeleportEntity(entvecPosNULL_VECTORNULL_VECTOR); 
Why?
__________________
Sorry for noob questions.
Sorry for bad english.
I'mSane is offline
Send a message via Skype™ to I'mSane
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-28-2010 , 16:49   Re: Entity teleportation..
Reply With Quote #2

A little bit of code from Zuko's Weapon Spawner
you must define g_pos[3] at the beginning of your plugin. Then this will return true if there is a spawn point it hit or false if it goes on into infinity.
then teleport the entity using g_pos as the place for it to go.
PHP Code:
SetTeleportEndPoint(client)
{
    
decl Float:vAngles[3];
    
decl Float:vOrigin[3];
    
decl Float:vBuffer[3];
    
decl Float:vStart[3];
    
decl Float:Distance;
    
    
GetClientEyePosition(client,vOrigin);
    
GetClientEyeAngles(clientvAngles);
    
    
//get endpoint for teleport
    
new Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SHOTRayType_InfiniteTraceEntityFilterPlayer);

    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(vStarttrace);
        
GetVectorDistance(vOriginvStartfalse);
        
Distance = -35.0;
        
GetAngleVectors(vAnglesvBufferNULL_VECTORNULL_VECTOR);
        
g_pos[0] = vStart[0] + (vBuffer[0]*Distance);
        
g_pos[1] = vStart[1] + (vBuffer[1]*Distance);
        
g_pos[2] = vStart[2] + (vBuffer[2]*Distance);
    }
    else
    {
        
CloseHandle(trace);
        return 
false;
    }
    
CloseHandle(trace);
    return 
true;

__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
I'mSane
Member
Join Date: Apr 2010
Location: SPb, Russia
Old 11-29-2010 , 06:40   Re: Entity teleportation..
Reply With Quote #3

Yes, now it works! Thank you!
__________________
Sorry for noob questions.
Sorry for bad english.
I'mSane is offline
Send a message via Skype™ to I'mSane
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 11-30-2010 , 13:23   Re: Entity teleportation..
Reply With Quote #4

when you're alive the trace hits the player since the trace starts inside the player. you defined the filter as TraceEntityFilterPlayers inside this function you can choose whether the ray should hit the entity or not.
blodia 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 13:28.


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