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

#include <amxmod>

/*
* amx_teleport < part of nick > [ x ] [ y ] [ z ]
*  - Teleports to stored location or x y z 
* 
* amx_userorigin [ part of nick ]
*  - Prints and Stores your x y z unless a player name is given in which case it returns amd stores that players x y z
*/

new storedorigin[3]

public admin_teleport(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_teleport < part of nick > [ x ] [ y ] [ z ] ")
		return PLUGIN_HANDLED
	}
	new name[32]	
	read_argv(1,name,32)
	if (argc > 2) 
	{
		new origin[3]
		new Sx[12],Sy[12],Sz[12]
		read_argv(2,Sx,12)
		read_argv(3,Sy,12)
		read_argv(4,Sz,12)
		origin[0] = str_to_num(Sx)
		origin[1] = str_to_num(Sy)
		origin[2] = str_to_num(Sz)
		new player = find_player("lb",name)
		if (player) {
			if (get_user_flags(player)&ADMIN_IMMUNITY){
				client_print(id,print_console,"[AMX] The player has immunity")
				return PLUGIN_HANDLED
			}
			set_user_origin(player, origin)
			get_user_name(player,name,32)
			client_print(id,print_console,"[AMX] Client ^"%s^" has been teleported to x:%i y:%i z%i",name,origin[0],origin[1],origin[2])
		}
		else {
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
		}
	}
	else 
	{ 
		new player = find_player("lb",name)
		if (player) {
			if (get_user_flags(player)&ADMIN_IMMUNITY){
				client_print(id,print_console,"[AMX] The player has immunity")
				return PLUGIN_HANDLED
			}
			set_user_origin(player, storedorigin)
			get_user_name(player,name,32)
			client_print(id,print_console,"[AMX] Client ^"%s^" has been teleported to the stored origin: x:%i y:%i z%i",name,storedorigin[0],storedorigin[1],storedorigin[2])
		}
		else {
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
		}
	}
		
	return PLUGIN_HANDLED
}

public admin_userorigin(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()
	new origin[3]
	if (argc < 2) 
	{
		get_user_origin(id, origin)
		storedorigin = origin
		client_print(id,print_console,"[AMX] Your Origin: x:%i y:%i z%i (stored)",origin[0],origin[1],origin[2])
	}
	else
	{
		new name[32]
		read_argv(1,name,32)
		new player = find_player("lb",name)
		if (player) 
		{
			get_user_origin(player, origin)
			storedorigin = origin
			get_user_name(player,name,32)
			client_print(id,print_console,"[AMX] Client ^"%s^" Origin: x:%i y:%i z%i (stored)",name,origin[0],origin[1],origin[2])
		}
		else 
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
	}
	return PLUGIN_HANDLED
}

public plugin_init() 
{
	register_plugin("Admin Teleport","0.8","f117bomb")
	register_clcmd("amx_teleport","admin_teleport",ADMIN_LEVEL_A,"amx_teleport < part of nick > [ x ] [ y ] [ z ]")
	register_clcmd("amx_userorigin","admin_userorigin",ADMIN_LEVEL_A,"amx_userorigin [ part of nick ]")
	return PLUGIN_CONTINUE
}

