Serwery wiaderko.com Zwiń / Rozwiń kategorię

HashJama [TP] 193.33.176.148:27015 | tp.wiaderko.com status serwera HashJama [TP] połącz

HashJama CS:GO [DM] 193.33.176.53:27015 | dm.wiaderko.com status serwera HashJama CS:GO [DM] połącz

HashJama CS:GO [FFA] 193.33.176.15:27015 | ffa.wiaderko.com status serwera HashJama CS:GO FFA [FFA] połącz

HashJama [TeamSpeak 3] 62.210.99.220:9987 | ts.wiaderko.com status serwera HashJama [TP ELITE] 62.210.99.220:27015 połącz

SPONSOR:
pukawka.pl

Nabór na JUNIOR ADMINA forum - Więcej informacji > Klik <
Pokaż wyniki od 1 do 2 z 2
  1. #1
    el Wymiataczos Awatar powerman3
    Dołączył
    May 2009
    Posty
    515
    Thanks
    24
    Thanked 22 Times in 21 Posts

    Domyślnie Przerobienie pluginu ctf

    Witam, prosze o przerobienie tego pluginu zeby nie bylo do wyboru broni tak jak na csdm
    Kod:
    /*
    *   _______     _      _  __          __
    *  | _____/    | |    | | \ \   __   / /
    *  | |         | |    | |  | | /  \ | |
    *  | |         | |____| |  | |/ __ \| |
    *  | |   ___   | ______ |  |   /  \   |
    *  | |  |_  |  | |    | |  |  /    \  |
    *  | |    | |  | |    | |  | |      | |
    *  | |____| |  | |    | |  | |      | |
    *  |_______/   |_|    |_|  \_/      \_/
    *
    *
    *
    *  Last Edited: 08-25-08
    *
    *  ============
    *   Changelog:
    *  ============
    *
    *  v3.1b
    *    -Flag Holders no longer get spawn protection
    *
    *  v3.1a
    *    -de_ map objective respawn bug hard-fix
    *    -cs_ map objective respawn bug fix
    *    -Minor fixes
    *
    *  v3.1
    *    -Added Infinite Ammo
    *    -Added Random option to weapons menu
    *    -Optimized amx_ctf_on function
    *
    *  v3.0
    *    -Rewrite #2
    *
    *  v2.0
    *    -Rewrite
    *
    *  v1.0
    *    -Initial Release
    *
    */
    
    #define VERSION	"3.1b"
    
    #include <amxmodx>
    #include <amxmisc>
    #include <fun>
    #include <cstrike>
    #include <csx>
    #include <fakemeta>
    
    //Remove the '//' on the next line for AMXX 1.76d compadability.
    //#define amxx176d
    
    //Max Distance from player->flag for touch to occur
    #define PICKUP_DISTANCE	100.0
    
    #define MAX_OBJECTIVES	10
    #define MAX_OBJ_TYPES	8
    
    //CTF CS Weapon Constants
    #define CTF_SCOUT		1	//a
    #define CTF_XM1014		2	//b
    #define CTF_MAC10		4	//c
    #define CTF_AUG			8	//d
    #define CTF_UMP45		16	//e
    #define CTF_SG550		32	//f
    #define CTF_GALIL		64	//g
    #define CTF_FAMAS		128	//h
    #define CTF_AWP			256	//i
    #define CTF_MP5NAVY		512	//j
    #define CTF_M249		1024	//k
    #define CTF_M3			2048	//l
    #define CTF_M4A1		4096	//m
    #define CTF_TMP			8192	//n
    #define CTF_G3SG1		16384	//o
    #define CTF_SG552		32768	//p
    #define CTF_AK47		65536	//q
    #define CTF_P90			131072	//r
    #define CTF_P228		262144	//s
    #define CTF_ELITE		524288	//t
    #define CTF_FIVESEVEN		1048576	//u
    #define CTF_USP			2097152	//v
    #define CTF_GLOCK18		4194304	//w
    #define CTF_DEAGLE		8388608	//x
    #define CTF_VEST		16777216//y
    #define CTF_VESTHELM		33554432//z
    
    static const weapon_names[26][16] = 
    {
    	"Scout",
    	"XM1014",
    	"Mac10",
    	"Aug",
    	"UMP",
    	"SG550",
    	"Galil",
    	"Famas",
    	"AWP",
    	"MP5Navy",
    	"M249",
    	"M3",
    	"M4A1",
    	"TMP",
    	"G3SG1",
    	"SG552",
    	"AK47",
    	"P90",
    	"P228",
    	"Elite",
    	"Fiveseven",
    	"USP",
    	"Glock18",
    	"Deagle",
    	"VEST",
    	"VESTHELM"
    }
    
    //Map Objective Removal
    new num_objectives
    new Float:objective[MAX_OBJECTIVES][3]
    new objective_type[MAX_OBJECTIVES]
    new objective_solidity[MAX_OBJECTIVES]
    new Float:objectiveminsize[MAX_OBJECTIVES][3]
    new Float:objectivemaxsize[MAX_OBJECTIVES][3]
    new bool:give_c4
    static const map_objectives[MAX_OBJ_TYPES][24] =
    {
    	"func_bomb_target",
    	"func_escapezone",
    	"func_hostage_rescue",
    	"func_vip_safetyzone",
    	"hostage_entity",
    	"info_bomb_target",
    	"info_hostage_rescue",
    	"info_vip_start"
    }
    //Map Objective Removal - de_ bug fix
    new weapon[33][31]
    new CsArmorType:armortype[33]
    new armoramount[33]
    new bool:killing
    new WeaponNames[31][] =
    {
    	"", //Blank
    	"weapon_p228",
    	"", //Nothing
    	"weapon_scout",
    	"weapon_hegrenade",
    	"weapon_xm1014",
    	"", //C4
    	"weapon_mac10",
    	"weapon_aug",
    	"weapon_smokegrenade",
    	"weapon_elite",
    	"weapon_fiveseven",
    	"weapon_ump45",
    	"weapon_sg550",
    	"weapon_galil",
    	"weapon_famas",
    	"weapon_usp",
    	"weapon_glock18",
    	"weapon_awp",
    	"weapon_mp5navy",
    	"weapon_m249",
    	"weapon_m3",
    	"weapon_m4a1",
    	"weapon_tmp",
    	"weapon_g3sg1",
    	"weapon_flashbang",
    	"weapon_deagle",
    	"weapon_sg552",
    	"weapon_ak47",
    	"", //Knife
    	"weapon_p90"
    }
    
    //CVAR Pointers
    new togglecvar, respawntime, maxcaps, spawnprotection
    #if !defined amxx176d
    new allowableweapons, nades
    #endif
    new bool:play_sounds
    
    //Flag
    new Float:maxs[2][3] = {{-4800.0,-4800.0,-4800.0},{-4800.0,-4800.0,-4800.0}}
    new Float:mins[2][3] = {{4800.0,4800.0,4800.0},{4800.0,4800.0,4800.0}}
    new I_max[2][3]
    new I_min[2][3]
    static const holo_model[] = "models/holo.mdl"
    static const blue_flag_model[] = "models/blue_flag.mdl"
    static const red_flag_model[] = "models/red_flag.mdl"
    static const flag_captured[] = "PVPFlagCaptured.mp3"
    static const flag_returned[] = "PVPFlagReturned.mp3"
    static const flag_taken[] = "PVPFlagTaken.mp3"
    new beamsprite
    new flag_holder[2]
    new flagstand_ents[2]
    new bool:is_in_safezone[33]
    new TScore, CTScore
    
    new saytext_msgid
    new maxplayers
    
    //Weapon Menu
    new bool:firsttime[33]
    new bool:ask[33]
    new weapon_picked[2][33]
    new cur_offset[33]
    new options_on_menu[8][33]
    
    //Voting
    new voterounddelay, votecvar, votelength, votedelay
    new bool:roundend
    new bool:voting
    new bool:voted
    new yes, no
    
    public plugin_init()
    {
    	register_plugin("GHW Capture The Flag",VERSION,"GHW_Chronic")
    
    	togglecvar = register_cvar("ctf_on","1")
    #if defined amxx176d
    	register_cvar("ctf_weapons","abcdefghijklmnopqrstuvwxyz")
    #else
    	allowableweapons = register_cvar("ctf_weapons","abcdefghijklmnopqrstuvwxyz")
    #endif
    #if defined amxx176d
    	register_cvar("ctf_nades","hhff")
    #else
    	nades = register_cvar("ctf_nades","hhff")
    #endif
    	respawntime = register_cvar("ctf_respawntime","3.0")
    	maxcaps = register_cvar("ctf_maxcaps","25")
    	votecvar = register_cvar("ctf_vote","1")
    	votelength = register_cvar("ctf_votelength","20.0")
    	votedelay = register_cvar("ctf_votedelay","180.0")
    	voterounddelay = register_cvar("ctf_voterounddelay","5.0")
    	spawnprotection = register_cvar("ctf_spawnprotection","1")
    
    	//register_clcmd("say /spawnme","respawn_player")
    	//register_clcmd("say_team /spawnme","respawn_player")
    	register_clcmd("say /guns","cmd_guns")
    	register_clcmd("say_team /guns","cmd_guns")
    	register_clcmd("say guns","cmd_guns")
    	register_clcmd("say_team guns","cmd_guns")
    	register_clcmd("say /ctfvote","say_vote_hook")
    	register_clcmd("say_team /ctfvote","say_vote_hook")
    	register_concmd("amx_ctf_addweap","cmd_addweap",ADMIN_BAN,"<Weapon> Un-Restricts a weapon from the weapons menu.")
    	register_concmd("amx_ctf_removeweap","cmd_delweap",ADMIN_BAN,"<Weapon> Restricts a weapon from the weapons menu.")
    
    	register_concmd("amx_ctf_set_tflag","cmd_set_tflag",ADMIN_BAN,"Sets your current location to the new T Flag Spawn Location.")
    	register_concmd("amx_ctf_set_ctflag","cmd_set_ctflag",ADMIN_BAN,"Sets your current location to the new CT Flag Spawn Location.")
    	register_concmd("amx_ctf_off","cmd_off",ADMIN_BAN,"Turn CTF Off")
    	register_concmd("amx_ctf_on","cmd_on",ADMIN_BAN,"Turn CTF On")
    
    	register_menucmd(register_menuid("WeaponMethodMenu"),(1<<0)|(1<<1)|(1<<2),"weapon_method_pushed")
    	register_menucmd(register_menuid("PrimaryWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9),"prim_weapons_pushed")
    	register_menucmd(register_menuid("SecWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7),"sec_weapons_pushed")
    	register_menucmd(register_menuid("ctfvote"),(1<<0)|(1<<1), "Key_Hook")
    
    	register_forward(FM_Think,"FM_Think_Hook")
    	register_forward(FM_PlayerPreThink,"FM_PlayerPreThink_Hook")
    	register_forward(FM_SetModel,"Hook_SetModel",1)
    	register_event("DeathMsg","DeathMsg","a")
    	register_event("SendAudio","endround","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
    	register_logevent("newround",2,"1=Round_Start")
    
    	saytext_msgid = get_user_msgid("SayText")
    	maxplayers = get_maxplayers()
    
    	if(get_pcvar_num(togglecvar))
    	{
    		ctf_on()
    	}
    }
    
    /*
    cmd_delweap cmd_addweap
    */
    
    public cmd_delweap(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,2))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	new arg[32]
    	read_argv(1,arg,31)
    
    	new cvar_value[32]
    #if defined amxx176d
    	get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    	get_pcvar_string(allowableweapons,cvar_value,31)
    #endif
    
    	new flags = read_flags(cvar_value)
    	for(new i=0;i<26;i++)
    	{
    		if(equali(arg,weapon_names[i]))
    		{
    			new remove_flag = power(2,i)
    			if(flags & remove_flag)
    			{
    				console_print(id,"[AMXX] Removing weapon %s from the choice list.",weapon_names[i])
    				flags -= remove_flag
    				get_flags(flags,cvar_value,31)
    				set_cvar_string("ctf_weapons",cvar_value)
    			}
    			else
    			{
    				console_print(id,"[AMXX] Weapon %s is already off choice list.",weapon_names[i])
    				
    			}
    
    			break;
    		}
    	}
    
    	return PLUGIN_HANDLED
    }
    
    public cmd_addweap(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,2))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	new arg[32]
    	read_argv(1,arg,31)
    
    	new cvar_value[32]
    #if defined amxx176d
    	get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    	get_pcvar_string(allowableweapons,cvar_value,31)
    #endif
    
    	for(new i=0;i<26;i++)
    	{
    		if(equali(arg,weapon_names[i]))
    		{
    			new flags = read_flags(cvar_value)
    			new add_flag = power(2,i)
    			if(!(flags & add_flag))
    			{
    				console_print(id,"[AMXX] Adding weapon %s to the choice list.",weapon_names[i])
    				flags += add_flag
    				get_flags(flags,cvar_value,31)
    				set_cvar_string("ctf_weapons",cvar_value)
    			}
    			else
    			{
    				console_print(id,"[AMXX] Weapon %s is already on choice list.",weapon_names[i])
    				
    			}
    
    			break;
    		}
    	}
    
    	return PLUGIN_HANDLED
    }
    
    /*
      Respawn on Team Select
    */
    
    public client_putinserver(id)
    {
    	set_task(1.0,"catch_jointeam",id,"",0,"b")
    	ask[id] = true
    	firsttime[id] = true
    }
    
    public catch_jointeam(id)
    {
    	if(get_pcvar_num(togglecvar) && is_user_connected(id))
    	{
    		static CsTeams:team
    		team = cs_get_user_team(id)
    		if(team==CS_TEAM_T || team==CS_TEAM_T)
    		{
    			remove_task(id)
    			respawn_player(id)
    		}
    	}
    	else
    	{
    		remove_task(id)
    	}
    }
    
    
    /*
      Base Respawn Code
    */
    
    public respawn_player(id)
    {
    	if(get_pcvar_num(togglecvar) && is_user_connected(id))
    	{
    		//Make the engine think he is spawning
    		set_pev(id,pev_deadflag,DEAD_RESPAWNABLE)
    		set_pev(id,pev_iuser1,0)
    		dllfunc(DLLFunc_Think,id)
    
    		//Move his body so if corpse is created it is not in map
    		engfunc(EngFunc_SetOrigin,id,Float:{-4800.0,-4800.0,-4800.0})
    
    		//Actual Spawn
    		set_task(0.5,"spawnagain",id)
    	}
    }
    
    public spawnagain(id)
    {
    	//Make sure he didn't disconnect in the 0.5 seconds that have passed.
    	if(is_user_connected(id))
    	{
    		//Spawn player
    		spawn(id)
    		dllfunc(DLLFunc_Spawn,id)
    
    		set_task(1.0,"weapon_method_menu",id)
    	}
    }
    
    
    /*
      CSDM Style weapons menu
    */
    
    public weapon_method_menu(id)
    {
    	if(is_user_bot(id))
    	{
    		weapon_picked[0][id] = 16
    		weapon_picked[1][id] = 23
    		give_weapons(id)
    	}
    	else if(firsttime[id])
    	{
    		firsttime[id] = false
    		prim_weapons_menu(id,0)
    	}
    	else
    	{
    		cur_offset[id] = 0
    		if(ask[id])
    		{
    			show_menu(id,(1<<0)|(1<<1)|(1<<2),"Weapon Selection Method^n^n1. Last Guns^n2. Last Guns + Save^n3. New Guns",-1,"WeaponMethodMenu")
    		}
    		else
    		{
    			give_weapons(id)
    		}
    	}
    }
    
    public weapon_method_pushed(id,key)
    {
    	switch(key)
    	{
    		case 0:
    		{
    			ask[id] = true
    			give_weapons(id)
    		}
    		case 1:
    		{
    			new string[200]
    			format(string,199,"[red][CTF][/red] Type [green]guns[/green] to re-activate the gun menu.")
    			show_colored_message(id,string,199)
    			ask[id] = false
    			give_weapons(id)
    		}
    		case 2:
    		{
    			ask[id] = true
    			prim_weapons_menu(id,0)
    		}
    	}
    
    	return ;
    }
    
    public prim_weapons_menu(id,offset)
    {
    	if(offset<0) offset = 0
    
    	new cvar_value[32]
    #if defined amxx176d
    	get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    	get_pcvar_string(allowableweapons,cvar_value,31)
    #endif
    	new flags = read_flags(cvar_value)
    
    	new keys, curnum, menu[2048]
    	for(new i=offset;i<19;i++)
    	{
    		if(i==18)
    		{
    			options_on_menu[curnum][id] = 24
    			keys += (1<<curnum)
    			curnum++
    			format(menu,2047,"%s^n%d. Random",menu,curnum)
    			break;
    		}
    		else if(flags & power(2,i))
    		{
    			options_on_menu[curnum][id] = i
    			keys += (1<<curnum)
    
    			curnum++
    			format(menu,2047,"%s^n%d. %s",menu,curnum,weapon_names[i])
    
    			if(curnum==8)
    				break;
    		}
    	}
    
    	format(menu,2047,"\ySelect Primary Weapon:\w^n^n%s^n",menu)
    	if(curnum==8 && offset<12)
    	{
    		keys += (1<<8)
    		format(menu,2047,"%s^n9. Next",menu)
    	}
    	if(offset)
    	{
    		keys += (1<<9)
    		format(menu,2047,"%s^n0. Back",menu)
    	}
    
    	show_menu(id,keys,menu,-1,"PrimaryWeaponSelect")
    }
    
    public prim_weapons_pushed(id,key)
    {
    	if(key<8)
    	{
    		weapon_picked[0][id] = options_on_menu[key][id]
    		cur_offset[id] = 0
    		sec_weapons_menu(id,0)
    	}
    	else
    	{
    		if(key==8)
    			cur_offset[id] += 8
    		if(key==9)
    			cur_offset[id] -= 8
    		prim_weapons_menu(id,cur_offset[id])
    	}
    
    	return ;
    }
    
    public sec_weapons_menu(id,offset)
    {
    	if(offset<0) offset = 0
    
    	new cvar_value[32]
    #if defined amxx176d
    	get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    	get_pcvar_string(allowableweapons,cvar_value,31)
    #endif
    	new flags = read_flags(cvar_value)
    
    	new keys, curnum, menu[2048]
    	for(new i=18;i<24;i++)
    	{
    		if(flags & power(2,i))
    		{
    			options_on_menu[curnum][id] = i
    			keys += (1<<curnum)
    
    			curnum++
    			format(menu,2047,"%s^n%d. %s",menu,curnum,weapon_names[i])
    		}
    	}
    	options_on_menu[curnum][id] = 25
    	keys += (1<<curnum)
    	curnum++
    	format(menu,2047,"%s^n%d. Random",menu,curnum)
    
    	format(menu,2047,"\ySelect Secondary Weapon:\w^n^n%s",menu)
    
    	show_menu(id,keys,menu,-1,"SecWeaponSelect")
    }
    
    public sec_weapons_pushed(id,key)
    {
    	if(key<8)
    	{
    		weapon_picked[1][id] = options_on_menu[key][id]
    	}
    
    	give_weapons(id)
    
    	return ;
    }
    
    public give_weapons(id)
    {
    	strip_user_weapons(id)
    
    	give_item(id,"weapon_knife")
    
    	new weapon[32]
    	new csw = csw_contant(weapon_picked[0][id])
    	get_weaponname(csw,weapon,31)
    	give_item(id,weapon)
    	cs_set_user_bpammo(id,csw,999)
    
    	csw = csw_contant(weapon_picked[1][id])
    	get_weaponname(csw,weapon,31)
    	give_item(id,weapon)
    	cs_set_user_bpammo(id,csw,999)
    
    #if defined amxx176d
    	get_cvar_string("ctf_nades",weapon,31)
    #else
    	get_pcvar_string(nades,weapon,31)
    #endif
    	new he, flash, smoke
    	for(new i=0;i<strlen(weapon);i++)
    	{
    		switch(weapon[i])
    		{
    			case 'h': he++
    			case 'f': flash++
    			case 's': smoke++
    		}
    	}
    
    	if(he) give_item(id,"weapon_hegrenade"), cs_set_user_bpammo(id,CSW_HEGRENADE,he)
    	if(flash) give_item(id,"weapon_flashbang"), cs_set_user_bpammo(id,CSW_FLASHBANG,flash)
    	if(smoke) give_item(id,"weapon_smokegrenade"), cs_set_user_bpammo(id,CSW_SMOKEGRENADE,smoke)
    
    #if defined amxx176d
    	get_cvar_string("ctf_weapons",weapon,31)
    #else
    	get_pcvar_string(allowableweapons,weapon,31)
    #endif
    	new flags = read_flags(weapon)
    	if(flags & CTF_VESTHELM) cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
    	else if(flags & CTF_VEST) cs_set_user_armor(id,100,CS_ARMOR_KEVLAR)
    }
    
    public csw_contant(weapon)
    {
    	new num = 29
    	switch(weapon)
    	{
    		case 0: num = 3
    		case 1: num = 5
    		case 2: num = 7
    		case 3: num = 8
    		case 4: num = 12
    		case 5: num = 13
    		case 6: num = 14
    		case 7: num = 15
    		case 8: num = 18
    		case 9: num = 19
    		case 10: num = 20
    		case 11: num = 21
    		case 12: num = 22
    		case 13: num = 23
    		case 14: num = 24
    		case 15: num = 27
    		case 16: num = 28
    		case 17: num = 30
    		case 18: num = 1
    		case 19: num = 10
    		case 20: num = 11
    		case 21: num = 16
    		case 22: num = 17
    		case 23: num = 26
    		case 24:
    		{
    			new s_weapon[32]
    #if defined amxx176d
    			get_cvar_string("ctf_weapons",s_weapon,31)
    #else
    			get_pcvar_string(allowableweapons,s_weapon,31)
    #endif
    			new flags = read_flags(s_weapon)
    			do
    			{
    				num = random_num(0,18)
    				if(!(num & flags))
    				{
    					num = -1
    				}
    			}
    			while(num==-1)
    			num = csw_contant(num)
    		}
    		case 25:
    		{
    			new s_weapon[32]
    #if defined amxx176d
    			get_cvar_string("ctf_weapons",s_weapon,31)
    #else
    			get_pcvar_string(allowableweapons,s_weapon,31)
    #endif
    			new flags = read_flags(s_weapon)
    			do
    			{
    				num = random_num(18,23)
    				if(!(num & flags))
    				{
    					num = -1
    				}
    			}
    			while(num==-1)
    			num = csw_contant(num)
    		}
    	}
    	return num;
    }
    
    public cmd_guns(id)
    {
    	ask[id] = true
    	weapon_method_menu(id)
    }
    
    
    /*
      Weapon Despawn
    */
    
    public Hook_SetModel(ent,model[])
    {
    	if(get_pcvar_num(togglecvar) && pev_valid(ent) && ent>maxplayers)
    	{
    		if(containi(model,"models/w_")==0)
    		{
    			if(containi(model,"nade")!=-1 || containi(model,"flash")!=-1)
    			{
    				set_task(2.0,"remove_nade_ent",ent,model,31)
    			}
    			else
    			{
    				set_task(0.1,"remove_ent",ent,model,31)
    			}
    		}
    	}
    }
    
    public remove_ent(model[32],ent)
    {
    	if(pev_valid(ent))
    	{
    		static model2[32]
    		pev(ent,pev_model,model2,31)
    		if(equal(model,model2))	engfunc(EngFunc_RemoveEntity,ent)
    	}
    }
    
    public remove_nade_ent(model[32],ent)
    {
    	if(pev_valid(ent))
    	{
    		static model2[32]
    		pev(ent,pev_model,model2,31)
    		if(equal(model,model2))
    		{
    			static Float:velocity[3]
    			pev(ent,pev_velocity,velocity)
    	
    			if(!velocity[0] && !velocity[1] && !velocity[2])
    				set_pev(ent,pev_flags,FL_KILLME)
    		}
    	}
    }
    
    
    /*
      Base Setup - Spawn Protection & Flag Spawn
    */
    
    public plugin_precache() 
    {
    	precache_model(holo_model)
    	precache_model(red_flag_model)
    	precache_model(blue_flag_model)
    
    	beamsprite = precache_model("sprites/dot.spr")
    	precache_model("models/scientist.mdl")
    
    	if(get_pcvar_num(register_cvar("ctf_sounds","1")))
    	{
    		play_sounds = true
    		precache_sound(flag_captured)
    		precache_sound(flag_returned)
    		precache_sound(flag_taken)
    	}
    }
    
    public cmd_set_tflag(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,1))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	setflagspawn(id,0)
    
    	console_print(id,"[CTF] T Flag Spawn Location Saved.")
    
    	return PLUGIN_HANDLED
    }
    
    public cmd_set_ctflag(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,1))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	setflagspawn(id,1)
    
    	console_print(id,"[CTF] CT Flag Spawn Location Saved.")
    
    	return PLUGIN_HANDLED
    }
    
    public setflagspawn(id,team)
    {
    	new bool:readfromfile = false
    	new configfile[200]
    	get_configsdir(configfile,199)
    	format(configfile,199,"%s/CTF_FlagSpawns.ini",configfile)
    
    	new mapname[32]
    	get_mapname(mapname,31)
    	new string[200]
    	format(string,199,"%s | T | ",mapname)
    
    	new Float:origin[3], Float:origin2[3]
    	switch(team)
    	{
    		case 0:
    		{
    			pev(flag_holder[1],pev_origin,origin2)
    			pev(id,pev_origin,origin)
    			engfunc(EngFunc_SetOrigin,flag_holder[0],origin)
    		}
    		case 1:
    		{
    			pev(flag_holder[0],pev_origin,origin)
    			pev(id,pev_origin,origin2)
    			engfunc(EngFunc_SetOrigin,flag_holder[1],origin2)
    		}
    	}
    
    	if(file_exists(configfile))
    	{
    		new read[200], trash, Fsize = file_size(configfile,1)
    		for(new i=0;i<Fsize;i++)
    		{
    			read_file(configfile,i,read,199,trash)
    
    			if(containi(read,string)==0)
    			{
    				format(string,199,"%s | T | %f %f %f | CT | %f %f %f",mapname,origin[0],origin[1],origin[2],origin2[0],origin2[1],origin2[2])
    				write_file(configfile,string,i)
    				readfromfile = true
    				break;
    			}
    		}
    	}
    
    	if(!readfromfile)
    	{
    		format(string,199,"%s | T | %f %f %f | CT | %f %f %f",mapname,origin[0],origin[1],origin[2],origin2[0],origin2[1],origin2[2])
    		write_file(configfile,string,-1)
    
    	}
    }
    
    public find_minmaxs()
    {
    	new Float:origin[3], i
    	new ent = engfunc(EngFunc_FindEntityByString,maxplayers,"classname","info_player_deathmatch")
    	while(ent)
    	{
    		if(pev_valid(ent))
    		{
    			pev(ent,pev_origin,origin)
    			for(i=0;i<3;i++)
    			{
    				if(origin[i] < mins[0][i])
    					mins[0][i] = origin[i]
    				if(origin[i] > maxs[0][i])
    					maxs[0][i] = origin[i]
    			}
    		}
    		ent = engfunc(EngFunc_FindEntityByString,ent,"classname","info_player_deathmatch")
    	}
    
    	ent = engfunc(EngFunc_FindEntityByString,maxplayers,"classname","info_player_start")
    	while(ent)
    	{
    		if(pev_valid(ent))
    		{
    			pev(ent,pev_origin,origin)
    			for(i=0;i<3;i++)
    			{
    				if(origin[i] < mins[1][i])
    					mins[1][i] = origin[i]
    				if(origin[i] > maxs[1][i])
    					maxs[1][i] = origin[i]
    			}
    		}
    		ent = engfunc(EngFunc_FindEntityByString,ent,"classname","info_player_start")
    	}
    
    	maxs[0][2] += 70.0
    	mins[1][2] -= 70.0
    	maxs[0][0] += 32.0
    	mins[1][0] -= 32.0
    	maxs[0][1] += 32.0
    	mins[1][1] -= 32.0
    
    	new Float:T_origin[3], Float:CT_origin[3]
    	get_flagstand_origins(CT_origin,T_origin)
    
    	ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    	set_pev(ent,pev_classname,"Flagstand_Model")
    	engfunc(EngFunc_SetModel,ent,holo_model)
    	set_pev(ent,pev_effects,EF_BRIGHTLIGHT)
    	set_pev(ent,pev_renderfx,kRenderFxGlowShell)
    	set_pev(ent,pev_rendercolor,Float:{255.0,0.0,0.0})
    	set_pev(ent,pev_rendermode,kRenderNormal)
    	set_pev(ent,pev_renderamt,255.0)
    	set_pev(ent,pev_gaitsequence,0)
    	set_pev(ent,pev_sequence,0)
    	set_pev(ent,pev_framerate,0.7)
    	engfunc(EngFunc_SetOrigin,ent,T_origin)
    	engfunc(EngFunc_DropToFloor,ent)
    	pev(ent,pev_origin,origin)
    	origin[2] += 36.0
    	engfunc(EngFunc_SetOrigin,ent,origin)
    	set_pev(ent,pev_nextthink,1.0)
    	flagstand_ents[0] = ent
    	flag_holder[0] = ent
    
    	ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    	set_pev(ent,pev_classname,"Flagstand_Model")
    	engfunc(EngFunc_SetModel,ent,holo_model)
    	set_pev(ent,pev_effects,EF_BRIGHTLIGHT)
    	set_pev(ent,pev_renderfx,kRenderFxGlowShell)
    	set_pev(ent,pev_rendercolor,Float:{0.0,0.0,255.0})
    	set_pev(ent,pev_rendermode,kRenderNormal)
    	set_pev(ent,pev_renderamt,255.0)
    	set_pev(ent,pev_gaitsequence,0)
    	set_pev(ent,pev_sequence,0)
    	set_pev(ent,pev_framerate,0.7)
    	engfunc(EngFunc_SetOrigin,ent,CT_origin)
    	engfunc(EngFunc_DropToFloor,ent)
    	pev(ent,pev_origin,origin)
    	origin[2] += 36.0
    	engfunc(EngFunc_SetOrigin,ent,origin)
    	set_pev(ent,pev_nextthink,1.0)
    	flagstand_ents[1] = ent
    	flag_holder[1] = ent
    
    	for(new i=0;i<2;i++)
    	{
    		for(new j=0;j<3;j++)
    		{
    			I_max[i][j] = floatround(maxs[i][j])
    			I_min[i][j] = floatround(mins[i][j])
    		}
    	}
    
    	set_task(5.0,"create_beamsprites")
    	set_task(10.0,"create_beamsprites",1500,"",0,"b")
    
    	ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    	set_pev(ent,pev_classname,"CTF_T_Flag")
    	engfunc(EngFunc_SetModel,ent,red_flag_model)
    	set_pev(ent,pev_movetype,MOVETYPE_FLY)
    	FM_Think_Hook(ent)
    
    	ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    	set_pev(ent,pev_classname,"CTF_CT_Flag")
    	engfunc(EngFunc_SetModel,ent,blue_flag_model)
    	set_pev(ent,pev_movetype,MOVETYPE_FLY)
    	FM_Think_Hook(ent)
    }
    
    public get_flagstand_origins(Float:CT_origin[3],Float:T_origin[3])
    {
    	new i
    	new Float:midpoint[2][3]
    	for(i=0;i<2;i++)
    	{
    		for(new j=0;j<3;j++)
    		{
    			midpoint[i][j] = (maxs[i][j] + mins[i][j]) / 2.0
    		}
    	}
    
    	new configfile[200]
    	get_configsdir(configfile,199)
    	format(configfile,199,"%s/CTF_FlagSpawns.ini",configfile)
    
    	T_origin[0] = midpoint[0][0]
    	T_origin[1] = midpoint[0][1]
    	T_origin[2] = midpoint[0][2]
    	CT_origin[0] = midpoint[1][0]
    	CT_origin[1] = midpoint[1][1]
    	CT_origin[2] = midpoint[1][2]
    
    	new mapname[32]
    	get_mapname(mapname,31)
    	new string[200]
    	format(string,199,"%s | T | ",mapname)
    
    	if(file_exists(configfile))
    	{
    		new read[200], trash, Fsize = file_size(configfile,1)
    		for(new i=0;i<Fsize;i++)
    		{
    			read_file(configfile,i,read,199,trash)
    
    			if(containi(read,string)==0)
    			{
    				format(read,199,read[strlen(string)])
    				replace_all(read,199," | CT |","")
    				strbreak(read,string,199,read,199)
    				T_origin[0] = str_to_float(string)
    				strbreak(read,string,199,read,199)
    				T_origin[1] = str_to_float(string)
    				strbreak(read,string,199,read,199)
    				T_origin[2] = str_to_float(string)
    				strbreak(read,string,199,read,199)
    				CT_origin[0] = str_to_float(string)
    				strbreak(read,string,199,read,199)
    				CT_origin[1] = str_to_float(string)
    				strbreak(read,string,199,read,199)
    				CT_origin[2] = str_to_float(string)
    				break;
    			}
    		}
    	}
    
    	return ;
    }
    
    public FM_Think_Hook(ent)
    {
    	if(pev_valid(ent))
    	{
    		static classname[32]
    		pev(ent,pev_classname,classname,31)
    		if(equal(classname,"Flagstand_Model"))
    		{
    			static Float:angles[3]
    			pev(ent,pev_angles,angles)
    			angles[1] += 0.3
    			while(angles[1]>180.0) angles[1] -= 360.0
    			set_pev(ent,pev_angles,angles)
    			set_pev(ent,pev_nextthink,1.0)
    		}
    		else if(equal(classname,"CTF_T_Flag"))
    		{
    			Flag_Think_Hook(ent,0)
    			set_pev(ent,pev_nextthink,1.0)
    		}
    		else if(equal(classname,"CTF_CT_Flag"))
    		{
    			Flag_Think_Hook(ent,1)
    			set_pev(ent,pev_nextthink,1.0)
    		}
    	}
    }
    
    public create_beamsprites()
    {
    	if(get_pcvar_num(spawnprotection))
    	{
    		//T Base
    		create_beam_message(I_max[0][0],I_max[0][1],I_max[0][2],I_max[0][0],I_min[0][1],I_max[0][2],255,0)
    		//create_beam_message(I_max[0][0],I_max[0][1],I_min[0][2],I_max[0][0],I_min[0][1],I_min[0][2],255,0)
    		create_beam_message(I_max[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_max[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
    	
    		create_beam_message(I_max[0][0],I_max[0][1],I_max[0][2],I_min[0][0],I_max[0][1],I_max[0][2],255,0)
    		//create_beam_message(I_max[0][0],I_max[0][1],I_min[0][2],I_min[0][0],I_max[0][1],I_min[0][2],255,0)
    		create_beam_message(I_max[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_min[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
    	
    		create_beam_message(I_min[0][0],I_max[0][1],I_max[0][2],I_min[0][0],I_min[0][1],I_max[0][2],255,0)
    		//create_beam_message(I_min[0][0],I_max[0][1],I_min[0][2],I_min[0][0],I_min[0][1],I_min[0][2],255,0)
    		create_beam_message(I_min[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_min[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
    	
    		create_beam_message(I_min[0][0],I_min[0][1],I_max[0][2],I_max[0][0],I_min[0][1],I_max[0][2],255,0)
    		//create_beam_message(I_min[0][0],I_min[0][1],I_min[0][2],I_max[0][0],I_min[0][1],I_min[0][2],255,0)
    		create_beam_message(I_min[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_max[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
    	
    		//CT Base
    		create_beam_message(I_max[1][0],I_max[1][1],I_max[1][2],I_max[1][0],I_min[1][1],I_max[1][2],0,255)
    		//create_beam_message(I_max[1][0],I_max[1][1],I_min[1][2],I_max[1][0],I_min[1][1],I_min[1][2],255,0)
    		create_beam_message(I_max[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_max[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
    	
    		create_beam_message(I_max[1][0],I_max[1][1],I_max[1][2],I_min[1][0],I_max[1][1],I_max[1][2],0,255)
    		//create_beam_message(I_max[1][0],I_max[1][1],I_min[1][2],I_min[1][0],I_max[1][1],I_min[1][2],255,0)
    		create_beam_message(I_max[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_min[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
    	
    		create_beam_message(I_min[1][0],I_max[1][1],I_max[1][2],I_min[1][0],I_min[1][1],I_max[1][2],0,255)
    		//create_beam_message(I_min[1][0],I_max[1][1],I_min[1][2],I_min[1][0],I_min[1][1],I_min[1][2],255,0)
    		create_beam_message(I_min[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_min[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
    	
    		create_beam_message(I_min[1][0],I_min[1][1],I_max[1][2],I_max[1][0],I_min[1][1],I_max[1][2],0,255)
    		//create_beam_message(I_min[1][0],I_min[1][1],I_min[1][2],I_max[1][0],I_min[1][1],I_min[1][2],255,0)
    		create_beam_message(I_min[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_max[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
    	}
    }
    
    public create_beam_message(origin1_0,origin1_1,origin1_2,origin2_0,origin2_1,origin2_2,r,b)
    {
    	message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
    	write_byte(0)		//TE_BEAMPOINTS
    	write_coord(origin1_0)
    	write_coord(origin1_1)
    	write_coord(origin1_2)
    	write_coord(origin2_0)
    	write_coord(origin2_1)
    	write_coord(origin2_2)
    	write_short(beamsprite)
    	write_byte(1)	// framestart
    	write_byte(1)	// framerate
    	write_byte(110)	// life in 0.1's
    	write_byte(5)	// width
    	write_byte(0)	// noise
    	write_byte(r)
    	write_byte(0)
    	write_byte(b)
    	write_byte(200)	// brightness
    	write_byte(0)	// speed
    	message_end()
    }
    
    public FM_PlayerPreThink_Hook(id)
    {
    	if(is_user_alive(id) && !is_user_bot(id) && get_pcvar_num(spawnprotection) && get_pcvar_num(togglecvar) && id!=flag_holder[0] && id!=flag_holder[1])
    	{
    		static Float:origin[3]
    		pev(id,pev_origin,origin)
    		if(is_in_safezone[id])
    		{
    			new buttons = pev(id,pev_button)
    			if(buttons & IN_ATTACK) buttons -= IN_ATTACK
    			if(buttons & IN_ATTACK2) buttons -= IN_ATTACK2
    			set_pev(id,pev_button,buttons)
    
    			buttons = pev(id,pev_oldbuttons)
    			if(buttons & IN_ATTACK) buttons -= IN_ATTACK
    			if(buttons & IN_ATTACK2) buttons -= IN_ATTACK2
    			set_pev(id,pev_oldbuttons,buttons)
    
    			if(!((origin[0]<=maxs[0][0] && origin[0]>=mins[0][0] && origin[1]<=maxs[0][1] && origin[1]>=mins[0][1]) || (origin[0]<=maxs[1][0] && origin[0]>=mins[1][0] && origin[1]<=maxs[1][1] && origin[1]>=mins[1][1])))
    			{
    				unsafezone(id)
    			}
    		}
    		else if((origin[0]<=maxs[0][0] && origin[0]>=mins[0][0] && origin[1]<=maxs[0][1] && origin[1]>=mins[0][1]) || (origin[0]<=maxs[1][0] && origin[0]>=mins[1][0] && origin[1]<=maxs[1][1] && origin[1]>=mins[1][1]))
    		{
    			switch(cs_get_user_team(id))
    			{
    				case CS_TEAM_T: in_safezone(id,255,0,0)
    				case CS_TEAM_CT: in_safezone(id,0,0,255)
    				default: in_safezone(id,0,255,0)
    			}
    		}
    	}
    }
    
    public in_safezone(id,r,g,b)
    {
    	set_user_godmode(id,1)
    	set_user_rendering(id,kRenderFxGlowShell,r,g,b,kRenderTransColor,50)
    	is_in_safezone[id] = true
    	message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    	write_short(~0)
    	write_short(~0)
    	write_short(1<<12)
    	write_byte(r)
    	write_byte(g)
    	write_byte(b)
    	write_byte(100)
    	message_end()
    	new param[3]
    	param[0] = r
    	param[1] = g
    	param[2] = b
    	if(!task_exists(id + 20000)) set_task(8.0,"reflash",id + 20000,param,3,"b")
    	set_task(0.5,"reflash",id + 20000,param,3)
    }
    
    public reflash(param[3],id)
    {
    	id -= 20000
    	if(!is_in_safezone[id] || !is_user_alive(id))
    	{
    		remove_task(id + 20000)
    	}
    	else
    	{
    		message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    		write_short(~0)
    		write_short(~0)
    		write_short(1<<12)
    		write_byte(param[0])
    		write_byte(param[1])
    		write_byte(param[2])
    		write_byte(100)
    		message_end()
    	}
    }
    
    public unsafezone(id)
    {
    	set_user_godmode(id)
    	set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255)
    	is_in_safezone[id] = false
    	message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    	write_short(~0)
    	write_short(~0)
    	write_short(1<<12)
    	write_byte(0)
    	write_byte(0)
    	write_byte(0)
    	write_byte(1)
    	message_end()
    	remove_task(id + 20000)
    }
    
    
    /*
      Flag Think
    */
    
    public Flag_Think_Hook(ent,team)
    {
    	if(pev_valid(flag_holder[team]))
    	{
    		static Float:origin[3], Float:origin2[3]
    		pev(flag_holder[team],pev_origin,origin)
    		origin[2] += 16.0
    		pev(ent,pev_origin,origin2)
    		if(get_distance_f(origin,origin2)>50.0)
    			engfunc(EngFunc_SetOrigin,ent,origin)
    
    		if(flag_holder[team]!=flagstand_ents[team] && flag_holder[(team + 1) % 2]==flagstand_ents[(team + 1) % 2])
    		{
    			pev(flagstand_ents[(team + 1) % 2],pev_origin,origin)
    			if(get_distance_f(origin2,origin)<PICKUP_DISTANCE)
    			{
    				new string[200]
    				new cvar_value = get_pcvar_num(maxcaps)
    				new ministring[4]
    				if(team)
    				{
    					ministring = "CT"
    					TScore++
    					if(cvar_value<=TScore)
    					{
    						format(string,199,"[red][CTF][/red] Game Over. [green]Ts[/green] won.")
    						show_colored_message(0,string,199)
    						endmap()
    					}
    				}
    				else
    				{
    					ministring = "T"
    					CTScore++
    					if(cvar_value<=CTScore)
    					{
    						format(string,199,"[red][CTF][/red] Game Over. [green]CTs[/green] won.")
    						show_colored_message(0,string,199)
    						endmap()
    					}
    				}
    				new name[32]
    				get_user_name(flag_holder[team],name,31)
    				format(string,199,"[red][CTF][/red] [green]%s[/green] captured the [green]%s[/green] flag.",name,ministring)
    				if(play_sounds) client_cmd(0,"mp3 play sound/%s",flag_captured)
    				show_colored_message(0,string,199)
    				flag_holder[team] = flagstand_ents[team]
    				write_hudmsg()
    
    	
    				return ;
    			}
    		}
    
    		pev(flag_holder[team],pev_velocity,origin)
    		set_pev(ent,pev_velocity,origin)
    	}
    
    	if(flag_holder[team]==flagstand_ents[team] || !flag_holder[team])
    	{
    		static Float:origin[3]
    		static Float:flag_origin[3]
    		pev(ent,pev_origin,flag_origin)
    		static players[32], num
    		get_players(players,num,"ach")
    		for(new i=0;i<num;i++)
    		{
    			if(get_user_team(players[i])!=(team + 1))
    			{
    				pev(players[i],pev_origin,origin)
    				if(get_distance_f(origin,flag_origin)<PICKUP_DISTANCE)
    				{
    					new ministring[4]
    					if(team) ministring = "CT"
    					else ministring = "T"
    					flag_holder[team] = players[i]
    					new name[32]
    					new string[200]
    					get_user_name(players[i],name,31)
    					format(string,199,"[red][CTF][/red] [green]%s[/green] picked up the [green]%s[/green] flag.",name,ministring)
    					if(play_sounds) client_cmd(0,"mp3 play sound/%s",flag_taken)
    					show_colored_message(0,string,199)
    					flag_holder[team] = players[i]
    					write_hudmsg()
    					unsafezone(players[i])
    					break;
    				}
    			}
    			else if(!flag_holder[team])
    			{
    				pev(players[i],pev_origin,origin)
    				if(get_distance_f(origin,flag_origin)<PICKUP_DISTANCE)
    				{
    					new ministring[4]
    					if(team) ministring = "CT"
    					else ministring = "T"
    					flag_holder[team] = players[i]
    					new name[32]
    					new string[200]
    					get_user_name(players[i],name,31)
    					format(string,199,"[red][CTF][/red] [green]%s[/green] returned the [green]%s[/green] flag.",name,ministring)
    					if(play_sounds) client_cmd(0,"mp3 play sound/%s",flag_returned)
    					show_colored_message(0,string,199)
    					flag_holder[team] = flagstand_ents[team]
    					write_hudmsg()
    					break;
    				}
    			}
    		}
    	}
    
    	return ;
    }
    
    public client_disconnect(id)
    {
    	if(read_data(2)==flag_holder[0])
    	{
    		flag_holder[0] = 0
    		new string[200]
    		format(string,199,"[red][CTF][/red] [green]UNKNOWN[/green] dropped the [green]T[/green] flag.")
    		if(play_sounds) client_cmd(0,"mp3 play sound/%s",flag_taken)
    		show_colored_message(0,string,199)
    		write_hudmsg()
    	}
    	else if(read_data(2)==flag_holder[1])
    	{
    		flag_holder[1] = 0
    		new string[200]
    		format(string,199,"[red][CTF][/red] [green]UNKNOWN[/green] dropped the [green]CT[/green] flag.")
    		if(play_sounds) client_cmd(0,"mp3 play sound/%s",flag_taken)
    		show_colored_message(0,string,199)
    		write_hudmsg()
    	}
    }
    
    public DeathMsg()
    {
    	new victim = read_data(2)
    	if(is_user_connected(victim))
    	{
    		if(victim==flag_holder[0])
    		{
    			flag_holder[0] = 0
    			new name[32]
    			new string[200]
    			get_user_name(victim,name,31)
    			format(string,199,"[red][CTF][/red] [green]%s[/green] dropped the [green]T[/green] flag.",name)
    			show_colored_message(0,string,199)
    			write_hudmsg()
    		}
    		else if(victim==flag_holder[1])
    		{
    			flag_holder[1] = 0
    			new name[32]
    			new string[200]
    			get_user_name(victim,name,31)
    			format(string,199,"[red][CTF][/red] [green]%s[/green] dropped the [green]CT[/green] flag.",name)
    			show_colored_message(0,string,199)
    			write_hudmsg()
    		}
    		set_task(get_pcvar_float(respawntime),"respawn_player",victim)
    	}
    }
    
    public show_colored_message(id,string[],maxlen)
    {
    	replace_all(string,maxlen,"[blue]","^x03")
    	replace_all(string,maxlen,"[/blue]","^x01")
    	replace_all(string,maxlen,"[red]","^x03")
    	replace_all(string,maxlen,"[/red]","^x01")
    	replace_all(string,maxlen,"[green]","^x04")
    	replace_all(string,maxlen,"[/green]","^x01")
    	format(string,maxlen,"^x04^x01%s",string)
    
    	static q
    	q++
    	if(!id)
    	{
    		static players[32], num
    		get_players(players,num,"ch")
    		for(new i=0;i<num;i++)
    		{
    			message_begin(MSG_ONE,saytext_msgid,{0,0,0},players[i])
    			write_byte(players[i])
    			write_string(string)
    			message_end()
    		}
    	}
    	else
    	{
    		message_begin(MSG_ONE,saytext_msgid,{0,0,0},id)
    		write_byte(id)
    		write_string(string)
    		message_end()
    	}
    }
    
    public write_hudmsg()
    {
    	new flagloc[32]
    	if(!flag_holder[0])
    	{
    		format(flagloc,31,"On Ground")
    	}
    	else if(flag_holder[0]==flagstand_ents[0])
    	{
    		format(flagloc,31,"Base")
    	}
    	else if(is_user_alive(flag_holder[0]))
    	{
    		get_user_name(flag_holder[0],flagloc,31)
    	}
    
    	set_hudmessage(255, 0, 0, -1.0, 0.03, 0, 6.0, 12.0, 0.0, 0.0)
    	show_hudmessage(0,"[ %d ] T Flag: %s",TScore,flagloc)
    
    	if(!flag_holder[1])
    	{
    		format(flagloc,31,"On Ground")
    	}
    	else if(flag_holder[1]==flagstand_ents[0])
    	{
    		format(flagloc,31,"Base")
    	}
    	else if(is_user_alive(flag_holder[1]))
    	{
    		get_user_name(flag_holder[1],flagloc,31)
    	}
    
    	set_hudmessage(0, 0, 255, -1.0, 0.03, 0, 6.0, 12.0, 0.0, 0.0,3)
    	show_hudmessage(0,"_^n [ %d ] CT Flag: %s",CTScore,flagloc)
    }
    
    public endmap()
    {
    	new trash
    	new map[32]
    	new configfile[200]
    	get_basedir(configfile,199)
    	format(configfile,199,"%s/maps.ini",configfile)
    	format(map,31,"de_dust")
    	if(file_exists(configfile)) read_file(configfile,random_num(0,file_size(configfile,1) - 1),map,31,trash)
    	if(!is_map_valid(map))
    	{
    		if(file_size(configfile,1)<3)
    		{
    			server_cmd("amx_map de_dust2;amx_map de_dust2_cz")
    		}
    		else
    		{
    			set_task(0.1,"endmap")
    		}
    	}
    	else server_cmd("amx_map %s",map)
    }
    
    
    /*
      CTF Vote (From v2.0)
    */
    
    public say_vote_hook(id)
    {
    	if(!get_pcvar_num(votecvar))
    	{
    		client_print(id,print_chat,"[CTF] Voting disabled")
    	}
    	else if(roundend)
    	{
    		client_print(id,print_chat,"[CTF] Voting can't start. People are buying.")
    	}
    	else if(voting)
    	{
    		client_print(id,print_chat,"[CTF] Voting currently in progrss.")
    	}
    	else if(voted)
    	{
    		client_print(id,print_chat,"[CTF] Can't vote this soon after a vote.")
    	}
    	else if(get_pcvar_num(togglecvar))
    	{
    		voting=true
    		voted=true
    		show_menu(0,(1<<0)|(1<<1),"\bTurn CTF off?^n^n\w1. Yes^n\w2. No",-1,"ctfvote")
    		set_task(get_pcvar_float(votelength),"voting_over",0)
    		set_task(get_pcvar_float(votedelay),"voted_over")
    	}
    	else
    	{
    		voting=true
    		voted=true
    		show_menu(0,(1<<0)|(1<<1),"\bTurn CTF on?^n^n\w1. Yes^n\w2. No",-1,"ctfvote")
    		set_task(get_pcvar_float(votelength),"voting_over",1)
    		set_task(get_pcvar_float(votedelay),"voted_over")
    	}
    }
    
    public Key_Hook(id,key)
    {
    	if(voting)
    	{
    		client_print(id,print_chat,"[CTF] Vote Accepted.")
    		if(!key) yes++
    		else no++
    	}
    }
    
    public voting_over(num)
    {
    	if(num)
    	{
    		client_print(0,print_chat,"[CTF] Voting to turn CTF on results: Yes: %d | No: %d",yes,no)
    		if(yes>no)
    		{
    			ctf_on()
    		}
    	}
    	else
    	{
    		client_print(0,print_chat,"[CTF] Voting to turn CTF off results: Yes: %d | No: %d",yes,no)
    		if(yes>no)
    		{
    			ctf_off()
    		}
    	}
    	yes=0
    	no=0
    	voting=false
    }
    
    public voted_over()
    {
    	voted=false
    }
    
    public endround()
    {
    	roundend =  true
    	set_task(7.0 + get_pcvar_float(voterounddelay),"roundstart")
    }
    
    public roundstart()
    {
    	roundend = false
    }
    
    
    /*
      Off / On Functions
    */
    
    public ctf_off()
    {
    	set_pcvar_num(togglecvar,0)
    	remove_task(1234)
    	remove_task(1500)
    	engfunc(EngFunc_SetOrigin,flagstand_ents[0],Float:{-4800.0,-4800.0,-4800.0})
    	engfunc(EngFunc_SetOrigin,flagstand_ents[1],Float:{-4800.0,-4800.0,-4800.0})
    	flag_holder[0] = flagstand_ents[0]
    	flag_holder[1] = flagstand_ents[1]
    	add_objectives()
    	for(new i=1;i<=32;i++)
    	{
    		if(is_user_alive(i) && is_in_safezone[i])
    		{
    			unsafezone(i)
    		}
    	}
    }
    
    public ctf_on()
    {
    	set_pcvar_num(togglecvar,1)
    	set_task(10.0,"create_beamsprites",1500,"",0,"b")
    	if(!pev_valid(flagstand_ents[0]) || !pev_valid(flagstand_ents[1]))
    	{
    		set_task(0.5,"find_minmaxs")
    	}
    	else
    	{
    		new Float:T_origin[3], Float:CT_origin[3]
    		get_flagstand_origins(CT_origin,T_origin)
    		engfunc(EngFunc_SetOrigin,flagstand_ents[0],T_origin)
    		engfunc(EngFunc_SetOrigin,flagstand_ents[1],CT_origin)
    		engfunc(EngFunc_DropToFloor,flagstand_ents[0])
    		engfunc(EngFunc_DropToFloor,flagstand_ents[1])
    		pev(flagstand_ents[0],pev_origin,T_origin)
    		pev(flagstand_ents[1],pev_origin,CT_origin)
    		T_origin[2] += 36.0
    		CT_origin[2] += 36.0
    		engfunc(EngFunc_SetOrigin,flagstand_ents[0],T_origin)
    		engfunc(EngFunc_SetOrigin,flagstand_ents[1],CT_origin)
    	}
    	set_task(10.0,"write_hudmsg",1234,"",0,"b")
    	remove_objectives()
    	set_task(10.0,"ctf_restartround")
    	remove_task(5547)
    	remove_task(5548)
    	client_print(0,print_center,"[CTF] CTF Enabled. Round Restarting in 10 seconds.")
    }
    
    public ctf_restartround()
    {
    	set_cvar_num("sv_restartround",1)
    	for(new i=1;i<=32;i++)
    	{
    		if(is_user_connected(i))
    		{
    			firsttime[i] = true
    			weapon_method_menu(i)
    		}
    	}
    }
    
    
    /*
      Off / On Commands
    */
    
    public cmd_off(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,1))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	if(get_pcvar_num(togglecvar))
    	{
    		console_print(id,"[CTF] CTF Turned Off.")
    		ctf_off()
    		new string[200]
    		format(string,199,"[red][CTF][/red] CTF Turned [green]Off[/green].")
    		show_colored_message(0,string,199)
    	}
    	else
    	{
    		console_print(id,"[CTF] CTF Is Already Turned Off.")
    	}
    
    	return PLUGIN_HANDLED
    }
    
    
    public cmd_on(id,level,cid)
    {
    	if(!cmd_access(id,level,cid,1))
    	{
    		return PLUGIN_HANDLED
    	}
    
    	if(!get_pcvar_num(togglecvar))
    	{
    		console_print(id,"[CTF] CTF Turned On.")
    		ctf_on()
    		new string[200]
    		format(string,199,"[red][CTF][/red] CTF Turned [green]On[/green].")
    		show_colored_message(0,string,199)
    	}
    	else
    	{
    		console_print(id,"[CTF] CTF Is Already Turned On.")
    	}
    
    	return PLUGIN_HANDLED
    }
    
    /*
      Remove Map Objectives
    */
    
    public remove_objectives()
    {
    	new ent
    
    	for(new i=0;i<MAX_OBJ_TYPES;i++)
    	{
    		ent = engfunc(EngFunc_FindEntityByString,maxplayers,"classname",map_objectives[i])
    		while(ent)
    		{
    			if(pev_valid(ent))
    			{
    				objective_type[num_objectives] = i
    				pev(ent,pev_origin,objective[num_objectives])
    				pev(ent,pev_size,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
    				pev(ent,pev_solid,objective_solidity[num_objectives])
    				engfunc(EngFunc_RemoveEntity,ent)
    				num_objectives++
    			}
    			ent = engfunc(EngFunc_FindEntityByString,ent,"classname",map_objectives[i])
    		}
    	}
    
    	give_c4 = false
    }
    
    public add_objectives()
    {
    	new ent
    	for(num_objectives--;num_objectives>=0;num_objectives--)
    	{
    		if(objective_type[num_objectives]==0 || objective_type[num_objectives]==5) give_c4 = true
    		ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,map_objectives[objective_type[num_objectives]]))
    		set_pev(ent,pev_classname,map_objectives[objective_type[num_objectives]])
    		set_pev(ent,pev_origin,objective[num_objectives])
    		set_pev(ent,pev_solid,objective_solidity[num_objectives])
    		engfunc(EngFunc_SetSize,ent,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
    		set_pev(ent,pev_size,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
    		dllfunc(DLLFunc_Spawn,ent)
    		dllfunc(DLLFunc_Think,ent)
    		for(new i=0;i<3;i++)
    		{
    			objective[num_objectives][i] = 0.0
    			objectiveminsize[num_objectives][i] = 0.0
    			objectivemaxsize[num_objectives][i] = 0.0
    		}
    	}
    	num_objectives=0
    }
    
    //All this handles de_ maps - making them re-work if ctf is turned off during runtime.
    public newround()
    {
    	if(give_c4) set_task(0.5,"manually_give_c4",5547)
    }
    
    public manually_give_c4()
    {
    	if(!get_pcvar_num(togglecvar))
    	{
    		new found = 0
    		static start
    		if(start<1 || start>maxplayers) start = 1
    		for(;start<=maxplayers;start++)
    		{
    			if(is_user_alive(start) && cs_get_user_team(start)==CS_TEAM_T)
    			{
    				found = start
    				break;
    			}
    		}
    		if(!found)
    		{
    			for(start = 0;start<=maxplayers;start++)
    			{
    				if(is_user_alive(start) && cs_get_user_team(start)==CS_TEAM_T)
    				{
    					found = start
    					break;
    				}
    			}
    		}
    		if(found) give_item(found,"weapon_c4")
    	}
    	set_task(get_cvar_float("mp_roundtime") * 60.0,"force_endround",5548)
    }
    
    public bomb_planted() remove_task(5548)
    
    public force_endround()
    {
    	getweapons()
    	set_task(0.5,"killum")
    }
    
    public getweapons()
    {
    	static i, i2
    	for(i=1;i<=maxplayers;i++)
    	{
    		arrayset(weapon[i],0,31)
    		if(is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
    		{
    			armoramount[i] = cs_get_user_armor(i,armortype[i])
    			for(i2=1;i2<=30;i2++)
    			{
    				if(i2!=2 && i2!=6 && i2!=29)
    				{
    					if(user_has_weapon(i,i2))
    					{
    						weapon[i][i2] = cs_get_user_bpammo(i,i2)
    						if(!weapon[i][i2])  weapon[i][i2] = 1
    					}
    				}
    			}
    		}
    	}
    }
    
    public killum()
    {
    	killing=true
    	new msgblock = get_msg_block(get_user_msgid("DeathMsg"))
    
    	set_msg_block(get_user_msgid("DeathMsg"),BLOCK_SET)
    	new i
    	for(i=1;i<=maxplayers;i++)
    	{
    		if(is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
    		{
    			user_kill(i)
    			client_print(i,print_chat,"[AMXX] You Failed to complete map objective. Respawning.")
    			set_task(4.0,"spawnum",i)
    		}
    	}
    	set_msg_block(get_user_msgid("DeathMsg"),msgblock)
    	killing=false
    	set_task(4.5,"giveweapons")
    }
    
    public plugin_log()
    {
    	if(killing)
    	{
    		return PLUGIN_HANDLED
    	}
    	return PLUGIN_CONTINUE
    }
    
    public spawnum(id)
    {
    	cs_set_user_deaths(id,cs_get_user_deaths(id) - 1)
    	set_user_frags(id,get_user_frags(id) + 1)
    	dllfunc(DLLFunc_Spawn,id)
    }
    
    public giveweapons()
    {
    	new i, i2
    	for(i=1;i<=maxplayers;i++)
    	{
    		if(is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
    		{
    			
    			cs_set_user_armor(i,armoramount[i],armortype[i])
    			strip_user_weapons(i)
    			for(i2=1;i2<=30;i2++)
    			{
    				if(i2!=2 && i2!=6 && i2!=29)
    				{
    					if(weapon[i][i2])
    					{
    						give_item(i,WeaponNames[i2])
    						cs_set_user_bpammo(i,i2,weapon[i][i2])
    					}
    				}
    			}
    			give_item(i,"weapon_knife")
    		}
    	}
    }

  2. #2
    Tata Neo i Taza Awatar seba
    Dołączył
    Jun 2007
    Wiek
    12
    Posty
    12,293
    Thanks
    7
    Thanked 662 Times in 376 Posts

    Domyślnie Odp: Przerobienie pluginu ctf

    Kod php:
    /*
    *   _______     _      _  __          __
    *  | _____/    | |    | | \ \   __   / /
    *  | |         | |    | |  | | /  \ | |
    *  | |         | |____| |  | |/ __ \| |
    *  | |   ___   | ______ |  |   /  \   |
    *  | |  |_  |  | |    | |  |  /    \  |
    *  | |    | |  | |    | |  | |      | |
    *  | |____| |  | |    | |  | |      | |
    *  |_______/   |_|    |_|  \_/      \_/
    *
    *
    *
    *  Last Edited: 08-25-08
    *
    *  ============
    *   Changelog:
    *  ============
    *
    *  v3.1b
    *    -Flag Holders no longer get spawn protection
    *
    *  v3.1a
    *    -de_ map objective respawn bug hard-fix
    *    -cs_ map objective respawn bug fix
    *    -Minor fixes
    *
    *  v3.1
    *    -Added Infinite Ammo
    *    -Added Random option to weapons menu
    *    -Optimized amx_ctf_on function
    *
    *  v3.0
    *    -Rewrite #2
    *
    *  v2.0
    *    -Rewrite
    *
    *  v1.0
    *    -Initial Release
    *
    */

    #define VERSION    "3.1b"

    #include <amxmodx>
    #include <amxmisc>
    #include <fun>
    #include <cstrike>
    #include <csx>
    #include <fakemeta>

    //Remove the '//' on the next line for AMXX 1.76d compadability.
    //#define amxx176d

    //Max Distance from player->flag for touch to occur
    #define PICKUP_DISTANCE    100.0

    #define MAX_OBJECTIVES    10
    #define MAX_OBJ_TYPES    8

    //CTF CS Weapon Constants
    #define CTF_SCOUT        1    //a
    #define CTF_XM1014        2    //b
    #define CTF_MAC10        4    //c
    #define CTF_AUG            8    //d
    #define CTF_UMP45        16    //e
    #define CTF_SG550        32    //f
    #define CTF_GALIL        64    //g
    #define CTF_FAMAS        128    //h
    #define CTF_AWP            256    //i
    #define CTF_MP5NAVY        512    //j
    #define CTF_M249        1024    //k
    #define CTF_M3            2048    //l
    #define CTF_M4A1        4096    //m
    #define CTF_TMP            8192    //n
    #define CTF_G3SG1        16384    //o
    #define CTF_SG552        32768    //p
    #define CTF_AK47        65536    //q
    #define CTF_P90            131072    //r
    #define CTF_P228        262144    //s
    #define CTF_ELITE        524288    //t
    #define CTF_FIVESEVEN        1048576    //u
    #define CTF_USP            2097152    //v
    #define CTF_GLOCK18        4194304    //w
    #define CTF_DEAGLE        8388608    //x
    #define CTF_VEST        16777216//y
    #define CTF_VESTHELM        33554432//z

    static const weapon_names[26][16] = 
    {
    "Scout",
    "XM1014",
    "Mac10",
    "Aug",
    "UMP",
    "SG550",
    "Galil",
    "Famas",
    "AWP",
    "MP5Navy",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "SG552",
    "AK47",
    "P90",
    "P228",
    "Elite",
    "Fiveseven",
    "USP",
    "Glock18",
    "Deagle",
    "VEST",
    "VESTHELM"
    }

    //Map Objective Removal
    new num_objectives
    new Float:objective[MAX_OBJECTIVES][3]
    new 
    objective_type[MAX_OBJECTIVES]
    new 
    objective_solidity[MAX_OBJECTIVES]
    new 
    Float:objectiveminsize[MAX_OBJECTIVES][3]
    new 
    Float:objectivemaxsize[MAX_OBJECTIVES][3]
    new 
    bool:give_c4
    static const map_objectives[MAX_OBJ_TYPES][24] =
    {
    "func_bomb_target",
    "func_escapezone",
    "func_hostage_rescue",
    "func_vip_safetyzone",
    "hostage_entity",
    "info_bomb_target",
    "info_hostage_rescue",
    "info_vip_start"
    }
    //Map Objective Removal - de_ bug fix
    new weapon[33][31]
    new 
    CsArmorType:armortype[33]
    new 
    armoramount[33]
    new 
    bool:killing
    new WeaponNames[31][] =
    {
    ""//Blank
    "weapon_p228",
    ""//Nothing
    "weapon_scout",
    "weapon_hegrenade",
    "weapon_xm1014",
    ""//C4
    "weapon_mac10",
    "weapon_aug",
    "weapon_smokegrenade",
    "weapon_elite",
    "weapon_fiveseven",
    "weapon_ump45",
    "weapon_sg550",
    "weapon_galil",
    "weapon_famas",
    "weapon_usp",
    "weapon_glock18",
    "weapon_awp",
    "weapon_mp5navy",
    "weapon_m249",
    "weapon_m3",
    "weapon_m4a1",
    "weapon_tmp",
    "weapon_g3sg1",
    "weapon_flashbang",
    "weapon_deagle",
    "weapon_sg552",
    "weapon_ak47",
    ""//Knife
    "weapon_p90"
    }

    //CVAR Pointers
    new togglecvarrespawntimemaxcapsspawnprotection
    #if !defined amxx176d
    new allowableweapons//, nades
    #endif
    new bool:play_sounds

    //Flag
    new Float:maxs[2][3] = {{-4800.0,-4800.0,-4800.0},{-4800.0,-4800.0,-4800.0}}
    new 
    Float:mins[2][3] = {{4800.0,4800.0,4800.0},{4800.0,4800.0,4800.0}}
    new 
    I_max[2][3]
    new 
    I_min[2][3]
    static const 
    holo_model[] = "models/holo.mdl"
    static const blue_flag_model[] = "models/blue_flag.mdl"
    static const red_flag_model[] = "models/red_flag.mdl"
    static const flag_captured[] = "PVPFlagCaptured.mp3"
    static const flag_returned[] = "PVPFlagReturned.mp3"
    static const flag_taken[] = "PVPFlagTaken.mp3"
    new beamsprite
    new flag_holder[2]
    new 
    flagstand_ents[2]
    new 
    bool:is_in_safezone[33]
    new 
    TScoreCTScore

    new saytext_msgid
    new maxplayers

    //Weapon Menu
    /*new bool:firsttime[33]
    new bool:ask[33]
    new weapon_picked[2][33]
    new cur_offset[33]
    new options_on_menu[8][33]*/

    //Voting
    new voterounddelayvotecvarvotelengthvotedelay
    new bool:roundend
    new bool:voting
    new bool:voted
    new yesno

    public plugin_init()
    {
    register_plugin("GHW Capture The Flag",VERSION,"GHW_Chronic")

    togglecvar register_cvar("ctf_on","1")
    #if defined amxx176d
    register_cvar("ctf_weapons","abcdefghijklmnopqrstuvwxyz")
    #else
    allowableweapons register_cvar("ctf_weapons","abcdefghijklmnopqrstuvwxyz")
    #endif
    //#if defined amxx176d
    register_cvar("ctf_nades","hhff")
    //#else
    //nades = register_cvar("ctf_nades","hhff")
    //#endif
    respawntime register_cvar("ctf_respawntime","3.0")
    maxcaps register_cvar("ctf_maxcaps","25")
    votecvar register_cvar("ctf_vote","1")
    votelength register_cvar("ctf_votelength","20.0")
    votedelay register_cvar("ctf_votedelay","180.0")
    voterounddelay register_cvar("ctf_voterounddelay","5.0")
    spawnprotection register_cvar("ctf_spawnprotection","1")

    //register_clcmd("say /spawnme","respawn_player")
    //register_clcmd("say_team /spawnme","respawn_player")
    register_clcmd("say /guns","cmd_guns")
    register_clcmd("say_team /guns","cmd_guns")
    register_clcmd("say guns","cmd_guns")
    register_clcmd("say_team guns","cmd_guns")
    register_clcmd("say /ctfvote","say_vote_hook")
    register_clcmd("say_team /ctfvote","say_vote_hook")
    //register_concmd("amx_ctf_addweap","cmd_addweap",ADMIN_BAN,"<Weapon> Un-Restricts a weapon from the weapons menu.")
    //register_concmd("amx_ctf_removeweap","cmd_delweap",ADMIN_BAN,"<Weapon> Restricts a weapon from the weapons menu.")

    register_concmd("amx_ctf_set_tflag","cmd_set_tflag",ADMIN_BAN,"Sets your current location to the new T Flag Spawn Location.")
    register_concmd("amx_ctf_set_ctflag","cmd_set_ctflag",ADMIN_BAN,"Sets your current location to the new CT Flag Spawn Location.")
    register_concmd("amx_ctf_off","cmd_off",ADMIN_BAN,"Turn CTF Off")
    register_concmd("amx_ctf_on","cmd_on",ADMIN_BAN,"Turn CTF On")

    //register_menucmd(register_menuid("WeaponMethodMenu"),(1<<0)|(1<<1)|(1<<2),"weapon_method_pushed")
    //register_menucmd(register_menuid("PrimaryWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9),"prim_weapons_pushed")
    //register_menucmd(register_menuid("SecWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7),"sec_weapons_pushed")
    register_menucmd(register_menuid("ctfvote"),(1<<0)|(1<<1), "Key_Hook")

    register_forward(FM_Think,"FM_Think_Hook")
    register_forward(FM_PlayerPreThink,"FM_PlayerPreThink_Hook")
    register_forward(FM_SetModel,"Hook_SetModel",1)
    register_event("DeathMsg","DeathMsg","a")
    register_event("SendAudio","endround","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
    register_logevent("newround",2,"1=Round_Start")

    saytext_msgid get_user_msgid("SayText")
    maxplayers get_maxplayers()

    if(
    get_pcvar_num(togglecvar))
    {
    ctf_on()
    }
    }

    /*
    cmd_delweap cmd_addweap
    */
    /*
    public cmd_delweap(id,level,cid)
    {
    if(!cmd_access(id,level,cid,2))
    {
    return PLUGIN_HANDLED
    }

    new arg[32]
    read_argv(1,arg,31)

    new cvar_value[32]
    #if defined amxx176d
    get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    get_pcvar_string(allowableweapons,cvar_value,31)
    #endif

    new flags = read_flags(cvar_value)
    for(new i=0;i<26;i++)
    {
    if(equali(arg,weapon_names[i]))
    {
    new remove_flag = power(2,i)
    if(flags & remove_flag)
    {
        console_print(id,"[AMXX] Removing weapon %s from the choice list.",weapon_names[i])
        flags -= remove_flag
        get_flags(flags,cvar_value,31)
        set_cvar_string("ctf_weapons",cvar_value)
    }
    else
    {
        console_print(id,"[AMXX] Weapon %s is already off choice list.",weapon_names[i])
        
    }

    break;
    }
    }

    return PLUGIN_HANDLED
    }

    public cmd_addweap(id,level,cid)
    {
    if(!cmd_access(id,level,cid,2))
    {
    return PLUGIN_HANDLED
    }

    new arg[32]
    read_argv(1,arg,31)

    new cvar_value[32]
    #if defined amxx176d
    get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    get_pcvar_string(allowableweapons,cvar_value,31)
    #endif

    for(new i=0;i<26;i++)
    {
    if(equali(arg,weapon_names[i]))
    {
    new flags = read_flags(cvar_value)
    new add_flag = power(2,i)
    if(!(flags & add_flag))
    {
        console_print(id,"[AMXX] Adding weapon %s to the choice list.",weapon_names[i])
        flags += add_flag
        get_flags(flags,cvar_value,31)
        set_cvar_string("ctf_weapons",cvar_value)
    }
    else
    {
        console_print(id,"[AMXX] Weapon %s is already on choice list.",weapon_names[i])
        
    }

    break;
    }
    }

    return PLUGIN_HANDLED
    }


    Respawn on Team Select
    */

    public client_putinserver(id)
    {
    set_task(1.0,"catch_jointeam",id,"",0,"b")
    //ask[id] = true
    //firsttime[id] = true
    }

    public 
    catch_jointeam(id)
    {
    if(
    get_pcvar_num(togglecvar) && is_user_connected(id))
    {
    static 
    CsTeams:team
    team 
    cs_get_user_team(id)
    if(
    team==CS_TEAM_T || team==CS_TEAM_T)
    {
    remove_task(id)
    respawn_player(id)
    }
    }
    else
    {
    remove_task(id)
    }
    }


    /*
    Base Respawn Code
    */

    public respawn_player(id)
    {
    if(
    get_pcvar_num(togglecvar) && is_user_connected(id))
    {
    //Make the engine think he is spawning
    set_pev(id,pev_deadflag,DEAD_RESPAWNABLE)
    set_pev(id,pev_iuser1,0)
    dllfunc(DLLFunc_Think,id)

    //Move his body so if corpse is created it is not in map
    engfunc(EngFunc_SetOrigin,id,Float:{-4800.0,-4800.0,-4800.0})

    //Actual Spawn
    set_task(0.5,"spawnagain",id)
    }
    }

    public 
    spawnagain(id)
    {
    //Make sure he didn't disconnect in the 0.5 seconds that have passed.
    if(is_user_connected(id))
    {
    //Spawn player
    spawn(id)
    dllfunc(DLLFunc_Spawn,id)

    //set_task(1.0,"weapon_method_menu",id)
    }
    }


    /*
    CSDM Style weapons menu
    */
    /*
    public weapon_method_menu(id)
    {
    if(is_user_bot(id))
    {
    weapon_picked[0][id] = 16
    weapon_picked[1][id] = 23
    give_weapons(id)
    }
    else if(firsttime[id])
    {
    firsttime[id] = false
    prim_weapons_menu(id,0)
    }
    else
    {
    cur_offset[id] = 0
    if(ask[id])
    {
    show_menu(id,(1<<0)|(1<<1)|(1<<2),"Weapon Selection Method^n^n1. Last Guns^n2. Last Guns + Save^n3. New Guns",-1,"WeaponMethodMenu")
    }
    else
    {
    give_weapons(id)
    }
    }
    }

    public weapon_method_pushed(id,key)
    {
    switch(key)
    {
    case 0:
    {
    ask[id] = true
    give_weapons(id)
    }
    case 1:
    {
    new string[200]
    format(string,199,"[red][CTF][/red] Type [green]guns[/green] to re-activate the gun menu.")
    show_colored_message(id,string,199)
    ask[id] = false
    give_weapons(id)
    }
    case 2:
    {
    ask[id] = true
    prim_weapons_menu(id,0)
    }
    }

    return ;
    }

    public prim_weapons_menu(id,offset)
    {
    if(offset<0) offset = 0

    new cvar_value[32]
    #if defined amxx176d
    get_cvar_string("ctf_weapons",cvar_value,31)
    #else
    get_pcvar_string(allowableweapons,cvar_value,31)
    #endif
    new flags = read_flags(cvar_value)

    new keys, curnum, menu[2048]
    for(new i=offset;i<19;i++)
    {
    if(i==18)
    {
    options_on_menu[curnum][id] = 24
    keys += (1<<curnum)
    curnum++
    format(menu,2047,"%s^n%d. Random",menu,curnum)
    break;
    }
    else if(flags & power(2,i))
    {
    options_on_menu[curnum][id] = i
    keys += (1<<curnum)

    curnum++
    format(menu,2047,"%s^n%d. %s",menu,curnum,weapon_names[i])

    if(curnum==8)
        break;
    }
    }

    format(menu,2047,"\ySelect Primary Weapon:\w^n^n%s^n",menu)
    if(curnum==8 && offset<12)
    {
    keys += (1<<8)
    format(menu,2047,"%s^n9. Next",menu)
    }
    if(offset)
    {
    keys += (1<<9)
    format(menu,2047,"%s^n0. Back",menu)
    }

    show_menu(id,keys,menu,-1,"PrimaryWeaponSelect")
    }

    public prim_weapons_pushed(id,key)
    {
    if(key<8)
    {
    weapon_picked[0][id] = options_on_menu[key][id]
    cur_offset[id] = 0
    sec_weapons_menu(id,0)
    }
    else
    {
    if(key==8)
        cur_offset[id] += 8
        if(key==9)
            cur_offset[id] -= 8
            prim_weapons_menu(id,cur_offset[id])
        }
        
        return ;
    }

    public sec_weapons_menu(id,offset)
    {
        if(offset<0) offset = 0
        
        new cvar_value[32]
        #if defined amxx176d
        get_cvar_string("ctf_weapons",cvar_value,31)
        #else
        get_pcvar_string(allowableweapons,cvar_value,31)
        #endif
        new flags = read_flags(cvar_value)
        
        new keys, curnum, menu[2048]
        for(new i=18;i<24;i++)
        {
            if(flags & power(2,i))
            {
                options_on_menu[curnum][id] = i
                keys += (1<<curnum)
                
                curnum++
                format(menu,2047,"%s^n%d. %s",menu,curnum,weapon_names[i])
            }
        }
        options_on_menu[curnum][id] = 25
        keys += (1<<curnum)
        curnum++
        format(menu,2047,"%s^n%d. Random",menu,curnum)
        
        format(menu,2047,"\ySelect Secondary Weapon:\w^n^n%s",menu)
        
        show_menu(id,keys,menu,-1,"SecWeaponSelect")
    }

    public sec_weapons_pushed(id,key)
    {
        if(key<8)
        {
            weapon_picked[1][id] = options_on_menu[key][id]
        }
        
        give_weapons(id)
        
        return ;
    }

    public give_weapons(id)
    {
        strip_user_weapons(id)
        
        give_item(id,"weapon_knife")
        
        new weapon[32]
        new csw = csw_contant(weapon_picked[0][id])
        get_weaponname(csw,weapon,31)
        give_item(id,weapon)
        cs_set_user_bpammo(id,csw,999)
        
        csw = csw_contant(weapon_picked[1][id])
        get_weaponname(csw,weapon,31)
        give_item(id,weapon)
        cs_set_user_bpammo(id,csw,999)
        
        #if defined amxx176d
        get_cvar_string("ctf_nades",weapon,31)
        #else
        get_pcvar_string(nades,weapon,31)
        #endif
        new he, flash, smoke
        for(new i=0;i<strlen(weapon);i++)
        {
            switch(weapon[i])
            {
                case 'h': he++
                    case 'f': flash++
                    case 's': smoke++
                }
        }
        
        if(he) give_item(id,"weapon_hegrenade"), cs_set_user_bpammo(id,CSW_HEGRENADE,he)
        if(flash) give_item(id,"weapon_flashbang"), cs_set_user_bpammo(id,CSW_FLASHBANG,flash)
        if(smoke) give_item(id,"weapon_smokegrenade"), cs_set_user_bpammo(id,CSW_SMOKEGRENADE,smoke)
        
        #if defined amxx176d
        get_cvar_string("ctf_weapons",weapon,31)
        #else
        get_pcvar_string(allowableweapons,weapon,31)
        #endif
        new flags = read_flags(weapon)
        if(flags & CTF_VESTHELM) cs_set_user_armor(id,100,CS_ARMOR_VESTHELM)
        else if(flags & CTF_VEST) cs_set_user_armor(id,100,CS_ARMOR_KEVLAR)
        }
    */
    public csw_contant(weapon)
    {
        new 
    num 29
        
    switch(weapon)
        {
            case 
    0num 3
                
    case 1num 5
                
    case 2num 7
                
    case 3num 8
                
    case 4num 12
                
    case 5num 13
                
    case 6num 14
                
    case 7num 15
                
    case 8num 18
                
    case 9num 19
                
    case 10num 20
                
    case 11num 21
                
    case 12num 22
                
    case 13num 23
                
    case 14num 24
                
    case 15num 27
                
    case 16num 28
                
    case 17num 30
                
    case 18num 1
                
    case 19num 10
                
    case 20num 11
                
    case 21num 16
                
    case 22num 17
                
    case 23num 26
                
    case 24:
            {
                new 
    s_weapon[32]
                
    #if defined amxx176d
                
    get_cvar_string("ctf_weapons",s_weapon,31)
                
    #else
                
    get_pcvar_string(allowableweapons,s_weapon,31)
                
    #endif
                
    new flags read_flags(s_weapon)
                do
            {
                
    num random_num(0,18)
                if(!(
    num flags))
                {
                    
    num = -1
                
    }
            }
            while(
    num==-1)
                
    num csw_contant(num)
            }
            case 
    25:
            {
                new 
    s_weapon[32]
                
    #if defined amxx176d
                
    get_cvar_string("ctf_weapons",s_weapon,31)
                
    #else
                
    get_pcvar_string(allowableweapons,s_weapon,31)
                
    #endif
                
    new flags read_flags(s_weapon)
                do
            {
                
    num random_num(18,23)
                if(!(
    num flags))
                {
                    
    num = -1
                
    }
            }
            while(
    num==-1)
                
    num csw_contant(num)
            }
        }
        return 
    num;
    }
    /*
    public cmd_guns(id)
    {
        ask[id] = true
        //weapon_method_menu(id)
    }

    */
    /*
    Weapon Despawn
    */

    public Hook_SetModel(ent,model[])
    {
        if(
    get_pcvar_num(togglecvar) && pev_valid(ent) && ent>maxplayers)
        {
            if(
    containi(model,"models/w_")==0)
            {
                if(
    containi(model,"nade")!=-|| containi(model,"flash")!=-1)
                {
                    
    set_task(2.0,"remove_nade_ent",ent,model,31)
                }
                else
                {
                    
    set_task(0.1,"remove_ent",ent,model,31)
                }
            }
        }
    }

    public 
    remove_ent(model[32],ent)
    {
        if(
    pev_valid(ent))
        {
            static 
    model2[32]
            
    pev(ent,pev_model,model2,31)
            if(
    equal(model,model2))    engfunc(EngFunc_RemoveEntity,ent)
        }
    }

    public 
    remove_nade_ent(model[32],ent)
    {
        if(
    pev_valid(ent))
        {
            static 
    model2[32]
            
    pev(ent,pev_model,model2,31)
            if(
    equal(model,model2))
            {
                static 
    Float:velocity[3]
                
    pev(ent,pev_velocity,velocity)
                
                if(!
    velocity[0] && !velocity[1] && !velocity[2])
                    
    set_pev(ent,pev_flags,FL_KILLME)
            }
        }
    }


    /*
    Base Setup - Spawn Protection & Flag Spawn
    */

    public plugin_precache() 
    {
        
    precache_model(holo_model)
        
    precache_model(red_flag_model)
        
    precache_model(blue_flag_model)
        
        
    beamsprite precache_model("sprites/dot.spr")
        
    precache_model("models/scientist.mdl")
        
        if(
    get_pcvar_num(register_cvar("ctf_sounds","1")))
        {
            
    play_sounds true
            precache_sound
    (flag_captured)
            
    precache_sound(flag_returned)
            
    precache_sound(flag_taken)
        }
    }

    public 
    cmd_set_tflag(id,level,cid)
    {
        if(!
    cmd_access(id,level,cid,1))
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        
    setflagspawn(id,0)
        
        
    console_print(id,"[CTF] T Flag Spawn Location Saved.")
        
        return 
    PLUGIN_HANDLED
    }

    public 
    cmd_set_ctflag(id,level,cid)
    {
        if(!
    cmd_access(id,level,cid,1))
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        
    setflagspawn(id,1)
        
        
    console_print(id,"[CTF] CT Flag Spawn Location Saved.")
        
        return 
    PLUGIN_HANDLED
    }

    public 
    setflagspawn(id,team)
    {
        new 
    bool:readfromfile false
        
    new configfile[200]
        
    get_configsdir(configfile,199)
        
    format(configfile,199,"%s/CTF_FlagSpawns.ini",configfile)
        
        new 
    mapname[32]
        
    get_mapname(mapname,31)
        new 
    string[200]
        
    format(string,199,"%s | T | ",mapname)
        
        new 
    Float:origin[3], Float:origin2[3]
        switch(
    team)
        {
            case 
    0:
            {
                
    pev(flag_holder[1],pev_origin,origin2)
                
    pev(id,pev_origin,origin)
                
    engfunc(EngFunc_SetOrigin,flag_holder[0],origin)
            }
            case 
    1:
            {
                
    pev(flag_holder[0],pev_origin,origin)
                
    pev(id,pev_origin,origin2)
                
    engfunc(EngFunc_SetOrigin,flag_holder[1],origin2)
            }
        }
        
        if(
    file_exists(configfile))
        {
            new 
    read[200], trashFsize file_size(configfile,1)
            for(new 
    i=0;i<Fsize;i++)
            {
                
    read_file(configfile,i,read,199,trash)
                
                if(
    containi(read,string)==0)
                {
                    
    format(string,199,"%s | T | %f %f %f | CT | %f %f %f",mapname,origin[0],origin[1],origin[2],origin2[0],origin2[1],origin2[2])
                    
    write_file(configfile,string,i)
                    
    readfromfile true
                    
    break;
                }
            }
        }
        
        if(!
    readfromfile)
        {
            
    format(string,199,"%s | T | %f %f %f | CT | %f %f %f",mapname,origin[0],origin[1],origin[2],origin2[0],origin2[1],origin2[2])
            
    write_file(configfile,string,-1)
            
        }
    }

    public 
    find_minmaxs()
    {
        new 
    Float:origin[3], i
        
    new ent engfunc(EngFunc_FindEntityByString,maxplayers,"classname","info_player_deathmatch")
        while(
    ent)
        {
            if(
    pev_valid(ent))
            {
                
    pev(ent,pev_origin,origin)
                for(
    i=0;i<3;i++)
                {
                    if(
    origin[i] < mins[0][i])
                        
    mins[0][i] = origin[i]
                    if(
    origin[i] > maxs[0][i])
                        
    maxs[0][i] = origin[i]
                }
            }
            
    ent engfunc(EngFunc_FindEntityByString,ent,"classname","info_player_deathmatch")
        }
        
        
    ent engfunc(EngFunc_FindEntityByString,maxplayers,"classname","info_player_start")
        while(
    ent)
        {
            if(
    pev_valid(ent))
            {
                
    pev(ent,pev_origin,origin)
                for(
    i=0;i<3;i++)
                {
                    if(
    origin[i] < mins[1][i])
                        
    mins[1][i] = origin[i]
                    if(
    origin[i] > maxs[1][i])
                        
    maxs[1][i] = origin[i]
                }
            }
            
    ent engfunc(EngFunc_FindEntityByString,ent,"classname","info_player_start")
        }
        
        
    maxs[0][2] += 70.0
        mins
    [1][2] -= 70.0
        maxs
    [0][0] += 32.0
        mins
    [1][0] -= 32.0
        maxs
    [0][1] += 32.0
        mins
    [1][1] -= 32.0
        
        
    new Float:T_origin[3], Float:CT_origin[3]
        
    get_flagstand_origins(CT_origin,T_origin)
        
        
    ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
    set_pev(ent,pev_classname,"Flagstand_Model")
        
    engfunc(EngFunc_SetModel,ent,holo_model)
        
    set_pev(ent,pev_effects,EF_BRIGHTLIGHT)
        
    set_pev(ent,pev_renderfx,kRenderFxGlowShell)
        
    set_pev(ent,pev_rendercolor,Float:{255.0,0.0,0.0})
        
    set_pev(ent,pev_rendermode,kRenderNormal)
        
    set_pev(ent,pev_renderamt,255.0)
        
    set_pev(ent,pev_gaitsequence,0)
        
    set_pev(ent,pev_sequence,0)
        
    set_pev(ent,pev_framerate,0.7)
        
    engfunc(EngFunc_SetOrigin,ent,T_origin)
        
    engfunc(EngFunc_DropToFloor,ent)
        
    pev(ent,pev_origin,origin)
        
    origin[2] += 36.0
        engfunc
    (EngFunc_SetOrigin,ent,origin)
        
    set_pev(ent,pev_nextthink,1.0)
        
    flagstand_ents[0] = ent
        flag_holder
    [0] = ent
        
        ent 
    engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
    set_pev(ent,pev_classname,"Flagstand_Model")
        
    engfunc(EngFunc_SetModel,ent,holo_model)
        
    set_pev(ent,pev_effects,EF_BRIGHTLIGHT)
        
    set_pev(ent,pev_renderfx,kRenderFxGlowShell)
        
    set_pev(ent,pev_rendercolor,Float:{0.0,0.0,255.0})
        
    set_pev(ent,pev_rendermode,kRenderNormal)
        
    set_pev(ent,pev_renderamt,255.0)
        
    set_pev(ent,pev_gaitsequence,0)
        
    set_pev(ent,pev_sequence,0)
        
    set_pev(ent,pev_framerate,0.7)
        
    engfunc(EngFunc_SetOrigin,ent,CT_origin)
        
    engfunc(EngFunc_DropToFloor,ent)
        
    pev(ent,pev_origin,origin)
        
    origin[2] += 36.0
        engfunc
    (EngFunc_SetOrigin,ent,origin)
        
    set_pev(ent,pev_nextthink,1.0)
        
    flagstand_ents[1] = ent
        flag_holder
    [1] = ent
        
        
    for(new i=0;i<2;i++)
        {
            for(new 
    j=0;j<3;j++)
            {
                
    I_max[i][j] = floatround(maxs[i][j])
                
    I_min[i][j] = floatround(mins[i][j])
            }
        }
        
        
    set_task(5.0,"create_beamsprites")
        
    set_task(10.0,"create_beamsprites",1500,"",0,"b")
        
        
    ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
    set_pev(ent,pev_classname,"CTF_T_Flag")
        
    engfunc(EngFunc_SetModel,ent,red_flag_model)
        
    set_pev(ent,pev_movetype,MOVETYPE_FLY)
        
    FM_Think_Hook(ent)
        
        
    ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
    set_pev(ent,pev_classname,"CTF_CT_Flag")
        
    engfunc(EngFunc_SetModel,ent,blue_flag_model)
        
    set_pev(ent,pev_movetype,MOVETYPE_FLY)
        
    FM_Think_Hook(ent)
    }

    public 
    get_flagstand_origins(Float:CT_origin[3],Float:T_origin[3])
    {
        new 
    i
        
    new Float:midpoint[2][3]
        for(
    i=0;i<2;i++)
        {
            for(new 
    j=0;j<3;j++)
            {
                
    midpoint[i][j] = (maxs[i][j] + mins[i][j]) / 2.0
            
    }
        }
        
        new 
    configfile[200]
        
    get_configsdir(configfile,199)
        
    format(configfile,199,"%s/CTF_FlagSpawns.ini",configfile)
        
        
    T_origin[0] = midpoint[0][0]
        
    T_origin[1] = midpoint[0][1]
        
    T_origin[2] = midpoint[0][2]
        
    CT_origin[0] = midpoint[1][0]
        
    CT_origin[1] = midpoint[1][1]
        
    CT_origin[2] = midpoint[1][2]
        
        new 
    mapname[32]
        
    get_mapname(mapname,31)
        new 
    string[200]
        
    format(string,199,"%s | T | ",mapname)
        
        if(
    file_exists(configfile))
        {
            new 
    read[200], trashFsize file_size(configfile,1)
            for(new 
    i=0;i<Fsize;i++)
            {
                
    read_file(configfile,i,read,199,trash)
                
                if(
    containi(read,string)==0)
                {
                    
    format(read,199,read[strlen(string)])
                    
    replace_all(read,199," | CT |","")
                    
    strbreak(read,string,199,read,199)
                    
    T_origin[0] = str_to_float(string)
                    
    strbreak(read,string,199,read,199)
                    
    T_origin[1] = str_to_float(string)
                    
    strbreak(read,string,199,read,199)
                    
    T_origin[2] = str_to_float(string)
                    
    strbreak(read,string,199,read,199)
                    
    CT_origin[0] = str_to_float(string)
                    
    strbreak(read,string,199,read,199)
                    
    CT_origin[1] = str_to_float(string)
                    
    strbreak(read,string,199,read,199)
                    
    CT_origin[2] = str_to_float(string)
                    break;
                }
            }
        }
        
        return ;
    }

    public 
    FM_Think_Hook(ent)
    {
        if(
    pev_valid(ent))
        {
            static 
    classname[32]
            
    pev(ent,pev_classname,classname,31)
            if(
    equal(classname,"Flagstand_Model"))
            {
                static 
    Float:angles[3]
                
    pev(ent,pev_angles,angles)
                
    angles[1] += 0.3
                
    while(angles[1]>180.0angles[1] -= 360.0
                set_pev
    (ent,pev_angles,angles)
                
    set_pev(ent,pev_nextthink,1.0)
            }
            else if(
    equal(classname,"CTF_T_Flag"))
            {
                
    Flag_Think_Hook(ent,0)
                
    set_pev(ent,pev_nextthink,1.0)
            }
            else if(
    equal(classname,"CTF_CT_Flag"))
            {
                
    Flag_Think_Hook(ent,1)
                
    set_pev(ent,pev_nextthink,1.0)
            }
        }
    }

    public 
    create_beamsprites()
    {
        if(
    get_pcvar_num(spawnprotection))
        {
            
    //T Base
            
    create_beam_message(I_max[0][0],I_max[0][1],I_max[0][2],I_max[0][0],I_min[0][1],I_max[0][2],255,0)
            
    //create_beam_message(I_max[0][0],I_max[0][1],I_min[0][2],I_max[0][0],I_min[0][1],I_min[0][2],255,0)
            
    create_beam_message(I_max[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_max[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
            
            
    create_beam_message(I_max[0][0],I_max[0][1],I_max[0][2],I_min[0][0],I_max[0][1],I_max[0][2],255,0)
            
    //create_beam_message(I_max[0][0],I_max[0][1],I_min[0][2],I_min[0][0],I_max[0][1],I_min[0][2],255,0)
            
    create_beam_message(I_max[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_min[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
            
            
    create_beam_message(I_min[0][0],I_max[0][1],I_max[0][2],I_min[0][0],I_min[0][1],I_max[0][2],255,0)
            
    //create_beam_message(I_min[0][0],I_max[0][1],I_min[0][2],I_min[0][0],I_min[0][1],I_min[0][2],255,0)
            
    create_beam_message(I_min[0][0],I_max[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_min[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
            
            
    create_beam_message(I_min[0][0],I_min[0][1],I_max[0][2],I_max[0][0],I_min[0][1],I_max[0][2],255,0)
            
    //create_beam_message(I_min[0][0],I_min[0][1],I_min[0][2],I_max[0][0],I_min[0][1],I_min[0][2],255,0)
            
    create_beam_message(I_min[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,I_max[0][0],I_min[0][1],(I_max[0][2] + I_min[0][2]) / 2,255,0)
            
            
    //CT Base
            
    create_beam_message(I_max[1][0],I_max[1][1],I_max[1][2],I_max[1][0],I_min[1][1],I_max[1][2],0,255)
            
    //create_beam_message(I_max[1][0],I_max[1][1],I_min[1][2],I_max[1][0],I_min[1][1],I_min[1][2],255,0)
            
    create_beam_message(I_max[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_max[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
            
            
    create_beam_message(I_max[1][0],I_max[1][1],I_max[1][2],I_min[1][0],I_max[1][1],I_max[1][2],0,255)
            
    //create_beam_message(I_max[1][0],I_max[1][1],I_min[1][2],I_min[1][0],I_max[1][1],I_min[1][2],255,0)
            
    create_beam_message(I_max[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_min[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
            
            
    create_beam_message(I_min[1][0],I_max[1][1],I_max[1][2],I_min[1][0],I_min[1][1],I_max[1][2],0,255)
            
    //create_beam_message(I_min[1][0],I_max[1][1],I_min[1][2],I_min[1][0],I_min[1][1],I_min[1][2],255,0)
            
    create_beam_message(I_min[1][0],I_max[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_min[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
            
            
    create_beam_message(I_min[1][0],I_min[1][1],I_max[1][2],I_max[1][0],I_min[1][1],I_max[1][2],0,255)
            
    //create_beam_message(I_min[1][0],I_min[1][1],I_min[1][2],I_max[1][0],I_min[1][1],I_min[1][2],255,0)
            
    create_beam_message(I_min[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,I_max[1][0],I_min[1][1],(I_max[1][2] + I_min[1][2]) / 2,0,255)
        }
    }

    public 
    create_beam_message(origin1_0,origin1_1,origin1_2,origin2_0,origin2_1,origin2_2,r,b)
    {
        
    message_begin(MSG_BROADCASTSVC_TEMPENTITY
        
    write_byte(0)        //TE_BEAMPOINTS
        
    write_coord(origin1_0)
        
    write_coord(origin1_1)
        
    write_coord(origin1_2)
        
    write_coord(origin2_0)
        
    write_coord(origin2_1)
        
    write_coord(origin2_2)
        
    write_short(beamsprite)
        
    write_byte(1)    // framestart
        
    write_byte(1)    // framerate
        
    write_byte(110)    // life in 0.1's
        
    write_byte(5)    // width
        
    write_byte(0)    // noise
        
    write_byte(r)
        
    write_byte(0)
        
    write_byte(b)
        
    write_byte(200)    // brightness
        
    write_byte(0)    // speed
        
    message_end()
    }

    public 
    FM_PlayerPreThink_Hook(id)
    {
        if(
    is_user_alive(id) && !is_user_bot(id) && get_pcvar_num(spawnprotection) && get_pcvar_num(togglecvar) && id!=flag_holder[0] && id!=flag_holder[1])
        {
            static 
    Float:origin[3]
            
    pev(id,pev_origin,origin)
            if(
    is_in_safezone[id])
            {
                new 
    buttons pev(id,pev_button)
                if(
    buttons IN_ATTACKbuttons -= IN_ATTACK
                
    if(buttons IN_ATTACK2buttons -= IN_ATTACK2
                set_pev
    (id,pev_button,buttons)
                
                
    buttons pev(id,pev_oldbuttons)
                if(
    buttons IN_ATTACKbuttons -= IN_ATTACK
                
    if(buttons IN_ATTACK2buttons -= IN_ATTACK2
                set_pev
    (id,pev_oldbuttons,buttons)
                
                if(!((
    origin[0]<=maxs[0][0] && origin[0]>=mins[0][0] && origin[1]<=maxs[0][1] && origin[1]>=mins[0][1]) || (origin[0]<=maxs[1][0] && origin[0]>=mins[1][0] && origin[1]<=maxs[1][1] && origin[1]>=mins[1][1])))
                {
                    
    unsafezone(id)
                }
            }
            else if((
    origin[0]<=maxs[0][0] && origin[0]>=mins[0][0] && origin[1]<=maxs[0][1] && origin[1]>=mins[0][1]) || (origin[0]<=maxs[1][0] && origin[0]>=mins[1][0] && origin[1]<=maxs[1][1] && origin[1]>=mins[1][1]))
            {
                switch(
    cs_get_user_team(id))
                {
                    case 
    CS_TEAM_Tin_safezone(id,255,0,0)
                        case 
    CS_TEAM_CTin_safezone(id,0,0,255)
                        default: 
    in_safezone(id,0,255,0)
                }
            }
        }
    }

    public 
    in_safezone(id,r,g,b)
    {
        
    set_user_godmode(id,1)
        
    set_user_rendering(id,kRenderFxGlowShell,r,g,b,kRenderTransColor,50)
        
    is_in_safezone[id] = true
        message_begin
    (MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
        
    write_short(~0)
        
    write_short(~0)
        
    write_short(1<<12)
        
    write_byte(r)
        
    write_byte(g)
        
    write_byte(b)
        
    write_byte(100)
        
    message_end()
        new 
    param[3]
        
    param[0] = r
        param
    [1] = g
        param
    [2] = b
        
    if(!task_exists(id 20000)) set_task(8.0,"reflash",id 20000,param,3,"b")
        
    set_task(0.5,"reflash",id 20000,param,3)
    }

    public 
    reflash(param[3],id)
    {
        
    id -= 20000
        
    if(!is_in_safezone[id] || !is_user_alive(id))
        {
            
    remove_task(id 20000)
        }
        else
        {
            
    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
            
    write_short(~0)
            
    write_short(~0)
            
    write_short(1<<12)
            
    write_byte(param[0])
            
    write_byte(param[1])
            
    write_byte(param[2])
            
    write_byte(100)
            
    message_end()
        }
    }

    public 
    unsafezone(id)
    {
        
    set_user_godmode(id)
        
    set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255)
        
    is_in_safezone[id] = false
        message_begin
    (MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
        
    write_short(~0)
        
    write_short(~0)
        
    write_short(1<<12)
        
    write_byte(0)
        
    write_byte(0)
        
    write_byte(0)
        
    write_byte(1)
        
    message_end()
        
    remove_task(id 20000)
    }


    /*
    Flag Think
    */

    public Flag_Think_Hook(ent,team)
    {
        if(
    pev_valid(flag_holder[team]))
        {
            static 
    Float:origin[3], Float:origin2[3]
            
    pev(flag_holder[team],pev_origin,origin)
            
    origin[2] += 16.0
            pev
    (ent,pev_origin,origin2)
            if(
    get_distance_f(origin,origin2)>50.0)
                
    engfunc(EngFunc_SetOrigin,ent,origin)
            
            if(
    flag_holder[team]!=flagstand_ents[team] && flag_holder[(team 1) % 2]==flagstand_ents[(team 1) % 2])
            {
                
    pev(flagstand_ents[(team 1) % 2],pev_origin,origin)
                if(
    get_distance_f(origin2,origin)<PICKUP_DISTANCE)
                {
                    new 
    string[200]
                    new 
    cvar_value get_pcvar_num(maxcaps)
                    new 
    ministring[4]
                    if(
    team)
                    {
                        
    ministring "CT"
                        
    TScore++
                        if(
    cvar_value<=TScore)
                        {
                            
    format(string,199,"[red][CTF][/red] Game Over. [green]Ts[/green] won.")
                            
    show_colored_message(0,string,199)
                            
    endmap()
                        }
                    }
                    else
                    {
                        
    ministring "T"
                        
    CTScore++
                        if(
    cvar_value<=CTScore)
                        {
                            
    format(string,199,"[red][CTF][/red] Game Over. [green]CTs[/green] won.")
                            
    show_colored_message(0,string,199)
                            
    endmap()
                        }
                    }
                    new 
    name[32]
                    
    get_user_name(flag_holder[team],name,31)
                    
    format(string,199,"[red][CTF][/red] [green]%s[/green] captured the [green]%s[/green] flag.",name,ministring)
                    if(
    play_soundsclient_cmd(0,"mp3 play sound/%s",flag_captured)
                    
    show_colored_message(0,string,199)
                    
    flag_holder[team] = flagstand_ents[team]
                    
    write_hudmsg()
                    
                    
                    return ;
                }
            }
            
            
    pev(flag_holder[team],pev_velocity,origin)
            
    set_pev(ent,pev_velocity,origin)
        }
        
        if(
    flag_holder[team]==flagstand_ents[team] || !flag_holder[team])
        {
            static 
    Float:origin[3]
            static 
    Float:flag_origin[3]
            
    pev(ent,pev_origin,flag_origin)
            static 
    players[32], num
            get_players
    (players,num,"ach")
            for(new 
    i=0;i<num;i++)
            {
                if(
    get_user_team(players[i])!=(team 1))
                {
                    
    pev(players[i],pev_origin,origin)
                    if(
    get_distance_f(origin,flag_origin)<PICKUP_DISTANCE)
                    {
                        new 
    ministring[4]
                        if(
    teamministring "CT"
                        
    else ministring "T"
                        
    flag_holder[team] = players[i]
                        new 
    name[32]
                        new 
    string[200]
                        
    get_user_name(players[i],name,31)
                        
    format(string,199,"[red][CTF][/red] [green]%s[/green] picked up the [green]%s[/green] flag.",name,ministring)
                        if(
    play_soundsclient_cmd(0,"mp3 play sound/%s",flag_taken)
                        
    show_colored_message(0,string,199)
                        
    flag_holder[team] = players[i]
                        
    write_hudmsg()
                        
    unsafezone(players[i])
                        break;
                    }
                }
                else if(!
    flag_holder[team])
                {
                    
    pev(players[i],pev_origin,origin)
                    if(
    get_distance_f(origin,flag_origin)<PICKUP_DISTANCE)
                    {
                        new 
    ministring[4]
                        if(
    teamministring "CT"
                        
    else ministring "T"
                        
    flag_holder[team] = players[i]
                        new 
    name[32]
                        new 
    string[200]
                        
    get_user_name(players[i],name,31)
                        
    format(string,199,"[red][CTF][/red] [green]%s[/green] returned the [green]%s[/green] flag.",name,ministring)
                        if(
    play_soundsclient_cmd(0,"mp3 play sound/%s",flag_returned)
                        
    show_colored_message(0,string,199)
                        
    flag_holder[team] = flagstand_ents[team]
                        
    write_hudmsg()
                        break;
                    }
                }
            }
        }
        
        return ;
    }

    public 
    client_disconnect(id)
    {
        if(
    read_data(2)==flag_holder[0])
        {
            
    flag_holder[0] = 0
            
    new string[200]
            
    format(string,199,"[red][CTF][/red] [green]UNKNOWN[/green] dropped the [green]T[/green] flag.")
            if(
    play_soundsclient_cmd(0,"mp3 play sound/%s",flag_taken)
            
    show_colored_message(0,string,199)
            
    write_hudmsg()
        }
        else if(
    read_data(2)==flag_holder[1])
        {
            
    flag_holder[1] = 0
            
    new string[200]
            
    format(string,199,"[red][CTF][/red] [green]UNKNOWN[/green] dropped the [green]CT[/green] flag.")
            if(
    play_soundsclient_cmd(0,"mp3 play sound/%s",flag_taken)
            
    show_colored_message(0,string,199)
            
    write_hudmsg()
        }
    }

    public 
    DeathMsg()
    {
        new 
    victim read_data(2)
        if(
    is_user_connected(victim))
        {
            if(
    victim==flag_holder[0])
            {
                
    flag_holder[0] = 0
                
    new name[32]
                new 
    string[200]
                
    get_user_name(victim,name,31)
                
    format(string,199,"[red][CTF][/red] [green]%s[/green] dropped the [green]T[/green] flag.",name)
                
    show_colored_message(0,string,199)
                
    write_hudmsg()
            }
            else if(
    victim==flag_holder[1])
            {
                
    flag_holder[1] = 0
                
    new name[32]
                new 
    string[200]
                
    get_user_name(victim,name,31)
                
    format(string,199,"[red][CTF][/red] [green]%s[/green] dropped the [green]CT[/green] flag.",name)
                
    show_colored_message(0,string,199)
                
    write_hudmsg()
            }
            
    set_task(get_pcvar_float(respawntime),"respawn_player",victim)
        }
    }

    public 
    show_colored_message(id,string[],maxlen)
    {
        
    replace_all(string,maxlen,"[blue]","^x03")
        
    replace_all(string,maxlen,"[/blue]","^x01")
        
    replace_all(string,maxlen,"[red]","^x03")
        
    replace_all(string,maxlen,"[/red]","^x01")
        
    replace_all(string,maxlen,"[green]","^x04")
        
    replace_all(string,maxlen,"[/green]","^x01")
        
    format(string,maxlen,"^x04^x01%s",string)
        
        static 
    q
        q
    ++
        if(!
    id)
        {
            static 
    players[32], num
            get_players
    (players,num,"ch")
            for(new 
    i=0;i<num;i++)
            {
                
    message_begin(MSG_ONE,saytext_msgid,{0,0,0},players[i])
                
    write_byte(players[i])
                
    write_string(string)
                
    message_end()
            }
        }
        else
        {
            
    message_begin(MSG_ONE,saytext_msgid,{0,0,0},id)
            
    write_byte(id)
            
    write_string(string)
            
    message_end()
        }
    }

    public 
    write_hudmsg()
    {
        new 
    flagloc[32]
        if(!
    flag_holder[0])
        {
            
    format(flagloc,31,"On Ground")
        }
        else if(
    flag_holder[0]==flagstand_ents[0])
        {
            
    format(flagloc,31,"Base")
        }
        else if(
    is_user_alive(flag_holder[0]))
        {
            
    get_user_name(flag_holder[0],flagloc,31)
        }
        
        
    set_hudmessage(25500, -1.00.0306.012.00.00.0)
        
    show_hudmessage(0,"[ %d ] T Flag: %s",TScore,flagloc)
        
        if(!
    flag_holder[1])
        {
            
    format(flagloc,31,"On Ground")
        }
        else if(
    flag_holder[1]==flagstand_ents[0])
        {
            
    format(flagloc,31,"Base")
        }
        else if(
    is_user_alive(flag_holder[1]))
        {
            
    get_user_name(flag_holder[1],flagloc,31)
        }
        
        
    set_hudmessage(00255, -1.00.0306.012.00.00.0,3)
        
    show_hudmessage(0,"_^n [ %d ] CT Flag: %s",CTScore,flagloc)
    }

    public 
    endmap()
    {
        new 
    trash
        
    new map[32]
        new 
    configfile[200]
        
    get_basedir(configfile,199)
        
    format(configfile,199,"%s/maps.ini",configfile)
        
    format(map,31,"de_dust")
        if(
    file_exists(configfile)) read_file(configfile,random_num(0,file_size(configfile,1) - 1),map,31,trash)
        if(!
    is_map_valid(map))
        {
            if(
    file_size(configfile,1)<3)
            {
                
    server_cmd("amx_map de_dust2;amx_map de_dust2_cz")
            }
            else
            {
                
    set_task(0.1,"endmap")
            }
        }
        else 
    server_cmd("amx_map %s",map)
    }


    /*
    CTF Vote (From v2.0)
    */

    public say_vote_hook(id)
    {
        if(!
    get_pcvar_num(votecvar))
        {
            
    client_print(id,print_chat,"[CTF] Voting disabled")
        }
        else if(
    roundend)
        {
            
    client_print(id,print_chat,"[CTF] Voting can't start. People are buying.")
        }
        else if(
    voting)
        {
            
    client_print(id,print_chat,"[CTF] Voting currently in progrss.")
        }
        else if(
    voted)
        {
            
    client_print(id,print_chat,"[CTF] Can't vote this soon after a vote.")
        }
        else if(
    get_pcvar_num(togglecvar))
        {
            
    voting=true
            voted
    =true
            show_menu
    (0,(1<<0)|(1<<1),"\bTurn CTF off?^n^n\w1. Yes^n\w2. No",-1,"ctfvote")
            
    set_task(get_pcvar_float(votelength),"voting_over",0)
            
    set_task(get_pcvar_float(votedelay),"voted_over")
        }
        else
        {
            
    voting=true
            voted
    =true
            show_menu
    (0,(1<<0)|(1<<1),"\bTurn CTF on?^n^n\w1. Yes^n\w2. No",-1,"ctfvote")
            
    set_task(get_pcvar_float(votelength),"voting_over",1)
            
    set_task(get_pcvar_float(votedelay),"voted_over")
        }
    }

    public 
    Key_Hook(id,key)
    {
        if(
    voting)
        {
            
    client_print(id,print_chat,"[CTF] Vote Accepted.")
            if(!
    keyyes++
            else 
    no++
        }
    }

    public 
    voting_over(num)
    {
        if(
    num)
        {
            
    client_print(0,print_chat,"[CTF] Voting to turn CTF on results: Yes: %d | No: %d",yes,no)
            if(
    yes>no)
            {
                
    ctf_on()
            }
        }
        else
        {
            
    client_print(0,print_chat,"[CTF] Voting to turn CTF off results: Yes: %d | No: %d",yes,no)
            if(
    yes>no)
            {
                
    ctf_off()
            }
        }
        
    yes=0
        no
    =0
        voting
    =false
    }

    public 
    voted_over()
    {
        
    voted=false
    }

    public 
    endround()
    {
        
    roundend =  true
        set_task
    (7.0 get_pcvar_float(voterounddelay),"roundstart")
    }

    public 
    roundstart()
    {
        
    roundend false
    }


    /*
    Off / On Functions
    */

    public ctf_off()
    {
        
    set_pcvar_num(togglecvar,0)
        
    remove_task(1234)
        
    remove_task(1500)
        
    engfunc(EngFunc_SetOrigin,flagstand_ents[0],Float:{-4800.0,-4800.0,-4800.0})
        
    engfunc(EngFunc_SetOrigin,flagstand_ents[1],Float:{-4800.0,-4800.0,-4800.0})
        
    flag_holder[0] = flagstand_ents[0]
        
    flag_holder[1] = flagstand_ents[1]
        
    add_objectives()
        for(new 
    i=1;i<=32;i++)
        {
            if(
    is_user_alive(i) && is_in_safezone[i])
            {
                
    unsafezone(i)
            }
        }
    }

    public 
    ctf_on()
    {
        
    set_pcvar_num(togglecvar,1)
        
    set_task(10.0,"create_beamsprites",1500,"",0,"b")
        if(!
    pev_valid(flagstand_ents[0]) || !pev_valid(flagstand_ents[1]))
        {
            
    set_task(0.5,"find_minmaxs")
        }
        else
        {
            new 
    Float:T_origin[3], Float:CT_origin[3]
            
    get_flagstand_origins(CT_origin,T_origin)
            
    engfunc(EngFunc_SetOrigin,flagstand_ents[0],T_origin)
            
    engfunc(EngFunc_SetOrigin,flagstand_ents[1],CT_origin)
            
    engfunc(EngFunc_DropToFloor,flagstand_ents[0])
            
    engfunc(EngFunc_DropToFloor,flagstand_ents[1])
            
    pev(flagstand_ents[0],pev_origin,T_origin)
            
    pev(flagstand_ents[1],pev_origin,CT_origin)
            
    T_origin[2] += 36.0
            CT_origin
    [2] += 36.0
            engfunc
    (EngFunc_SetOrigin,flagstand_ents[0],T_origin)
            
    engfunc(EngFunc_SetOrigin,flagstand_ents[1],CT_origin)
        }
        
    set_task(10.0,"write_hudmsg",1234,"",0,"b")
        
    remove_objectives()
        
    //set_task(10.0,"ctf_restartround")
        
    remove_task(5547)
        
    remove_task(5548)
        
    client_print(0,print_center,"[CTF] CTF Enabled. Round Restarting in 10 seconds.")
    }
    /*
    public ctf_restartround()
    {
        set_cvar_num("sv_restartround",1)
        for(new i=1;i<=32;i++)
        {
            if(is_user_connected(i))
            {
                firsttime[i] = true
                //weapon_method_menu(i)
            }
        }
    }

    */
    /*
    Off / On Commands
    */

    public cmd_off(id,level,cid)
    {
        if(!
    cmd_access(id,level,cid,1))
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        if(
    get_pcvar_num(togglecvar))
        {
            
    console_print(id,"[CTF] CTF Turned Off.")
            
    ctf_off()
            new 
    string[200]
            
    format(string,199,"[red][CTF][/red] CTF Turned [green]Off[/green].")
            
    show_colored_message(0,string,199)
        }
        else
        {
            
    console_print(id,"[CTF] CTF Is Already Turned Off.")
        }
        
        return 
    PLUGIN_HANDLED
    }


    public 
    cmd_on(id,level,cid)
    {
        if(!
    cmd_access(id,level,cid,1))
        {
            return 
    PLUGIN_HANDLED
        
    }
        
        if(!
    get_pcvar_num(togglecvar))
        {
            
    console_print(id,"[CTF] CTF Turned On.")
            
    ctf_on()
            new 
    string[200]
            
    format(string,199,"[red][CTF][/red] CTF Turned [green]On[/green].")
            
    show_colored_message(0,string,199)
        }
        else
        {
            
    console_print(id,"[CTF] CTF Is Already Turned On.")
        }
        
        return 
    PLUGIN_HANDLED
    }

    /*
    Remove Map Objectives
    */

    public remove_objectives()
    {
        new 
    ent
        
        
    for(new i=0;i<MAX_OBJ_TYPES;i++)
        {
            
    ent engfunc(EngFunc_FindEntityByString,maxplayers,"classname",map_objectives[i])
            while(
    ent)
            {
                if(
    pev_valid(ent))
                {
                    
    objective_type[num_objectives] = i
                    pev
    (ent,pev_origin,objective[num_objectives])
                    
    pev(ent,pev_size,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
                    
    pev(ent,pev_solid,objective_solidity[num_objectives])
                    
    engfunc(EngFunc_RemoveEntity,ent)
                    
    num_objectives++
                }
                
    ent engfunc(EngFunc_FindEntityByString,ent,"classname",map_objectives[i])
            }
        }
        
        
    give_c4 false
    }

    public 
    add_objectives()
    {
        new 
    ent
        
    for(num_objectives--;num_objectives>=0;num_objectives--)
        {
            if(
    objective_type[num_objectives]==|| objective_type[num_objectives]==5give_c4 true
            ent 
    engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,map_objectives[objective_type[num_objectives]]))
            
    set_pev(ent,pev_classname,map_objectives[objective_type[num_objectives]])
            
    set_pev(ent,pev_origin,objective[num_objectives])
            
    set_pev(ent,pev_solid,objective_solidity[num_objectives])
            
    engfunc(EngFunc_SetSize,ent,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
            
    set_pev(ent,pev_size,objectiveminsize[num_objectives],objectivemaxsize[num_objectives])
            
    dllfunc(DLLFunc_Spawn,ent)
            
    dllfunc(DLLFunc_Think,ent)
            for(new 
    i=0;i<3;i++)
            {
                
    objective[num_objectives][i] = 0.0
                objectiveminsize
    [num_objectives][i] = 0.0
                objectivemaxsize
    [num_objectives][i] = 0.0
            
    }
        }
        
    num_objectives=0
    }

    //All this handles de_ maps - making them re-work if ctf is turned off during runtime.
    public newround()
    {
        if(
    give_c4set_task(0.5,"manually_give_c4",5547)
    }

    public 
    manually_give_c4()
    {
        if(!
    get_pcvar_num(togglecvar))
        {
            new 
    found 0
            
    static start
            
    if(start<|| start>maxplayersstart 1
            
    for(;start<=maxplayers;start++)
            {
                if(
    is_user_alive(start) && cs_get_user_team(start)==CS_TEAM_T)
                {
                    
    found start
                    
    break;
                }
            }
            if(!
    found)
            {
                for(
    start 0;start<=maxplayers;start++)
                {
                    if(
    is_user_alive(start) && cs_get_user_team(start)==CS_TEAM_T)
                    {
                        
    found start
                        
    break;
                    }
                }
            }
            if(
    foundgive_item(found,"weapon_c4")
        }
        
    set_task(get_cvar_float("mp_roundtime") * 60.0,"force_endround",5548)
    }

    public 
    bomb_planted() remove_task(5548)

    public 
    force_endround()
    {
        
    getweapons()
        
    set_task(0.5,"killum")
    }

    public 
    getweapons()
    {
        static 
    ii2
        
    for(i=1;i<=maxplayers;i++)
        {
            
    arrayset(weapon[i],0,31)
            if(
    is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
            {
                
    armoramount[i] = cs_get_user_armor(i,armortype[i])
                for(
    i2=1;i2<=30;i2++)
                {
                    if(
    i2!=&& i2!=&& i2!=29)
                    {
                        if(
    user_has_weapon(i,i2))
                        {
                            
    weapon[i][i2] = cs_get_user_bpammo(i,i2)
                            if(!
    weapon[i][i2])  weapon[i][i2] = 1
                        
    }
                    }
                }
            }
        }
    }

    public 
    killum()
    {
        
    killing=true
        
    new msgblock get_msg_block(get_user_msgid("DeathMsg"))
        
        
    set_msg_block(get_user_msgid("DeathMsg"),BLOCK_SET)
        new 
    i
        
    for(i=1;i<=maxplayers;i++)
        {
            if(
    is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
            {
                
    user_kill(i)
                
    client_print(i,print_chat,"[AMXX] You Failed to complete map objective. Respawning.")
                
    set_task(4.0,"spawnum",i)
            }
        }
        
    set_msg_block(get_user_msgid("DeathMsg"),msgblock)
        
    killing=false
        set_task
    (4.5,"giveweapons")
    }

    public 
    plugin_log()
    {
        if(
    killing)
        {
            return 
    PLUGIN_HANDLED
        
    }
        return 
    PLUGIN_CONTINUE
    }

    public 
    spawnum(id)
    {
        
    cs_set_user_deaths(id,cs_get_user_deaths(id) - 1)
        
    set_user_frags(id,get_user_frags(id) + 1)
        
    dllfunc(DLLFunc_Spawn,id)
    }

    public 
    giveweapons()
    {
        new 
    ii2
        
    for(i=1;i<=maxplayers;i++)
        {
            if(
    is_user_alive(i) && cs_get_user_team(i)==CS_TEAM_T)
            {
                
                
    cs_set_user_armor(i,armoramount[i],armortype[i])
                
    strip_user_weapons(i)
                for(
    i2=1;i2<=30;i2++)
                {
                    if(
    i2!=&& i2!=&& i2!=29)
                    {
                        if(
    weapon[i][i2])
                        {
                            
    give_item(i,WeaponNames[i2])
                            
    cs_set_user_bpammo(i,i2,weapon[i][i2])
                        }
                    }
                }
                
    give_item(i,"weapon_knife")
            }
        }

    Zerknij czy śmiga.

Podobne wątki

  1. Przerobienie pluginu VIP
    By tYsU^ in forum Pisanie pluginów AMXX
    Odpowiedzi: 1
    Ostatni post / autor: 28-01-2011, 11:15
  2. Prośba o przerobienie pluginu
    By $Mok3r in forum Pisanie pluginów AMXX
    Odpowiedzi: 0
    Ostatni post / autor: 17-01-2011, 03:00
  3. Prośba o przerobienie pluginu
    By mateuszszwaba in forum Pisanie pluginów AMXX
    Odpowiedzi: 2
    Ostatni post / autor: 23-12-2010, 10:18
  4. Przerobienie pluginu
    By #T-Pain in forum Pisanie pluginów AMXX
    Odpowiedzi: 2
    Ostatni post / autor: 14-12-2010, 17:38
  5. Przerobienie pluginu
    By Kub@S in forum Problemy i konfiguracja AMXX
    Odpowiedzi: 4
    Ostatni post / autor: 29-07-2010, 09:17
  6. [Przerobienie] prośba o przerobienie pluginu na non steam
    By Nindża in forum Pisanie pluginów AMXX
    Odpowiedzi: 1
    Ostatni post / autor: 04-07-2010, 21:11
  7. Prośba o przerobienie pluginu
    By Spyrek in forum Pisanie pluginów AMXX
    Odpowiedzi: 1
    Ostatni post / autor: 23-06-2010, 16:18
  8. Przerobienie PLUGINU
    By ToToro_ in forum Pisanie pluginów AMXX
    Odpowiedzi: 4
    Ostatni post / autor: 08-06-2010, 17:26
  9. Przerobienie Pluginu
    By bolek007 in forum Pisanie pluginów AMXX
    Odpowiedzi: 7
    Ostatni post / autor: 31-08-2009, 13:53
  10. Przerobienie pluginu
    By Bongos1 in forum Szukam pluginu AMX/AMXX
    Odpowiedzi: 1
    Ostatni post / autor: 21-05-2008, 12:16

Odwiedzający poszukiwali:

CTF_FlagSpawns.ini

(amx_map s get_mapname)

capture the flag 2.0 przerobienie

capture the flag.amxx przerobienie

register_clcmd(say spawnme respawn_player)

Uprawnienia umieszczania postów

  • Nie możesz zakładać nowych tematów
  • Nie możesz pisać wiadomości
  • Nie możesz dodawać załączników
  • Nie możesz edytować swoich postów
  •