
/* AMX Mod script. 
* 
* (c) Copyright 2002-2003, f117bomb 
* This file is provided as is (no warranties). 
*/ 

#include <amxmod> 
#include <amxmisc> 

/*
* Usage: amx_slay2 <authid, nick, @team or #userid> [1-lightning|2-blood|3-explode]
* Examples:
* amx_slay2 @CT 1
* amx_slay2 @TERRORIST 3
* amx_slay2 #213
*
*/

new light, smoke, white

slay_player(id,victim,type) {
	new origin[3], srco[3], name[32]
	get_user_name(victim,name,31)
	get_user_origin(victim,origin)
	origin[2] -= 26
	srco[0]=origin[0]+150
	srco[1]=origin[1]+150
	srco[2]=origin[2]+400
	switch(type){
	case 1:{
	lightning(srco,origin)
	emit_sound(victim,CHAN_ITEM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	case 2:{
	blood(origin)
	emit_sound(victim,CHAN_ITEM, "weapons/headshot2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	case 3:	explode(origin)
	}
	user_kill(victim,1)
	console_print(id,"Client ^"%s^" has been slayed",name)
} 

public admin_slay(id,level,cid) {
	if (!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED
	new arg[32], arg2[3], type
	read_argv(1,arg,31)
	read_argv(2,arg2,2)
	type = strtonum(arg2)
	if (arg[0]=='@'){
		new players[32], inum , name[32]
		get_players(players,inum,"ae",arg[1])
		if (inum==0){
			console_print(id,"No clients in such team")
			return PLUGIN_HANDLED
		}
		for(new a=0;a<inum;++a){
			if (get_user_flags(players[a])&ADMIN_IMMUNITY){
				get_user_name(players[a],name,31)
				console_print(id,"Skipping ^"%s^" because client has immunity",name)
				continue
			}
			slay_player(id,players[a],type)
		}
	}
	else {
		new player = cmd_target(id,arg,5)
		if (!player) return PLUGIN_HANDLED
		slay_player(id,player,type)
	}
	return PLUGIN_HANDLED 
} 

public plugin_precache(){ 
	light = precache_model("sprites/lgtning.spr")
	smoke = precache_model("sprites/steam1.spr")
	white = precache_model("sprites/white.spr")
	precache_sound( "ambience/thunder_clap.wav")
	precache_sound( "weapons/headshot2.wav")
	return PLUGIN_CONTINUE
}

public plugin_init() { 
	register_plugin("Admin Slay 2","0.9.2","f117bomb") 
	register_concmd("amx_slay2","admin_slay",ADMIN_SLAY,"<authid, nick, @team or #userid> [1-lightning|2-blood|3-explode]") 
	return PLUGIN_CONTINUE 
}

explode(vec1[3]) { 
	// blast circles 
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1) 
	write_byte( 21 ) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2] + 16) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2] + 1936) 
	write_short( white ) 
	write_byte( 0 ) // startframe 
	write_byte( 0 ) // framerate 
	write_byte( 2 ) // life 
	write_byte( 16 ) // width 
	write_byte( 0 ) // noise 
	write_byte( 188 ) // r 
	write_byte( 220 ) // g 
	write_byte( 255 ) // b 
	write_byte( 255 ) //brightness 
	write_byte( 0 ) // speed 
	message_end()
	//Explosion2 
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte( 12 ) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2]) 
	write_byte( 188 ) // byte (scale in 0.1's) 
	write_byte( 10 ) // byte (framerate) 
	message_end()
	//Smoke 
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1) 
	write_byte( 5 ) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2]) 
	write_short( smoke ) 
	write_byte( 2 )  
	write_byte( 10 )  
	message_end()
} 

blood(vec1[3]) { 
	//LAVASPLASH 
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte( 10 ) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2]) 
	message_end() 
} 

lightning(vec1[3],vec2[3]) { 
	//Lightning 
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY) 
	write_byte( 0 ) 
	write_coord(vec1[0]) 
	write_coord(vec1[1]) 
	write_coord(vec1[2]) 
	write_coord(vec2[0]) 
	write_coord(vec2[1]) 
	write_coord(vec2[2]) 
	write_short( light ) 
	write_byte( 1 ) // framestart 
	write_byte( 5 ) // framerate 
	write_byte( 2 ) // life 
	write_byte( 20 ) // width 
	write_byte( 30 ) // noise 
	write_byte( 200 ) // r, g, b 
	write_byte( 200 ) // r, g, b 
	write_byte( 200 ) // r, g, b 
	write_byte( 200 ) // brightness 
	write_byte( 200 ) // speed 
	message_end()
	//Sparks 
	message_begin( MSG_PVS, SVC_TEMPENTITY,vec2) 
	write_byte( 9 ) 
	write_coord( vec2[0] ) 
	write_coord( vec2[1] ) 
	write_coord( vec2[2] ) 
	message_end()
	//Smoke     
	message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec2) 
	write_byte( 5 ) 
	write_coord(vec2[0]) 
	write_coord(vec2[1]) 
	write_coord(vec2[2]) 
	write_short( smoke ) 
	write_byte( 10 )  
	write_byte( 10 )  
	message_end()
}

