Raised This Month: $ Target: $400
 0% 

Get player touch with different player on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-13-2013 , 18:45   Get player touch with different player on death
Reply With Quote #1

How to check player touch or not with different player on death?

Last edited by FromTheFuture; 04-13-2013 at 19:11.
FromTheFuture is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 11:19   Re: Get player touch with different player on death
Reply With Quote #2

Hi. I decided to try to make the check.
Here's the code:

PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("test""1""didoWEE");
    
RegisterHam(Ham_Killed"player""HookKill"1);
}

public 
HookKill(victimkiller)
{
    if(!
is_user_connected(killer)) return HAM_IGNORED;
    if(!
is_user_connected(victim)) return HAM_IGNORED;
    
    new 
Float:VecVictimOrigin[3];
    new 
Float:VecKillerOrigin[3];
    
    
entity_get_vector(victimEV_VEC_originVecVictimOrigin);
    
entity_get_vector(killerEV_VEC_originVecKillerOrigin);
    
    if(
VecVictimOrigin[0] - VecKillerOrigin[0] == 16.0 /* If they touch on X axis */
    
|| VecKillerOrigin[0] - VecVictimOrigin[0] == 16.0 /* If they touch on X axis */
    
|| VecVictimOrigin[1] - VecKillerOrigin[1] == 16.0 /* If they touch on Y axis */
    
|| VecKillerOrigin[1] - VecVictimOrigin[1] == 16.0 /* If they touch on Y axis */
    
|| VecVictimOrigin[2] - VecKillerOrigin[2] == 72.0 /* If they touch on Z axis, no duck*/
    
|| VecKillerOrigin[2] - VecVictimOrigin[2] == 72.0 /* If they touch on Z axis, no duck*/
    
|| VecVictimOrigin[2] - VecKillerOrigin[2] == 54.0 /* If they touch on Z axis, one of them is ducking*/
    
|| VecKillerOrigin[2] - VecVictimOrigin[2] == 54.0 /* If they touch on Z axis, one of them is ducking*/
    
|| VecVictimOrigin[2] - VecKillerOrigin[2] == 36.0 /* If they touch on Z axis, they both are ducking*/
    
|| VecKillerOrigin[2] - VecVictimOrigin[2] == 36.0/* If they touch on Z axis, they both are ducking*/
    
{
        
// do something if they are touching
    
}
    else
    {
        
// do something if they are not touching
    
}
    
    return 
HAM_IGNORED;

BTW, I don't know if it is working ...

Last edited by didoWEE; 04-15-2013 at 11:20.
didoWEE is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-15-2013 , 11:47   Re: Get player touch with different player on death
Reply With Quote #3

Quote:
Originally Posted by didoWEE View Post
Hi. I decided to try to make the check.
Here's the code:

BTW, I don't know if it is working ...
Thank You, I need it, but I want to check who from my team was touching me and I must do it with cycle, it will be hard to server?
Or better will be if I do this with register_touch forward?
FromTheFuture is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-15-2013 , 12:03   Re: Get player touch with different player on death
Reply With Quote #4

didoWEE,Victim cannot be not connected
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 12:15   Re: Get player touch with different player on death
Reply With Quote #5

Quote:
Originally Posted by Bos93 View Post
didoWEE,Victim cannot be not connected
Lol ?? And can you tell me why ?

Quote:
Originally Posted by FromTheFuture View Post
Or better will be if I do this with register_touch forward?
I think I know how to do it. However first I will try other way. I'll post it leter

Last edited by didoWEE; 04-15-2013 at 12:24.
didoWEE is offline
tonykaram1993
Senior Member
Join Date: Mar 2013
Location: This World
Old 04-15-2013 , 12:20   Re: Get player touch with different player on death
Reply With Quote #6

Not connected means not in the server. How can a player (not in the server) and be a victim at the same time?
When you hooked "Ham_Killed" you hooked it to a "player" and not something else, so that check is unnecessary.
__________________
My Plugins:
UltimatePlugin
UltimateSurf
UltimateAdmin
Code:
rcon version | rcon amxx version | rcon meta version
rcon amxx plugins | rcon meta list | rcon status
I AM INACTIVE ON THIS FORUM - For direct contact: [email protected]
tonykaram1993 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-15-2013 , 12:37   Re: Get player touch with different player on death
Reply With Quote #7

Try this:
Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta> #define m_iPlayerTeam   114 public plugin_init() {     RegisterHam( Ham_Killed, "player", "CBase_PlayerKilled" ); } public CBase_PlayerKilled( iVictim/*, iAttacker, shouldgib*/ ) {     new Players[ 32 ], i, iEnt = -1;     new Float:flOrigin[ 3 ], szClass[ 32 ];         pev( iVictim, pev_origin, flOrigin );         while( ( iEnt = engfunc( EngFunc_FindEntityInSphere, iEnt, flOrigin, 20.0 ) ) )     {           if( iEnt == iVictim)             continue;                 pev( iEnt, pev_classname, szClass, charsmax( szClass ) );                 if( equal( szClass, "player" ) )         {             if( get_pdata_int( iVictim, m_iPlayerTeam ) == get_pdata_int( iEnt, m_iPlayerTeam ) )             {                 Players[ i ] = iEnt;                 i++;             }         }     }         //Array Players is a list of each team player you were touching when you died }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 12:40   Re: Get player touch with different player on death
Reply With Quote #8

Quote:
Originally Posted by didoWEE View Post
However first I will try other way. I'll post it leter
PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("test""1""didoWEE");
    
RegisterHam(Ham_Killed"player""HookKill"1);
}

public 
HookKill(victimkiller)
{
    if(!
is_user_connected(killer)) return HAM_IGNORED;
    
// if(!is_user_connected(victim)) return HAM_IGNORED;
    // Maybe you are right ...
    
    
new CsTeams:team cs_get_user_team(victim);
    
    new 
Float:VecVictimOrigin[3];
    
entity_get_vector(victimEV_VEC_originVecVictimOrigin);
    
    new 
id = -1;
    
    new 
Float:VecTeammateOrigin[3];
    
    while((
id find_ent_in_sphere(idVecVictimOrigin72.0)) != 0)
    {
        if(
cs_get_user_team(id) != team) continue;
        
        
entity_get_vector(idEV_VEC_originVecTeammateOrigin);
        
        if(
VecVictimOrigin[0] - VecTeammateOrigin[0] == 16.0
        
|| VecTeammateOrigin[0] - VecVictimOrigin[0] == 16.0
        
|| VecVictimOrigin[1] - VecTeammateOrigin[1] == 16.0
        
|| VecTeammateOrigin[1] - VecVictimOrigin[1] == 16.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 72.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 72.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 54.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 54.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 36.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 36.0)
        {
            
// do something if they are touching
        
}
        else
        {
            
// do something if they are not touching
        
}
    }
    return 
HAM_IGNORED;


Last edited by didoWEE; 04-15-2013 at 12:50. Reason: Optimazed :D
didoWEE is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-15-2013 , 12:54   Re: Get player touch with different player on death
Reply With Quote #9

Quote:
Originally Posted by didoWEE View Post
PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("test""1""didoWEE");
    
RegisterHam(Ham_Killed"player""HookKill"1);
}

public 
HookKill(victimkiller)
{
    if(!
is_user_connected(killer)) return HAM_IGNORED;
    
// if(!is_user_connected(victim)) return HAM_IGNORED; // Maybe you are right ...
    
    
new CsTeams:team cs_get_user_team(victim);
    
    new 
Float:VecVictimOrigin[3];
    
entity_get_vector(victimEV_VEC_originVecVictimOrigin);
    
    new 
id = -1;
    new 
Float:VecTeammateOrigin[3];
    
    while((
id find_ent_in_sphere(idVecVictimOrigin72.0)) != 0)
    {
        if(
cs_get_user_team(id) != team) continue;
        
        
entity_get_vector(idEV_VEC_originVecTeammateOrigin);
        
        if(
VecVictimOrigin[0] - VecTeammateOrigin[0] == 16.0
        
|| VecTeammateOrigin[0] - VecVictimOrigin[0] == 16.0
        
|| VecVictimOrigin[1] - VecTeammateOrigin[1] == 16.0
        
|| VecTeammateOrigin[1] - VecVictimOrigin[1] == 16.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 72.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 72.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 54.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 54.0
        
|| VecVictimOrigin[2] - VecTeammateOrigin[2] == 36.0
        
|| VecTeammateOrigin[2] - VecVictimOrigin[2] == 36.0)
        {
            
// do something if they are touching
        
}
        else
        {
            
// do something if they are not touching
        
}
    }
    
    return 
HAM_IGNORED;

What's to say that your loop won't find an entity that isn't a player?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-15-2013 , 12:57   Re: Get player touch with different player on death
Reply With Quote #10

Quote:
Originally Posted by hornet View Post
What's to say that your loop won't find an entity that isn't a player?
Ty

PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("test""1""didoWEE");
    
RegisterHam(Ham_Killed"player""HookKill"1);
}

public 
HookKill(victimkiller)
{
    if(!
is_user_connected(killer)) return HAM_IGNORED;
    
// if(!is_user_connected(victim)) return HAM_IGNORED;
    // Maybe you are right ...
    
    
new CsTeams:team cs_get_user_team(victim);
    
    new 
Float:VecFlVictimOrigin[3];
    
entity_get_vector(victimEV_VEC_originVecFlVictimOrigin);
    
    new 
id = -1;
    
    new 
Float:VecFlTeammateOrigin[3];
    
    while((
id find_ent_in_sphere(idVecFlVictimOrigin72.0)) != 0)
    {
        
// if(!is_user_connected(id)) continue;
        
if(!is_user_alive(id)) continue; // won't give you errors if is_user_alive checks is_user_connected
        
if(cs_get_user_team(id) != team) continue;
        
        
entity_get_vector(idEV_VEC_originVecFlTeammateOrigin);
        
        if(
VecFlVictimOrigin[0] - VecFlTeammateOrigin[0] == 16.0
        
|| VecFlTeammateOrigin[0] - VecFlVictimOrigin[0] == 16.0
        
|| VecFlVictimOrigin[1] - VecFlTeammateOrigin[1] == 16.0
        
|| VecFlTeammateOrigin[1] - VecFlVictimOrigin[1] == 16.0
        
|| VecFlVictimOrigin[2] - VecFlTeammateOrigin[2] == 72.0
        
|| VecFlTeammateOrigin[2] - VecFlVictimOrigin[2] == 72.0
        
|| VecFlVictimOrigin[2] - VecFlTeammateOrigin[2] == 54.0
        
|| VecFlTeammateOrigin[2] - VecFlVictimOrigin[2] == 54.0
        
|| VecFlVictimOrigin[2] - VecFlTeammateOrigin[2] == 36.0
        
|| VecFlTeammateOrigin[2] - VecFlVictimOrigin[2] == 36.0)
        {
            
// do something if they are touching
        
}
        else
        {
            
// do something if they are not touching
        
}
    }
    return 
HAM_IGNORED;


Last edited by didoWEE; 04-15-2013 at 12:59.
didoWEE 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 10:55.


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