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

Solved [CS:GO]TeleportEntity Teleporting way higher than supposed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nezur0s
Junior Member
Join Date: Feb 2020
Old 04-01-2020 , 18:02   [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #1

Hello ! I've been trying to make a deadswap plugin , it's supposed to store the positions of dead players then when someone calls sm_deadswap open up a menu to teleport to dead players, I use GetClientAbsOrigin or GetEntProp(client,PROP_SEND,m_vecOrigin,Posit ionDead[client]) i tried both, inside Player_death event with hook mode pre, And then inside the menu handler of DeadSwap menu, I Use a TeleportEntity to tp to the dead player's location by doing TeleportEntity(client,PositionDead[client])
But i noticed that everytime the x ,y cordinate work fine, but the z cordinate get shifted by like +74 for some weird reasons here's my code:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>




float g_fDeathLocation[MAXPLAYERS+1][3];
float g_fDeathAngles[MAXPLAYERS+1][3];
int g_iWasDucking[MAXPLAYERS+1];

public 
void OnPluginStart()
{
RegConsoleCmd("sm_deadswap"Command_DeadSwap);
HookEvent("player_death"Event_PlayerDeathPreEventHookMode_Pre);
}

public 
Action Event_PlayerDeathPre(Event event,const char[] name,bool dontBroadcast)
{
GetDeathLocationInfo(GetClientOfUserId(event.GetInt("userid")));
}

public 
Action Event_RoundStart(Event event,const char[] name,bool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        
ResetLocation(i);
    }
}

public 
Action Command_DeadSwap(int clientint args)
{
    
Menu menu_dswap = new Menu(MenuHandlerDeadSwap);
    
menu_dswap.SetTitle("To which dead you want to tp");
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)){
            if(!
IsPlayerAlive(i))
            {
                if (
g_fDeathLocation[client][0] != || g_fDeathLocation[client][1] != || g_fDeathLocation[client][2] != 0)
                {
                
char id[64];
                
char name[64];
                
IntToString(iidsizeof(id));
                
GetClientName(inamesizeof(name));
                
menu_dswap.AddItem(idname);
                }
            }
        }    
    }
    
menu_dswap.ExitButton false;
    
menu_dswap.Display(client20);
 
    return 
Plugin_Handled;
}

public 
int MenuHandlerDeadSwap(Menu menuMenuAction actionint clientint param)
{
    
/* If an option was selected, tell the client about the item. */
    
if (action == MenuAction_Select)
    {
        
char id[32];
        
menu.GetItem(paramidsizeof(id));
        
int cl StringToInt(id);
        if (
g_iWasDucking[cl])
        {
        
SetEntProp(clientProp_Send"m_bDucked"1);
        }
        
TeleportEntity(clientg_fDeathLocation[cl], g_fDeathAngles[cl], NULL_VECTOR);
    }
    
/* If the menu was cancelled, print a message to the server about it. */
    
else if (action == MenuAction_Cancel)
    {
        
PrintToServer("Client %d's menu was cancelled.  Reason: %d"clientparam);
    }
    
/* If the menu has ended, destroy it */
    
else if (action == MenuAction_End)
    {
        
delete menu;
    }
}

void GetDeathLocationInfo(int client)
{
    
GetClientAbsOrigin(clientg_fDeathLocation[client]);
    
GetClientAbsAngles(clientg_fDeathAngles[client]);
    
g_iWasDucking[client] = GetEntProp(clientProp_Send"m_bDucked");
}

void ResetLocation(int client)
{
    
g_fDeathLocation[client] = NULL_VECTOR;
    
g_fDeathAngles[client]   = NULL_VECTOR;
    
g_iWasDucking[client]    = 0;


Thanks for your time (PS: I could maybe do a -64 on the positions but i still wouldn't understand why the position is Shifted upwards because normally Both TeleportEntity and GetEntProp or GetClientAbsOrigin work on the m_VecOrigin Value so they would tp the client on his foot)

Last edited by Nezur0s; 04-01-2020 at 19:59.
Nezur0s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-01-2020 , 18:31   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #2

You could try GetClientEyePosition
https://sm.alliedmods.net/new-api/sd...entEyePosition

GetClientAbsOrigin is origin, under player model (depends model).
Then GetClientEyePosition is behind head.
Bacardi is offline
Nezur0s
Junior Member
Join Date: Feb 2020
Old 04-01-2020 , 18:42   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #3

Thanks but I really wanted to understand why it does this behaviour because if all this are using and setting m_VecOrigin why do I endup with a player significally above the normal positions maybe like 74 units (even if they have the same player model) because they should both set the same value which is m_vecOrigin

I saw this behaviour also in the Hrespawn plugin, a plugin which respawns a player at his death location, he shifts the death location Z cordinate by a -64 if he was not crouching at a -46 if he was crouching but I don't know why he does that. link for the Hrespawn plugin maybe that will help
https://github.com/iNilo/sourcemod-p...ter/respawn.sp
Nezur0s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-01-2020 , 18:56   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #4

Maybe something happen in same time when event player_death is executed and ragdoll spawned.
Another test you could try is make little timer, to delay before taking position.

*edit
Maybe Teleport is what it is.

Last edited by Bacardi; 04-01-2020 at 18:57.
Bacardi is offline
Nezur0s
Junior Member
Join Date: Feb 2020
Old 04-01-2020 , 19:20   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #5

I am gonna try to use the came code just to tp a player to an other player and see if it teleport's correctly

**Maybe Teleport is what it is.** Didn't really understand you sorry I use a translate program can you explain ?
Nezur0s is offline
Nezur0s
Junior Member
Join Date: Feb 2020
Old 04-01-2020 , 19:57   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #6

You're right it's indeed that when I used the code in normal situation no death event it works just fine for some reasons the game tp's the client at his eye position when he dies (my theory is that for spectators so when he dies he get's put at the eye level and can spectate normally !) I am gonna put this in solved and bit a later post my solution

Last edited by Nezur0s; 04-01-2020 at 19:59.
Nezur0s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-01-2020 , 20:04   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #7

__________________
Do not Private Message @me
Bacardi is offline
Nezur0s
Junior Member
Join Date: Feb 2020
Old 04-01-2020 , 20:08   Re: [CS:GO]TeleportEntity Teleporting way higher than supposed
Reply With Quote #8

Found an other thing apparently in Player_Death event pre, The Player AbsOrigin and The player Eyeposition are in the same point (same cordinates in printchatall) and Thanks Bacardi for the help

Last edited by Nezur0s; 04-01-2020 at 20:11.
Nezur0s 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 18:48.


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