Yay!! After 4 - 6 hours of intense scripting and error checking. I've finally been able to get the first version of this hero working. Description: The "Real" Flash. Can run around the world in the blink of an eye. I've made this hero out of the request of ParaDOX and I think that it has come along fairly well. It is an ability hero where you hold down the key to go extremely fast and when you let go you go back to your regular, flash self with his regular speed. Code: (If any of you can follow what this is then you deserve to make your own heroes as well)
// GLOBAL VARIABLESnew gHeroName[]="SuperFlash"new bool:gHasFlashPower[SH_MAXSLOTS+1]new bool:gFlashMode[SH_MAXSLOTS+1]new gUserHealth[SH_MAXSLOTS+1]new gUserArmor[SH_MAXSLOTS+1]new gFlashHealth[SH_MAXSLOTS+1]new gFlashArmor[SH_MAXSLOTS+1]new gSuperFlashHealth, gSuperFlashArmornew fwd_speed[SH_MAXSLOTS+1]//----------------------------------------------------------------------------------------------public plugin_init(){ // Plugin Info register_plugin("SUPERHERO Super Flash","2.00","{MC}DarkMidoriko / {MC}ParaDOX") // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG register_cvar("superflash_level", "10" ) register_cvar("superflash_speed", "1000" ) register_cvar("superflash_speed2","350") register_cvar("superflash_health", "50") register_cvar("superflash_armor", "25") // FIRE THE EVENT TO CREATE THIS SUPERHERO! shCreateHero(gHeroName, "Super Speed", "You Can Use Instant Flash Speed!", true, "superflash_level") // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS) // INIT register_srvcmd("superflash_init", "superflash_init") shRegHeroInit(gHeroName, "superflash_init") shSetMaxSpeed(gHeroName, "superflash_speed", "[0]" ) // KEYDOWN register_srvcmd("flash_kd", "flash_kd") shRegKeyDown(gHeroName, "flash_kd") // KEYUP register_srvcmd("flash_ku", "flash_ku") shRegKeyUp(gHeroName, "flash_ku") register_event("ResetHUD", "newSpawn", "b") register_event("DeathMsg", "flash_death", "a")}//----------------------------------------------------------------------------------------------public superflash_init(){ // First Argument is an id new temp 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) if ( hasPowers && is_user_alive(id) ) { gFlashHealth[id] = get_cvar_num("superflash_health") gFlashArmor[id] = get_cvar_num("superflash_armor") } else if ( !hasPowers && gHasFlashPower[id] && is_user_alive(id) && gFlashMode[id] ) { flash_removespeed(id) } gHasFlashPower[id] = (hasPowers != 0) //Log Client Cvars query_client_cvar(id, "cl_forwardspeed", "fwd_speed_get");}//----------------------------------------------------------------------------------------------public plugin_cfg(){ loadHPAM()}//----------------------------------------------------------------------------------------------public loadHPAM(){ // These cvars are checked very often gSuperFlashHealth = get_cvar_num("superflash_health") gSuperFlashArmor = get_cvar_num("superflash_armor")}//----------------------------------------------------------------------------------------------public newSpawn(id){ if ( shModActive() && gHasFlashPower[id] && is_user_alive(id) ) { if ( gFlashMode[id] ) { flash_removespeed(id) } // reset varibles gFlashHealth[id] = gSuperFlashHealth gFlashArmor[id] = gSuperFlashArmor }}//----------------------------------------------------------------------------------------------public flash_kd(){ if ( !hasRoundStarted() ) return // First Argument is an id new temp 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) if ( !gHasFlashPower[id] || !is_user_alive(id) ) return loadHPAM() flash_setspeed(id)}//----------------------------------------------------------------------------------------------public flash_setspeed(id){ if ( !gHasFlashPower[id] || !is_user_alive(id) ) return gFlashMode[id] = true new speed[11] get_cvar_string("superflash_speed",speed, 10) set_user_maxspeed(id , str_to_float(speed) ) client_cmd(id, "cl_forwardspeed %f", str_to_float(speed) ) set_task(1.0, "flash_loop", id, "", 0, "b") //shRemSpeedPower(id) gUserHealth[id] = get_user_health(id) if ( gUserHealth[id] > gFlashHealth[id] ) { set_user_health(id, gFlashHealth[id]) } gUserArmor[id] = get_user_armor(id) if ( gUserArmor[id] > gFlashArmor[id] ) { set_user_armor(id, gFlashArmor[id]) } else if ( gUserArmor[id] <= 0 ) { // If they have no armor give them some give_item(id, "item_assaultsuit") set_user_armor(id, gFlashArmor[id]) gUserArmor[id] = gFlashArmor[id] } // Let them know they are in Flash Mode new message[128] { format(message, 127, "Super Flash - You Are Now In Super Flash Mode - Speed: %f", str_to_float(speed) ) } set_hudmessage(200, 200, 200, -1.0, 0.3, 0, 0.25, 2.0, 0.0, 0.0, 17) show_hudmessage(id, message)}//----------------------------------------------------------------------------------------------public flash_loop(id){ if ( !shModActive() || !gHasFlashPower[id] || !is_user_alive(id) || !gFlashMode[id] ) return //Prevents regen from adding HP if ( get_user_health(id) > gFlashHealth[id] ) { set_user_health(id, gFlashHealth[id]) } //Prevents regen from adding AP if ( get_user_armor(id) > gFlashArmor [id]) { set_user_armor(id, gFlashArmor[id]) }}//----------------------------------------------------------------------------------------------public flash_ku(){ if ( !hasRoundStarted() ) return // First Argument is an id new temp read_argv(1,temp,5) new id = str_to_num(temp) if ( !gHasFlashPower[id] || !is_user_alive(id) || !gFlashMode[id] ) return flash_removespeed(id)}//----------------------------------------------------------------------------------------------public flash_removespeed(id){ remove_task(id) if ( !is_user_connected(id) ) return new speed2[11] get_cvar_string("superflash_speed2",speed2, 10) if ( is_user_alive(id) && gFlashMode[id] && hasRoundStarted() ) { // reset users HP and Flash Mode mode HP if ( gUserHealth[id] > gFlashHealth[id] ) { gFlashHealth[id] = get_user_health(id) // If they are regened HP higher then cvar got to set it back down if ( gFlashHealth[id] > gSuperFlashHealth ) { gFlashHealth[id] = gSuperFlashHealth } set_user_health(id, gUserHealth[id]) } // reset users AP and save Flash Mode AP if ( gUserArmor[id] > gFlashArmor[id] ) { gFlashArmor[id] = get_user_armor(id) // If they are regened AP higher then cvar got to set it back down if ( gFlashArmor[id] > gSuperFlashArmor ) { gFlashArmor[id] = gSuperFlashArmor } set_user_armor(id, gUserArmor[id]) } set_user_maxspeed(id , str_to_float(speed2) ) client_cmd(id, "cl_forwardspeed %f", str_to_float(speed2) ) //Let them know they are no longer in Flash Mode new message[128] format(message, 127, "Super Flash - You Have Left Flash Mode") set_hudmessage(200, 200, 200, -1.0, 0.3, 0, 0.25, 2.0, 0.0, 0.0,17) show_hudmessage(id, message) }}//---------------------------------------------------------------------------------------------public flash_death(){ new id = read_data(2) if ( !gHasFlashPower[id] ) return flash_removespeed(id)}//---------------------------------------------------------------------------------------------public client_disconnect(id){ if ( !gHasFlashPower[id] ) return remove_task(id) gFlashMode[id] = false}//---------------------------------------------------------------------------------------------