
/***************************************************************************
 * amx_ejl_personalgavity.sma     version 1.1  Date: 12/24/2002
 *  Author: Eric Lidman      ejlmozart@hotmail.com
 *  Alias: Ludwig van        Upgrade: http://lidmanmusic.com/cs/plugins.html           
 *
 * Just a silly plugin to change the gravity of one player or a team instead
 *  of for the whole server.
 *
 * COMMANDS:
 * 
 *    amx_grav <part of nick or @ team> <percentage of server gravity> [drop]
 *
 * EXAMPLES OF ACTUAL USAGE:
 *
 *    amx_grav Lud 50     --- gives Lud 400 gravity if normal gravity is on
 *    amx_grav Lud -1 drop   --- gives Lud negative gravity and shoots him to
 *                               the upmost limits of the map then makes him
 *                               drop his weapons too (thus it can be used
 *                               as a punishement command, not just fun).
 *    amx_grav @ TERRORIST -100 drop  --- sends the whole terrorist team up
 *                                        into the sky and makes them drop
 *                                        all thier weapons
 *
 **************************************************************************/

#include <amxmod>
#include <fun>


public admin_grav(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_H)){
		client_print(id,print_console,"[AMX] You have no access to that command")
		return PLUGIN_HANDLED
	}
	new argc = read_argc()
	if (argc < 3) {
		client_print(id,print_console,"[AMX] Usage:  amx_grav < part of nick > or < @ team > < percent of sv_gravtiy > [<drop> optional drop weapons] ")
		return PLUGIN_HANDLED
	}
	new grav[12]
	new Float:igrav
	new aname[32]
	new arg1[12]
	new drop[16]
	read_argv(1,arg1,12)
	if (equal(arg1,"@")){
		new players[32], inum, teamname[32]
		read_argv(2,teamname,32)
		read_argv(3,grav,12)
		read_argv(4,drop,16)
		igrav = str_to_num(grav) * 0.01
		if(igrav == 0.0)
			igrav = -1.0	
		get_players(players,inum,"e",teamname)
		for(new i = 0 ;i < inum ;++i){
			set_user_gravity(players[i],igrav)
			if(igrav < 0){
				client_cmd(players[i],"+jump")
				set_task(1.0,"delayed_jmp_rst",0,players[i],1)
			}
			if(equali(drop,"drop",4)){
				engclient_cmd(players[i],"drop")
				engclient_cmd(players[i],"drop")
				engclient_cmd(players[i],"drop")
			}
		}
		if (inum){
			get_user_name(id,aname,32)
			client_print(id,print_console,"[AMX] All clients from ^"%s^" team gravity has been set",teamname)
			client_print(0,print_chat,"[AMY]  %s  used command  amx_grav %s %s",aname,teamname,grav)
			log_message("[AMY]  %s  used command amx_grav  %s %s",aname,teamname,grav)

		}else{
			client_print(id,print_console,"[AMX] No clients in such team")
		}
	}else {
		new name[32]		
		read_argv(1,name,32)
		read_argv(2,grav,12)
		read_argv(3,drop,16)
		igrav = str_to_num(grav) * 0.01
		if(igrav == 0.0)
			igrav = -1.0		
		new player= find_player("b",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_gravity(player,igrav)
			get_user_name(player,name,32)
			get_user_name(id,aname,32)
			client_print(id,print_console,"[AMX] Client ^"%s^" gravity has been set",name)
			client_print(0,print_chat,"[AMY]  %s  used command  amx_grav %s %s",aname,name,grav)
			log_message("[AMY]  %s  used command amx_grav  %s %s",aname,name,grav)
			if(igrav < 0){
				new splayer[1]
				splayer[0] = player
				client_cmd(player,"+jump")
				set_task(1.0,"delayed_jmp_rst",0,splayer,1)
			}
			if(equali(drop,"drop",4)){
				engclient_cmd(player,"drop")
				engclient_cmd(player,"drop")
				engclient_cmd(player,"drop")
			}
		}
		else {
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
		}
	}
	return PLUGIN_HANDLED
}

public delayed_jmp_rst(playa[])
{
	client_cmd(playa[0],"-jump")
}


public plugin_init()
{
	register_plugin("Admin Personal Gravity","0.8","EJL")
	register_clcmd("amx_grav","admin_grav",ADMIN_LEVEL_H,"amx_grav < part of nick > or < @ team > < gravity > [<drop> optional drop weapons]")
	return PLUGIN_CONTINUE
}


