[Modificare] Plugin

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

24 Mar 2020, 13:53

Am incercat sa compilez acest plugin:

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Rush"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "YONTU" // credite Psycrow (sursa pluginului lui: http://gamebanana.com/gamefiles/3038 )

// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------
#define ADMIN_ACCESS	ADMIN_IMMUNITY
new const force_field_model[] = "models/aura8.mdl";
new const tag[] = "[ANTI RUSH]";
// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------

new const force_field_class[] = "forcefield";

new Array:ff_count, Array:ff_origin_x, Array:ff_origin_y, Array:ff_origin_z;
new bool:g_save_cpl, bool:can_pass;
new cvar_ff_color, cvar_ff_restricted_team, cvar_remove_ff;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar("no_rush_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
	set_cvar_string("no_rush_", PLUGIN_VERSION);

	register_touch(force_field_class, "player", "fw_touch_player");
	register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

	register_clcmd("say /camp", "cmd_open_menu");
	register_clcmd("say_team /camp", "cmd_open_menu");

	cvar_ff_color = register_cvar("ff_color", "0");	// 0 = random colors | 1 = t colors | 2 = ct colors
	cvar_ff_restricted_team = register_cvar("ff_restricted_access", "0");	// 0 = both | 1 = only t | 2 = only ct
	cvar_remove_ff = register_cvar("ff_remove_after", "25");	// int number

	new map[32];
	get_mapname(map, charsmax(map));
	formatex(map, charsmax(map),"%s.ini",map);
	
	new cfg_dir[64], dir, file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	
	dir = open_dir(cfg_dir, file, charsmax(file));
	
	if(!dir)
		mkdir(cfg_dir);
	
	while(next_file(dir, file, charsmax(file)))
	{
		if(file[0] == '.')
			continue;
				
		if(equal(map, file))
		{
			format(file, charsmax(file), "%s/%s", cfg_dir, file);
			get_origins(file);
			break;
		}
	}
}

public plugin_precache()
{
	precache_model(force_field_model);
}

public plugin_end()
{
	ArrayDestroy(ff_count);
	ArrayDestroy(ff_origin_x);
	ArrayDestroy(ff_origin_y);
	ArrayDestroy(ff_origin_z);
}

public plugin_natives() 
{
	ff_count = ArrayCreate(1, 1);
	ff_origin_x = ArrayCreate(1, 1);
	ff_origin_y = ArrayCreate(1, 1);
	ff_origin_z = ArrayCreate(1, 1);
}

public set_maps_cfg()
{
	new map1[32];
	get_mapname(map1, charsmax(map1));
	formatex(map1, charsmax(map1), "%s.ini", map1);
	
	new cfg_dir[64], file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	formatex(file, charsmax(file),"%s/%s",cfg_dir, map1);
	
	if(!dir_exists(cfg_dir))
		mkdir(cfg_dir);
	
	delete_file(file);
	
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;
	
	new text[128], i, Float:fOrigin[3], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		//drop_to_floor(ent);
		pev(ent, pev_origin, fOrigin);
		format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"", fOrigin[0], fOrigin[1], fOrigin[2]);
		write_file(file, text, -1);
	}
}

public get_origins(dir[128])
{	
	new map[32];
	get_mapname(map, charsmax(map));
	new file = fopen(dir, "rt");
	if(!file)
	{
		server_print("%s Originile hartii %s sunt invalide. Creeaza altele.", tag, map);
		return;
	}
	
	while(file && !feof(file))
	{
		new line[101];
		fgets(file, line, charsmax(line));
			
		if(line[0] == ';' || equal(line, ""))
			continue;
			
		new iOrigins[3][32], Float:fOrigins[3];	
		parse(line, iOrigins[0], charsmax(iOrigins[]), iOrigins[1], charsmax(iOrigins[]), iOrigins[2], charsmax(iOrigins[]));
		
		fOrigins[0] = str_to_float(iOrigins[0]);
		fOrigins[1] = str_to_float(iOrigins[1]);
		fOrigins[2] = str_to_float(iOrigins[2]);
		//origin[count][0] = str_to_float(iOrigins[0]);
		//origin[count][1] = str_to_float(iOrigins[1]);
		//origin[count++][2] = str_to_float(iOrigins[2]);
		
		create_spawn(fOrigins);
	}
	fclose(file);
	can_pass = false;
	
	if(!ArraySize(ff_count))
		server_print("%s Nu am gasit nicio origine pentru harta %s", tag, map);
	else if(ArraySize(ff_count) == 1)
		server_print("%s Am gasit o singura origine unde pot creea un camp de forta pentru harta %s", tag, map);
	else
		server_print("%s Am gasit %d origini pentru harta %s", tag, ArraySize(ff_count), map);
}

public event_NewRound()
{
	set_task(random_float(1.0, 2.0), "task_create_ff", 231);
	set_task(float(get_pcvar_num(cvar_remove_ff)), "task_remove_ff", 232);
}

public task_create_ff()
{
	can_pass = false;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Timp de!g %d!t secunde nu poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public task_remove_ff()
{
	can_pass = true;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Cele!g %d!t secunde au expirat. Acum poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public cmd_open_menu(id)
{
	if(!(get_user_flags(id) & ADMIN_ACCESS))
	{
		ColorChat(id, "!4%s!1 Doar!3 ADMINII!1 au acces!", tag);
		return PLUGIN_HANDLED;
	}
	
	new menu_name[128], origins_count = ArraySize(ff_count);
	formatex(menu_name, charsmax(menu_name), "\wCreeaza\r campuri de forta\w^nTotal:\y %d", origins_count);

	new menu = menu_create(menu_name, "menu_handler");
	menu_additem(menu, "\wCreeaza un camp", "1", 0);
	
	if(!origins_count)
	{
		menu_additem(menu, "\dSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\dSterge toate campurile", "3", 0);
	}
	else
	{
		menu_additem(menu, "\wSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\wSterge toate campurile", "3", 0);
	}
	
	if(!g_save_cpl)
		menu_additem(menu, "\dSalveaza toate campurile de forta", "4", 0);
	else
		menu_additem(menu, "\wSalveaza toate campurile de forta", "4", 0);

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
		
	return PLUGIN_HANDLED;
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new origins_count = ArraySize(ff_count);
	switch(item)
	{
		case 0:
		{	
			g_save_cpl = true;
			
			new Float:fOrigins[3];
			fm_get_aim_origin(id, fOrigins);
			
			create_spawn(fOrigins);
			cmd_open_menu(id);
		}
		case 1:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			origins_count--;
			remove_entity(ArrayGetCell(ff_count, origins_count));
			ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);
			
			ColorChat(id, "!g%s !tCamp eliminat cu succes.", tag);
			g_save_cpl = true;
			cmd_open_menu(id);
		}
		case 2:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			new i;
			for(i = 0; i < origins_count; i++)
				remove_entity(ArrayGetCell(ff_count, i));
				
			ArrayClear(ff_count);
			ArrayClear(ff_origin_x);
			ArrayClear(ff_origin_y);
			ArrayClear(ff_origin_z);
			
			ColorChat(id, "!g%s !tAm sters toate cele !g%d !tcampuri de forta.", tag, origins_count);
			g_save_cpl = true;
			
			cmd_open_menu(id);
		}
		case 3:
		{
			if(!g_save_cpl)
			{
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			g_save_cpl = false;
			set_maps_cfg();
			
			ColorChat(id, "!g%s !tAm salvat cu succes toate campurile de forta.", tag);
			cmd_open_menu(id);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public create_spawn(Float:fOrigins[3])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(!pev_valid(ent))
		return;
	
	ArrayPushCell(ff_count, ent);
	ArrayPushCell(ff_origin_x, fOrigins[0]);
	ArrayPushCell(ff_origin_y, fOrigins[1]);
	ArrayPushCell(ff_origin_z, fOrigins[2]);
	
	set_pev(ent, pev_origin, fOrigins);
	engfunc(EngFunc_SetModel, ent, force_field_model);
	set_pev(ent, pev_solid, SOLID_TRIGGER);	// BBOX
	set_pev(ent, pev_movetype, MOVETYPE_NONE);
	set_pev(ent, pev_classname, force_field_class);
	set_pev(ent, pev_renderfx, kRenderFxGlowShell);
	set_pev(ent, pev_rendermode, kRenderTransAlpha);
	set_pev(ent, pev_renderamt, 50.0);
	
	new Float:color[3], cvar = get_pcvar_num(cvar_ff_color);
	color[0] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 255.0 : 0.0;
	color[1] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 0.0;
	color[2] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 255.0;
	set_pev(ent, pev_rendercolor, color);

	new Float:mins[3] = {-184.7, -63.5, -132.9};
	new Float:maxs[3] = {184.7, 63.5, 132.9};
	engfunc(EngFunc_SetSize, ent, mins, maxs);

	entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);

	drop_to_floor(ent);
}

public fw_touch_player(touched, toucher)
{
	new access = get_pcvar_num(cvar_ff_restricted_team);
	if(get_user_team(toucher) == 1 && access == 2 || get_user_team(toucher) == 2 && access == 1 || can_pass)
		return;
	
	new Float:fOriginsToucher[3], Float:fOriginsEnt[3], i;
	pev(touched, pev_origin, fOriginsToucher);
	pev(toucher, pev_origin, fOriginsEnt);
		
	for(i = 0; i < 3; i++)
	{
		fOriginsEnt -= fOriginsToucher;
		fOriginsEnt *= 10.0;
	}
	
	set_pev(toucher, pev_velocity, fOriginsEnt);
	set_pev(toucher, pev_impulse, fOriginsEnt);
	ColorChat(toucher, "!g%s !tTocmai te-ai izbit de un camp de forta.", tag);
}

stock ColorChat(id, String[], any:...)
{
	static szMesage[192];
	vformat(szMesage, charsmax(szMesage), String, 3);
	
	replace_all(szMesage, charsmax(szMesage), "!n", "^1");
	replace_all(szMesage, charsmax(szMesage), "!t", "^3");
	replace_all(szMesage, charsmax(szMesage), "!g", "^4");
	
	static g_msg_SayText = 0;
	if(!g_msg_SayText)
		g_msg_SayText = get_user_msgid("SayText");
	
	new Players[32], iNum = 1, i;

 	if(id) Players[0] = id;
	else get_players(Players, iNum, "ch");
	
	for(--iNum; iNum >= 0; iNum--)
	{
		i = Players[iNum];
		
		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
		write_byte(i);
		write_string(szMesage);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Si imi da umatoarea eroare:

Code: Select all

AMX Mod X Compiler 1.8.3-manual
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

plugin.sma(378) : error 023: array assignment must be simple assignment
plugin.sma(378) : warning 215: expression has no effect
plugin.sma(379) : error 023: array assignment must be simple assignment
plugin.sma(379) : warning 215: expression has no effect

2 Errors.
Could not locate output file plugin.amx (compile failed).
Se poate rezolva? Multumesc :)
Sigilat.ro
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

24 Mar 2020, 14:10

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Rush"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "YONTU" // credite Psycrow (sursa pluginului lui: http://gamebanana.com/gamefiles/3038 )

// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------
#define ADMIN_ACCESS	ADMIN_IMMUNITY
new const force_field_model[] = "models/aura8.mdl";
new const tag[] = "[ANTI RUSH]";
// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------

new const force_field_class[] = "forcefield";

new Array:ff_count, Array:ff_origin_x, Array:ff_origin_y, Array:ff_origin_z;
new bool:g_save_cpl, bool:can_pass;
new cvar_ff_color, cvar_ff_restricted_team, cvar_remove_ff;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar("no_rush_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
	set_cvar_string("no_rush_", PLUGIN_VERSION);

	register_touch(force_field_class, "player", "fw_touch_player");
	register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

	register_clcmd("say /camp", "cmd_open_menu");
	register_clcmd("say_team /camp", "cmd_open_menu");

	cvar_ff_color = register_cvar("ff_color", "0");	// 0 = random colors | 1 = t colors | 2 = ct colors
	cvar_ff_restricted_team = register_cvar("ff_restricted_access", "0");	// 0 = both | 1 = only t | 2 = only ct
	cvar_remove_ff = register_cvar("ff_remove_after", "25");	// int number

	new map[32];
	get_mapname(map, charsmax(map));
	formatex(map, charsmax(map),"%s.ini",map);
	
	new cfg_dir[64], dir, file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	
	dir = open_dir(cfg_dir, file, charsmax(file));
	
	if(!dir)
		mkdir(cfg_dir);
	
	while(next_file(dir, file, charsmax(file)))
	{
		if(file[0] == '.')
			continue;
				
		if(equal(map, file))
		{
			format(file, charsmax(file), "%s/%s", cfg_dir, file);
			get_origins(file);
			break;
		}
	}
}

public plugin_precache()
{
	precache_model(force_field_model);
}

public plugin_end()
{
	ArrayDestroy(ff_count);
	ArrayDestroy(ff_origin_x);
	ArrayDestroy(ff_origin_y);
	ArrayDestroy(ff_origin_z);
}

public plugin_natives() 
{
	ff_count = ArrayCreate(1, 1);
	ff_origin_x = ArrayCreate(1, 1);
	ff_origin_y = ArrayCreate(1, 1);
	ff_origin_z = ArrayCreate(1, 1);
}

public set_maps_cfg()
{
	new map1[32];
	get_mapname(map1, charsmax(map1));
	formatex(map1, charsmax(map1), "%s.ini", map1);
	
	new cfg_dir[64], file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	formatex(file, charsmax(file),"%s/%s",cfg_dir, map1);
	
	if(!dir_exists(cfg_dir))
		mkdir(cfg_dir);
	
	delete_file(file);
	
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;
	
	new text[128], i, Float:fOrigin[3], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		//drop_to_floor(ent);
		pev(ent, pev_origin, fOrigin);
		format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"", fOrigin[0], fOrigin[1], fOrigin[2]);
		write_file(file, text, -1);
	}
}

public get_origins(dir[128])
{	
	new map[32];
	get_mapname(map, charsmax(map));
	new file = fopen(dir, "rt");
	if(!file)
	{
		server_print("%s Originile hartii %s sunt invalide. Creeaza altele.", tag, map);
		return;
	}
	
	while(file && !feof(file))
	{
		new line[101];
		fgets(file, line, charsmax(line));
			
		if(line[0] == ';' || equal(line, ""))
			continue;
			
		new iOrigins[3][32], Float:fOrigins[3];	
		parse(line, iOrigins[0], charsmax(iOrigins[]), iOrigins[1], charsmax(iOrigins[]), iOrigins[2], charsmax(iOrigins[]));
		
		fOrigins[0] = str_to_float(iOrigins[0]);
		fOrigins[1] = str_to_float(iOrigins[1]);
		fOrigins[2] = str_to_float(iOrigins[2]);
		//origin[count][0] = str_to_float(iOrigins[0]);
		//origin[count][1] = str_to_float(iOrigins[1]);
		//origin[count++][2] = str_to_float(iOrigins[2]);
		
		create_spawn(fOrigins);
	}
	fclose(file);
	can_pass = false;
	
	if(!ArraySize(ff_count))
		server_print("%s Nu am gasit nicio origine pentru harta %s", tag, map);
	else if(ArraySize(ff_count) == 1)
		server_print("%s Am gasit o singura origine unde pot creea un camp de forta pentru harta %s", tag, map);
	else
		server_print("%s Am gasit %d origini pentru harta %s", tag, ArraySize(ff_count), map);
}

public event_NewRound()
{
	set_task(random_float(1.0, 2.0), "task_create_ff", 231);
	set_task(float(get_pcvar_num(cvar_remove_ff)), "task_remove_ff", 232);
}

public task_create_ff()
{
	can_pass = false;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Timp de!g %d!t secunde nu poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public task_remove_ff()
{
	can_pass = true;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Cele!g %d!t secunde au expirat. Acum poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public cmd_open_menu(id)
{
	if(!(get_user_flags(id) & ADMIN_ACCESS))
	{
		ColorChat(id, "!4%s!1 Doar!3 ADMINII!1 au acces!", tag);
		return PLUGIN_HANDLED;
	}
	
	new menu_name[128], origins_count = ArraySize(ff_count);
	formatex(menu_name, charsmax(menu_name), "\wCreeaza\r campuri de forta\w^nTotal:\y %d", origins_count);

	new menu = menu_create(menu_name, "menu_handler");
	menu_additem(menu, "\wCreeaza un camp", "1", 0);
	
	if(!origins_count)
	{
		menu_additem(menu, "\dSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\dSterge toate campurile", "3", 0);
	}
	else
	{
		menu_additem(menu, "\wSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\wSterge toate campurile", "3", 0);
	}
	
	if(!g_save_cpl)
		menu_additem(menu, "\dSalveaza toate campurile de forta", "4", 0);
	else
		menu_additem(menu, "\wSalveaza toate campurile de forta", "4", 0);

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
		
	return PLUGIN_HANDLED;
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new origins_count = ArraySize(ff_count);
	switch(item)
	{
		case 0:
		{	
			g_save_cpl = true;
			
			new Float:fOrigins[3];
			fm_get_aim_origin(id, fOrigins);
			
			create_spawn(fOrigins);
			cmd_open_menu(id);
		}
		case 1:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			origins_count--;
			remove_entity(ArrayGetCell(ff_count, origins_count));
			ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);
			
			ColorChat(id, "!g%s !tCamp eliminat cu succes.", tag);
			g_save_cpl = true;
			cmd_open_menu(id);
		}
		case 2:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			new i;
			for(i = 0; i < origins_count; i++)
				remove_entity(ArrayGetCell(ff_count, i));
				
			ArrayClear(ff_count);
			ArrayClear(ff_origin_x);
			ArrayClear(ff_origin_y);
			ArrayClear(ff_origin_z);
			
			ColorChat(id, "!g%s !tAm sters toate cele !g%d !tcampuri de forta.", tag, origins_count);
			g_save_cpl = true;
			
			cmd_open_menu(id);
		}
		case 3:
		{
			if(!g_save_cpl)
			{
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			g_save_cpl = false;
			set_maps_cfg();
			
			ColorChat(id, "!g%s !tAm salvat cu succes toate campurile de forta.", tag);
			cmd_open_menu(id);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public create_spawn(Float:fOrigins[3])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(!pev_valid(ent))
		return;
	
	ArrayPushCell(ff_count, ent);
	ArrayPushCell(ff_origin_x, fOrigins[0]);
	ArrayPushCell(ff_origin_y, fOrigins[1]);
	ArrayPushCell(ff_origin_z, fOrigins[2]);
	
	set_pev(ent, pev_origin, fOrigins);
	engfunc(EngFunc_SetModel, ent, force_field_model);
	set_pev(ent, pev_solid, SOLID_TRIGGER);	// BBOX
	set_pev(ent, pev_movetype, MOVETYPE_NONE);
	set_pev(ent, pev_classname, force_field_class);
	set_pev(ent, pev_renderfx, kRenderFxGlowShell);
	set_pev(ent, pev_rendermode, kRenderTransAlpha);
	set_pev(ent, pev_renderamt, 50.0);
	
	new Float:color[3], cvar = get_pcvar_num(cvar_ff_color);
	color[0] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 255.0 : 0.0;
	color[1] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 0.0;
	color[2] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 255.0;
	set_pev(ent, pev_rendercolor, color);

	new Float:mins[3] = {-184.7, -63.5, -132.9};
	new Float:maxs[3] = {184.7, 63.5, 132.9};
	engfunc(EngFunc_SetSize, ent, mins, maxs);

	entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);

	drop_to_floor(ent);
}

public fw_touch_player(touched, toucher)
{
	new access = get_pcvar_num(cvar_ff_restricted_team);
	if(get_user_team(toucher) == 1 && access == 2 || get_user_team(toucher) == 2 && access == 1 || can_pass)
		return;
	
	new Float:fOriginsToucher[3], Float:fOriginsEnt[3], i;
	pev(touched, pev_origin, fOriginsToucher);
	pev(toucher, pev_origin, fOriginsEnt);
		
	for(i = 0; i < 3; i++)
	{
		fOriginsEnt[i] -= fOriginsToucher[i];
		fOriginsEnt[i] *= 10.0;
	}
	
	set_pev(toucher, pev_velocity, fOriginsEnt);
	set_pev(toucher, pev_impulse, fOriginsEnt);
	ColorChat(toucher, "!g%s !tTocmai te-ai izbit de un camp de forta.", tag);
}

stock ColorChat(id, String[], any:...)
{
	static szMesage[192];
	vformat(szMesage, charsmax(szMesage), String, 3);
	
	replace_all(szMesage, charsmax(szMesage), "!n", "^1");
	replace_all(szMesage, charsmax(szMesage), "!t", "^3");
	replace_all(szMesage, charsmax(szMesage), "!g", "^4");
	
	static g_msg_SayText = 0;
	if(!g_msg_SayText)
		g_msg_SayText = get_user_msgid("SayText");
	
	new Players[32], iNum = 1, i;

 	if(id) Players[0] = id;
	else get_players(Players, iNum, "ch");
	
	for(--iNum; iNum >= 0; iNum--)
	{
		i = Players[iNum];
		
		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
		write_byte(i);
		write_string(szMesage);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

24 Mar 2020, 16:13

EDIT:

Descriere: Cu ajutorul acestui plugin iti poti creea entitati, numite campuri de forta de o anumita dimensiune, ce nu-ti permit trecerea prin ele, adica te imping inapoi in spate fara a te omori/kick/ban si alte prostii.

Acel "te imping inapoi" mi se pare prea puternic, daca sari cand mergi catre in camp de forta te impinge foarte tare si destul de sus, daca sunt cutii / obiecte pe langa poti sa te folosesti de campuri pentru a te urca pe ele, se poate sa se scoate impingerea si sa se lasa doar mesajul in chat, eventual in loc de impingere sa fie un blind de 1 secunde :)
Last edited by diavolu111 on 24 Mar 2020, 17:24, edited 2 times in total.
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

24 Mar 2020, 17:21

ar trb să ți l rotească mereu cu un unghi de 90 pentru ultimul câmp

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Rush"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "YONTU" // credite Psycrow (sursa pluginului lui: http://gamebanana.com/gamefiles/3038 )

// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------
#define ADMIN_ACCESS	ADMIN_IMMUNITY
new const force_field_model[] = "models/aura8.mdl";
new const tag[] = "[ANTI RUSH]";
// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------

new const force_field_class[] = "forcefield";

new Array:ff_count, Array:ff_origin_x, Array:ff_origin_y, Array:ff_origin_z;
new bool:g_save_cpl, bool:can_pass;
new cvar_ff_color, cvar_ff_restricted_team, cvar_remove_ff;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar("no_rush_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
	set_cvar_string("no_rush_", PLUGIN_VERSION);

	register_touch(force_field_class, "player", "fw_touch_player");
	register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

	register_clcmd("say /camp", "cmd_open_menu");
	register_clcmd("say_team /camp", "cmd_open_menu");

	cvar_ff_color = register_cvar("ff_color", "0");	// 0 = random colors | 1 = t colors | 2 = ct colors
	cvar_ff_restricted_team = register_cvar("ff_restricted_access", "0");	// 0 = both | 1 = only t | 2 = only ct
	cvar_remove_ff = register_cvar("ff_remove_after", "25");	// int number

	new map[32];
	get_mapname(map, charsmax(map));
	formatex(map, charsmax(map),"%s.ini",map);
	
	new cfg_dir[64], dir, file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	
	dir = open_dir(cfg_dir, file, charsmax(file));
	
	if(!dir)
		mkdir(cfg_dir);
	
	while(next_file(dir, file, charsmax(file)))
	{
		if(file[0] == '.')
			continue;
				
		if(equal(map, file))
		{
			format(file, charsmax(file), "%s/%s", cfg_dir, file);
			get_origins(file);
			break;
		}
	}
}

public plugin_precache()
{
	precache_model(force_field_model);
}

public plugin_end()
{
	ArrayDestroy(ff_count);
	ArrayDestroy(ff_origin_x);
	ArrayDestroy(ff_origin_y);
	ArrayDestroy(ff_origin_z);
}

public plugin_natives() 
{
	ff_count = ArrayCreate(1, 1);
	ff_origin_x = ArrayCreate(1, 1);
	ff_origin_y = ArrayCreate(1, 1);
	ff_origin_z = ArrayCreate(1, 1);
}

public set_maps_cfg()
{
	new map1[32];
	get_mapname(map1, charsmax(map1));
	formatex(map1, charsmax(map1), "%s.ini", map1);
	
	new cfg_dir[64], file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	formatex(file, charsmax(file),"%s/%s",cfg_dir, map1);
	
	if(!dir_exists(cfg_dir))
		mkdir(cfg_dir);
	
	delete_file(file);
	
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;
	
	new text[128], i, Float:fOrigin[3], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		//drop_to_floor(ent);
		pev(ent, pev_origin, fOrigin);
		format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"", fOrigin[0], fOrigin[1], fOrigin[2]);
		write_file(file, text, -1);
	}
}

public get_origins(dir[128])
{	
	new map[32];
	get_mapname(map, charsmax(map));
	new file = fopen(dir, "rt");
	if(!file)
	{
		server_print("%s Originile hartii %s sunt invalide. Creeaza altele.", tag, map);
		return;
	}
	
	while(file && !feof(file))
	{
		new line[101];
		fgets(file, line, charsmax(line));
			
		if(line[0] == ';' || equal(line, ""))
			continue;
			
		new iOrigins[3][32], Float:fOrigins[3];	
		parse(line, iOrigins[0], charsmax(iOrigins[]), iOrigins[1], charsmax(iOrigins[]), iOrigins[2], charsmax(iOrigins[]));
		
		fOrigins[0] = str_to_float(iOrigins[0]);
		fOrigins[1] = str_to_float(iOrigins[1]);
		fOrigins[2] = str_to_float(iOrigins[2]);
		//origin[count][0] = str_to_float(iOrigins[0]);
		//origin[count][1] = str_to_float(iOrigins[1]);
		//origin[count++][2] = str_to_float(iOrigins[2]);
		
		create_spawn(fOrigins);
	}
	fclose(file);
	can_pass = false;
	
	if(!ArraySize(ff_count))
		server_print("%s Nu am gasit nicio origine pentru harta %s", tag, map);
	else if(ArraySize(ff_count) == 1)
		server_print("%s Am gasit o singura origine unde pot creea un camp de forta pentru harta %s", tag, map);
	else
		server_print("%s Am gasit %d origini pentru harta %s", tag, ArraySize(ff_count), map);
}

public event_NewRound()
{
	set_task(random_float(1.0, 2.0), "task_create_ff", 231);
	set_task(float(get_pcvar_num(cvar_remove_ff)), "task_remove_ff", 232);
}

public task_create_ff()
{
	can_pass = false;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Timp de!g %d!t secunde nu poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public task_remove_ff()
{
	can_pass = true;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Cele!g %d!t secunde au expirat. Acum poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public cmd_open_menu(id)
{
	if(!(get_user_flags(id) & ADMIN_ACCESS))
	{
		ColorChat(id, "!4%s!1 Doar!3 ADMINII!1 au acces!", tag);
		return PLUGIN_HANDLED;
	}
	
	new menu_name[128], origins_count = ArraySize(ff_count);
	formatex(menu_name, charsmax(menu_name), "\wCreeaza\r campuri de forta\w^nTotal:\y %d", origins_count);

	new menu = menu_create(menu_name, "menu_handler");
	menu_additem(menu, "\wCreeaza un camp", "1", 0);
	
	if(!origins_count)
	{
		menu_additem(menu, "\dSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\dSterge toate campurile", "3", 0);
	}
	else
	{
		menu_additem(menu, "\wSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\wSterge toate campurile", "3", 0);
	}
	
	menu_additem(menu, "\wSchimba pozitia unui camp", "4", 0);
	
	if(!g_save_cpl)
		menu_additem(menu, "\dSalveaza toate campurile de forta", "5", 0);
	else
		menu_additem(menu, "\wSalveaza toate campurile de forta", "5", 0);

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
		
	return PLUGIN_HANDLED;
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new origins_count = ArraySize(ff_count);
	switch(item)
	{
		case 0:
		{	
			g_save_cpl = true;
			
			new Float:fOrigins[3];
			fm_get_aim_origin(id, fOrigins);
			
			create_spawn(fOrigins);
			cmd_open_menu(id);
		}
		case 1:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			origins_count--;
			remove_entity(ArrayGetCell(ff_count, origins_count));
			ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);
			
			ColorChat(id, "!g%s !tCamp eliminat cu succes.", tag);
			g_save_cpl = true;
			cmd_open_menu(id);
		}
		case 2:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			new i;
			for(i = 0; i < origins_count; i++)
				remove_entity(ArrayGetCell(ff_count, i));
				
			ArrayClear(ff_count);
			ArrayClear(ff_origin_x);
			ArrayClear(ff_origin_y);
			ArrayClear(ff_origin_z);
			
			ColorChat(id, "!g%s !tAm sters toate cele !g%d !tcampuri de forta.", tag, origins_count);
			g_save_cpl = true;
			
			cmd_open_menu(id);
		}
		case 3:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			/*ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);*/
			
			new Float:vAngles[3];
			vAngles[1] += 90.0;
			entity_set_vector(ArrayGetCell(ff_count, origins_count), EV_VEC_angles, vAngles);
			cmd_open_menu(id);
			
			ColorChat(id, "!g%s !tCamp modificat cu succes.", tag);
		}
		case 4:
		{
			if(!g_save_cpl)
			{
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			g_save_cpl = false;
			set_maps_cfg();
			
			ColorChat(id, "!g%s !tAm salvat cu succes toate campurile de forta.", tag);
			cmd_open_menu(id);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public create_spawn(Float:fOrigins[3])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(!pev_valid(ent))
		return;
	
	ArrayPushCell(ff_count, ent);
	ArrayPushCell(ff_origin_x, fOrigins[0]);
	ArrayPushCell(ff_origin_y, fOrigins[1]);
	ArrayPushCell(ff_origin_z, fOrigins[2]);
	
	set_pev(ent, pev_origin, fOrigins);
	engfunc(EngFunc_SetModel, ent, force_field_model);
	set_pev(ent, pev_solid, SOLID_TRIGGER);	// BBOX
	set_pev(ent, pev_movetype, MOVETYPE_NONE);
	set_pev(ent, pev_classname, force_field_class);
	set_pev(ent, pev_renderfx, kRenderFxGlowShell);
	set_pev(ent, pev_rendermode, kRenderTransAlpha);
	set_pev(ent, pev_renderamt, 50.0);
	
	new Float:color[3], cvar = get_pcvar_num(cvar_ff_color);
	color[0] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 255.0 : 0.0;
	color[1] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 0.0;
	color[2] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 255.0;
	set_pev(ent, pev_rendercolor, color);

	new Float:mins[3] = {-184.7, -63.5, -132.9};
	new Float:maxs[3] = {184.7, 63.5, 132.9};
	engfunc(EngFunc_SetSize, ent, mins, maxs);

	entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);

	drop_to_floor(ent);
}

public fw_touch_player(touched, toucher)
{
	new access = get_pcvar_num(cvar_ff_restricted_team);
	if(get_user_team(toucher) == 1 && access == 2 || get_user_team(toucher) == 2 && access == 1 || can_pass)
		return;
	
	new Float:fOriginsToucher[3], Float:fOriginsEnt[3], i;
	pev(touched, pev_origin, fOriginsToucher);
	pev(toucher, pev_origin, fOriginsEnt);
		
	for(i = 0; i < 3; i++)
	{
		fOriginsEnt[i] -= fOriginsToucher[i];
		fOriginsEnt[i] *= 10.0;
	}
	
	set_pev(toucher, pev_velocity, fOriginsEnt);
	set_pev(toucher, pev_impulse, fOriginsEnt);
	ColorChat(toucher, "!g%s !tTocmai te-ai izbit de un camp de forta.", tag);
}

stock ColorChat(id, String[], any:...)
{
	static szMesage[192];
	vformat(szMesage, charsmax(szMesage), String, 3);
	
	replace_all(szMesage, charsmax(szMesage), "!n", "^1");
	replace_all(szMesage, charsmax(szMesage), "!t", "^3");
	replace_all(szMesage, charsmax(szMesage), "!g", "^4");
	
	static g_msg_SayText = 0;
	if(!g_msg_SayText)
		g_msg_SayText = get_user_msgid("SayText");
	
	new Players[32], iNum = 1, i;

 	if(id) Players[0] = id;
	else get_players(Players, iNum, "ch");
	
	for(--iNum; iNum >= 0; iNum--)
	{
		i = Players[iNum];
		
		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
		write_byte(i);
		write_string(szMesage);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

24 Mar 2020, 17:25

am dat edit... prima data nu l-a rotit si nu inteleg de ce... si am dat si rr la server, dar dupa ce am mai schimbat harta a inceput sa mearga bine... cine stie de la ce...

ar mai fi ceva:

Descriere: Cu ajutorul acestui plugin iti poti creea entitati, numite campuri de forta de o anumita dimensiune, ce nu-ti permit trecerea prin ele, adica te imping inapoi in spate fara a te omori/kick/ban si alte prostii.

Acel "te imping inapoi" mi se pare prea puternic, daca sari cand mergi catre campul de forta te impinge foarte tare si destul de sus, daca sunt cutii / obiecte pe langa poti sa te folosesti de campuri pentru a te urca pe ele, se poate sa se scoate impingerea si sa se lasa doar mesajul in chat, eventual in loc de impingere sa fie un blind de 1 secunda :)
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

24 Mar 2020, 18:00

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Rush"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "YONTU" // credite Psycrow (sursa pluginului lui: http://gamebanana.com/gamefiles/3038 )

// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------
#define ADMIN_ACCESS	ADMIN_IMMUNITY
new const force_field_model[] = "models/aura8.mdl";
new const tag[] = "[ANTI RUSH]";
const Float:Push = 3.0 //aici e puterea de impingere
// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------

new const force_field_class[] = "forcefield";

new Array:ff_count, Array:ff_origin_x, Array:ff_origin_y, Array:ff_origin_z;
new bool:g_save_cpl, bool:can_pass;
new cvar_ff_color, cvar_ff_restricted_team, cvar_remove_ff;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar("no_rush_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
	set_cvar_string("no_rush_", PLUGIN_VERSION);

	register_touch(force_field_class, "player", "fw_touch_player");
	register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

	register_clcmd("say /camp", "cmd_open_menu");
	register_clcmd("say_team /camp", "cmd_open_menu");

	cvar_ff_color = register_cvar("ff_color", "0");	// 0 = random colors | 1 = t colors | 2 = ct colors
	cvar_ff_restricted_team = register_cvar("ff_restricted_access", "0");	// 0 = both | 1 = only t | 2 = only ct
	cvar_remove_ff = register_cvar("ff_remove_after", "25");	// int number

	new map[32];
	get_mapname(map, charsmax(map));
	formatex(map, charsmax(map),"%s.ini",map);
	
	new cfg_dir[64], dir, file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	
	dir = open_dir(cfg_dir, file, charsmax(file));
	
	if(!dir)
		mkdir(cfg_dir);
	
	while(next_file(dir, file, charsmax(file)))
	{
		if(file[0] == '.')
			continue;
				
		if(equal(map, file))
		{
			format(file, charsmax(file), "%s/%s", cfg_dir, file);
			get_origins(file);
			break;
		}
	}
}

public plugin_precache()
{
	precache_model(force_field_model);
}

public plugin_end()
{
	ArrayDestroy(ff_count);
	ArrayDestroy(ff_origin_x);
	ArrayDestroy(ff_origin_y);
	ArrayDestroy(ff_origin_z);
}

public plugin_natives() 
{
	ff_count = ArrayCreate(1, 1);
	ff_origin_x = ArrayCreate(1, 1);
	ff_origin_y = ArrayCreate(1, 1);
	ff_origin_z = ArrayCreate(1, 1);
}

public set_maps_cfg()
{
	new map1[32];
	get_mapname(map1, charsmax(map1));
	formatex(map1, charsmax(map1), "%s.ini", map1);
	
	new cfg_dir[64], file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	formatex(file, charsmax(file),"%s/%s",cfg_dir, map1);
	
	if(!dir_exists(cfg_dir))
		mkdir(cfg_dir);
	
	delete_file(file);
	
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;
	
	new text[128], i, Float:fOrigin[3], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		//drop_to_floor(ent);
		pev(ent, pev_origin, fOrigin);
		format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"", fOrigin[0], fOrigin[1], fOrigin[2]);
		write_file(file, text, -1);
	}
}

public get_origins(dir[128])
{	
	new map[32];
	get_mapname(map, charsmax(map));
	new file = fopen(dir, "rt");
	if(!file)
	{
		server_print("%s Originile hartii %s sunt invalide. Creeaza altele.", tag, map);
		return;
	}
	
	while(file && !feof(file))
	{
		new line[101];
		fgets(file, line, charsmax(line));
			
		if(line[0] == ';' || equal(line, ""))
			continue;
			
		new iOrigins[3][32], Float:fOrigins[3];	
		parse(line, iOrigins[0], charsmax(iOrigins[]), iOrigins[1], charsmax(iOrigins[]), iOrigins[2], charsmax(iOrigins[]));
		
		fOrigins[0] = str_to_float(iOrigins[0]);
		fOrigins[1] = str_to_float(iOrigins[1]);
		fOrigins[2] = str_to_float(iOrigins[2]);
		//origin[count][0] = str_to_float(iOrigins[0]);
		//origin[count][1] = str_to_float(iOrigins[1]);
		//origin[count++][2] = str_to_float(iOrigins[2]);
		
		create_spawn(fOrigins);
	}
	fclose(file);
	can_pass = false;
	
	if(!ArraySize(ff_count))
		server_print("%s Nu am gasit nicio origine pentru harta %s", tag, map);
	else if(ArraySize(ff_count) == 1)
		server_print("%s Am gasit o singura origine unde pot creea un camp de forta pentru harta %s", tag, map);
	else
		server_print("%s Am gasit %d origini pentru harta %s", tag, ArraySize(ff_count), map);
}

public event_NewRound()
{
	set_task(random_float(1.0, 2.0), "task_create_ff", 231);
	set_task(float(get_pcvar_num(cvar_remove_ff)), "task_remove_ff", 232);
}

public task_create_ff()
{
	can_pass = false;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Timp de!g %d!t secunde nu poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public task_remove_ff()
{
	can_pass = true;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Cele!g %d!t secunde au expirat. Acum poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
}

public cmd_open_menu(id)
{
	if(!(get_user_flags(id) & ADMIN_ACCESS))
	{
		ColorChat(id, "!4%s!1 Doar!3 ADMINII!1 au acces!", tag);
		return PLUGIN_HANDLED;
	}
	
	new menu_name[128], origins_count = ArraySize(ff_count);
	formatex(menu_name, charsmax(menu_name), "\wCreeaza\r campuri de forta\w^nTotal:\y %d", origins_count);

	new menu = menu_create(menu_name, "menu_handler");
	menu_additem(menu, "\wCreeaza un camp", "1", 0);
	
	if(!origins_count)
	{
		menu_additem(menu, "\dSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\dSterge toate campurile", "3", 0);
	}
	else
	{
		menu_additem(menu, "\wSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\wSterge toate campurile", "3", 0);
	}
	
	menu_additem(menu, "\wSchimba pozitia unui camp", "4", 0);
	
	if(!g_save_cpl)
		menu_additem(menu, "\dSalveaza toate campurile de forta", "5", 0);
	else
		menu_additem(menu, "\wSalveaza toate campurile de forta", "5", 0);

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
		
	return PLUGIN_HANDLED;
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new origins_count = ArraySize(ff_count);
	switch(item)
	{
		case 0:
		{	
			g_save_cpl = true;
			
			new Float:fOrigins[3];
			fm_get_aim_origin(id, fOrigins);
			
			create_spawn(fOrigins);
			cmd_open_menu(id);
		}
		case 1:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			origins_count--;
			remove_entity(ArrayGetCell(ff_count, origins_count));
			ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);
			
			ColorChat(id, "!g%s !tCamp eliminat cu succes.", tag);
			g_save_cpl = true;
			cmd_open_menu(id);
		}
		case 2:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			new i;
			for(i = 0; i < origins_count; i++)
				remove_entity(ArrayGetCell(ff_count, i));
				
			ArrayClear(ff_count);
			ArrayClear(ff_origin_x);
			ArrayClear(ff_origin_y);
			ArrayClear(ff_origin_z);
			
			ColorChat(id, "!g%s !tAm sters toate cele !g%d !tcampuri de forta.", tag, origins_count);
			g_save_cpl = true;
			
			cmd_open_menu(id);
		}
		case 3:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			/*ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);*/
			
			new Float:vAngles[3];
			vAngles[1] += 90.0;
			entity_set_vector(ArrayGetCell(ff_count, origins_count), EV_VEC_angles, vAngles);
			cmd_open_menu(id);
			
			ColorChat(id, "!g%s !tCamp modificat cu succes.", tag);
		}
		case 4:
		{
			if(!g_save_cpl)
			{
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			g_save_cpl = false;
			set_maps_cfg();
			
			ColorChat(id, "!g%s !tAm salvat cu succes toate campurile de forta.", tag);
			cmd_open_menu(id);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public create_spawn(Float:fOrigins[3])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(!pev_valid(ent))
		return;
	
	ArrayPushCell(ff_count, ent);
	ArrayPushCell(ff_origin_x, fOrigins[0]);
	ArrayPushCell(ff_origin_y, fOrigins[1]);
	ArrayPushCell(ff_origin_z, fOrigins[2]);
	
	set_pev(ent, pev_origin, fOrigins);
	engfunc(EngFunc_SetModel, ent, force_field_model);
	set_pev(ent, pev_solid, SOLID_TRIGGER);	// BBOX
	set_pev(ent, pev_movetype, MOVETYPE_NONE);
	set_pev(ent, pev_classname, force_field_class);
	set_pev(ent, pev_renderfx, kRenderFxGlowShell);
	set_pev(ent, pev_rendermode, kRenderTransAlpha);
	set_pev(ent, pev_renderamt, 50.0);
	
	new Float:color[3], cvar = get_pcvar_num(cvar_ff_color);
	color[0] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 255.0 : 0.0;
	color[1] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 0.0;
	color[2] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 255.0;
	set_pev(ent, pev_rendercolor, color);

	new Float:mins[3] = {-184.7, -63.5, -132.9};
	new Float:maxs[3] = {184.7, 63.5, 132.9};
	engfunc(EngFunc_SetSize, ent, mins, maxs);

	entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);

	drop_to_floor(ent);
}

public fw_touch_player(touched, toucher)
{
	new access = get_pcvar_num(cvar_ff_restricted_team);
	if(get_user_team(toucher) == 1 && access == 2 || get_user_team(toucher) == 2 && access == 1 || can_pass)
		return;
	
	new Float:fOriginsToucher[3], Float:fOriginsEnt[3], i;
	pev(touched, pev_origin, fOriginsToucher);
	pev(toucher, pev_origin, fOriginsEnt);
		
	for(i = 0; i < 3; i++)
	{
		fOriginsEnt[i] -= fOriginsToucher[i];
		fOriginsEnt[i] *= Push;
	}
	
	set_pev(toucher, pev_velocity, fOriginsEnt);
	set_pev(toucher, pev_impulse, fOriginsEnt);//aici e directa
	ColorChat(toucher, "!g%s !tTocmai te-ai izbit de un camp de forta.", tag);
}

stock ColorChat(id, String[], any:...)
{
	static szMesage[192];
	vformat(szMesage, charsmax(szMesage), String, 3);
	
	replace_all(szMesage, charsmax(szMesage), "!n", "^1");
	replace_all(szMesage, charsmax(szMesage), "!t", "^3");
	replace_all(szMesage, charsmax(szMesage), "!g", "^4");
	
	static g_msg_SayText = 0;
	if(!g_msg_SayText)
		g_msg_SayText = get_user_msgid("SayText");
	
	new Players[32], iNum = 1, i;

 	if(id) Players[0] = id;
	else get_players(Players, iNum, "ch");
	
	for(--iNum; iNum >= 0; iNum--)
	{
		i = Players[iNum];
		
		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
		write_byte(i);
		write_string(szMesage);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

24 Mar 2020, 18:41

merge perfect, se poate da tc :)
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

25 Mar 2020, 13:49

am mai gasit ceva ce se poate face la acest plugin, se poate face ca "campul" acela sa fie vazut doar de ct?
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

25 Mar 2020, 16:04

explică ce face acest plugin la cine merge pe cine blochează
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

27 Mar 2020, 22:48

deci pluginul e facut sa blocheze ambele echipe, dar poate fi setat prin cvar daca blocheaza ct / t / ambele. eu il folosesc doar pentru echipa ct si as vrea sa vada acest camp doar echipa ct :)
si ar mai fi ceva nu prea imi place ca dupa ce setezi un camp si jucatorul ajunge la el acesta se invarte dupa jucator... ar putea fi facut ca odata ce l-ai setat unde ai vrut sa raman fix?
diavolu111
Membru, skill +1
Membru, skill +1
Posts: 285
Joined: 11 Oct 2014, 17:18
Detinator Steam: Da
Detinator server CS: Red.Evils.Ro
Fond eXtream: 0
Location: Alba Iulia
Has thanked: 5 times
Contact:

29 Mar 2020, 02:35

L E V I N te uiti te rog peste ultima cerere din acest topic, daca ai timp si daca poti sa editezi pluginul asa:
deci pluginul e facut sa blocheze ambele echipe, dar poate fi setat prin cvar daca blocheaza ct / t / ambele. eu il folosesc doar pentru echipa ct si as vrea sa vada acest camp doar echipa ct :)
si ar mai fi ceva nu prea imi place ca dupa ce setezi un camp si jucatorul ajunge la el acesta se invarte dupa jucator... ar putea fi facut ca odata ce l-ai setat unde ai vrut sa raman fix?
Multumesc :)
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

29 Mar 2020, 21:18

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN_NAME "Anti Rush"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "YONTU" // credite Psycrow (sursa pluginului lui: http://gamebanana.com/gamefiles/3038 )

// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------
#define ADMIN_ACCESS	ADMIN_IMMUNITY
new const force_field_model[] = "models/aura8.mdl";
new const tag[] = "[ANTI RUSH]";
const Float:Push = 3.0 //aici e puterea de impingere
// --------------------------------------------
//   ------------- DE EDITAT ---------------
// --------------------------------------------

new const force_field_class[] = "forcefield";

new Array:ff_count, Array:ff_origin_x, Array:ff_origin_y, Array:ff_origin_z;
new bool:g_save_cpl, bool:can_pass;
new cvar_ff_color, cvar_ff_restricted_team, cvar_remove_ff;

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_cvar("no_rush_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
	set_cvar_string("no_rush_", PLUGIN_VERSION);

	register_touch(force_field_class, "player", "fw_touch_player");
	register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

	register_clcmd("say /camp", "cmd_open_menu");
	register_clcmd("say_team /camp", "cmd_open_menu");

	cvar_ff_color = register_cvar("ff_color", "0");	// 0 = random colors | 1 = t colors | 2 = ct colors
	cvar_ff_restricted_team = register_cvar("ff_restricted_access", "0");	// 0 = both | 1 = only t | 2 = only ct
	cvar_remove_ff = register_cvar("ff_remove_after", "25");	// int number

	new map[32];
	get_mapname(map, charsmax(map));
	formatex(map, charsmax(map),"%s.ini",map);
	
	new cfg_dir[64], dir, file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	
	dir = open_dir(cfg_dir, file, charsmax(file));
	
	if(!dir)
		mkdir(cfg_dir);
	
	while(next_file(dir, file, charsmax(file)))
	{
		if(file[0] == '.')
			continue;
				
		if(equal(map, file))
		{
			format(file, charsmax(file), "%s/%s", cfg_dir, file);
			get_origins(file);
			break;
		}
	}
}

public plugin_precache()
{
	precache_model(force_field_model);
}

public plugin_end()
{
	ArrayDestroy(ff_count);
	ArrayDestroy(ff_origin_x);
	ArrayDestroy(ff_origin_y);
	ArrayDestroy(ff_origin_z);
}

public plugin_natives() 
{
	ff_count = ArrayCreate(1, 1);
	ff_origin_x = ArrayCreate(1, 1);
	ff_origin_y = ArrayCreate(1, 1);
	ff_origin_z = ArrayCreate(1, 1);
}

public set_maps_cfg()
{
	new map1[32];
	get_mapname(map1, charsmax(map1));
	formatex(map1, charsmax(map1), "%s.ini", map1);
	
	new cfg_dir[64], file[128];
	get_configsdir(cfg_dir, charsmax(cfg_dir));
	formatex(cfg_dir, charsmax(cfg_dir), "%s/force_field", cfg_dir);
	formatex(file, charsmax(file),"%s/%s",cfg_dir, map1);
	
	if(!dir_exists(cfg_dir))
		mkdir(cfg_dir);
	
	delete_file(file);
	
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;
	
	new text[128], i, Float:fOrigin[3], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		//drop_to_floor(ent);
		pev(ent, pev_origin, fOrigin);
		format(text, charsmax(text),"^"%f^" ^"%f^" ^"%f^"", fOrigin[0], fOrigin[1], fOrigin[2]);
		write_file(file, text, -1);
	}
}

public get_origins(dir[128])
{	
	new map[32];
	get_mapname(map, charsmax(map));
	new file = fopen(dir, "rt");
	if(!file)
	{
		server_print("%s Originile hartii %s sunt invalide. Creeaza altele.", tag, map);
		return;
	}
	
	while(file && !feof(file))
	{
		new line[101];
		fgets(file, line, charsmax(line));
			
		if(line[0] == ';' || equal(line, ""))
			continue;
			
		new iOrigins[3][32], Float:fOrigins[3];	
		parse(line, iOrigins[0], charsmax(iOrigins[]), iOrigins[1], charsmax(iOrigins[]), iOrigins[2], charsmax(iOrigins[]));
		
		fOrigins[0] = str_to_float(iOrigins[0]);
		fOrigins[1] = str_to_float(iOrigins[1]);
		fOrigins[2] = str_to_float(iOrigins[2]);
		//origin[count][0] = str_to_float(iOrigins[0]);
		//origin[count][1] = str_to_float(iOrigins[1]);
		//origin[count++][2] = str_to_float(iOrigins[2]);
		
		create_spawn(fOrigins);
	}
	fclose(file);
	can_pass = false;
	
	if(!ArraySize(ff_count))
		server_print("%s Nu am gasit nicio origine pentru harta %s", tag, map);
	else if(ArraySize(ff_count) == 1)
		server_print("%s Am gasit o singura origine unde pot creea un camp de forta pentru harta %s", tag, map);
	else
		server_print("%s Am gasit %d origini pentru harta %s", tag, ArraySize(ff_count), map);
}

public event_NewRound()
{
	set_task(random_float(1.0, 2.0), "task_create_ff", 231);
	set_task(float(get_pcvar_num(cvar_remove_ff)), "task_remove_ff", 232);
}

public task_create_ff()
{
	can_pass = false;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Timp de!g %d!t secunde nu poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
	invis_team()
}

public task_remove_ff()
{
	can_pass = true;
	new origins_count = ArraySize(ff_count);
	if(!origins_count)
		return;

	new i, classname[32], ent;
	for(i = 0; i < origins_count; i++)
	{
		ent = ArrayGetCell(ff_count, i);
		pev(ent, pev_classname, classname, charsmax(classname));

		if(!equal(classname, force_field_class))
			continue;

		entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) | EF_NODRAW);
	}
	ColorChat(0, "!g%s!t Cele!g %d!t secunde au expirat. Acum poti face!n rush!t.", tag, get_pcvar_num(cvar_remove_ff));
	invis_team()
}

public cmd_open_menu(id)
{
	if(!(get_user_flags(id) & ADMIN_ACCESS))
	{
		ColorChat(id, "!4%s!1 Doar!3 ADMINII!1 au acces!", tag);
		return PLUGIN_HANDLED;
	}
	
	new menu_name[128], origins_count = ArraySize(ff_count);
	formatex(menu_name, charsmax(menu_name), "\wCreeaza\r campuri de forta\w^nTotal:\y %d", origins_count);

	new menu = menu_create(menu_name, "menu_handler");
	menu_additem(menu, "\wCreeaza un camp", "1", 0);
	
	if(!origins_count)
	{
		menu_additem(menu, "\dSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\dSterge toate campurile", "3", 0);
	}
	else
	{
		menu_additem(menu, "\wSterge ultimul camp creeat", "2", 0);
		menu_additem(menu, "\wSterge toate campurile", "3", 0);
	}
	
	menu_additem(menu, "\wSchimba pozitia unui camp", "4", 0);
	
	if(!g_save_cpl)
		menu_additem(menu, "\dSalveaza toate campurile de forta", "5", 0);
	else
		menu_additem(menu, "\wSalveaza toate campurile de forta", "5", 0);

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
		
	return PLUGIN_HANDLED;
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new origins_count = ArraySize(ff_count);
	switch(item)
	{
		case 0:
		{	
			g_save_cpl = true;
			
			new Float:fOrigins[3];
			fm_get_aim_origin(id, fOrigins);
			
			create_spawn(fOrigins);
			cmd_open_menu(id);
		}
		case 1:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			origins_count--;
			remove_entity(ArrayGetCell(ff_count, origins_count));
			ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);
			
			ColorChat(id, "!g%s !tCamp eliminat cu succes.", tag);
			g_save_cpl = true;
			cmd_open_menu(id);
		}
		case 2:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			new i;
			for(i = 0; i < origins_count; i++)
				remove_entity(ArrayGetCell(ff_count, i));
				
			ArrayClear(ff_count);
			ArrayClear(ff_origin_x);
			ArrayClear(ff_origin_y);
			ArrayClear(ff_origin_z);
			
			ColorChat(id, "!g%s !tAm sters toate cele !g%d !tcampuri de forta.", tag, origins_count);
			g_save_cpl = true;
			
			cmd_open_menu(id);
		}
		case 3:
		{
			if(!origins_count)
			{
				ColorChat(id, "!g%s !tNu am gasit niciun camp de forta. Creaza mai intai unul.", tag);
				menu_destroy(menu);
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			/*ArrayDeleteItem(ff_count, origins_count);
			ArrayDeleteItem(ff_origin_x, origins_count);
			ArrayDeleteItem(ff_origin_y, origins_count);
			ArrayDeleteItem(ff_origin_z, origins_count);*/
			
			new Float:vAngles[3];
			vAngles[1] += 90.0;
			entity_set_vector(ArrayGetCell(ff_count, origins_count), EV_VEC_angles, vAngles);
			cmd_open_menu(id);
			
			ColorChat(id, "!g%s !tCamp modificat cu succes.", tag);
		}
		case 4:
		{
			if(!g_save_cpl)
			{
				cmd_open_menu(id);
				return PLUGIN_HANDLED;
			}
			
			g_save_cpl = false;
			set_maps_cfg();
			
			ColorChat(id, "!g%s !tAm salvat cu succes toate campurile de forta.", tag);
			cmd_open_menu(id);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public create_spawn(Float:fOrigins[3])
{
	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	if(!pev_valid(ent))
		return;
	
	ArrayPushCell(ff_count, ent);
	ArrayPushCell(ff_origin_x, fOrigins[0]);
	ArrayPushCell(ff_origin_y, fOrigins[1]);
	ArrayPushCell(ff_origin_z, fOrigins[2]);
	
	set_pev(ent, pev_origin, fOrigins);
	engfunc(EngFunc_SetModel, ent, force_field_model);
	set_pev(ent, pev_solid, SOLID_BBOX);
	set_pev(ent, pev_movetype, MOVETYPE_NONE);
	set_pev(ent, pev_classname, force_field_class);
	set_pev(ent, pev_renderfx, kRenderFxGlowShell);
	set_pev(ent, pev_rendermode, kRenderTransAlpha);
	set_pev(ent, pev_renderamt, 50.0);
	switch(get_pcvar_num(cvar_ff_restricted_team))
	{
		case 1:	set_pev(ent,pev_team,1)
		case 2:	set_pev(ent,pev_team,1)
	}
	
	new Float:color[3], cvar = get_pcvar_num(cvar_ff_color);
	color[0] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 255.0 : 0.0;
	color[1] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 0.0;
	color[2] = cvar == 0 ? random_float(0.0, 255.0) : cvar == 1 ? 0.0 : 255.0;
	set_pev(ent, pev_rendercolor, color);

	new Float:mins[3] = {-184.7, -63.5, -132.9};
	new Float:maxs[3] = {184.7, 63.5, 132.9};
	engfunc(EngFunc_SetSize, ent, mins, maxs);

	entity_set_int(ent, EV_INT_effects, entity_get_int(ent, EV_INT_effects) & ~EF_NODRAW);

	drop_to_floor(ent);
}

public invis_team()
{
	new players[32],num,id,ent=-1,bool:found
	get_players(players,num,"ach")
	while((ent=find_ent_by_class(ent,force_field_class))>0)	{	found=true	}
	for(new a=0;a<num;a++)
	{
		id=players[a]
		if(get_user_team(id)!=pev(ent,pev_team)&&found)	set_pev(ent, pev_renderamt, 0.0);
	}
}

public fw_touch_player(touched, toucher)
{
	new access = get_pcvar_num(cvar_ff_restricted_team);
	if(get_user_team(toucher) == 1 && access == 2 || get_user_team(toucher) == 2 && access == 1 || can_pass)
		return;
	
	new Float:fOriginsToucher[3], Float:fOriginsEnt[3], i;
	pev(touched, pev_origin, fOriginsToucher);
	pev(toucher, pev_origin, fOriginsEnt);
		
	for(i = 0; i < 3; i++)
	{
		fOriginsEnt[i] -= fOriginsToucher[i];
		fOriginsEnt[i] *= Push;
	}
	
	set_pev(toucher, pev_velocity, fOriginsEnt);
	set_pev(toucher, pev_impulse, fOriginsEnt);//aici e directa
	ColorChat(toucher, "!g%s !tTocmai te-ai izbit de un camp de forta.", tag);
}

stock ColorChat(id, String[], any:...)
{
	static szMesage[192];
	vformat(szMesage, charsmax(szMesage), String, 3);
	
	replace_all(szMesage, charsmax(szMesage), "!n", "^1");
	replace_all(szMesage, charsmax(szMesage), "!t", "^3");
	replace_all(szMesage, charsmax(szMesage), "!g", "^4");
	
	static g_msg_SayText = 0;
	if(!g_msg_SayText)
		g_msg_SayText = get_user_msgid("SayText");
	
	new Players[32], iNum = 1, i;

 	if(id) Players[0] = id;
	else get_players(Players, iNum, "ch");
	
	for(--iNum; iNum >= 0; iNum--)
	{
		i = Players[iNum];
		
		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
		write_byte(i);
		write_string(szMesage);
		message_end();
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Last edited by L E V I N on 30 Mar 2020, 12:11, edited 1 time in total.
Reason: fix
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests