Заявка за plugin [AFK]

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
bobywTf
Извън линия
Потребител
Потребител
Мнения: 21
Регистриран на: 21 Ное 2021, 14:28
Се отблагодари: 6 пъти
Получена благодарност: 3 пъти

Заявка за plugin [AFK]

Мнение от bobywTf » 14 Яну 2022, 01:08

Здравейте, някой може ли да направи плъгин като BAD Camper, да излиза метър с секундите и като стигне на 100% да слапва по 5 дмг + съобщение в чата по избор ["играч" "текст"] докато не стигне на 5HP и след това да го изкара в Spectator + [съобщение по избор].
Благодаря предварително ако на някой му се занимава ! :yahoo:

Аватар
TryAgain
Извън линия
Потребител
Потребител
Мнения: 157
Регистриран на: 25 Яну 2017, 16:59
Се отблагодари: 1 път
Получена благодарност: 13 пъти

Заявка за plugin [AFK]

Мнение от TryAgain » 14 Яну 2022, 01:28

wrath @ AFK Control

Но не съм сигурен дали е това ,където търсиш.

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <cromchat>
#include <fun>	// for setting HP on "hurt" punishment... rather not use...hmm

#pragma semicolon 1


// ***************************************************
// ******************** DEFINES **********************

#define PLUGIN "AFManager"
#define VERSION "1.0"
#define AUTHOR "melbs"

#define MAX_LENGTH 32
#define CHECK_TASK 31337

// ****** types of punishment ******
#define POKE	1
#define PROD	2
#define HURT	3
#define SLAY	4
#define MOVE	5
#define KICK	6

// ****** cvar defines ******
#define AFKCMD		"afm_afkcmd",		"1"	// allow "say /afk" command
#define AFKTIME 	"afm_afktime",		"25.0"	// amount of time to be marked as afk
#define ANNOUNCE	"afm_announce",		"1"	// announce punishments to server
#define CHECKTIME	"afm_checktime",	"7.0"	// time between checks
#define DROPBOMB	"afm_dropbomb",		"1"	
#define ENABLE		"afm_enable",		"1"
#define HPTICKAMOUNT	"afm_hptickamount",	"5"	// health subtracted when punishment is hp drop
#define HPTICKTIME	"afm_hpticktime",	"5"	// time between health being taken
#define LOG		"afm_log",		"0"	// log actions
#define MINPLAYERS	"afm_minplayers",	"2"	// min player # for checking afks
#define PREFIX		"afm_prefix",		"[afk]"	// the name of afks. If useprefix == 1
#define PUNISHMENT 	"afm_punishment",	"2"	// type of punishment
#define USEPREFIX	"afm_useprefix",	"0"	// add prefix to afkers?
#define JOIN_SPEC_TEXT	"Tvoq text tuk"

// ***************************************************
// ******************** GLOBALS **********************
new const AMX_SAYLANG[]="[AFM] %L";
new g_playersnum;
new g_players[MAX_LENGTH];
new Float:g_times[MAX_LENGTH+1] = { 0.0, ... }; // sum time players are afk
new g_origins[MAX_LENGTH+1][3];	// NOTE: initializes to garbage; this is not a problem
				// g_origins[0] used as a tmp for comparison in main loop			
// ****** variable pointers ******
new g_pcv_afkcmd;
new g_pcv_afktime;
new g_pcv_announce;
new g_pcv_checktime;
new g_pcv_dropbomb;
new g_pcv_enable;
new g_pcv_hptickamount;
new g_pcv_hpticktime;
new g_pcv_log;
new g_pcv_minplayers;
new g_pcv_prefix;
new g_pcv_punishment;
new g_pcv_useprefix;
new g_pcv_freezetime;


// ***************************************************
// ******************* FUNCTIONS *********************

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("afm_version",VERSION, FCVAR_SERVER|FCVAR_SPONLY);

	// register variables
	g_pcv_afkcmd = 		register_cvar(AFKCMD);
	g_pcv_afktime = 	register_cvar(AFKTIME);
	g_pcv_announce = 	register_cvar(ANNOUNCE);
	g_pcv_checktime = 	register_cvar(CHECKTIME);
	g_pcv_dropbomb = 	register_cvar(DROPBOMB);
	g_pcv_enable = 		register_cvar(ENABLE);
	g_pcv_hptickamount  = 	register_cvar(HPTICKAMOUNT);
	g_pcv_hpticktime  = 	register_cvar(HPTICKTIME);
	g_pcv_log = 		register_cvar(LOG);
	g_pcv_minplayers  = 	register_cvar(MINPLAYERS);
	g_pcv_prefix = 		register_cvar(PREFIX);
	g_pcv_punishment = 	register_cvar(PUNISHMENT);
	g_pcv_useprefix = 	register_cvar(USEPREFIX);

	register_dictionary("afm_lang.txt");

	// register for new round event, so we know when freezetime is happening
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
	
	register_clcmd("say /afk", "move_afk_cmd",-1, "- Move to spectate to afk for a bit");
	
	g_pcv_freezetime = get_cvar_pointer("mp_freezetime");
}

public event_new_round()
{
	remove_task(CHECK_TASK);

	// if the plugin is enabled and has minimum required players
	if( is_enabled() && get_playersnum() >= get_minplayers() ) {
		new Float:freezetime = get_freezetime();
		
		if ( freezetime == 0.0 )
			start_check_afk_think(0);
		else
			set_task(freezetime, "start_check_afk_think", CHECK_TASK);
	}
	
	return PLUGIN_CONTINUE;
}
	
public move_afk_cmd(p_player)
{
	if( afkcmd_enabled() )
		move_to_spec(p_player);
	else
		client_print(p_player, print_console, AMX_SAYLANG, p_player, "NOACCESS");
}
	
public move_to_spec(p_player)
{
	new name[33];
	
	if( is_user_alive(p_player) )
	{
		// must kill to actually switch team
		user_kill(p_player, 1);	// slay but dont change k/d
		cs_set_user_deaths(p_player, cs_get_user_deaths(p_player) - 1);
	}
	
	cs_set_user_team(p_player, CS_TEAM_SPECTATOR);
	get_user_name(p_player, name, charsmax(name));
	CC_SendMessage(0, "[%s %s]", name, JOIN_SPEC_TEXT);
}

public start_check_afk_think(p_id)
	set_task(get_checkinterval(), "check_afk_think", CHECK_TASK,_,0,"b");

public check_afk_think(p_ent)
{
	get_players(g_players, g_playersnum);
	for(new i=0; i < g_playersnum; i++)
	{
		new player = g_players[i];
		
		// make sure the player is still alive to check origin
		if( is_user_alive(player) )
		{
			// get current position of player
			get_user_origin(player, g_origins[0]);
			
			// if origins are the same, assume the player has not moved. ignore gaps in interval
			if( equal(g_origins[player], g_origins[0], 3) ) {
				g_times[player] += get_checkinterval();
			} else {
				g_times[player] = 0.0;
				copy(g_origins[player], 3, g_origins[0]);	// copy the new origin to the old
			}

			new Float:afktime = get_afktime();
			if(g_times[player] >= afktime ) {
				handle_afk(player, afktime);	// the player is now considered AFK
			}
		}
	}

	return PLUGIN_CONTINUE;
}

handle_afk(p_player, Float:p_afktime)
{
	new afktime = floatround(p_afktime);
	new playername[MAX_LENGTH];
	get_user_name(p_player, playername, MAX_LENGTH - 1);
	
	switch ( get_punishment() )
	{
		case POKE:
		{
			client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_POKE", playername, afktime);
			do_log(p_player, playername, afktime, "LOG_POKE");
		}
		case PROD:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_PROD", playername, afktime);
				
			user_slap(p_player, 5);
			do_log(p_player, playername, afktime, "LOG_PROD");
		}
		case HURT:
		{
			// if already hurting player, do not handle
			if(!task_exists(p_player))
			{
				if(announcing_enabled())
					client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_HURT", playername, afktime);

				set_task( get_hpticktime(), "hurt_player", p_player, g_origins[p_player], 3, "b");
				do_log(p_player, playername, afktime, "LOG_HURT");
			}
		}
		case SLAY:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_SLAY", playername, afktime);
	
			user_kill(p_player, 1);	// slay but dont change k/d
			cs_set_user_deaths(p_player, cs_get_user_deaths(p_player) - 1);
			do_log(p_player, playername, afktime, "LOG_SLAY");
			
		}
		case MOVE:
		{
			if(announcing_enabled())
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_SPEC", playername, afktime);

			move_to_spec(p_player);
			do_log(p_player, playername, afktime, AMX_SAYLANG);
		}
		case KICK:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_KICK", playername, afktime);
					
			server_cmd("kick #%d ^"%L^"", get_user_userid(p_player), LANG_PLAYER, "DAS_BOOT", afktime);
			do_log(p_player, playername, afktime, "LOG_KICK");
		}
	}
	
	if( is_user_alive(p_player))
	{
		if(dropbomb_enabled() && user_has_weapon(p_player, CSW_C4)) // cs_get_user_team(pPlayer) == CS_TEAM_T &&
		{
			client_cmd(p_player,"drop weapon_c4 ");
	
			if(announcing_enabled())
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_BOMB", playername, afktime);
	
			do_log(p_player, playername, afktime, "LOG_BOMB");
		}
		
		if( prefix_enabled() )
		{
			new prefix[MAX_LENGTH];
			get_pcvar_string(g_pcv_prefix, prefix, MAX_LENGTH - 1);
			
			// if the name is not already prefixed
			if( !equal(playername, prefix, strlen(prefix)) ) {
				client_cmd(p_player, "name ^"%s%s^"", prefix, playername);
							
				if( logging_enabled() ) {
					log_amx(AMX_SAYLANG, LANG_SERVER, "LOG_NAME");
				}
			}
		}
	}
	
	g_times[p_player] = 0.0;	// reset time to save a few cycles next time
}

public hurt_player(const p_origin[], p_player)
{
	new tmporigins[3];
	get_user_origin(p_player, tmporigins);	// do this instead of checking g_origins because we
		// dont know how long the interval is set to.
	
	if(!equal(p_origin, tmporigins, 3))
		remove_task(p_player);
	else
		set_user_health(p_player, get_user_health(p_player) - get_hptickamount());
}

// all logs have the same information displayed, so it's easier to do it like this :)
do_log(p_player, const p_playername[], p_afktime, const p_langkey[])
{
	if( logging_enabled() )
	{
		new ip[MAX_LENGTH];
		new authid[MAX_LENGTH];
	
		get_user_ip(p_player, ip, MAX_LENGTH - 1);
		get_user_authid(p_player, authid, MAX_LENGTH - 1);
	
		log_amx(AMX_SAYLANG, LANG_SERVER, p_langkey, p_playername, authid, ip, p_afktime);
	}
}

stock prefix_enabled()
	return get_pcvar_num(g_pcv_useprefix);

stock dropbomb_enabled()
	return get_pcvar_num(g_pcv_dropbomb);

stock afkcmd_enabled()
	return get_pcvar_num(g_pcv_afkcmd);

stock Float:get_freezetime()
	return get_pcvar_float(g_pcv_freezetime);

stock is_enabled()
	return get_pcvar_num(g_pcv_enable);

stock Float:get_checkinterval()
	return get_pcvar_float(g_pcv_checktime);

stock Float:get_afktime()
	return get_pcvar_float(g_pcv_afktime);

stock get_minplayers()
	return get_pcvar_num(g_pcv_minplayers);

stock get_punishment()
	return get_pcvar_num(g_pcv_punishment);

public get_hptickamount()
	return get_pcvar_num(g_pcv_hptickamount);

stock Float:get_hpticktime()
	return get_pcvar_float(g_pcv_hpticktime);
	
stock announcing_enabled()
	return get_pcvar_num(g_pcv_announce);
	
stock logging_enabled()
	return get_pcvar_num(g_pcv_log);
На 42 ред си пишеш текста :)

Код за потвърждение: Избери целия код

#define JOIN_SPEC_TEXT	"Tvoq text tuk"

Аватар
bobywTf
Извън линия
Потребител
Потребител
Мнения: 21
Регистриран на: 21 Ное 2021, 14:28
Се отблагодари: 6 пъти
Получена благодарност: 3 пъти

Заявка за plugin [AFK]

Мнение от bobywTf » 14 Яну 2022, 14:36

TryAgain написа:
14 Яну 2022, 01:28
wrath @ AFK Control

Но не съм сигурен дали е това ,където търсиш.

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <cromchat>
#include <fun>	// for setting HP on "hurt" punishment... rather not use...hmm

#pragma semicolon 1


// ***************************************************
// ******************** DEFINES **********************

#define PLUGIN "AFManager"
#define VERSION "1.0"
#define AUTHOR "melbs"

#define MAX_LENGTH 32
#define CHECK_TASK 31337

// ****** types of punishment ******
#define POKE	1
#define PROD	2
#define HURT	3
#define SLAY	4
#define MOVE	5
#define KICK	6

// ****** cvar defines ******
#define AFKCMD		"afm_afkcmd",		"1"	// allow "say /afk" command
#define AFKTIME 	"afm_afktime",		"25.0"	// amount of time to be marked as afk
#define ANNOUNCE	"afm_announce",		"1"	// announce punishments to server
#define CHECKTIME	"afm_checktime",	"7.0"	// time between checks
#define DROPBOMB	"afm_dropbomb",		"1"	
#define ENABLE		"afm_enable",		"1"
#define HPTICKAMOUNT	"afm_hptickamount",	"5"	// health subtracted when punishment is hp drop
#define HPTICKTIME	"afm_hpticktime",	"5"	// time between health being taken
#define LOG		"afm_log",		"0"	// log actions
#define MINPLAYERS	"afm_minplayers",	"2"	// min player # for checking afks
#define PREFIX		"afm_prefix",		"[afk]"	// the name of afks. If useprefix == 1
#define PUNISHMENT 	"afm_punishment",	"2"	// type of punishment
#define USEPREFIX	"afm_useprefix",	"0"	// add prefix to afkers?
#define JOIN_SPEC_TEXT	"Tvoq text tuk"

// ***************************************************
// ******************** GLOBALS **********************
new const AMX_SAYLANG[]="[AFM] %L";
new g_playersnum;
new g_players[MAX_LENGTH];
new Float:g_times[MAX_LENGTH+1] = { 0.0, ... }; // sum time players are afk
new g_origins[MAX_LENGTH+1][3];	// NOTE: initializes to garbage; this is not a problem
				// g_origins[0] used as a tmp for comparison in main loop			
// ****** variable pointers ******
new g_pcv_afkcmd;
new g_pcv_afktime;
new g_pcv_announce;
new g_pcv_checktime;
new g_pcv_dropbomb;
new g_pcv_enable;
new g_pcv_hptickamount;
new g_pcv_hpticktime;
new g_pcv_log;
new g_pcv_minplayers;
new g_pcv_prefix;
new g_pcv_punishment;
new g_pcv_useprefix;
new g_pcv_freezetime;


// ***************************************************
// ******************* FUNCTIONS *********************

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	register_cvar("afm_version",VERSION, FCVAR_SERVER|FCVAR_SPONLY);

	// register variables
	g_pcv_afkcmd = 		register_cvar(AFKCMD);
	g_pcv_afktime = 	register_cvar(AFKTIME);
	g_pcv_announce = 	register_cvar(ANNOUNCE);
	g_pcv_checktime = 	register_cvar(CHECKTIME);
	g_pcv_dropbomb = 	register_cvar(DROPBOMB);
	g_pcv_enable = 		register_cvar(ENABLE);
	g_pcv_hptickamount  = 	register_cvar(HPTICKAMOUNT);
	g_pcv_hpticktime  = 	register_cvar(HPTICKTIME);
	g_pcv_log = 		register_cvar(LOG);
	g_pcv_minplayers  = 	register_cvar(MINPLAYERS);
	g_pcv_prefix = 		register_cvar(PREFIX);
	g_pcv_punishment = 	register_cvar(PUNISHMENT);
	g_pcv_useprefix = 	register_cvar(USEPREFIX);

	register_dictionary("afm_lang.txt");

	// register for new round event, so we know when freezetime is happening
	register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
	
	register_clcmd("say /afk", "move_afk_cmd",-1, "- Move to spectate to afk for a bit");
	
	g_pcv_freezetime = get_cvar_pointer("mp_freezetime");
}

public event_new_round()
{
	remove_task(CHECK_TASK);

	// if the plugin is enabled and has minimum required players
	if( is_enabled() && get_playersnum() >= get_minplayers() ) {
		new Float:freezetime = get_freezetime();
		
		if ( freezetime == 0.0 )
			start_check_afk_think(0);
		else
			set_task(freezetime, "start_check_afk_think", CHECK_TASK);
	}
	
	return PLUGIN_CONTINUE;
}
	
public move_afk_cmd(p_player)
{
	if( afkcmd_enabled() )
		move_to_spec(p_player);
	else
		client_print(p_player, print_console, AMX_SAYLANG, p_player, "NOACCESS");
}
	
public move_to_spec(p_player)
{
	new name[33];
	
	if( is_user_alive(p_player) )
	{
		// must kill to actually switch team
		user_kill(p_player, 1);	// slay but dont change k/d
		cs_set_user_deaths(p_player, cs_get_user_deaths(p_player) - 1);
	}
	
	cs_set_user_team(p_player, CS_TEAM_SPECTATOR);
	get_user_name(p_player, name, charsmax(name));
	CC_SendMessage(0, "[%s %s]", name, JOIN_SPEC_TEXT);
}

public start_check_afk_think(p_id)
	set_task(get_checkinterval(), "check_afk_think", CHECK_TASK,_,0,"b");

public check_afk_think(p_ent)
{
	get_players(g_players, g_playersnum);
	for(new i=0; i < g_playersnum; i++)
	{
		new player = g_players[i];
		
		// make sure the player is still alive to check origin
		if( is_user_alive(player) )
		{
			// get current position of player
			get_user_origin(player, g_origins[0]);
			
			// if origins are the same, assume the player has not moved. ignore gaps in interval
			if( equal(g_origins[player], g_origins[0], 3) ) {
				g_times[player] += get_checkinterval();
			} else {
				g_times[player] = 0.0;
				copy(g_origins[player], 3, g_origins[0]);	// copy the new origin to the old
			}

			new Float:afktime = get_afktime();
			if(g_times[player] >= afktime ) {
				handle_afk(player, afktime);	// the player is now considered AFK
			}
		}
	}

	return PLUGIN_CONTINUE;
}

handle_afk(p_player, Float:p_afktime)
{
	new afktime = floatround(p_afktime);
	new playername[MAX_LENGTH];
	get_user_name(p_player, playername, MAX_LENGTH - 1);
	
	switch ( get_punishment() )
	{
		case POKE:
		{
			client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_POKE", playername, afktime);
			do_log(p_player, playername, afktime, "LOG_POKE");
		}
		case PROD:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_PROD", playername, afktime);
				
			user_slap(p_player, 5);
			do_log(p_player, playername, afktime, "LOG_PROD");
		}
		case HURT:
		{
			// if already hurting player, do not handle
			if(!task_exists(p_player))
			{
				if(announcing_enabled())
					client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_HURT", playername, afktime);

				set_task( get_hpticktime(), "hurt_player", p_player, g_origins[p_player], 3, "b");
				do_log(p_player, playername, afktime, "LOG_HURT");
			}
		}
		case SLAY:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_SLAY", playername, afktime);
	
			user_kill(p_player, 1);	// slay but dont change k/d
			cs_set_user_deaths(p_player, cs_get_user_deaths(p_player) - 1);
			do_log(p_player, playername, afktime, "LOG_SLAY");
			
		}
		case MOVE:
		{
			if(announcing_enabled())
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_SPEC", playername, afktime);

			move_to_spec(p_player);
			do_log(p_player, playername, afktime, AMX_SAYLANG);
		}
		case KICK:
		{
			if(announcing_enabled()) 
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_KICK", playername, afktime);
					
			server_cmd("kick #%d ^"%L^"", get_user_userid(p_player), LANG_PLAYER, "DAS_BOOT", afktime);
			do_log(p_player, playername, afktime, "LOG_KICK");
		}
	}
	
	if( is_user_alive(p_player))
	{
		if(dropbomb_enabled() && user_has_weapon(p_player, CSW_C4)) // cs_get_user_team(pPlayer) == CS_TEAM_T &&
		{
			client_cmd(p_player,"drop weapon_c4 ");
	
			if(announcing_enabled())
				client_print(0, print_chat, AMX_SAYLANG, LANG_PLAYER, "MSG_BOMB", playername, afktime);
	
			do_log(p_player, playername, afktime, "LOG_BOMB");
		}
		
		if( prefix_enabled() )
		{
			new prefix[MAX_LENGTH];
			get_pcvar_string(g_pcv_prefix, prefix, MAX_LENGTH - 1);
			
			// if the name is not already prefixed
			if( !equal(playername, prefix, strlen(prefix)) ) {
				client_cmd(p_player, "name ^"%s%s^"", prefix, playername);
							
				if( logging_enabled() ) {
					log_amx(AMX_SAYLANG, LANG_SERVER, "LOG_NAME");
				}
			}
		}
	}
	
	g_times[p_player] = 0.0;	// reset time to save a few cycles next time
}

public hurt_player(const p_origin[], p_player)
{
	new tmporigins[3];
	get_user_origin(p_player, tmporigins);	// do this instead of checking g_origins because we
		// dont know how long the interval is set to.
	
	if(!equal(p_origin, tmporigins, 3))
		remove_task(p_player);
	else
		set_user_health(p_player, get_user_health(p_player) - get_hptickamount());
}

// all logs have the same information displayed, so it's easier to do it like this :)
do_log(p_player, const p_playername[], p_afktime, const p_langkey[])
{
	if( logging_enabled() )
	{
		new ip[MAX_LENGTH];
		new authid[MAX_LENGTH];
	
		get_user_ip(p_player, ip, MAX_LENGTH - 1);
		get_user_authid(p_player, authid, MAX_LENGTH - 1);
	
		log_amx(AMX_SAYLANG, LANG_SERVER, p_langkey, p_playername, authid, ip, p_afktime);
	}
}

stock prefix_enabled()
	return get_pcvar_num(g_pcv_useprefix);

stock dropbomb_enabled()
	return get_pcvar_num(g_pcv_dropbomb);

stock afkcmd_enabled()
	return get_pcvar_num(g_pcv_afkcmd);

stock Float:get_freezetime()
	return get_pcvar_float(g_pcv_freezetime);

stock is_enabled()
	return get_pcvar_num(g_pcv_enable);

stock Float:get_checkinterval()
	return get_pcvar_float(g_pcv_checktime);

stock Float:get_afktime()
	return get_pcvar_float(g_pcv_afktime);

stock get_minplayers()
	return get_pcvar_num(g_pcv_minplayers);

stock get_punishment()
	return get_pcvar_num(g_pcv_punishment);

public get_hptickamount()
	return get_pcvar_num(g_pcv_hptickamount);

stock Float:get_hpticktime()
	return get_pcvar_float(g_pcv_hpticktime);
	
stock announcing_enabled()
	return get_pcvar_num(g_pcv_announce);
	
stock logging_enabled()
	return get_pcvar_num(g_pcv_log);
На 42 ред си пишеш текста :)

Код за потвърждение: Избери целия код

#define JOIN_SPEC_TEXT	"Tvoq text tuk"
Пробвал съм го и не съм много доволен по добре със стария bad_camp.
Не е това което ми трябва.

Аватар
impossible
Извън линия
Потребител
Потребител
Мнения: 448
Регистриран на: 15 Юни 2019, 12:41
Се отблагодари: 23 пъти
Получена благодарност: 40 пъти

Заявка за plugin [AFK]

Мнение от impossible » 14 Яну 2022, 17:51

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <fun>
#define SND_STOP (1<<5)
new playercoord0[33][3]
new playercoord1[33][3]
new playercoord2[33][3]
new playercoord3[33][3]
new playercoord4[33][3]
new campmeter[33]
new bool:pausecounter[33]
new bool:bombplanted
new bool:de_map
new camptolerancedefending = 180
new camptoleranceattacking = 200
public sqrt(num) {
	new div = num; 
	new result = 1;
	while (div > result) {	// end when div == result, or just below
		div = (div + result) / 2	// take mean value as new divisor
		result = num / div
	}
	return div;
}
public unpausecounter(parm[]) {
	new id = parm[0]
	pausecounter[id] = false
	return PLUGIN_CONTINUE
}
public displaymeter(id) {
	if (get_cvar_num("anticamping_meter") != 0) {
		if (campmeter[id] > 100) {
			set_hudmessage(random(255), random(255), random(255), -1.0, 0.3, 2, 0.1, 1.5, 0.02, 0.02, -2)
			show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
		} else if (campmeter[id] > 90) {
			set_hudmessage(random(255), random(255), random(255), -1.0, 0.3, 2, 0.1, 1.5, 0.02, 0.02, -2)
			show_hudmessage(id,"Go away !!!^nYour CAMPMETER is %i%",campmeter[id])
		} else if (campmeter[id] > 80){
			set_hudmessage(random(255), random(255), random(255), -1.0, 0.3, 2, 0.1, 2.1, 0.02, 0.02, -2)
			show_hudmessage(id,"CAMPmeter: %i%",campmeter[id])
		} else if (campmeter[id] > 50 ) {
			set_hudmessage(random(255), random(255), random(255), -0.9, 0.3, 2, 0.1, 2.1, 0.02, 0.02, -2)
			show_hudmessage(id,"CampMeter: %i%",campmeter[id])
		} else if (campmeter[id] > 20 ) {
			set_hudmessage(random(255), random(255), random(255), -0.9, 0.3, 2, 0.1, 2.1, 0.02, 0.02, -2)
			show_hudmessage(id,"Campmeter: %i%",campmeter[id])
			
		}
	}
	return PLUGIN_HANDLED
}
public checkcamping(){
	if (get_cvar_num("anticamping") == 0){
		set_task(1.0,"checkcamping",1)
		return PLUGIN_CONTINUE
	}
	new players[32]
	new numberofplayers
	new variance[3]
	new average[3]
	new variancetotal
	new standarddeviation
	new id
	new team
	new i
	new j
	get_players(players, numberofplayers, "a")
	for (i = 0; i < numberofplayers; ++i) {
		while (i < numberofplayers && pausecounter[players[i]]) {
			++i
		}
		if (i >= numberofplayers){
			set_task(1.0,"checkcamping",1)
			return PLUGIN_CONTINUE
		}
		id = players[i]
		for (j = 0; j < 3; ++j) {
			playercoord4[id][j] = playercoord3[id][j]
			playercoord3[id][j] = playercoord2[id][j]
			playercoord2[id][j] = playercoord1[id][j]
			playercoord1[id][j] = playercoord0[id][j]
		}
		get_user_origin(id, playercoord0[id], 0)
		for (j = 0; j < 3; ++j) {
			average[j] = (playercoord0[id][j] +
							playercoord1[id][j] +
							playercoord2[id][j] +
							playercoord3[id][j] +
							playercoord4[id][j]) / 5
			variance[j] = (((playercoord0[id][j] - average[j]) * (playercoord0[id][j] - average[j]) +
							  (playercoord1[id][j] - average[j]) * (playercoord1[id][j] - average[j]) +
							  (playercoord2[id][j] - average[j]) * (playercoord2[id][j] - average[j]) +
							  (playercoord3[id][j] - average[j]) * (playercoord3[id][j] - average[j]) +
							  (playercoord4[id][j] - average[j]) * (playercoord4[id][j] - average[j])) / 4)
		}
		variancetotal=variance[0]+variance[1]+variance[2]
		standarddeviation=sqrt(variancetotal)
		team = get_user_team(id)
		if (!de_map){
			if (team==2)	// Team 1 = Terro, Team 2 = CT
				campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
			else
				campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
		}
		else if (bombplanted){
			if (team == 1)	// Team 1 = Terro, Team 2 = CT
				campmeter[id] = 0
			else
				campmeter[id] += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
		}
		else{
			if (team==2)	// Team 1 = Terro, Team 2 = CT
				campmeter[id] += (camptolerancedefending-standarddeviation)/get_cvar_num("anticamping_camptime")
			else
				campmeter[id] += (camptoleranceattacking-standarddeviation)/get_cvar_num("anticamping_camptime")
		}
		if (campmeter[id] < 80 ) {
			emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
		}
		if (campmeter[id] < 0) {
			campmeter[id] = 0
		} else if (campmeter[id]>100) {
			switch(get_cvar_num("anticamping")) {
				case 1: {
					user_slap(id,get_cvar_num("anticamping_healthpunish"))
				}
				case 2: {
					set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish"))
				}
				case 3: {
					emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
				}
			}
			campmeter[id] = 100
		} else if (campmeter[id] > 90) {
			switch(get_cvar_num("anticamping")) {
				case 1: {
					user_slap(id,get_cvar_num("anticamping_healthpunish") / 5)
				}
				case 2: {
					set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
				}
				case 3: {
					emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.5, ATTN_NORM, 0, PITCH_NORM)
				}
			}
		} else if (campmeter[id]>80){
			switch(get_cvar_num("anticamping")) {
				case 1: {
					user_slap(id,get_cvar_num("anticamping_healthpunish") / 10)
				}
				case 2: {
					set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 10)
				}
				case 3: {
					emit_sound(id,CHAN_VOICE,"player/heartbeat1.wav", 0.1, ATTN_NORM, 0, PITCH_NORM)
				}
			}
		}
		displaymeter(id)
	}
	set_task(2.0,"checkcamping",1)
	return PLUGIN_CONTINUE
}
public damage_event(id) {
	if (get_cvar_num("anticamping") != 0) {
		new enemy = get_user_attacker(id)
		if (is_user_connected(enemy) && get_user_team(id)!=get_user_team(enemy)) {
			campmeter[id]=0
			campmeter[enemy]=0
		}
		return PLUGIN_CONTINUE
	}
	return PLUGIN_CONTINUE
}
public new_round(id) {
	if (get_cvar_num("anticamping") != 0) {
		bombplanted=false
		pausecounter[id]=true
		campmeter[id]=0
		new Float:freezetime = get_cvar_float("mp_freezetime")+1.0
		new parm[1]
		parm[0]=id
		set_task(freezetime,"unpausecounter",0,parm,1)
		return PLUGIN_CONTINUE
	}
	return PLUGIN_CONTINUE
}
public bartime_event(id) {
	if (get_cvar_num("anticamping") != 0) {
		pausecounter[id]=true
		campmeter[id]=0
		new Float:bar_time=float(read_data(1)+1)
		new parm[1]
		parm[0]=id
		set_task(bar_time,"unpausecounter",0,parm,1)
		return PLUGIN_CONTINUE
	}
	return PLUGIN_CONTINUE
}
public bomb_planted() {
	if (get_cvar_num("anticamping") != 0) {
		bombplanted=true
		return PLUGIN_CONTINUE
	}
	return PLUGIN_CONTINUE
}
public got_bomb(id) {
	if (get_cvar_num("anticamping") != 0) {
		de_map=true
		return PLUGIN_CONTINUE
	}
	return PLUGIN_CONTINUE
}
public round_end() {
	if (get_cvar_num("anticamping") != 0) {
		new players[32]
		new numberofplayers
		new id
		new i
		get_players(players, numberofplayers, "a")
		for (i = 0; i < numberofplayers; ++i) {
			id=players[i]
			pausecounter[id]=true
			return PLUGIN_CONTINUE
		}
	}
	return PLUGIN_CONTINUE
}
public plugin_precache() {
	precache_sound("player/heartbeat1.wav")
	return PLUGIN_CONTINUE
}
public plugin_init() {
	register_plugin("AntiCamping Advanced","1.01","SpaceDude - ADVanced edit...")
	register_event("Damage", "damage_event", "b", "2!0")
	register_event("BarTime","bartime_event","b")
	register_event("ResetHUD", "new_round", "b")
	register_event("SendAudio", "bomb_planted", "a", "2&%!MRAD_BOMBPL")
	register_event("SendAudio", "round_end", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
	register_event("StatusIcon", "got_bomb", "be", "1=1", "1=2", "2=c4")
	register_cvar("anticamping","1",0)  //0=Disabled, 1=Slap, 2=Health Reduction, 3=Heartbeat
	register_cvar("anticamping_camptime","20",0)  //Amount of time allowed to camp
	register_cvar("anticamping_healthpunish","5",0)  //Amount of health taken due to punishment
	register_cvar("anticamping_meter","1",0) //Display 'campmeter' to each cilent
	set_task(1.0,"checkcamping",1)
	return PLUGIN_CONTINUE
}

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 24 госта