#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Aim commands"
#define VERSION "1.0"
#define AUTHOR "BreaKer"
#define ACCESS ADMIN_SLAY
#define ACCESS2 ADMIN_BAN

new bool:isUserBuried[32]
new pCvarBanTime
public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	pCvarBanTime = register_cvar("ac_bantime", "60")
	register_clcmd("+slap", "userSlap", ACCESS, "Slap a player aiming at it!")
	register_clcmd("+slay", "userSlay", ACCESS, "Slay a player aiming at it!")
	register_clcmd("+bury", "userBury", ACCESS, "Bury a player aiming at it!")
	register_clcmd("+unbury", "userUnbury", ACCESS, "Unbury a player aiming at it!")
	register_clcmd("+kick", "userKick", ACCESS, "Kick a player aiming at it!")
	register_clcmd("+ban", "userBan", ACCESS2, "Ban a player aiming at it!")
}

public userSlap(id) {
	new player
	new body
	new Name[32]
	get_user_aiming(id, player, body)
	get_user_name(id, Name, charsmax(Name))
	if(get_user_flags(id) & ACCESS) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't slap someone with immunity!")
		}
		else {
			if(is_user_alive(player)) {
				user_slap(player, 0)
				client_print(player, print_chat, "You have been slapped by %s", Name)
			}
		}
	}
}

public userSlay(id) {
	new player
	new body
	new Name[32]
	get_user_aiming(id, player, body)
	get_user_name(id, Name, charsmax(Name))
	if(get_user_flags(id) & ACCESS) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't slay someone with immunity!")
		}
		else {
			if(is_user_alive(player)) {
				user_kill(player)
				client_print(player, print_chat, "%s killed you!", Name)
			}
		}
	}
}

public userBury(id) {
	new player
	new body
	new Name[32]
	new origin[3]
	get_user_aiming(id, player, body)
	get_user_name(id, Name, charsmax(Name))
	if(get_user_flags(id) & ACCESS) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't bury someone with immunity!")
		}
		else {
			if(is_user_alive(player) && !isUserBuried[player]) {
				get_user_origin(player, origin, 0)
				origin[2] = origin[2] - 36
				set_user_origin(player, origin)
				isUserBuried[player] = true
				client_print(player, print_chat, "%s buried you!", Name)
			}
		}
	}
}

public userUnbury(id) {
	new player
	new body
	new Name[32]
	new origin[3]
	get_user_aiming(id, player, body)
	get_user_name(id, Name, charsmax(Name))
	if(get_user_flags(id) & ACCESS) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't unbury someone with immunity!")
		}
		else {
			if(is_user_alive(player) && isUserBuried[player]) {
				get_user_origin(player, origin, 0)
				origin[2] = origin [2] + 36
				set_user_origin(player, origin)
				isUserBuried[player] = false
				client_print(player, print_chat, "%s unburied you!", Name)
			}
		}
	}
}

public userKick(id) {
	new player
	new body
	get_user_aiming(id, player, body)
	new iUserID = get_user_userid(player)
	if(get_user_flags(id) & ACCESS) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't kick someone with immunity!")
		}
		else {
			if(is_user_alive(player)) {
				client_cmd(id, "amx_kick #%d", iUserID)
			}
		}
	}
}

public userBan(id) {
	new player
	new body
	get_user_aiming(id, player, body)
	new iUserID = get_user_userid(player)
	if(get_user_flags(id) & ACCESS2) {
		if(is_user_alive(player) && get_user_flags(player) & ADMIN_IMMUNITY) {
			console_print(id, "You can't ban someone with immunity!")
		}
		else {
			if(is_user_alive(player)) {
				client_cmd(id, "amx_banip #%d %d", iUserID, get_pcvar_num(pCvarBanTime) )
			}
		}
	}
}			
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
*/
