Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

HPK


  • Zamknięty Temat jest zamknięty
2 odpowiedzi w tym temacie

#1 per_b.

    Życzliwy

  • Użytkownik

Reputacja: 1
Nowy

  • Postów:34
  • Lokalizacja:..
Offline

Napisano 28.10.2009 19:35

mam sobie taki kodzik HPK

#include <amxmodx>

#define TaskTime 15.0
#define HowManyChecks 10
#define ExtraPing 150		// ExtraPing + g_MaxPing : If a user has a ping above this, his ping Offense counter goes up 5 instead of 1

#define MAXPLAYERS 32
#define CheckUpdateRate 1	// 1 = Uses menu  | 2 = auto changes settings
#define UseSetInfo  1
#define HPK_IMMUNITY ADMIN_IMMUNITY

new g_PingOffence[MAXPLAYERS+1]
new g_CheckPlayer[MAXPLAYERS+1]		// To save the poor cpu having to keep track of the connected players
new g_MaxPing

#if CheckUpdateRate != 0
new g_MinUpdateRate
new g_MinRate
#endif
new g_MaxPlayers

#define PluginVersion "1.1.4"

public plugin_init() 
{
	register_plugin("Yet Another High Ping Kicker",PluginVersion,"EKS")
#if CheckUpdateRate == 1
	register_menucmd(register_menuid("yZbyt niskie cl_updaterate:"),1023,"MenuCheckSelection")
#endif
  	
#if CheckUpdateRate != 0
   	register_cvar("amx_minupdaterate","40")
	register_cvar("amx_minrate","10000")
#endif
	register_cvar("amx_maxping","200")
	register_cvar("amx_maxping_add","50")
	
	register_cvar("yhpk_version",PluginVersion,FCVAR_SERVER)
	set_task(TaskTime,"Task_CheckPlayers",64,_,_,"b")
	return PLUGIN_CONTINUE
}
public plugin_cfg()
{
	g_MaxPlayers = get_maxplayers()
	g_MaxPing = get_cvar_num("amx_maxping")
	
#if CheckUpdateRate != 0
	g_MinUpdateRate = get_cvar_num("amx_minupdaterate")
	g_MinRate = get_cvar_num("amx_minrate")
#endif

	new sTimeH[4] // Contains the hour in a sting
	get_time("%H",sTimeH,3) 
	new TimeH = str_to_num(sTimeH)
	if (TimeH < 14)
	{
		g_MaxPing = g_MaxPing + get_cvar_num("amx_maxping_add")
		server_print("[HPK] Time is %d, added +%d to maxping(%d)",TimeH,get_cvar_num("amx_maxping_add"),g_MaxPing)
	}
	else
		server_print("[HPK] Time is %d, maxping(%d)",TimeH,g_MaxPing)
}
public client_putinserver(id) 
{
	if(is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id))
		set_task(20.0,"Task_ActivatePingCheck",id,_,_,"a",1)		// Since when the user "just" connected, his ping is high, we dont want to get a false detection
}
public Task_ActivatePingCheck(id) 
{
	g_PingOffence[id] = 0
	g_CheckPlayer[id] = 1
#if CheckUpdateRate != 0	
	client_print(id,print_chat,"[HPK] Maksymalny dopuszczalny ping to  %d, a najnizsze dopuszczalne cl_updaterate to %d",g_MaxPing,g_MinUpdateRate)
#else
	client_print(id,print_chat,"[HPK] Maksymalny dopuszczalny ping to  %d",g_MaxPing)
#endif
}

public client_disconnect(id) 
{
	g_CheckPlayer[id] = 0
	remove_task(id)
}
public Task_CheckPlayers()
{
	for(new i=1;i<=g_MaxPlayers;i++) if(g_CheckPlayer[i])
		CheckPing(i)
   }

stock CheckPing(id)
{
#if CheckUpdateRate != 0
	new TempString[10]
	get_user_info(id,"cl_updaterate",TempString,9)
	new clrate = str_to_num(TempString)
	get_user_info(id,"rate",TempString,9)
	new rate = str_to_num(TempString) 
#endif

	new ping,loss
	get_user_ping(id,ping,loss)

	if(ping > g_MaxPing)
	{
		if(ping >= ExtraPing+g_MaxPing) g_PingOffence[id] = g_PingOffence[id] + 5		// If the user has a ping ExtraPing + g_MaxPing, he gets +5 instead of +1 in his ping offence counter
		else g_PingOffence[id]++
		
		if(g_PingOffence[id] >= HowManyChecks)
		{
			new Name[32],Auth[35]
			get_user_name(id,Name,31)
			get_user_authid(id,Auth,34)
			client_print(0,print_chat,"[HPK] %s zostal wyrzucony za zbyt wysoki ping %d",Name,g_MaxPing)
			server_cmd("kick #%d Zbyt duzy ping",get_user_userid(id))
			log_amx("%s<%s> zostal wyrzucony za zbyt wysoki ping (tj. %d)",Name,Auth,ping)
			return PLUGIN_CONTINUE
		}
		client_print(id,print_chat,"[HPK] Twoj ping przekracza %d, ogarnij go lub opusc serwer.",g_MaxPing)
	}
#if CheckUpdateRate == 1
	if(clrate < g_MinUpdateRate || rate < g_MinRate)
	{
		if(g_CheckPlayer[id] == 1 || g_CheckPlayer[id] == 3)
		{
		    ShowMenu(id)
		    
		    if(g_CheckPlayer[id] == 3)
			    g_CheckPlayer[id] = 2
		    else
		    {
			    g_CheckPlayer[id] = 2
		    }
		}
	}
	else if(clrate < g_MinUpdateRate && g_CheckPlayer[id] == 2)
	{
		new Name[32],Auth[35]
		get_user_name(id,Name,31)
		get_user_authid(id,Auth,34)
		client_print(0,print_chat,"[HPK] %s zostal wyrzucony za zbyt niskie cl_updaterate(%d)/rate(%d)",Name,clrate,rate)
		server_cmd("kick #%d Too low a cl_updaterate",get_user_userid(id))	
		log_amx("%s<%s> zostal wyrzucony za zbyt niskie cl_updaterate(%d)/rate(%d)",Name,Auth,clrate,rate)
		return PLUGIN_CONTINUE
	}
#endif
#if CheckUpdateRate == 2
	if(clrate < g_MinUpdateRate)
	{
#if UseSetInfo == 1
		format(TempString,9,"%d",g_MinUpdateRate)
		set_user_info(id,"cl_updaterate",TempString)
#else
	        client_cmd(id,"cl_updaterate %d",g_MinUpdateRate)
#endif
		client_print(id,print_chat,"[HPK] Twoj updaterate zostal zwiekszony do %d",g_MinUpdateRate)
	}
	if(rate < g_MinRate)
	{
#if UseSetInfo == 1
		format(TempString,9,"%d",g_MinRate)
		set_user_info(id,"rate",TempString)
#else
	        client_cmd(id,"rate %d",g_MinRate)
#endif
		client_print(id,print_chat,"[HPK] Twoj updaterate zostal zwiekszony do %d",g_MinRate)		
	}
#endif

	//client_print(id,3,"%d mial ping: %d(%d) loss %d clrate %d(%d) Rate: %d (%d)",id,ping,g_MaxPing,loss,clrate,g_MinUpdateRate,rate,g_MinRate)
	return PLUGIN_CONTINUE
}

#if CheckUpdateRate == 1
public ShowMenu(id)
{ 
	new szMenuBody[151] 
	new len,keys 
	len = format(szMenuBody,255,"y Zbyt niskie cl_updaterate/rate:^n Zwieksz cl_updaterate/rate lub opusc serwer")
	len += format(szMenuBody[len],150 - len,"^nw 1. Zwieksz do %d",g_MinUpdateRate) 
	len += format(szMenuBody[len],150 - len,"^nw 2. Opusc serwer") 


	keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9) 
	show_menu( id, keys, szMenuBody, -1 ) 
	return PLUGIN_CONTINUE 
}
public MenuCheckSelection(id,key) // Called by ShowReadyMenu
{ 
	new Name[32],Auth[35]
	get_user_name(id,Name,31)
	get_user_authid(id,Auth,34)
	
	if(key == 0) 
	{
		client_print(0,print_chat,"[HPK] %s wybral zwieksenie cl_updaterate/rate",Name)
		log_amx("%s<%s> wybral zwieksenie cl_updaterate/rate",Name,Auth)		
		client_cmd(id,"cl_updaterate %d",g_MinUpdateRate)
		client_cmd(id,"rate %d",g_MinRate)
	}
	else if(key == 1)
	{
		client_print(0,print_chat,"[HPK] %s odmowil zwieksenia cl_updaterate/rate",Name)
		server_cmd("kick #%d Zbyt niskie cl_updaterate/rate",get_user_userid(id))	
		log_amx("%s<%s> odmowil zwieksenia cl_updaterate/rate",Name,Auth)
	}
	else	// Made a wrong selection
		ShowMenu(id)

	return PLUGIN_CONTINUE
}
#endif

i nie wiem w który mmiejscu dodać

if ( get_user_flags(id) & HPK_IMMUNITY) {
        remove_task(id)
        client_print(id, print_chat, "[HPK] Sprawdzanie pingu Cie nie obejmuje, poniewaz masz immunitet...")
        return PLUGIN_CONTINUE
    }
żeby nie wywalało adminow z flagą a :|
próbowałem w public Task_ActivatePingCheck(id) ale wyskakuje błąd podczas kompilacji .. co robie źle ?;>
  • +
  • -
  • 0

#2 kasza

    Godlike

  • Przyjaciel

Reputacja: 887
Czempion

  • Postów:4102
  • GG:
  • Steam:steam
  • Imię:Imię
  • Lokalizacja:Lokalizacja
Offline

Napisano 28.10.2009 19:40

#define HPK_IMMUNITY ADMIN_IMMUNITY
wtdaje mi sie ze to juz jest
  • +
  • -
  • 0

Skillownia.com

 

 #3 [UWC3NG] Skillownia.com - 213.189.52.253:27301

 


#3 per_b.

    Życzliwy

  • Autor tematu
  • Użytkownik

Reputacja: 1
Nowy

  • Postów:34
  • Lokalizacja:..
Offline

Napisano 28.10.2009 19:49

#define HPK_IMMUNITY ADMIN_IMMUNITY
wtdaje mi sie ze to juz jest

no bo to tam dodałem
przeciez pozniej jest uzyte w sprawdzaniu flag HPK_IMMUNITY

[ Dodano: 29-10-2009, 22:11 ]
co znaczy błąd loose indentation

/groups/amxmodx/tmp3/text3zgDfE.sma(33) : warning 217: loose indentation
/groups/amxmodx/tmp3/text3zgDfE.sma(122) : warning 217: loose indentation

wstawiłem ten if do sprawdzania flag w stock checkping(id) , kompiluje mi ale wywala te 2 błędy up^

#include <amxmodx>

#define TaskTime 15.0
#define HowManyChecks 10
#define ExtraPing 150        // ExtraPing + g_MaxPing : If a user has a ping above this, his ping Offense counter goes up 5 instead of 1

#define MAXPLAYERS 32
#define CheckUpdateRate 1    // 1 = Uses menu  | 2 = auto changes settings
#define UseSetInfo  1
#define HPK_IMMUNITY ADMIN_IMMUNITY

new g_PingOffence[MAXPLAYERS+1]
new g_CheckPlayer[MAXPLAYERS+1]        // To save the poor cpu having to keep track of the connected players
new g_MaxPing

#if CheckUpdateRate != 0
new g_MinUpdateRate
new g_MinRate
#endif
new g_MaxPlayers

#define PluginVersion "1.1.4"

public plugin_init()
{
    register_plugin("Yet Another High Ping Kicker",PluginVersion,"EKS")
#if CheckUpdateRate == 1
    register_menucmd(register_menuid("yZbyt niskie cl_updaterate:"),1023,"MenuCheckSelection")
#endif
     
#if CheckUpdateRate != 0
       register_cvar("amx_minupdaterate","40")
    register_cvar("amx_minrate","10000")
#endif
    register_cvar("amx_maxping","200")
    register_cvar("amx_maxping_add","50")
   
    register_cvar("yhpk_version",PluginVersion,FCVAR_SERVER)
    set_task(TaskTime,"Task_CheckPlayers",64,_,_,"b")
    return PLUGIN_CONTINUE
}
public plugin_cfg()
{
    g_MaxPlayers = get_maxplayers()
    g_MaxPing = get_cvar_num("amx_maxping")
   
#if CheckUpdateRate != 0
    g_MinUpdateRate = get_cvar_num("amx_minupdaterate")
    g_MinRate = get_cvar_num("amx_minrate")
#endif

    new sTimeH[4] // Contains the hour in a sting
    get_time("%H",sTimeH,3)
    new TimeH = str_to_num(sTimeH)
    if (TimeH < 14)
    {
        g_MaxPing = g_MaxPing + get_cvar_num("amx_maxping_add")
        server_print("[HPK] Time is %d, added +%d to maxping(%d)",TimeH,get_cvar_num("amx_maxping_add"),g_MaxPing)
    }
    else
        server_print("[HPK] Time is %d, maxping(%d)",TimeH,g_MaxPing)

}
public client_putinserver(id)
{
    if(is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id))
        set_task(20.0,"Task_ActivatePingCheck",id,_,_,"a",1)        // Since when the user "just" connected, his ping is high, we dont want to get a false detection
}
public Task_ActivatePingCheck(id)
{
    g_PingOffence[id] = 0
    g_CheckPlayer[id] = 1
#if CheckUpdateRate != 0   
    client_print(id,print_chat,"[HPK] Maksymalny dopuszczalny ping to  %d, a najnizsze dopuszczalne cl_updaterate to %d",g_MaxPing,g_MinUpdateRate)
#else
    client_print(id,print_chat,"[HPK] Maksymalny dopuszczalny ping to  %d",g_MaxPing)
#endif
}


public client_disconnect(id)
{
    g_CheckPlayer[id] = 0
    remove_task(id)
}
public Task_CheckPlayers()
{
    for(new i=1;i<=g_MaxPlayers;i++) if(g_CheckPlayer[i])
        CheckPing(i)
   }

stock CheckPing(id)
{
#if CheckUpdateRate != 0
    new TempString[10]
    get_user_info(id,"cl_updaterate",TempString,9)
    new clrate = str_to_num(TempString)
    get_user_info(id,"rate",TempString,9)
    new rate = str_to_num(TempString)
#endif

    new ping,loss
    get_user_ping(id,ping,loss)

    if(ping > g_MaxPing)
    {
        if(ping >= ExtraPing+g_MaxPing) g_PingOffence[id] = g_PingOffence[id] + 5        // If the user has a ping ExtraPing + g_MaxPing, he gets +5 instead of +1 in his ping offence counter
        else g_PingOffence[id]++
       
        if(g_PingOffence[id] >= HowManyChecks)
        {
            new Name[32],Auth[35]
            get_user_name(id,Name,31)
            get_user_authid(id,Auth,34)
            client_print(0,print_chat,"[HPK] %s zostal wyrzucony za zbyt wysoki ping %d",Name,g_MaxPing)
            server_cmd("kick #%d Zbyt duzy ping",get_user_userid(id))
            log_amx("%s<%s> zostal wyrzucony za zbyt wysoki ping (tj. %d)",Name,Auth,ping)
            return PLUGIN_CONTINUE
        }
        client_print(id,print_chat,"[HPK] Twoj ping przekracza %d, ogarnij go lub opusc serwer.",g_MaxPing)
    }
 if ( get_user_flags(id) & HPK_IMMUNITY) {
        remove_task(id)
        client_print(id, print_chat, "[HPK] Sprawdzanie pingu Cie nie obejmuje, poniewaz masz immunitet...")
        return PLUGIN_CONTINUE
    }

#if CheckUpdateRate == 1
    if(clrate < g_MinUpdateRate || rate < g_MinRate)
    {
        if(g_CheckPlayer[id] == 1 || g_CheckPlayer[id] == 3)
        {
            ShowMenu(id)
           
            if(g_CheckPlayer[id] == 3)
                g_CheckPlayer[id] = 2
            else
            {
                g_CheckPlayer[id] = 2
            }
        }
    }
    else if(clrate < g_MinUpdateRate && g_CheckPlayer[id] == 2)
    {
        new Name[32],Auth[35]
        get_user_name(id,Name,31)
        get_user_authid(id,Auth,34)
        client_print(0,print_chat,"[HPK] %s zostal wyrzucony za zbyt niskie cl_updaterate(%d)/rate(%d)",Name,clrate,rate)
        server_cmd("kick #%d Too low a cl_updaterate",get_user_userid(id))   
        log_amx("%s<%s> zostal wyrzucony za zbyt niskie cl_updaterate(%d)/rate(%d)",Name,Auth,clrate,rate)
        return PLUGIN_CONTINUE
    }
#endif
#if CheckUpdateRate == 2
    if(clrate < g_MinUpdateRate)
    {
#if UseSetInfo == 1
        format(TempString,9,"%d",g_MinUpdateRate)
        set_user_info(id,"cl_updaterate",TempString)
#else
            client_cmd(id,"cl_updaterate %d",g_MinUpdateRate)
#endif
        client_print(id,print_chat,"[HPK] Twoj updaterate zostal zwiekszony do %d",g_MinUpdateRate)
    }
    if(rate < g_MinRate)
    {
#if UseSetInfo == 1
        format(TempString,9,"%d",g_MinRate)
        set_user_info(id,"rate",TempString)
#else
            client_cmd(id,"rate %d",g_MinRate)
#endif
        client_print(id,print_chat,"[HPK] Twoj updaterate zostal zwiekszony do %d",g_MinRate)       
    }
#endif

    //client_print(id,3,"%d mial ping: %d(%d) loss %d clrate %d(%d) Rate: %d (%d)",id,ping,g_MaxPing,loss,clrate,g_MinUpdateRate,rate,g_MinRate)
    return PLUGIN_CONTINUE
}

#if CheckUpdateRate == 1
public ShowMenu(id)
{
    new szMenuBody[151]
    new len,keys
    len = format(szMenuBody,255,"y Zbyt niskie cl_updaterate/rate:^n Zwieksz cl_updaterate/rate lub opusc serwer")
    len += format(szMenuBody[len],150 - len,"^nw 1. Zwieksz do %d",g_MinUpdateRate)
    len += format(szMenuBody[len],150 - len,"^nw 2. Opusc serwer")


    keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
    show_menu( id, keys, szMenuBody, -1 )
    return PLUGIN_CONTINUE
}
public MenuCheckSelection(id,key) // Called by ShowReadyMenu
{
    new Name[32],Auth[35]
    get_user_name(id,Name,31)
    get_user_authid(id,Auth,34)
   
    if(key == 0)
    {
        client_print(0,print_chat,"[HPK] %s wybral zwieksenie cl_updaterate/rate",Name)
        log_amx("%s<%s> wybral zwieksenie cl_updaterate/rate",Name,Auth)       
        client_cmd(id,"cl_updaterate %d",g_MinUpdateRate)
        client_cmd(id,"rate %d",g_MinRate)
    }
    else if(key == 1)
    {
        client_print(0,print_chat,"[HPK] %s odmowil zwieksenia cl_updaterate/rate",Name)
        server_cmd("kick #%d Zbyt niskie cl_updaterate/rate",get_user_userid(id))   
        log_amx("%s<%s> odmowil zwieksenia cl_updaterate/rate",Name,Auth)
    }
    else    // Made a wrong selection
        ShowMenu(id)

    return PLUGIN_CONTINUE
}
#endif

  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych