AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   AFK Management: Edit this script (https://forums.alliedmods.net/showthread.php?t=75608)

Mlk27 08-08-2008 23:29

AFK Management: Edit this script
 
hi. can anyone please remove function that kicks players for being unassigned to any teams and not choosing any models in this script?

thanks in advanced

+1 k

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN    "Hobo AFK Manager"
#define AUTHOR    "hoboman313"
#define VERSION    "1.2a"

#define MAX_PLAYERS 32
//Admins with this flag cannot be kicked
#define AFK_IMMUNITY ADMIN_IMMUNITY
#define AFK_MOVE_DIST 15

#define OFFSET_TEAM 114
#define OFFSET_INTERNALMODEL 126

#define PUNISH_UNASSIGNED 0
#define PUNISH_SPECTATOR 1
#define PUNISH_AFK_SPECTATOR 2
#define PUNISH_AFK_KICK 3
#define PUNISH_NOMODEL 4


enum CsInternalModel
{
    
CS_DONTCHANGE 0,
    
CS_CT_URBAN 1,
    
CS_T_TERROR 2,
    
CS_T_LEET 3,
    
CS_T_ARCTIC 4,
    
CS_CT_GSG9 5,
    
CS_CT_GIGN 6,
    
CS_CT_SAS 7,
    
CS_T_GUERILLA 8,
    
CS_CT_VIP 9,
    
CZ_T_MILITIA 10,
    
CZ_CT_SPETSNAZ 11
}

enum CsTeams
{
    
CS_TEAM_UNASSIGNED 0,
    
CS_TEAM_T 1,
    
CS_TEAM_CT 2,
    
CS_TEAM_SPECTATOR 3
}

new 
g_oldangles[MAX_PLAYERS+1][3], g_afktime[MAX_PLAYERS+1], saved_freqbool:freezetimeOver
new bool:player_spawned[MAX_PLAYERS+1],  msgSyncmaxplayersbool:selectedNoModel[MAX_PLAYERS+1]
//cvars
new maxAfkTimeaImmunitykickkickPlayersunassignedTimewarning_timecheck_frequency

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
check_frequencyregister_cvar("hobo_afk_frequency""1.0")
    
maxAfkTime register_cvar("hobo_afk_time""60")
    
aImmunity register_cvar("hobo_afk_immunity""1")
    
kick register_cvar("hobo_afk_kick""0")
    
kickPlayers register_cvar("hobo_afk_spectator_kick""16")
    
unassignedTime register_cvar("hobo_afk_unassigned_time""60")
    
warning_time register_cvar("hobo_afk_warning_time""10" )

    
msgSync CreateHudSyncObj()
    
maxplayers get_maxplayers()

    
register_logevent("round_start_event"2"1=Round_Start")

    
RegisterHam(Ham_Spawn"player""player_spawn"1)

    if( 
get_cvar_num("mp_freezetime") > )
        
register_event("HLTV""event_new_round""a""1=0""2=0")

    
saved_freq=get_pcvar_num(check_frequency)
    
set_task(get_pcvar_float(check_frequency), "checkPlayers"31337__"b")
}


public 
player_spawn(id)
{
    if( 
is_user_alive(id) && !is_user_bot(id) )
    {
        new 
arrId[1]
        
arrId[0]=id
        
//player isn't considered spawned until he drops to the ground
        
set_task0.5"playerSpawned"idarrId1  )
    }
}


public 
event_new_round()
    
freezetimeOver=false


public round_start_event()
{
    for( new 
1<= maxplayersi++ )
    {
        
player_spawned[i] = false

        
if( is_user_connected(i) && ( fm_get_user_team(i) == CS_TEAM_CT || fm_get_user_team(i) == CS_TEAM_T ) && !is_user_alive(i) && checkImmunity(i) )
        {
            if( 
selectedNoModel[i] == true )
                
punish_playeriPUNISH_NOMODEL )

            
selectedNoModel[i]=true
        
}
        else
            
selectedNoModel[i]=false
    
}

    if( 
saved_freq != get_pcvar_num(check_frequency) )
    {
        
change_task31337get_pcvar_float(check_frequency) )
        
saved_freq get_pcvar_num(check_frequency)
    }

    
freezetimeOver=true
}


public 
checkPlayers()
{
    static 
newangle[3]

    if(
freezetimeOver)
    {
        for ( new 
1<= maxplayersi++ )
        {
            if ( 
is_user_alive(i) && player_spawned[i] )
            {
                
get_user_origininewangle )

                if ( 
abs(newangle[0]-g_oldangles[i][0]) < AFK_MOVE_DIST && abs(newangle[1]-g_oldangles[i][1]) < AFK_MOVE_DIST && abs(newangle[2]-g_oldangles[i][2]) < AFK_MOVE_DIST )
                {
                    
g_afktime[i] += get_pcvar_num(check_frequency)

                    
check_afktime(i)
                }
                else
                {
                    
g_oldangles[i][0] = newangle[0]
                    
g_oldangles[i][1] = newangle[1]
                    
g_oldangles[i][2] = newangle[2]
                    
g_afktime[i] = 0
                
}
            }
        }
    }
}


public 
check_afktime(id)
{
    new 
afkTimeTmp get_pcvar_nummaxAfkTime ), afkTimeLeftkickOrSpect

    
static punishName[17]

    
afkTimeLeft afkTimeTmp g_afktime[id]

    if ( 
afkTimeLeft <= get_pcvar_num(warning_time) )
    {
        if( ( 
get_pcvar_num(kick) || get_playersnum() > get_pcvar_num(kickPlayers) ) && checkImmunity(id) )
        {
            
kickOrSpect=1
            punishName
="kicked"
        
}
        else
        {
            
kickOrSpect=0
            punishName
="put to Spectator"
        
}

        if(
afkTimeLeft>0)
        {
            
set_hudmessage(0100200, -1.00.2510.13.00.050.05, -1)
            
ShowSyncHudMsgidmsgSync"You have %d seconds to move or you will be %s for being AFK"afkTimeLeftpunishName )
        }
    }

    if( 
g_afktime[id] >= afkTimeTmp )
    {
        if( 
kickOrSpect==)
            
punish_player(idPUNISH_AFK_KICK )
        else
            
punish_player(idPUNISH_AFK_SPECTATOR )

        
g_afktime[id]=0
    
}
}


public 
client_disconnect(id)
{
    
g_afktime[id] = 0
    selectedNoModel
[id]= false
}


//a player connected so we must find and kick a spectator if there are any
public client_putinserver(id)
{
    if( 
is_user_bot(id) || is_user_hltv(id) )
        return

    if( 
checkImmunity(id) )
    {
        new 
arrId[1]
        
arrId[0] = id
        set_task
get_pcvar_floatunassignedTime ), "check_unassigned"id+40arrId)
    }

    if( 
get_playersnum() > get_pcvar_num(kickPlayers) )
    {
        for( new 
i=1i<=maxplayersi++ )
        {
            if( 
is_user_connected(i) && fm_get_user_team(i) == CS_TEAM_SPECTATOR && checkImmunity(i) )
            {
                
punish_playeriPUNISH_SPECTATOR )
                break
            }
        }
    }
}


public 
check_unassignedarrId[] )
{
    new 
id=arrId[0]

    
//if the player is unassigned after x seconds then kick him
    
if( is_user_connected(id) && fm_get_user_teamid ) == CS_TEAM_UNASSIGNED )
        
punish_playeridPUNISH_UNASSIGNED )
}


public 
playerSpawned(arrId[])
{
    new 
id=arrId[0]
    
get_user_originidg_oldangles[id] )
    
player_spawned[id] = true
}


stock punish_playeridpunishType )
{
    static 
name[32]
    
get_user_name(idname31)

    switch(
punishType)
    {
        case 
PUNISH_UNASSIGNED:
        {
            
client_print0print_chat"%s was kicked for being unnassigned longer than %d seconds"nameget_pcvar_num(unassignedTime) )
            
server_cmd("kick #%d ^"You were kicked for being unassigned for more than %d seconds^""get_user_userid(id ), get_pcvar_num(unassignedTime) )
        }
        case 
PUNISH_SPECTATOR:
        {
            
client_print0print_chat"%s was kicked for spectating on a server with more than %d players"nameget_pcvar_num(kickPlayers) )
            
server_cmd"kick #%d ^"The server is getting too full to allow spectators^""get_user_userid(id) )
        }
        case 
PUNISH_AFK_KICK:
        {
            
client_print(0print_chat"%s was kicked for being AFK longer than %d seconds"nameget_pcvar_num(maxAfkTime) )
            
server_cmd("kick #%d ^"You were kicked for being AFK longer than %d seconds^""get_user_userid(id), get_pcvar_num(maxAfkTime) )
        }
        case 
PUNISH_AFK_SPECTATOR:
        {
            
client_print(0print_chat"%s was put to Spectator for being AFK longer than %d seconds"nameget_pcvar_num(maxAfkTime) )
            
user_silentkill(id)
            
fm_set_user_teamidCS_TEAM_SPECTATOR )
        }
        case 
PUNISH_NOMODEL:
        {
            
client_print(0print_chat"%s was kicked for joining a team and idling without choosing a model."name )
            
server_cmd("kick #%d ^"You were kicked for joining a team and idling without choosing a model.^""get_user_userid(id) )
        }
    }
}


public 
checkImmunity(id)
{
    
//if immunity is disabled
    
if( get_pcvar_num(aImmunity)==)
        return 
true
    
//admin has AFK_IMMUNITY flag
    
else if( get_user_flags(id) & AFK_IMMUNITY )
        return 
false

    
return true
}


stock fm_set_user_team(idCsTeams:team)
{
    
set_pdata_int(idOFFSET_TEAM_:team)

    
dllfunc(DLLFunc_ClientUserInfoChangedid)

    static 
teaminfo[12], iMsgid_TeamInfo
    
switch(team)
    {
        case 
CS_TEAM_UNASSIGNED:
            
teaminfo="UNASSIGNED"
        
case CS_TEAM_T:
            
teaminfo="TERRORIST"
        
case CS_TEAM_CT:
            
teaminfo="CT"
        
case CS_TEAM_SPECTATOR:
            
teaminfo="SPECTATOR"
    
}

    if(!
iMsgid_TeamInfo)
        
iMsgid_TeamInfo get_user_msgid("TeamInfo")

    
message_begin(MSG_ALLiMsgid_TeamInfo)
    
write_byte(id)
    
write_string(teaminfo)
    
message_end()
}


stock CsTeams:fm_get_user_team(id)
    return 
CsTeams:get_pdata_int(idOFFSET_TEAM


AntiBots 08-08-2008 23:36

Re: AFK Management: Edit this script
 
Delete:
PHP Code:

public check_unassignedarrId[] ) 

    new 
id=arrId[0
 
    
//if the player is unassigned after x seconds then kick him 
    
if( is_user_connected(id) && fm_get_user_teamid ) == CS_TEAM_UNASSIGNED 
        
punish_playeridPUNISH_UNASSIGNED 


And:

PHP Code:

        case PUNISH_UNASSIGNED
        { 
            
client_print0print_chat"%s was kicked for being unnassigned longer than %d seconds"nameget_pcvar_num(unassignedTime) ) 
            
server_cmd("kick #%d ^"You were kicked for being unassigned for more than %d seconds^""get_user_userid(id ), get_pcvar_num(unassignedTime) ) 
        } 

</SPAN>

Mlk27 08-09-2008 00:07

Re: AFK Management: Edit this script
 
thanks. i just updated my first post. i need to remove kick for not choosing models as well.


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

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