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

#include <amxmod>

/*
* amx_slay_fx < part of nick >
* example:
* amx_slay_fx "Tom"
*
*/

new light

lightning(vec1[3],vec2[3])
{
	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 )
	write_byte( 5 )
	write_byte( 2 )
	write_byte( 20 )
	write_byte( 30 )
	write_byte( 200 )
	write_byte( 200 ) 
	write_byte( 200 )  
	write_byte( 200 )
	write_byte( 200 )
	message_end()

	message_begin( MSG_PVS, SVC_TEMPENTITY,vec2)
	write_byte( 9 )
	write_coord( vec2[0] )
	write_coord( vec2[1] )
	write_coord( vec2[2] )
	message_end()

}

public admin_slay_fx(id)
{
	if (!(get_user_flags(id)&ADMIN_SLAY)){
		client_print(id,print_console,"[AMX] You have no access to that command")
		return PLUGIN_HANDLED
	}
	if (read_argc()<2) {
		client_print(id,print_console,"[AMX] Usage:  amx_slay_fx < part of nick >")
		return PLUGIN_HANDLED
	}
	new name[32]
	read_argv(1,name,32)
	new tokill = find_player("b",name)
	if (tokill)	{
		if (get_user_flags(tokill)&ADMIN_IMMUNITY){
			client_print(id,print_console,"[AMX] The player has immunity")
			return PLUGIN_HANDLED
		}
		if (is_user_alive(tokill)==0)	{
			client_print(id,print_console,"[AMX] Client ^"%s^" is already dead",name)
			return PLUGIN_HANDLED
		}
		new origin[3]
		get_user_origin(tokill,origin)
		origin[2] = origin[2] - 26
		new sorigin[3]
		sorigin[0] = origin[0] + 150
		sorigin[1] = origin[1] + 150
		sorigin[2] = origin[2] + 400
		lightning(sorigin,origin)
		emit_sound(tokill,CHAN_ITEM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
		user_kill(tokill,1)
		get_user_name(tokill,name,32)
		client_print(id,print_console,"[AMX] Client ^"%s^" slayed",name)
	}
	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")
	precache_sound( "ambience/thunder_clap.wav")
	return PLUGIN_CONTINUE
}

public plugin_init()
{
	register_plugin("Admin Slay FX","0.5","default")
	register_clcmd("amx_slay_fx","admin_slay_fx",ADMIN_SLAY,"amx_slay_fx < part of nick >")
	return PLUGIN_CONTINUE
}

