AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switch (https://forums.alliedmods.net/showthread.php?t=60169)

vl@d 08-28-2007 09:56

Switch
 
I need a confirmation about switch.
this code:
Code:

switch(get_pcvar_num(mesaje_mode)){
        case 1:{
        ColorChat(player, RED, "Ai Scapat Bomba... Ratatule...");
        }
        case 2:{   
        set_hudmessage(random(255), random(255), random(255), 0.32, 0.26, 0, 6.0, 12.0)
        show_hudmessage(0, "%s A Scapat Bomba... Ce Ratat....",name)
            }
        }
    }

I need to know if the cvar mesaje_mode is set to 3 it will show to both colorchat and the hud.

Arkshine 08-28-2007 09:59

Re: Switch
 
If set to 3, nothing is happened.

Alka 08-28-2007 10:00

Re: Switch
 
If cvar mesaje_mode is set to 3 the plugin is showing..."nothing" !

@arkshine - Omg >.> ! second topic i was beated

vl@d 08-28-2007 10:04

Re: Switch
 
damn. that means i have to make another case with the hud and colrochat :|
ok thx.

Arkshine 08-28-2007 10:21

Re: Switch
 
To avoid to repeat code with a 'case 3:' , I will do that :

Something like :

Quote:

mesaje_mode < flags > : Show messages. Flags are additives.

a : Chat
b : HUD

Default value : "ab".

Before plugin_init() :

Code:
    #define CHAT_MSG ( 1 << 0 ) // a     #define HUD_MSG  ( 1 << 1 ) // b         new p_mesaje_mode;

Into plugin_init() :

Code:
    p_mesaje_mode = register_cvar( "mesaje_mode", "ab" );

Into your function :

Code:
    new flag = get_flags();         // Flag "a"     if( flag & CHAT_MSG )         ColorChat( player, RED, "Ai Scapat Bomba... Ratatule..." );         // Flag "b"     if( flag & HUD_MSG )     {         set_hudmessage( random( 255 ), random( 255 ), random( 255 ), 0.32, 0.26, 0, 6.0, 12.0 );         show_hudmessage( 0, "%s A Scapat Bomba... Ce Ratat....", name );     }

And this small stock to retrieve flags :

Code:
    stock get_flags()     {         static sFlags[4];         get_pcvar_string( p_mesaje_mode, sFlags, sizeof sFlags - 1 );         return read_flags( sFlags );     }

I like this way. Did you understand this idea?

vl@d 08-28-2007 11:50

Re: Switch
 
ooo yes this is much simpler :D
thx.
P.S. this event register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")

Is there a similer event for it, because the hud shows at the round start :|


All times are GMT -4. The time now is 16:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.