View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-29-2023 , 12:40   Re: Catch the event of a player untouching an entity
Reply With Quote #8

I got this to work between 2 player entities

PHP Code:

#include <amxmodx>
#include <engine>

new g_TouchedEntsMAX_PLAYERS ][ ][ 32 ];

#define SetBit(%1,%2)    (%1[%2>>5] |= (1<<(%2 & 31)))

public plugin_init() 
{
    
register_touch"player" "player" "PlayerTouched" );
    
    
set_task0.5 "CheckBits" , .flags="b" );
}

public 
PlayerTouchediTouched iToucher )
{
    
SetBitg_TouchedEntsiToucher ][ ] , iTouched );
}

public 
CheckBits()
{
    static 
szName132 ] , szName232 ];
    
    for ( new 
<= MAX_PLAYERS i++ )
    {
        if ( !
is_user_connected) ) continue;
        
        for ( new 
sizeofg_TouchedEnts[][] ) ; p++ )
        {
            for ( new 
32 k++ )
            {
                if ( !( 
g_TouchedEnts][ ][ ] & ( << ) ) && ( g_TouchedEnts][ ][ ] & ( << ) ) ) 
                {
                    
get_user_nameszName1 charsmaxszName1 ) );
                    
get_user_nameszName2 charsmaxszName2 ) );
                    
                    
client_printprint_chat "* %s stopped touching %s" szName1 szName2 );    
                }
            }
            
            
g_TouchedEnts][ ][ ] = g_TouchedEnts][ ][ ];
            
g_TouchedEnts][ ][ ] = 0;
        }
    }

__________________

Last edited by Bugsy; 10-29-2023 at 13:47.
Bugsy is offline