| PattyBiena |
07-11-2010 04:51 |
Re: Activating powers when you press the reload key
PHP Code:
#include <amxmodx> #include <fakemeta> #include <fun>
new const PLUGIN_INFO[][] = { "New Plugin", "1.0", "Author" } new g_class[33], Hability[33][2]
// Hability [0] is speed, [1] is gravity.
const TASK_SPEED = 515; const TASK_GRAVITY = 516;
enum { IS_BART = 0, IS_HOMER }
public plugin_init() { register_plugin(PLUGIN_INFO[0], PLUGIN_INFO[1], PLUGIN_INFO[2]) register_forward( FM_CmdStart , "fw_FMCmdStart" ) }
public client_disconnect(id) { Hability[id][0] = false Hability[id][1] = false }
public fw_FMCmdStart( id , uc_handle , seed ) { static class class = g_class[id] if ( get_uc( uc_handle , UC_Buttons ) & IN_RELOAD) { switch(class) { case IS_HOMER:if (!task_exists( TASK_GRAVITY + id)) activateGravity(id) case IS_BART: if (!task_exists( TASK_SPEED + id)) activateSpeed(id) } } }
activateGravity( id ) { if( is_user_alive( id ) && !Hability[id][1] ) { Hability[id][1] = true set_user_gravity( id, 0.3 ) set_user_rendering( id, kRenderFxGlowShell, 0, 50, 125, kRenderNormal, 255 ) set_task( 15.0, "removeGravity" , id + TASK_GRAVITY) client_print( id, print_chat , "^4[^3FreezeTag^4] ^3Your gravity has been activated!" ) } return PLUGIN_CONTINUE; }
public removeGravity( id ) { id -= TASK_GRAVITY; if (is_user_alive(id)) { set_user_gravity( id, 1.0 ) set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderNormal, 255 ) client_print( id, print_chat , "^4[^3FreezeTag^4] ^3Your gravity has expired!" ) Hability[id][1] = false } }
activateSpeed( id ) { if( is_user_alive( id ) && !Hability[id][0] ) { Hability[id][0] = true set_user_maxspeed( id, 400.0 ) set_user_rendering( id, kRenderFxGlowShell, 0, 50, 125, kRenderNormal, 255 ) set_task( 15.0, "removeSpeed" , id + TASK_SPEED) client_print( id, print_chat , "^4[^3FreezeTag^4] ^3Your speed has been activated!" ) } return PLUGIN_CONTINUE; }
public removeSpeed( id ) { id -= TASK_SPEED; if (is_user_alive(id)) { set_user_maxspeed( id, 250.0 ) set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderNormal, 255 ) client_print( id, print_chat , "^4[^3FreezeTag^4] ^3Your speed has expired!" ) } }
Optimized(?) Xd
|