
/* AMXMOD script.
*
* (c) Copyright 2000-2002, OLO
* This file is provided as is (no warranties).
*
*/

#include <amxmod>


/*
* amx_slay2 < part of nick > or < @ team > or < # index > [ effect: 1=lightning 2=blood 3=explode 4=none ]
*
*/
new light
new smoke
new white

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()
	
}

public slay_player(admin_index,victim_index,type)
{
	new name[32]	
	get_user_name(victim_index,name,32)
	if (get_user_flags(victim_index)&ADMIN_IMMUNITY)
	{
		client_print(admin_index,print_console,"[AMX] Client ^"%s^" has immunity",name)
		return PLUGIN_HANDLED
	}
	//Create Fx
	new origin[3]
	get_user_origin(victim_index,origin)
	origin[2] = origin[2] - 26
	new sorigin[3]
	sorigin[0] = origin[0] + 150
	sorigin[1] = origin[1] + 150
	sorigin[2] = origin[2] + 400
	if (type==1)
	{		
		lightning(sorigin,origin)
		emit_sound(victim_index,CHAN_ITEM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	if (type==2) 
	{
		blood(origin)
		emit_sound(victim_index,CHAN_ITEM, "weapons/headshot2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	if (type==3) 
		explode(origin)	
	//Slay				
	user_kill(victim_index,1)	
	client_print(admin_index,print_console,"[AMX] Client ^"%s^" has been slayed",name)
	return PLUGIN_CONTINUE
}

public admin_slay2(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_A)){
		client_print(id,print_console,"[AMX] You have no access to that command")
		return PLUGIN_HANDLED
	}
	new argc = read_argc()
	if (argc < 2) {
		client_print(id,print_console,"[AMX] Usage:  amx_slay2 < part of nick > or < @ team > or < # index > [ effect: 1=lightning 2=blood 3=explode 4=none ]")
		return PLUGIN_HANDLED
	}
	new arg1[32]
	new arg2[32]
	new arg3[32]
	read_argv(1,arg1,32)
	read_argv(2,arg2,32)
	read_argv(3,arg3,32)
	//Team
	if (equal(arg1,"@")){
		new players[32], inum
		get_players(players,inum,"e",arg2)
		for(new i = 0 ;i < inum ;++i)
			slay_player(id,players[i],str_to_num(arg3))
		if (inum)
			client_print(id,print_console,"[AMX] * All non-immune clients from ^"%s^" team affected *",arg2)
		else
			client_print(id,print_console,"[AMX] No clients in such team")
	}
	//Index
	else if (equal(arg1,"#")) {
		if (is_user_connected(str_to_num(arg2)))
			slay_player(id,str_to_num(arg2),str_to_num(arg3))
		else 
			client_print(id,print_console,"[AMX] Client not found")
	}
	//Part of Name
	else 
	{
		new player = find_player("lb",arg1)
		if (player)
			slay_player(id,player,str_to_num(arg2))
		else 
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
	}
	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 Slay2","0.7","f117bomb")
	register_clcmd("amx_slay2","admin_slay2",ADMIN_SLAY,"amx_slay2 < part of nick > or < @ team > or < # index > [ effect: 1=lightning 2=blood 3=explode 4=none ]")
	return PLUGIN_CONTINUE
}


