[Half-Life AMXX] / allinone.sma Repository:
ViewVC logotype

View of /allinone.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (download) (annotate)
Tue Nov 20 22:36:56 2007 UTC (12 years, 11 months ago) by ian
File size: 18202 byte(s)
Applied AGPLv3 license.
/*
All In One v0.7.32
Copyright (C) 2005-2007 Ian (Juan) Cammarata

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
http://ian.cammarata.us

To Do:

*/

#include <amxmodx>
#include <fun>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <cstrike2>
#include <lib_targets>

//Fun Compile
#define WCALT ADMIN_RESERVATION
//Normal Compile
//#define WCALT ADMIN_RCON

new bombtargent=0
new playersteam[32],bool:teamschanged=false
new playerspeed[32],bool:b_fly[32]

public aio_noclip(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,ALIVE+NOBOT,_,WCALT)
		if(targnum){
			new val=0,arg[2]
			if(read_argc()>2){
				read_argv(2,arg,sizeof(arg)-1)
				if(!equal(arg,"0"))val=1
			}
			for(new i=0;i<targnum;i++)set_user_noclip(targets[i],val)
			if(id!=0)if(id!=0)targets_activity(id,targets,targnum,val==1?"noclip enabled":"noclip disabled")
		}
	}
	return PLUGIN_HANDLED
}
public aio_fly(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			new bool:val=false,arg[2]
			if(read_argc()>2){
				read_argv(2,arg,sizeof(arg)-1)
				if(!equal(arg,"0"))val=true
			}
			for(new i=0;i<targnum;i++){
				b_fly[targets[i]]=val
				set_user_gravity(targets[i],val?-0.04:1.0)
			}
			if(id!=0)targets_activity(id,targets,targnum,val?"fly enabled":"fly disabled")
		}
	}
	return PLUGIN_HANDLED
}
public aio_godmode(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,ALIVE,_,WCALT)
		if(targnum){
			new val=0,arg[2]
			if(read_argc()>2){
				read_argv(2,arg,sizeof(arg)-1)
				if(!equal(arg,"0"))val=1
			}
			for(new i=0;i<targnum;i++)set_user_godmode(targets[i],val)
			if(id!=0)targets_activity(id,targets,targnum,val==1?"god mode enabled":"god mode disabled")
		}
	}
	return PLUGIN_HANDLED
}
public clexec(id,level,cid){
	if(cmd_access(id,level,cid,3)){
		new targets[32],targnum=0,trimlen=0,arg[100]
		targets=targets_find(id,targnum,IMMUNITY+LEVEL,_,WCALT)
		if(targnum){
			read_argv(1,arg,sizeof(arg))
			trimlen+=strlen(arg)+1
			read_args(arg,sizeof(arg))
			for(new i=0;i<targnum;i++)client_cmd(targets[i],arg[trimlen])
			new cmdname[21]
			format(cmdname,sizeof(cmdname)-1,"exec ^"%s^"",arg[trimlen])
			if(id!=0)targets_activity(id,targets,targnum,cmdname)
		}
	}
	return PLUGIN_HANDLED
}
public gravity(id,level,cid){
	if(cmd_access(id,level,cid,3)){
		new targets[32],targnum=0,arg[8],Float:grav
		targets=targets_find(id,targnum,ALIVE,_,WCALT)
		if(targnum){
			read_argv(2,arg,sizeof(arg))
			grav=strtonum(arg)*0.01
			for(new i=0;i<targnum;i++)set_user_gravity(targets[i],grav)
			new cmdname[21]
			format(cmdname,sizeof(cmdname)-1,"gravity %d/100",strtonum(arg))
			if(id!=0)targets_activity(id,targets,targnum,cmdname)
		}
	}
	return PLUGIN_HANDLED
}
/*public pspawn(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum
		targets=targets_find(id,targnum,DEAD,_,WCALT)
		if(targnum){
			for(new i=0;i<targnum;i++)cs_user_spawn(targets[i])
			if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}*/
public speed(id,level,cid){
	if(cmd_access(id,level,cid,3)){
		new targets[32],targnum=0,arg[8]
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			read_argv(2,arg,sizeof(arg))
			//for(new i=0;i<targnum;i++)entity_set_float(targets[i],EV_FL_maxspeed,floatstr(arg))
			for(new i=0;i<targnum;i++)playerspeed[targets[i]]=str_to_num(arg)
			new cmdname[21]
			format(cmdname,sizeof(cmdname)-1,"speed %d",strtonum(arg))
			if(id!=0)targets_activity(id,targets,targnum,cmdname)
		}
	}
	return PLUGIN_HANDLED
}
public client_PreThink(id){
	if(b_fly[id]){
		new Float:dvec[3]={0.0,0.0,0.0},btns=entity_get_int(id,EV_INT_button)
		if(btns&IN_FORWARD||btns&IN_BACK){
			velocity_by_aim(id,floatround(entity_get_float(id,EV_FL_maxspeed)*2),dvec)
			if(btns&IN_BACK){
				dvec[0]*=-1
				dvec[1]*=-1
				dvec[2]*=-1
			}
		}
		entity_set_vector(id,EV_VEC_velocity,dvec)
	}
	if(playerspeed[id]>0){
		new btns=entity_get_int(id,EV_INT_button),Float:dvec[3]
		entity_get_vector(id,EV_VEC_velocity,dvec)
		if(dvec[2]==0.0&&(btns&IN_FORWARD||btns&IN_BACK)&&(!(btns&IN_RUN)&&!(btns&IN_DUCK))){
			new Float:tvec[3]//,Float:lvec[3]
			new Float:mspeed=entity_get_float(id,EV_FL_maxspeed)
			//entity_get_vector(id,EV_VEC_angles,lvec)
			velocity_by_aim(id,floatround(mspeed),tvec)
			//if(dvec[0]!=0.0&&dvec[1]!=0.0)client_print(id,print_console,"dx:%f dy:%f dmax:%f ly:%f tx:%f ty:%f",dvec[0],dvec[1],mspeed,lvec[1],tvec[0],tvec[1])
			if(btns&IN_BACK){
				tvec[0]*=-1
				tvec[1]*=-1
			}
			/*else if(btns&IN_MOVELEFT){
			}
			else if(btns&IN_MOVERIGHT){
			}*/
			dvec[0]=tvec[0]*playerspeed[id]
			dvec[1]=tvec[1]*playerspeed[id]
			entity_set_vector(id,EV_VEC_velocity,dvec)
		}
	}
}
public slay(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,ALIVE+IMMUNITY+SELF,_,WCALT)
		if(targnum)for(new i=0;i<targnum;i++)user_kill(targets[i])
		targets_activity(id,targets,targnum,_,id==0?0:-1)
	}
	return PLUGIN_HANDLED
}
/*public headshot(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0,arg[24]
		targets=targets_find(id,targnum,ALIVE+IMMUNITY+SELF,_,WCALT)
		if(targnum){
			read_argv(2,arg,sizeof(arg))
			for(new i=0;i<targnum;i++)client_death(targets[i],id,arg,1)
			if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}*/
public give(id,level,cid){
	if(cmd_access(id,level,cid,3)){
		new arg[24]
		read_argv(2,arg,sizeof(arg)-1)
		strtolower(arg)
		if(!equal(arg,"item_airtank")){
			new targets[32],targnum=0
			targets=targets_find(id,targnum,ALIVE,_,WCALT)
			if(targnum){
				new strip=0,qty=1
				for(new i=3;i<read_argc();i++){
					new tmp[7]
					read_argv(i,tmp,sizeof(tmp)-1)
					if(strip==0){
						if(equali(tmp,"-strip"))strip=1
						if(equali(tmp,"-knife"))strip=2
					}
					if(qty==1&&equali(tmp,"-q",2)){
						qty=strtonum(tmp[2])>1?strtonum(tmp[2]):1
					}
				}
				for(new i=0;i<targnum;i++){
					if(strip>0)weaponstrip(targets[i],strip==1?1:0)
					new tid=targets[i]
					if(equal(arg,"item_nvg"))cs_set_user_nvg(id)
					else if(equal(arg,"item_shield"))cs_set_user_shield(tid,1)
					else if(equal(arg,"item_sodacan"))set_user_health(tid,get_user_health(tid)+(1*qty)<=100?get_user_health(tid)+(1*qty):100)
					else if(equal(arg,"item_healthkit"))set_user_health(tid,get_user_health(tid)+(15*qty)<=100?get_user_health(tid)+(15*qty):100)
					else if(equal(arg,"weapon_flashbang")){
						give_item(tid,arg)
						if(qty>1)set_pdata_int(tid,387,qty)
					}
					else if(equal(arg,"weapon_hegrenade")){
						give_item(tid,arg)
						if(qty>1)set_pdata_int(tid,388,qty)
					}
					else if(equal(arg,"weapon_smokegrenade")){
						give_item(tid,arg)
						if(qty>1)set_pdata_int(tid,389,qty)
					}
					else for(new j=0;j<clamp(qty,1,7);j++)give_item(tid,arg)
				}
				if(equal(arg,"weapon_",7))format(arg,sizeof(arg)-1,arg[7])
				if(equal(arg,"item_",5))format(arg,sizeof(arg)-1,arg[5])
				new cmdname[21]
				format(cmdname,sizeof(cmdname)-1,"give qty-%d %s",qty,arg)
				if(id!=0)targets_activity(id,targets,targnum,cmdname)
			}
		}
		else client_print(id,print_console,"[AMX] %s is an ivalid item.",arg)
	}
	return PLUGIN_HANDLED
}
public wpnlist(id){
	client_print(id,print_console,"Weapon list for amx_give command (precede weapon name with ^"weapon_^"):")
	client_print(id,print_console,"^tPistols: glock18, usp, p228, deagle, elite, fiveseven")
	client_print(id,print_console,"^tShotguns: m3, xm1014")
	client_print(id,print_console,"^tSMGs: mac10, tmp, mp5navy, ump45, p90")
	client_print(id,print_console,"^tRifles: galil, famas, ak47, m4a1, sg552, aug")
	client_print(id,print_console,"^tSnipers: scout, awp, g3sg1, sg550")
	client_print(id,print_console,"^tMGs: m249")
	client_print(id,print_console,"^tOther: knife, hegrenade, flashbang, smokegrenade, c4 (bomb)")
	return PLUGIN_HANDLED
}
public itemlist(id){
	client_print(id,print_console,"Item list for amx_give command (precede item name with ^"item_^"):")
	client_print(id,print_console,"^tHealth: healthkit (15hp), sodacan (1hp)")
	client_print(id,print_console,"^tArmor: assaultsuit (kevlar+helm), kevlar, battery (15ap)")
	client_print(id,print_console,"^tMisc: thighpack (Defuse Kit), longjump")
	client_print(id,print_console,"^tUnknown (Probably do nothing.): antidote, security, suit")
	return PLUGIN_HANDLED
}
public slap(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0,arg[5]
		targets=targets_find(id,targnum,ALIVE+IMMUNITY+SELF,_,WCALT)
		if(targnum){
			read_argv(2,arg,sizeof(arg))
			for(new i=0;i<targnum;i++)user_slap(targets[i],strtonum(arg))
			new cmdname[21]
			format(cmdname,sizeof(cmdname)-1,"slap (%d damage)",strtonum(arg))
			if(id!=0)targets_activity(id,targets,targnum,cmdname)
		}
	}
	return PLUGIN_HANDLED
}
public motd(id){
	show_motd(id,"motd.txt")
	return PLUGIN_HANDLED
}
public slashme(id){
	if(get_cvar_num("amx_slashme")){
		new msg[100]
		read_args(msg,sizeof(msg))
		if(equali(msg,"^"/me ",5)){
			new name[32]
			get_user_name(id,name,sizeof(name))
			copy(msg,strlen(msg)-6,msg[5])
			client_print(0,print_chat,"* %s %s *",name,msg)
			return PLUGIN_HANDLED
		}
	}
	return PLUGIN_CONTINUE
}
public forcet(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			//for(new i=0;i<targnum;i++)set_user_team(targets[i],1)
			if(targnum)for(new i=0;i<targnum;i++)playersteam[targets[i]]=1
			teamschanged=true
			//if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}
public forcect(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			//if(targnum)for(new i=0;i<targnum;i++)set_user_team(targets[i],2)
			if(targnum)for(new i=0;i<targnum;i++)playersteam[targets[i]]=2
			teamschanged=true
			//if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}
public forcespec(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			//if(targnum)for(new i=0;i<targnum;i++)set_user_team(targets[i],3)
			if(targnum)for(new i=0;i<targnum;i++)playersteam[targets[i]]=3
			teamschanged=true
			if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}
public teamswap(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,0,_,WCALT)
		if(targnum){
			for(new i=0;i<targnum;i++){
				new tid=targets[i]
				if(get_user_team(tid)==1)playersteam[tid]=2
				else if(get_user_team(tid)==2)playersteam[tid]=1
			}
			teamschanged=true
			if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}
public plantanywhere(id,level,cid){
	if(cmd_access(id,level,cid,1)){
		new targets[32],targnum=0
		targets=targets_find(id,targnum,ALIVE,_,WCALT)
		if(targnum){
			for(new i=0;i<targnum;i++)cs_set_user_plant(targets[i])
			//set_offset_int(targets[i],193,(1<<8))
			if(id!=0)targets_activity(id,targets,targnum)
		}
		if(!bombtargent){
			new ent=create_entity("func_bomb_target")
			if(ent>0){
				DispatchKeyValue(ent,"classname","func_bomb_target")
				DispatchSpawn(ent)
				entity_set_size(ent,Float:{-4096.0,-4096.0,-4096.0},Float:{4096.0,4096.0,4096.0})
				entity_set_origin(ent,Float:{0.0,0.0,0.0})
				bombtargent=ent
			}
		}
	}
	return PLUGIN_HANDLED
}
public round_end(){
	if(bombtargent){
		remove_entity(bombtargent)
		bombtargent=0
	}
	if(teamschanged){
		new players[32],num
		get_players(players,num)
		for(new i=0;i<num;i++){
			if(playersteam[players[i]]){
				cs_set_user_team(players[i],playersteam[players[i]])
				if(0<playersteam[players[i]]<3){
					if(is_user_alive(players[i])){
						set_msg_block(get_user_msgid("DeathMsg"),1)
						user_kill(players[i],1)
					}
					cs_set_user_deaths(players[i],cs_get_user_deaths(players[i])-1)
				}
			}
		}
		for(new i=0;i<32;i++)playersteam[i]=0
		teamschanged=false
	}
	return PLUGIN_HANDLED
}
public wpnstrip(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum
		targets=targets_find(id,targnum,ALIVE+IMMUNITY+SELF,_,WCALT)
		if(targnum){
			for(new i=0;i<targnum;i++)weaponstrip(targets[i],read_argc()<3?0:1)
			if(id!=0)targets_activity(id,targets,targnum)
		}
	}
	return PLUGIN_HANDLED
}
public kick_quit(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum
		targets=targets_find(id,targnum)
		if(targnum){
			for(new i=0;i<targnum;i++)engclient_cmd(targets[i],"quit")
		}
		if(id!=0)targets_activity(id,targets,targnum)
	}
	return PLUGIN_HANDLED
}
public stopsounds(id,level,cid){
	if(cmd_access(id,level,cid,2)){
		new targets[32],targnum
		targets=targets_find(id,targnum)
		if(targnum){
			for(new i=0;i<targnum;i++)engclient_cmd(targets[i],"stopsound")
		}
		if(id!=0)targets_activity(id,targets,targnum)
	}
	return PLUGIN_HANDLED
}
public handlesay(id,level,cid){
	new arg[16]
	read_argv(1,arg,15)
	if(equali(arg,"glow",4)){
		glow(id,level,cid,arg)
		return PLUGIN_HANDLED
	}
	return PLUGIN_CONTINUE
}
public glow(id,level,cid,arg[]){
	if(cmd_access(id,level,cid,2)){
		if(parse(arg,arg,0,arg,15)==2){
			new Float:col[3],bool:set=true
			if(equali(arg,"off")){
				client_print(id,print_chat,"[AMXX] You are no longer glowing.")
				entity_set_int(id,EV_INT_renderfx,kRenderFxNone)
				//set_user_rendering(id)
				set=false
			}
			else if(equali(arg,"red")){col[0]=255.0;col[1]=0.0;col[2]=0.0;}
			else if(equali(arg,"green")){col[0]=0.0;col[1]=255.0;col[2]=0.0;}
			else if(equali(arg,"blue")){col[0]=0.0;col[1]=0.0;col[2]=255.0;}
			else if(equali(arg,"orange")){col[0]=255.0;col[1]=165.0;col[2]=0.0;}
			else if(equali(arg,"yellow")){col[0]=255.0;col[1]=255.0;col[2]=0.0;}
			else if(equali(arg,"pink")){col[0]=255.0;col[1]=192.0;col[2]=203.0;}
			else if(equali(arg,"white")){col[0]=255.0;col[1]=255.0;col[2]=255.0;}
			else {
				client_print(id,print_chat,"[AMXX] Invalid glow value.")
				set=false
			}
			if(set){
				entity_set_int(id,EV_INT_renderfx,kRenderFxGlowShell)
				entity_set_vector(id,EV_VEC_rendercolor,col)
				//set_user_rendering(id,kRenderFxGlowShell,floatround(col[0]),floatround(col[1]),floatround(col[2]),_,255)
				client_print(id,print_chat,"[AMXX] You are now glowing %s.",arg)
			}
		}
		else client_print(id,print_chat,"[AMXX] Invalid number of arguments.")
	}
	else client_print(id,print_chat,"[AMXX] You have no access to the glow command.")
	return PLUGIN_HANDLED
}
public plugin_init(){
	register_plugin("All In One","0.8.2","Don Juan-jello")
//CVARS
	register_cvar("amx_slashme","1")
//Useful Commands
	register_concmd("amx_clexec","clexec",ADMIN_RCON,"<!>[name|^^|.|*name|#uid|@CT|@T] [command]")

	register_concmd("amx_teamswap","teamswap",ADMIN_RCON,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_t","forcet",ADMIN_RCON,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_ct","forcect",ADMIN_RCON,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_spec","forcespec",ADMIN_RCON,"<!>[name|^^|.|*name|#uid|@CT|@T]")

	register_concmd("amx_slay2","slay",ADMIN_SLAY,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_slap2","slap",ADMIN_SLAY,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_wpnstrip","wpnstrip",ADMIN_SLAY,"<!>[name|^^|.|*name|#uid|@CT|@T]")

	register_concmd("amx_quit","kick_quit",ADMIN_KICK,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_stopallsounds","stopsounds",ADMIN_KICK,"- Execute stopsound on all clients.")
//Fun Commands
	register_concmd("amx_noclip","aio_noclip",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] [1|0]")
	register_concmd("amx_fly","aio_fly",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] [1|0]")
	register_concmd("amx_godmode","aio_godmode",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] [1|0]")
	register_concmd("amx_gravity","gravity",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] [% norm grav]")
	//register_concmd("amx_spawn","pspawn",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T]")
	register_concmd("amx_speed","speed",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] [speed]")

	register_concmd("amx_give","give",ADMIN_VOTE,"<!>[name|^^|.|*name|#uid|@CT|@T] <item>")
	register_concmd("amx_give_wpnlist","wpnlist",0,"- Shows list of weapons for use with give.")
	register_concmd("amx_give_itemlist","itemlist",0,"- Shows list of items for use with give.")
	
	register_concmd("say","handlesay")

	//register_concmd("amx_headshot","headshot",ADMIN_SLAY,"<!>[name|^^|.|*name|#uid|@CT|@T] <wpn name>")
	register_concmd("amx_plant","plantanywhere",ADMIN_SLAY,"- Allow bomb plant anywhere.")
//Say commands
	register_clcmd("say /motd","motd",0,"- Veiw server MOTD.")
	register_clcmd("say","slashme",0)
//Events
	//register_logevent("round_start",2,"1=Round_Start")
	register_logevent("round_end",2,"1=Round_End")
	return PLUGIN_CONTINUE
}

Contact
ViewVC Help
Powered by ViewVC 1.0.4