- /*Kitalálta: Matthew 
- www.stayhosting.hu*/ 
- #include <amxmodx> 
- #include <amxmisc> 
- #include <cstrike> 
- #include <fakemeta> 
- #include <engine> 
- #include <hamsandwich> 
-   
- #define PLUGIN "Zoom Mod" 
- #define VERSION "1.0" 
- #define AUTHOR "Idarav" 
-   
- #define	ZOOM_DEFAULT	0 
- #define	ZOOM_OFF	1 
- #define	ZOOM_DRAGSHOT	2 
-   
- #define	TIME_DELAY	0.75 
- #define	TIME_ZOOM	0.25 
- #define TIME_VOTE_DELAY	300.0 
- #define TIME_VOTE_TIME	15.0 
-   
- #define ADMIN_FLAG	ADMIN_BAN 
-   
- new Float: lastzoom[33] 
- new cvar_zoom 
-   
- new weapons[][] = { 
- "weapon_awp", 
- "weapon_scout", 
- "weapon_sg550", 
- "weapon_g3sg1" 
- } 
-   
- new saytext_msgid 
-   
- //KEYSMENU 
- const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3 
- new szavazat[33]=-1 
- new szavazat_szam[3]=0 
- new Float: lastvote=-5000.0 
-   
- new warmupc = 30 
-   
- new g_iMaxPlayers 
- public plugin_init() { 
- 	register_plugin(PLUGIN, VERSION, AUTHOR) 
-   
- 	register_forward(FM_CmdStart, "cmdstart"); 
- 	register_forward(FM_EmitSound, "fw_EmitSound") 
-   
- 	for (new i = 0; i < sizeof(weapons); i++) 
- 		RegisterHam(Ham_Weapon_PrimaryAttack, weapons[i], "fw_Weapon_PrimaryAttack_Pre") 
-   
- 	register_event( "DeathMsg","playerkilled","a" ); 
-   
- 	register_menu("vote_menu", KEYSMENU, "cmd_vote_menu") 
- 	register_menu("ures_menu", KEYSMENU, "cmd_ures_menu") 
-   
- 	register_clcmd("say /zoomvote", "zoomvote") 
- 	register_clcmd("amx_zoomvote", "zoomvote_admin") 
-   
- 	register_clcmd("say zoomvotemenu", "vote_menu") 
- 	register_clcmd("say zv", "vote_menu") 
-   
- 	saytext_msgid = get_user_msgid("SayText") 
-   
- 	cvar_zoom = register_cvar("zoom_type", "1") 
-   
- 	g_iMaxPlayers = get_maxplayers() 
-   
- 	set_task(10.0, "warmup") 
- 	set_pcvar_num(cvar_zoom, 0) 
-   
- 	return PLUGIN_CONTINUE; 
- } 
-   
- public plugin_precache() 
- { 
- 	new iEnt 
- 	iEnt = create_entity("info_map_parameters") 
- 	DispatchKeyValue(iEnt, "buying", "3") 
- 	DispatchSpawn(iEnt) 
-   
- 	server_cmd("sv_restart 1") 
- } 
-   
- public client_disconnect(id) 
- { 
- 	szavazat[id]=-1 
- } 
- public client_putinserver(id) 
- { 
- 	szavazat[id]=-1 
- 	set_task(20.0, "reklam", id+1717) 
- } 
-   
- public warmup() 
- { 
- 	if(warmupc > 0) 
- 	{ 
- 		set_task(1.0, "warmup") 
- 		set_hudmessage(255, 170, 127, -1.0, 0.29, 0, 6.0, 1.0) 
- 		show_hudmessage(0, "Warmup^n%d sec", warmupc) 
- 		warmupc-- 
-   
- 	} 
- 	if(warmupc == 15) 
- 	{ 
- 		set_task(1.0, "zoomvote", 0) 
- 		set_task(2.0+TIME_VOTE_TIME, "rr") 
- 	} 
- } 
- public rr() 
- { 
- 	server_cmd("sv_restartround 1") 
- } 
-   
- public reklam(taskid) 
- { 
- 	taskid-=1717 
- 	print_color(taskid, "^x04[ZOOM]^x01 Ha szavazast szeretnel ird a chatbe: ^x03/zoomvote   ^x04(By Idarav)") 
- } 
-   
- public cmdstart( id, uc_handle, random_seed ) 
- { 
- 	new Float: gametime = get_gametime() 
- 	//static buttons; buttons = get_uc( uc_handle, UC_Buttons ) 
- 	//new oldbutton = get_user_oldbutton(id) 
- 	new zoom = cs_get_user_zoom(id) 
- 	//client_print(0, print_chat, "  VALAMI %d  %d    %f", id, zoom, gametime) 
-   
- 	if(zoom == 2 || zoom == 3) 
- 	{ 
- 		if(get_pcvar_num(cvar_zoom) == ZOOM_DRAGSHOT) 
- 		{ 
- 			if(lastzoom[id] == -1.0) 
- 			{ 
- 				lastzoom[id] = (gametime) 
- 			}else if(gametime-lastzoom[id] > TIME_ZOOM) 
- 			{ 
- 				cs_set_user_zoom(id, 1, 1) 
- 				new weapon = get_user_weapon(id) 
- 				switch(weapon) 
- 				{ 
- 					case CSW_AWP:	set_pev(id, pev_maxspeed, 210.0 ) 
- 					case CSW_SCOUT:	set_pev(id, pev_maxspeed, 260.0) 
- 					case CSW_SG550:	set_pev(id, pev_maxspeed, 210.0) 
- 					case CSW_G3SG1:	set_pev(id, pev_maxspeed, 210.0) 
- 				} 
- 				client_cmd(id, "-attack2") 
- 			} 
- 		}else if(get_pcvar_num(cvar_zoom) == ZOOM_OFF){ 
- 			cs_set_user_zoom(id, 1, 1) 
- 			new weapon = get_user_weapon(id) 
- 			switch(weapon) 
- 			{ 
- 				case CSW_AWP:	set_pev(id, pev_maxspeed, 210.0 ) 
- 				case CSW_SCOUT:	set_pev(id, pev_maxspeed, 260.0) 
- 				case CSW_SG550:	set_pev(id, pev_maxspeed, 210.0) 
- 				case CSW_G3SG1:	set_pev(id, pev_maxspeed, 210.0) 
- 			} 
- 			client_cmd(id, "-attack2") 
- 		} 
- 	}else{ 
- 		if(gametime-lastzoom[id] > TIME_DELAY) 
- 			lastzoom[id] = -1.0 
- 	} 
- } 
- public fw_Weapon_PrimaryAttack_Pre(entity) 
- { 
- 	if(get_pcvar_num(cvar_zoom) == ZOOM_DRAGSHOT) 
- 	{	 
- 		new id = pev(entity, pev_owner) 
- 		cs_set_user_zoom(id, 1, 1) 
- 		new weapon = get_user_weapon(id) 
- 		switch(weapon) 
- 		{ 
- 			case CSW_AWP:	set_pev(id, pev_maxspeed, 210.0 ) 
- 			case CSW_SCOUT:	set_pev(id, pev_maxspeed, 260.0) 
- 			case CSW_SG550:	set_pev(id, pev_maxspeed, 210.0) 
- 			case CSW_G3SG1:	set_pev(id, pev_maxspeed, 210.0) 
- 		} 
- 		client_cmd(id, "-attack2") 
- 	} 
-   
- } 
-   
-   
- public fw_EmitSound(id,channel,const sample[],Float:volume,Float:attn,flags,pitch) 
- { 
- 	if(is_user_connected(id) && lastzoom[id] != -1.0 && equal(sample, "weapons/zoom.wav")) 
- 	{ 
- 		emit_sound(id,channel,"",volume,attn,flags,pitch) 
- 		return FMRES_SUPERCEDE; 
- 	} 
- 	return FMRES_IGNORED 
- } 
-   
- /*=============================7 
- == ZOOM VOTE 
- ===*/ 
- public zoomvote(id) 
- { 
- 	new Float: gametime = get_gametime() 
-   
- 	if(gametime-lastvote >= TIME_VOTE_DELAY) 
- 	{ 
- 		print_color(0, "^x04[ZOOM]^x03 Szavazas lesz! ^x01(ha eltunik a szavazas menu azelott hogy szavaztal volna ird a chatbe: ^x04zv^x01 vagy ^x04zoomvotemenu^x01)") 
- 		set_task(3.0, "showvote") 
- 	}else if(warmupc>0) 
- 	{ 
- 		print_color(id, "^x04[ZOOM] ^x01Csak warmup utan indithatsz szavazast") 
- 	}else{ 
- 		new Float: kul = TIME_VOTE_DELAY-gametime+lastvote 
- 		new perc = floatround(kul/60+0.0, floatround_floor) 
- 		new sec = floatround(kul-perc*60+0.0, floatround_floor) 
- 		print_color(id, "^x04[ZOOM] ^x01Kovetkezo zavazasig meg varni kell ^x03%d^x01 percet es ^x03%d^x01 masodpercet", perc, sec) 
- 	} 
- } 
- public zoomvote_admin(id) 
- { 
- 	if(get_user_flags(id) & ADMIN_FLAG) 
- 	{ 
- 		new name[33] 
- 		get_user_name(id, name, 32) 
- 		print_color(0, "^x04[ZOOM]^x03 Szavazas lesz! ^x04[%s]", name) 
- 		print_color(0, "^x04[ZOOM]^x01 (ha eltunik a szavazas menu azelott hogy szavaztal volna ird a chatbe: ^x04zv^x01 vagy ^x04zoomvotemenu^x01)") 
- 		set_task(3.0, "showvote") 
- 	}else{ 
- 		client_print(id, print_console, "[ZOOM] Ezt a parancsot csak az adminok hasznalhatjak!") 
- 	} 
- } 
-   
- print_color(target, const message[], any:...) 
- { 
- 	static buffer[512], i, argscount 
- 	argscount = numargs() 
-   
- 	// Send to everyone 
- 	if (!target) 
- 	{ 
- 		static player 
- 		for (player = 1; player <= g_iMaxPlayers; player++) 
- 		{ 
- 			// Not connected 
- 			if (!is_user_connected(player)) 
- 				continue; 
-   
- 			// Remember changed arguments 
- 			static changed[5], changedcount // [5] = max LANG_PLAYER occurencies 
- 			changedcount = 0 
-   
- 			// Replace LANG_PLAYER with player id 
- 			for (i = 2; i < argscount; i++) 
- 			{ 
- 				if (getarg(i) == LANG_PLAYER) 
- 				{ 
- 					setarg(i, 0, player) 
- 					changed[changedcount] = i 
- 					changedcount++ 
- 				} 
- 			} 
-   
- 			// Format message for player 
- 			vformat(buffer, charsmax(buffer), message, 3) 
-   
- 			// Send it 
- 			message_begin(MSG_ONE_UNRELIABLE, saytext_msgid, _, player) 
- 			write_byte(player) 
- 			write_string(buffer) 
- 			message_end() 
-   
- 			// Replace back player id's with LANG_PLAYER 
- 			for (i = 0; i < changedcount; i++) 
- 				setarg(changed[i], 0, LANG_PLAYER) 
- 		} 
- 	} 
- 	// Send to specific target 
- 	else 
- 	{ 
- 		// Format message for player 
- 		vformat(buffer, charsmax(buffer), message, 3) 
-   
- 		// Send it 
- 		message_begin(MSG_ONE, saytext_msgid, _, target) 
- 		write_byte(target) 
- 		write_string(buffer) 
- 		message_end() 
- 	} 
- } 
-   
- public showvote() 
- { 
- 	lastvote = get_gametime() 
- 	for(new i=1; i<33; i++) 
- 	{ 
- 		if(is_user_connected(i)) 
- 		{ 
- 			szavazat[i]=-1 
- 			vote_menu(i) 
-   
- 		} 
- 	} 
- 	for(new i; i<sizeof(szavazat_szam); i++) 
- 	{ 
- 		szavazat_szam[i]=0 
- 	} 
- 	set_task(TIME_VOTE_TIME, "voteend") 
- } 
- public vote_menu(id) 
- { 
- 	if(szavazat[id] != -1) 
- 	{ 
- 		print_color(0, "^x04[ZOOM]^x01 Te mar szavaztal!") 
- 		return; 
- 	} 
- 	static menu[350], len 
- 	len = 0 
-   
- 	len += formatex(menu[len], charsmax(menu) - len, "\yZoom Mod szavazas...^n") 
- 	len += formatex(menu[len], charsmax(menu) - len, "\wMilyen modot szeretnel?^n^n") 
-   
-   
- 	len += formatex(menu[len], charsmax(menu) - len, "\y1.\w Alap mod^n") 
- 	len += formatex(menu[len], charsmax(menu) - len, "\y2.\w Ne lehessen zoomolni.^n") 
- 	len += formatex(menu[len], charsmax(menu) - len, "\y3.\w Drag Shot^n    (ez egy negyedmasodperces zoomot engedelyez)^n") 
-   
- 	show_menu(id, KEYSMENU, menu, -1, "vote_menu") 
- } 
-   
- public cmd_vote_menu(id, key) 
- { 
- 	switch(key) { 
- 		case 0:{ 
- 			print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Alap mod") 
- 			szavazat[id]=0; 
- 			return; 
- 		} 
- 		case 1:{ 
- 			print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Ne legyen zoom") 
- 			szavazat[id]=1; 
- 			return; 
- 		} 
- 		case 2:{ 
- 			print_color(id, "^x04[ZOOM]^x01 A te szavazatod:^x03 Drag Shot") 
- 			szavazat[id]=2; 
- 			return; 
- 		} 
- 	} 
- 	vote_menu(id) 
- 	return ; 
- } 
- //Üres menü 
- public ures_menu(id) 
- { 
- 	static menu[350], len 
- 	len = 0 
-   
- 	len += formatex(menu[len], charsmax(menu) - len, "  ") 
-   
- 	show_menu(id, KEYSMENU, menu, -1, "ures_menu") 
- } 
-   
-   
-   
- public cmd_ures_menu(id, key) 
- { 
- 	return ; 
- } 
-   
- public voteend() 
- { 
- 	for(new i=1; i<33; i++) 
- 	{ 
- 		if(is_user_connected(i)) 
- 		{ 
- 			if(szavazat[i] == -1) 
- 				ures_menu(i) 
- 			else 
- 				szavazat_szam[szavazat[i]]++ 
-   
- 		} 
- 	} 
- 	new nyert[50] 
- 	if(szavazat_szam[0] >= szavazat_szam[1]) 
- 	{ 
- 		if(szavazat_szam[0] >= szavazat_szam[2])// 0 
- 		{ 
- 			nyert = "Alap mod " 
- 			set_pcvar_num(cvar_zoom, ZOOM_DEFAULT) 
- 		}else{					// 2 
- 			nyert = "Drag Shot" 
- 			set_pcvar_num(cvar_zoom, ZOOM_DRAGSHOT) 
- 		} 
- 	}else{ 
- 		if(szavazat_szam[1] > szavazat_szam[2])	// 1 
- 		{ 
- 			nyert = "Ne legyen zoom" 
- 			set_pcvar_num(cvar_zoom, ZOOM_OFF) 
- 		}else{					// 2 
- 			nyert = "Drag Shot" 
- 			set_pcvar_num(cvar_zoom, ZOOM_DRAGSHOT) 
- 		} 
- 	} 
- 	print_color(0, "^x04[ZOOM]^x01 Szavazas vegeredmenye:^x03 Alap mod ^x01- ^x04%d ^x01|^x03Ne legyen zoom ^x01- ^x04%d ^x01|^x03 Drag Shot ^x01- ^x04%d ^x03--->  ^x01%s", szavazat_szam[0], szavazat_szam[1], szavazat_szam[2], nyert) 
-   
- } 
-   
- public playerkilled() 
- { 
- 	new id		=	read_data( 2 ); 
- 	new team2 = get_user_team(id) 
-   
- 	if((team2 == 2 || team2 == 1) && warmupc > 0) 
- 	{ 
- 		set_task(2.0, "respawn", id+55555) 
- 	} 
- } 
- public respawn(id) 
- { 
- 	id-=55555 
- 	ExecuteHamB(Ham_CS_RoundRespawn, id) 
- } 
-