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

How to check if a player (CT/T) is on head (CT/T)?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 08-07-2018 , 15:32   How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #1

Hello,

I need to check if a player (CT/T) is on a head (CT/T). I'm trying but without any progress.

Thanks for any help.

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

int iCT[MAXPLAYERS 1];
int iT[MAXPLAYERS 1];

int iP1CT[MAXPLAYERS 1];
int iP2T[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_z"z);
}

public 
Action z(clientargs)
{
    for (new 
1<= MaxClientsi++)
    {
        if(
!= && IsClientInGame(i))
        {
            if(
GetClientTeam(i) == CS_TEAM_CT)
            {
                
iP1CT[i] = GetClientOfUserId(i);
                
iCT[i] = GetEntDataEnt2(iP1CT[i], FindSendPropInfo("CBasePlayer""m_hGroundEntity"));
            }
            else if(
GetClientTeam(i) == CS_TEAM_T)
            {
                
iP2T[i] = GetClientOfUserId(i);
                
iT[i] = GetEntDataEnt2(iP2T[i], FindSendPropInfo("CBasePlayer""m_hGroundEntity"));
            }
        } 
    }
    
    if(
iP1CT[i] == iT[i])
    {
        
//CT is on T head
    
}
    else if(
iP2T[i] == iCT[i])
    {
        
//T is on CT head
    
}

__________________


Main owner of the CMGPORTAL.CZ.
---------------------------------------
My plugins:
[CS:GO] Panorama - Timeleft
[CS:GO] JailBreak - Be quiet, please!
Fastmancz is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-07-2018 , 17:50   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #2

I would do a trace straight down.
__________________
Neuro Toxin is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 08-07-2018 , 18:13   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #3

Very helpful answer... 🤦
__________________


Main owner of the CMGPORTAL.CZ.
---------------------------------------
My plugins:
[CS:GO] Panorama - Timeleft
[CS:GO] JailBreak - Be quiet, please!
Fastmancz is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 08-07-2018 , 18:30   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #4

Quote:
Originally Posted by Fastmancz View Post
Hello,

I need to check if a player (CT/T) is on a head (CT/T). I'm trying but without any progress.

Thanks for any help.

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

int iCT[MAXPLAYERS 1];
int iT[MAXPLAYERS 1];

int iP1CT[MAXPLAYERS 1];
int iP2T[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_z"z);
}

public 
Action z(clientargs)
{
    for (new 
1<= MaxClientsi++)
    {
        if(
!= && IsClientInGame(i))
        {
            if(
GetClientTeam(i) == CS_TEAM_CT)
            {
                
iP1CT[i] = GetClientOfUserId(i);
                
iCT[i] = GetEntDataEnt2(iP1CT[i], FindSendPropInfo("CBasePlayer""m_hGroundEntity"));
            }
            else if(
GetClientTeam(i) == CS_TEAM_T)
            {
                
iP2T[i] = GetClientOfUserId(i);
                
iT[i] = GetEntDataEnt2(iP2T[i], FindSendPropInfo("CBasePlayer""m_hGroundEntity"));
            }
        } 
    }
    
    if(
iP1CT[i] == iT[i])
    {
        
//CT is on T head
    
}
    else if(
iP2T[i] == iCT[i])
    {
        
//T is on CT head
    
}


Your code have a lot of errors and not even compile.


I would say something like this:
PHP Code:
#include <sourcemod> 
#include <cstrike> 

public void OnPluginStart() 

    
RegConsoleCmd("sm_z"z); 


public 
Action z(int clientint args
{
    
int iPlayerInGround;
    
    for (
int i 1<= MaxClientsi++) 
    { 
        if(
IsClientInGame(i)) 
        { 
            
iPlayerInGround GetEntPropEnt(iProp_Send"m_hGroundEntity"); 
            
            if(
IsValidClient(iPlayerInGround))
            {
                if(
GetClientTeam(iPlayerInGround) == CS_TEAM_CT && GetClientTeam(i) == CS_TEAM_T)
                {
                    
//T is on CT head 
                
}
                else if(
GetClientTeam(iPlayerInGround) == CS_TEAM_T && GetClientTeam(i) == CS_TEAM_CT)
                {
                    
//CT is on T head 
                
}
            }
        }  
    } 
    
    return 
Plugin_Handled;
}  

stock bool IsValidClient(int clientbool bAllowBots truebool bAllowDead false)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 08-07-2018 at 18:45.
Franc1sco is offline
Send a message via MSN to Franc1sco
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 08-07-2018 , 18:43   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #5

Quote:
Originally Posted by Fastmancz View Post
Very helpful answer... 🤦
This one can appear rude towards someone who is actually trying to help you, so I strongly suggest you to pay more attention to where you post in the future:

Looking at the section name, which is "Scripting", and not "Spoon-feeding", you were guided with possible ways to move on with your code.

If you want spoon-feeding, and have things served on a silver platter, the section to use is called Plugin/Gameplay Ideas and Requests.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-07-2018 , 23:04   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #6

Goto the scripting functions and put in trace.

If u trace straight down and the first hit is a player. Your on their head.
__________________
Neuro Toxin is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 08-07-2018 , 23:42   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #7

Quote:
Originally Posted by Fastmancz View Post
Very helpful answer... 🤦
If you want someone else to do your work for you, you've posted in the wrong section.
__________________
ddhoward is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 08-08-2018 , 00:05   Re: How to check if a player (CT/T) is on head (CT/T)?
Reply With Quote #8

Quote:
Originally Posted by arne1288 View Post
This one can appear rude towards someone who is actually trying to help you, so I strongly suggest you to pay more attention to where you post in the future:

Looking at the section name, which is "Scripting", and not "Spoon-feeding", you were guided with possible ways to move on with your code.

If you want spoon-feeding, and have things served on a silver platter, the section to use is called Plugin/Gameplay Ideas and Requests.
I'm sorry for my mistake. I didn't understand how Neuro Toxin thought it.

Thanks to Franc1sco, Neuro Toxin. It works.
__________________


Main owner of the CMGPORTAL.CZ.
---------------------------------------
My plugins:
[CS:GO] Panorama - Timeleft
[CS:GO] JailBreak - Be quiet, please!
Fastmancz 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 12:11.


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