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

Triggering entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
safetymoose
Senior Member
Join Date: Feb 2015
Old 06-05-2015 , 16:51   Triggering entities
Reply With Quote #1

Hi guys,

I need your help to capture an event where a certain entity gets triggered. For example, we have a door that is triggered to open/close by a button. I would like to send a message when someone opens or closes this door. I can catch when someone presses the button, but the problem is that people can spam the button, and it would flood messages. I would like to catch the exact moment when the door gets triggered.

something like "Player pressed the button and the door opened"

Multiple players could be spamming the button at the same time, but the message should only come once with the player who actually opened the door.

And i'm not just talking about doors, it could be any type of entity, triggered by a button.

What would you recommend?

Last edited by safetymoose; 06-05-2015 at 17:06.
safetymoose is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-05-2015 , 18:10   Re: Triggering entities
Reply With Quote #2

If you want to reset the buttons at any point so that they can be used again, call ClearEntsUsed(). Add as many button classnames as you'd like. I have 'func_button' below and also did 'hostage_entity' as a second example.
PHP Code:

#include <amxmodx>
#include <hamsandwich>

const ENTS_ARRAY_SIZE 64;

new 
g_bEntityUsedENTS_ARRAY_SIZE ];

public 
plugin_init()
{
    
RegisterHamHam_Use "func_button" "Ham_ButtonUse" );
    
RegisterHamHam_Use "hostage_entity" "Ham_ButtonUse" );
}

public 
Ham_ButtonUseiEntity iUser idActivator iUseType Float:fValue )

    new 
szName33 ];

    if ( ( 
iUseType == ) && ( fValue == 1.0 ) && is_user_aliveiUser ) )
    {
        if ( ( 
g_bEntityUsediEntity >> ] & (<< ( iEntity 31 ) ) ) )
        {
            return 
HAM_SUPERCEDE;
        }
        else
        {
            
get_user_nameiUser szName charsmaxszName ) );
            
client_printprint_chat "* Button was used by %s!" szName );
            
            
g_bEntityUsediEntity >> ] |= ( << ( iEntity 31 ) );
        }
    }
    
    return 
HAM_IGNORED;
}

public 
ClearEntsUsed()
{
    for ( new 
ENTS_ARRAY_SIZE i++ )
        
g_bEntityUsed] = 0;

__________________

Last edited by Bugsy; 06-06-2015 at 00:13.
Bugsy is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 06-06-2015 , 17:48   Re: Triggering entities
Reply With Quote #3

this is good to know, but it's not what i'm looking for.

I am trying to catch the moment when the button actually triggers the door to open/close. For example, it takes the door 5 seconds to open/close. The button can be pressed every 1 second. When i catch the use of the button, i only need the moment where it actually triggers the door, and ignore the other time it's pressed.

I thought about using a timer, but that is a bad idea, and it will not work for different situations...
safetymoose is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-06-2015 , 17:50   Re: Triggering entities
Reply With Quote #4

Its the first click though, right? There is just a delay for when the actual door moves.
__________________
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 23:21.


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