/* AMX Mod script.
*
* Teleport players
*  by JustinHoMi (justin@justinmitchell.net)
*  email: justin@justinmitchell.net
*  web: www.modkillers.com
*  irc: #modkillers (irc.gamesnet.net
*
* Usage: use admin_myorigin to store your origin
*        and admin_teleport <nick> will send them to the stored coords
*
*/

#include <amxmod>

new p_origin[33][3]

public admin_myorigin(id){
	if (!(get_user_flags(id)&ADMIN_SLAY)){
                client_print(id,print_console,"[AMX] You have no access to that command")
                return PLUGIN_HANDLED
        }

	get_user_origin(id,p_origin[id],0)
	client_print(id,print_console,"[AMX] Your coords are x %i y %i z %i and have been saved",p_origin[id][0],p_origin[id][1],p_origin[id][2])

	return PLUGIN_HANDLED
}

public admin_teleport(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_teleport < part of nick >")
                return PLUGIN_HANDLED
        }
                
        new arg[32]
        read_argv(1,arg,32)
        new player = find_player("b",arg)
         
        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,p_origin[id])
                new name[32]
                get_user_name(player,name,32)
                client_print(id,print_console,"[AMX] Client ^"%s^" teleported",name)
        }
        else{
                client_print(id,print_console,"[AMX] Client with that part of nick not found")
        }
         
        return PLUGIN_HANDLED
}

public plugin_init() {
	register_plugin("Teleport","0.5","JustinHoMi")
    register_clcmd("amx_myorigin","admin_myorigin",ADMIN_SLAY,"amx_myorigin")   
	register_clcmd("amx_teleport","admin_teleport",ADMIN_SLAY,"amx_teleport < part of nick >")
	return PLUGIN_CONTINUE
}
