// FLASH! - Run Faster

/* CVARS - copy and paste to shconfig.cfg

//Flash
flash_level 0
flash_speed 350		//the speed flash can run

*/

#include <amxmod>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Flash"
//----------------------------------------------------------------------------------------------
public plugin_init()
{
	// Plugin Info
	register_plugin("SUPERHERO Flash","1.18","{HOJ} Batman")

	// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
	register_cvar("flash_level", "0" )
	register_cvar("flash_speed", "350" )

	// FIRE THE EVENT TO CREATE THIS SUPERHERO!
	shCreateHero(gHeroName, "Super Speed", "You will run much faster with this hero", false, "flash_level" )

	// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
	// INIT
	register_srvcmd("flash_init", "flash_init")
	shRegHeroInit(gHeroName, "flash_init")

	// Let Server know about Flashes max speed
	shSetMaxSpeed(gHeroName, "flash_speed", "[0]" )
}
//----------------------------------------------------------------------------------------------
public flash_init()
{	
	// First Argument is an id
	new temp[6]
	read_argv(1,temp,5)
	new id=str_to_num(temp)

	// 2nd Argument is 0 or 1 depending on whether the id has flash
	read_argv(2,temp,5)
	new hasPowers = str_to_num(temp)

	// Got to slow down a Flash that lost his powers...
	if ( !hasPowers && is_user_connected(id) ) {
		shRemSpeedPower(id)
	}
}
//----------------------------------------------------------------------------------------------