View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-06-2017 , 23:14   Re: Ham_Touch spam issue
Reply With Quote #8

Instead of putting a timer on the touch, you can track the last player that was touched and not register a touch again until a different player is touched.

1 touches 2 [touch fires]
1 touches 2 [nothing happens]
1 touches 2 [nothing happens]
1 touches 4 [touch fires]
1 touches 4 [nothing happens]
1 touches 2 [touch fires]

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

#define MAX_PLAYERS 32

#define IsPlayer(%1)    (1<=%1<=MAX_PLAYERS)

new g_LastTouchedMAX_PLAYERS ];

public 
plugin_init() 
{
    
RegisterHamHam_Touch "player" "PlayerTouch" );
}

public 
client_connectid 
{
    
g_LastTouchedid ] = 0;
}

public 
PlayerTouchid player 
{
    if ( 
IsPlayerid ) && IsPlayerplayer ) )
    {
        if ( 
g_LastTouchedid ] != player )
        {
            
//Touched player
            
client_printid print_chat "Touched %d" player );
        }
        
        
g_LastTouchedid ] = player;
    }

__________________
Bugsy is offline