Raised This Month: $ Target: $400
 0% 

[REQ] Execute ham x times


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 01-28-2017 , 21:17   [REQ] Execute ham x times
Reply With Quote #1

I have a little plugin which triggers button by simply shooting at him, however I need to limit trigger count.

After x shots, player won't be able to trigger button anymore. Count to restart on new round

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

public plugin_init()
{
    
RegisterHam(Ham_TraceAttack"func_button""Ham_UseButton")
}



public 
Ham_UseButtoniEntiAttackerFloat:fDamageFloat:vDirection[3], TraceHandleiDamageBits 
{
    if(!
is_valid_ent(iEnt) || !is_user_alive(iAttacker) || get_user_flags(iAttacker) & ADMIN_RESERVATION)
        return;

    
ExecuteHamB(Ham_TouchiEntiAttacker)
    
entity_set_float(iEntEV_FL_frame0.0)


__________________
Airkish is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-29-2017 , 18:54   Re: [REQ] Execute ham x times
Reply With Quote #2

Untested
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>

#define MAX_PLAYERS 32

enum LimitTypes
{
    
Immunity,
    
Kick,
    
Reservation
}

new const 
TriggerLimitLimitTypes ] = 
{
    
999999,
    
2,
    
1
};

enum PlayerData
{
    
TriggerCount,
    
LimitTypes:LimitType
}

new 
g_TriggerDataMAX_PLAYERS ][ PlayerData ];

public 
plugin_init()
{
    
RegisterHamHam_TraceAttack "func_button" "Ham_UseButton" )
    
register_logevent"RoundStart" "1=Round_Start" )  
}

public 
client_authorizedid )
{
    new 
iFlags get_user_flagsid );
    
    if ( 
iFlags ADMIN_IMMUNITY )
    {
        
g_TriggerDataid ][ LimitType ] = Immunity;
    }
    else if ( 
iFlags ADMIN_KICK )
    {
        
g_TriggerDataid ][ LimitType ] = Kick;
    }
    else if ( 
iFlags ADMIN_RESERVATION )
    {
        
g_TriggerDataid ][ LimitType ] = Reservation;
    }
}
    
public 
Ham_UseButtoniEnt iAttacker Float:fDamage Float:vDirection] , TraceHandle iDamageBits 
{
    if( ( 
g_TriggerDataiAttacker ][ TriggerCount ] < TriggerLimitg_TriggerDataiAttacker ][ LimitType ] ] ) && is_valid_entiEnt ) && is_user_aliveiAttacker ) )
    {
        
ExecuteHamBHam_Touch iEnt iAttacker )
        
entity_set_floatiEnt EV_FL_frame 0.0 )
        
g_TriggerDataiAttacker ][ TriggerCount ]++;
    }
}

public 
RoundStart()
{
    for ( new 
sizeofg_TriggerData ) ; i++ )
        
g_TriggerData][ TriggerCount ] = 0;

__________________

Last edited by Bugsy; 01-29-2017 at 20:20.
Bugsy is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 01-29-2017 , 19:07   Re: [REQ] Execute ham x times
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Untested
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>

#define MAX_PLAYERS 32

const TriggerLimit 5;

new 
g_TriggerCountMAX_PLAYERS ];

public 
plugin_init()
{
    
RegisterHamHam_TraceAttack "func_button" "Ham_UseButton" )
    
register_logevent"RoundStart" "1=Round_Start" )  
}

public 
Ham_UseButtoniEnt iAttacker Float:fDamage Float:vDirection] , TraceHandle iDamageBits 
{
    if( ( 
g_TriggerCountiAttacker ] < TriggerLimit ) && is_valid_entiEnt ) && is_user_aliveiAttacker ) && !( get_user_flagsiAttacker ) & ADMIN_RESERVATION ) )
    {
        
ExecuteHamBHam_Touch iEnt iAttacker )
        
entity_set_floatiEnt EV_FL_frame 0.0 )
        
g_TriggerCountiAttacker ]++;
    }
}

public 
RoundStart()
{
    
arraysetg_TriggerCount sizeofg_TriggerCount ) );

Works!

I need another edit if u could:
Different TriggerCount for specific flag
ADMIN_RESERVATION 1
ADMIN_KICK 2
ADMIN_IMMUNITY unlimited
Thanks!
__________________
Airkish is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-29-2017 , 19:13   Re: [REQ] Execute ham x times
Reply With Quote #4

Can regular players without any of those flags trigger this and if so what is the limit for them?
__________________

Last edited by Bugsy; 01-29-2017 at 19:22.
Bugsy is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 01-29-2017 , 19:35   Re: [REQ] Execute ham x times
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Can regular players without any of those flags trigger this and if so what is the limit for them?
They can't
__________________
Airkish is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-29-2017 , 20:20   Re: [REQ] Execute ham x times
Reply With Quote #6

Above code has been edited
__________________
Bugsy is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 01-29-2017 , 20:33   Re: [REQ] Execute ham x times
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Above code has been edited
Thanks!

Not related to this request but could u take a look at this?
https://forums.alliedmods.net/showthread.php?t=293287
__________________
Airkish 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 20:58.


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