AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check times help (https://forums.alliedmods.net/showthread.php?t=188604)

Killer zm 06-28-2012 10:43

Check times help
 
I made an plugin for zombie plague mod where I checking if an human shot in head an AFK zombie then victim will be kicked .but I need to check this for many times because i tested and if an zombie is not moving and i shot in head he is kicked from first head shot and i need to be kicked from a many head shots here is the code .

in the code you will se farm ... i am not shure what is mean for you but i called this when 2 players make team to make ammo packs faster , when zonbie stay and human shot him to make more ammo packs .

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>

#define m_LastHitGroup        75   

new g_oldangles[33][3]


public 
plugin_init() 
{
    
register_plugin("Anti-Farm","1.0","killer zm"
    
    
RegisterHamHam_TakeDamage"player""CheckFarmers");
    
}

public 
CheckFarmers(victiminflictorattackerFloat:damagedamage_type
{
    for (new 
1<= get_maxplayers(); i++) 
    {    
    
        if( 
is_user_alive(i) && zp_get_user_zombie(i) && get_pdata_intim_LastHitGroup ) == HIT_HEAD )
        {    
        
            if (
is_user_alive(i) && zp_get_user_zombie(i) && is_user_connected(i)) 
            {
                new 
newangle[3]
                
get_user_origin(inewangle)
                
                if ( 
newangle[0] == g_oldangles[i][0] && newangle[1] == g_oldangles[i][1] && newangle[2] == g_oldangles[i][2] ) 
                {
                    new 
name[32]
                    
get_user_name(iname31)
                    
                    new 
afkattacker attacker
                        
                    client_print
(0print_chat"[A-F] %s was kicked for farm with %s"nameafkattacker)
                    
log_amx("[A-F] %s was kicked for farm with %i"nameafkattacker)
                    
server_cmd("kick #%d ^"[A-FYou was kicked for farm with %s^""get_user_authid(victim), afkattacker)
    
                } 
                else 
                {
                    
g_oldangles[i][0] = newangle[0]
                    
g_oldangles[i][1] = newangle[1]
                    
g_oldangles[i][2] = newangle[2]
                    return 
PLUGIN_CONTINUE
                
}
            
            }
        }    
    }
    return 
PLUGIN_HANDLED    



hornet 06-28-2012 11:01

Re: Check times help
 
This is what I wrote after you PMed me. I haven't tested it but it should work quite accurately to what you want.
Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta> #include <cstrike> #define AFK_KICK_TIME       5.0 #define TIME_UNTOUCHED      3.0 #define m_LastHitGroup      75 enum ( += 32 ) {     TASK_KICK =         1000,     TASK_SUBCHECK } new Float: g_flLastHitTime[ 33 ]; public plugin_init() {     RegisterHam( Ham_TakeDamage, "player", "ham_TakeDamage_Post", 1 ); } public client_disconnect( id ) {     remove_task( id + TASK_KICK );     remove_task( id + TASK_SUBCHECK ); } public ham_TakeDamage_Post( iVictim, iInflictor, iAttacker ) {     if( iAttacker && cs_get_user_team( iAttacker ) == CS_TEAM_CT && cs_get_user_team( iVictim ) == CS_TEAM_T         && get_pdata_int( iVictim, m_LastHitGroup ) == HIT_HEAD )     {         static Float: flVelocity[ 3 ];                 pev( iVictim, pev_velocity, flVelocity );                 if( vector_length( flVelocity ) < 1.0 )         {             g_flLastHitTime[ iVictim ] = get_gametime();                         if( !task_exists( iVictim + TASK_KICK ) )             {                 set_task( AFK_KICK_TIME, "task_Kick", iVictim + TASK_KICK );                 set_task( 0.2, "task_SubCheck", iVictim + TASK_SUBCHECK );             }         }     } } public task_SubCheck( id ) {     static Float: flVelocity[ 3 ];             pev( id, pev_velocity, flVelocity );             if( vector_length( flVelocity ) > 0.0 || get_gametime() - g_flLastHitTime[ id ] > TIME_UNTOUCHED )     {         remove_task( id + TASK_KICK );         remove_task( id + TASK_SUBCHECK );     }     else    set_task( 0.2, "task_SubCheck", id + TASK_SUBCHECK ); } public task_Kick( id ) {     id -= TASK_KICK;         server_cmd( "kick #%i ^"Inactive for too long!^"", get_user_userid( id ) ); }

Killer zm 06-28-2012 16:26

Re: Check times help
 
is not working can you just make for my code before kick check for x times, because my code is orking but player get kick if is not moving and at first head shot and i want to be kicked at 5 or more headshots ... please ...

hornet 06-28-2012 21:32

Re: Check times help
 
The method I made will work over time, not the amount of headshots. I didn't build off your code because it seems pointless to loop through players to solve this.
I'll make it for you later, but you should have an amount of time where if the player hasn't been shot then the amount of hits will reset, which is what I did, but instead I made the timer reset.


All times are GMT -4. The time now is 06:05.

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