|
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
|

06-25-2009
, 19:30
Re: make a case of a switch equal a string?
|
#10
|
Quote:
Originally Posted by fysiks
Also, you need to start using braces.
PHP Code:
if(is_user_alive(target)) set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,255) client_print(target,print_chat,"-[EVIL]- %s is no longer cloaked ",name)
If user is alive both are executed. If user is dead the second is still executed. Is this check really needed anyways?
|
the if is_user_alive bit was my way of trying to get it to do it whenever user is alive, but now I feel asif it should be removed, because this is not looping infinitely redoing the command constantly... (wouldnt that kill the server?)
the final product:
PHP Code:
#include <amxmodx> #include <fun> #include <amxmisc>
#define PLUGIN "Cloak" #define VERSION "1.0" #define AUTHOR "Master A.K.A. HLM"
new g_iVisibilityState[33]
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("amx_cloak","give_invis", ADMIN_KICK,"<name|#userid|steamid> <on/half/off> ") register_event("DeathMsg", "e_death", "a", "1>0") }
public give_invis(id,level,cid) { if(!cmd_access(id,level,cid,3)) return PLUGIN_HANDLED new szarg1[33], szarg2[8] read_argv(1,szarg1,32) read_argv(2,szarg2,7) new mode = str_to_num(szarg2) new target = cmd_target(id,szarg1,2) new name[32]; get_user_name(id, name, 32) if(target) { g_iVisibilityState[target] = mode if( equal( szarg2, "off" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,255) client_print(target,print_chat,"-[EVIL]- %s is no longer cloaked ",name) } else if( equal( szarg2, "half" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85) client_print(target,print_chat, "-[EVIL]- %s is partially cloaked ",name) // Partial Cloak } else if( equal( szarg2, "on" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0) client_print(target,print_chat, "-[EVIL]- %s is completely cloaked ",name) // Full Cloak } } return PLUGIN_HANDLED }
public e_death(id,level,cid) { new szarg1[33], szarg2[8] read_argv(1,szarg1,32) read_argv(2,szarg2,7) new mode = str_to_num(szarg2) new target = cmd_target(id,szarg1,2) new name[32]; get_user_name(id, name, 32) if( equal( szarg2, "off" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,255) } else if( equal( szarg2, "half" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85) client_print(target,print_chat, "-[EVIL]- %s, you are still partially cloaked! ",name) } else if( equal( szarg2, "on" ) ) { set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0) client_print(target,print_chat, "-[EVIL]- %s, you are still completely cloaked! ",name) } return PLUGIN_HANDLED }
the only problem is that it does NOT last through death.. I have a feeling that it is because I redefined the vars and whatnot.. is it possible to have a public in a public? or call upon the value of the args from a different function?
__________________
Last edited by HLM; 06-25-2009 at 19:56.
Reason: added the final product..
|
|