AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ] Execute ham x times (https://forums.alliedmods.net/showthread.php?t=293311)

Airkish 01-28-2017 21:17

[REQ] Execute ham x times
 
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)




Bugsy 01-29-2017 18:54

Re: [REQ] Execute ham x times
 
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;



Airkish 01-29-2017 19:07

Re: [REQ] Execute ham x times
 
Quote:

Originally Posted by Bugsy (Post 2490979)
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!

Bugsy 01-29-2017 19:13

Re: [REQ] Execute ham x times
 
Can regular players without any of those flags trigger this and if so what is the limit for them?

Airkish 01-29-2017 19:35

Re: [REQ] Execute ham x times
 
Quote:

Originally Posted by Bugsy (Post 2490981)
Can regular players without any of those flags trigger this and if so what is the limit for them?

They can't

Bugsy 01-29-2017 20:20

Re: [REQ] Execute ham x times
 
Above code has been edited

Airkish 01-29-2017 20:33

Re: [REQ] Execute ham x times
 
Quote:

Originally Posted by Bugsy (Post 2490991)
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


All times are GMT -4. The time now is 20:58.

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