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

Catch the event of a player untouching an entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RockTheStreet
New Member
Join Date: Oct 2023
Old 10-27-2023 , 12:44   Catch the event of a player untouching an entity
Reply With Quote #1

Hi.

Ladies and gentlemen, can you tell me how to catch an antach by a player to the essence?
Through register_touch I detect touch. It is also necessary to catch the untouch.
RockTheStreet is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-27-2023 , 15:32   Re: Catch the event of a player untouching an entity
Reply With Quote #2

If you rethink about it you will find it is not possible and the term untouching an entity doesn't exist...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
RockTheStreet
New Member
Join Date: Oct 2023
Old 10-27-2023 , 16:41   Re: Catch the event of a player untouching an entity
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
If you rethink about it you will find it is not possible and the term untouching an entity doesn't exist...
Let's go from the other side.

Is there a function to check whether the player is touching the entity or not? So that the condition can check whether the player is in contact with the entity or not.
RockTheStreet is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 10-27-2023 , 18:10   Re: Catch the event of a player untouching an entity
Reply With Quote #4

register_touch

to detect when it's not touching anymore, hook the think of player entity when touching and check if it's in touched entity area using find_entity_in_sphere

Last edited by lexzor; 10-27-2023 at 18:13.
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-27-2023 , 23:15   Re: Catch the event of a player untouching an entity
Reply With Quote #5

Quote:
Originally Posted by RockTheStreet View Post
Let's go from the other side.

Is there a function to check whether the player is touching the entity or not? So that the condition can check whether the player is in contact with the entity or not.
If you want to check if a certain player is not colliding with an entity simply check the player size if it is colliding with entity size...

You can do it in player prethink

PHP Code:

............

static 
Float:fOrigin1[3], Float:fOrigin2[3], Float:fMaxs1[3], Float:fMins1[3], Float:fMaxs2[3], Float:fMins2[3];
pev(idpev_originfOrigin1);
pev(idpev_maxsfMaxs1);
pev(idpev_minsfMins1);

xs_vec_add(fMaxs1fOrigin1fMaxs1);
xs_vec_add(fMins1fOrigin1fMins1);

pev(g_entitypev_originfOrigin2);
pev(g_entitypev_maxsfMaxs2);
pev(g_entitypev_minsfMins2);

xs_vec_add(fMaxs2fOrigin2fMaxs2);
xs_vec_add(fMins2fOrigin2fMins2);

if(!
BoundsIntersect(fMins1fMaxs1fMins2fMaxs2))
{
   
// Entities do not collide or touch!
}

...........

bool:BoundsIntersect(const  Float:mins1[3], const  Float:maxs1[3], const  Float:mins2[3], const Float:maxs2[3])
{
    if (
mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
        return 
false;
    if (
maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
        return 
false;
    return 
true;

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-27-2023 at 23:25.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
RockTheStreet
New Member
Join Date: Oct 2023
Old 10-28-2023 , 06:28   Re: Catch the event of a player untouching an entity
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
If you want to check if a certain player is not colliding with an entity simply check the player size if it is colliding with entity size...

You can do it in player prethink

PHP Code:

............

static 
Float:fOrigin1[3], Float:fOrigin2[3], Float:fMaxs1[3], Float:fMins1[3], Float:fMaxs2[3], Float:fMins2[3];
pev(idpev_originfOrigin1);
pev(idpev_maxsfMaxs1);
pev(idpev_minsfMins1);

xs_vec_add(fMaxs1fOrigin1fMaxs1);
xs_vec_add(fMins1fOrigin1fMins1);

pev(g_entitypev_originfOrigin2);
pev(g_entitypev_maxsfMaxs2);
pev(g_entitypev_minsfMins2);

xs_vec_add(fMaxs2fOrigin2fMaxs2);
xs_vec_add(fMins2fOrigin2fMins2);

if(!
BoundsIntersect(fMins1fMaxs1fMins2fMaxs2))
{
   
// Entities do not collide or touch!
}

...........

bool:BoundsIntersect(const  Float:mins1[3], const  Float:maxs1[3], const  Float:mins2[3], const Float:maxs2[3])
{
    if (
mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
        return 
false;
    if (
maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
        return 
false;
    return 
true;

I like this option better.
Thanks, I'll try.
RockTheStreet is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 10-29-2023 , 06:30   Re: Catch the event of a player untouching an entity
Reply With Quote #7

It's possible, in register_touch use set_task with 0.1 or for more accuracy do RequestFrame and in the callback check if the player is still touching the entity.
__________________

Last edited by JusTGo; 10-29-2023 at 06:31.
JusTGo is offline
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
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 06:35.


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