Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------//
- // EPILEPSY WARNING!!!!! //
- // This code contains flashing visual effects that may //
- // trigger symptoms of an epileptic seizure in sensitive //
- // users. Please exercise caution if you are sensitive //
- // to flashing lights. //
- //------------------------------------------------------------------//
- //-------------------- Includes --------------------//
- #include < amxmodx >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define ADMIN_ACCESS ADMIN_IMMUNITY
- //-------------------- Effect list --------------------//
- enum EffectInfo { effectname[ 32 ], effectid[ 64 ] }
- new Effectlist[][ EffectInfo ] =
- {
- { "NORMAL", "m" }, // normal
- { "UNDERWATER LIGHT MUTATION", "UNDERWATER LIGHT MUTATION" }, // UNDERWATER LIGHT MUTATION
- { "GENTLE PULSE 1", "jklmnopqrstuvwxyzyxwvutsrqponmlkj" }, // GENTLE PULSE 1
- { "SLOW STROBE", "aaaaaaaazzzzzzzz" }, // SLOW STROBE (fourth variety)
- { "FAST STROBE", "mamamamamama" }, // FAST STROBE
- { "SLOW STRONG PULSE", "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba" }, // SLOW STRONG PULSE
- { "SLOW PULSE NOT FADE TO BLACK", "abcdefghijklmnopqrrqponmlkjihgfedcba" }, // SLOW PULSE NOT FADE TO BLACK
- { "FLICKER #1", "mmnmmommommnonmmonqnmmo" }, // FLICKER (first variety)
- { "FLICKER #2", "nmonqnmomnmomomno" }, // FLICKER (second variety)
- { "FLUORESCENT FLICKER", "mmamammmmammamamaaamammma" }, // FLUORESCENT FLICKER
- { "CANDLE #1", "mmmmmaaaaammmmmaaaaaabcdefgabcdefg" }, // CANDLE (first variety)
- { "CANDLE #2", "mmmaaaabcdefgmmmmaaaammmaamm" }, // CANDLE (second variety)
- { "CANDLE #3", "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa" } // CANDLE (third variety)
- }
- //-------------------- Functions --------------------//
- new bool:letterprecentage = false, bool:specialeffect = false, bool:typemenu[ 33 ]
- new Lights[ 33 ][ 26 ], SLights[ 33 ], page[ 33 ], RememberPlayer[ 33 ]
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "advanced brightness", "v1.0", "RanAway`" )
- //-------------------- Commands --------------------//
- register_clcmd( "say /brightness", "BrightnessMenu" )
- register_clcmd( "nightvision", "BrightnessMenu" )
- }
- //-------------------- Authorized --------------------//
- public client_authorized( id ) Lights[ id ][ 0 ] = 'm', SLights[ id ] = 0
- //-------------------- Brightness menu --------------------//
- public BrightnessMenu( id )
- {
- new output[ 90 ], menu = menu_create( fmt( "\r[\w %s \r]\w Brightness adjuster", Prefix ), "sub_brightness" )
- //-------------------- Organize the menu --------------------//
- if( SLights[ id ] != 0 ) formatex( output, charsmax( output ), Effectlist[ SLights[ id ] ][ effectname ] )
- else get_brightness_string( Lights[ id ][ 0 ], output )
- SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'z' ? menu_addtext2( menu, "\r1. \dLight" ) : menu_additem( menu, "Light" )
- SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'a' ? menu_addtext2( menu, "\r2. \dDark" ) : menu_additem( menu, "Dark" )
- SLights[ id ] == 0 && Lights[ id ][ 0 ] == 'm' ? menu_addtext2( menu, "\r3. \dNormal^n" ) : menu_additem( menu, "Normal^n" )
- SLights[ id ] != 0 || Lights[ id ][ 0 ] == 'z' ? menu_addtext2( menu, "\r4. \dCustom \r+" ) : menu_additem( menu, "Custom \r+" )
- SLights[ id ] != 0 || Lights[ id ][ 0 ] == 'a' ? menu_addtext2( menu, "\r5. \dCustom \r-^n" ) : menu_additem( menu, "Custom \r-^n" )
- !specialeffect ? menu_addtext2( menu, "\d6. \dSpecial effects" ) : menu_additem( menu, fmt( "%sSpecial effects", SLights[ id ] != 0 ? "\y" : "\d" ) )
- ~get_user_flags( id ) & ADMIN_ACCESS ? menu_addtext2( menu, "\r7. \dAdmin options^n" ) : menu_additem( menu, "Admin options^n" )
- menu_addtext( menu, fmt( "\r<<< %s%s \r>>>", SLights[ id ] != 0 ? "\y" : "\d", output ), 0 )
- menu_display( id, menu )
- return 1
- }
- public sub_brightness( id, menu, item )
- {
- if( item == MENU_EXIT ) return menu_destroy( menu )
- if( item == 0 ) Lights[ id ][ 0 ] = 'z', SLights[ id ] = 0
- if( item == 1 ) Lights[ id ][ 0 ] = 'a', SLights[ id ] = 0
- if( item == 2 ) Lights[ id ][ 0 ] = 'm', SLights[ id ] = 0
- if( item == 3 && Lights[ id ][ 0 ]++ > 'z' ) Lights[ id ][ 0 ] = 'z'
- if( item == 4 && Lights[ id ][ 0 ]-- < 'a' ) Lights[ id ][ 0 ] = 'a'
- if( item == 5 )
- {
- //-------------------- Make sure the light set right --------------------//
- if( SLights[ id ]++ >= charsmax( Effectlist ) )
- {
- SLights[ id ] = 0
- set_light( id, Lights[ id ][ 0 ] )
- }
- else set_light( id, Effectlist[ SLights[ id ] ][ effectid ] )
- return BrightnessMenu( id )
- }
- if( item == 6 ) return AdminOptions( id )
- set_light( id, Lights[ id ][ 0 ] )
- return BrightnessMenu( id )
- }
- //-------------------- Admin options menu --------------------//
- public AdminOptions( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( ~get_user_flags( id ) & ADMIN_ACCESS || !is_user_connected( id ) ) return 0
- new warning[ 512 ], menu = menu_create( fmt( "\r[\w %s \r]\w Admin options", Prefix ), "sub_adminoptions" )
- formatex( warning, charsmax( warning ), "\d^n----------------- \rEPILEPSY WARNING!!!!!!!! \d------------------^n" )
- add( warning, charsmax( warning ), "\r-\y Flashing effects ahead; may cause seizures.^n" )
- add( warning, charsmax( warning ), "\r-\y Sensitive users should exercise caution.^n" )
- get_playersnum() > 1 ? menu_addtext2( menu, "\r1. \dselect player" ) : menu_additem( menu, "select player" )
- menu_additem( menu, "Change for all^n" )
- menu_additem( menu, fmt( "\r<<< \w%s \r>>>^n%s", letterprecentage ? "Letters" : "Precentage", warning ) )
- menu_additem( menu, fmt( "Special effects: %s", specialeffect ? "\ractivated" : "\ydeactivated" ) )
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu )
- return 1
- }
- public sub_adminoptions( id, menu, item )
- {
- if( item == MENU_EXIT ) return BrightnessMenu( id )
- if( item == 0 ) return typemenu[ id ] = true, page[ id ] = 0, selectplayer( id )
- if( item == 1 ) return typemenu[ id ] = false, adminbrightness( id )
- if( item == 2 ) letterprecentage ^= true
- if( item == 3 ) specialeffect ^= true
- return AdminOptions( id )
- }
- //-------------------- selecting menu --------------------//
- public selectplayer( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( ~get_user_flags( id ) & ADMIN_ACCESS || !is_user_connected( id ) ) return 0
- new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w select player", Prefix ), "sub_chooseplayer" )
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- //-------------------- If the player is not connected or yourself --------------------//
- if( !is_user_connected( i ) || i == id ) continue
- num_to_str( i, data, charsmax( data ) )
- menu_additem( menu, fmt( "%n", i ), data )
- }
- //-------------------- Previous / Next / Exit --------------------//
- menu_setprop( menu, MPROP_NEXTNAME, "next page" )
- menu_setprop( menu, MPROP_BACKNAME, "previous page" )
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu, page[ id ] )
- return 1
- }
- public sub_chooseplayer( id, menu, item )
- {
- if( item == MENU_EXIT ) return AdminOptions( id )
- //-------------------- Get player info --------------------//
- new data[ 6 ]
- menu_item_getinfo( menu, item, _, data, charsmax( data ) )
- player_menu_info( id, menu, menu, page[ id ] )
- //-------------------- If the player is not connected --------------------//
- if( !is_user_connected( str_to_num( data ) ) ) return selectplayer( id )
- //-------------------- Remember player's data --------------------//
- RememberPlayer[ id ] = str_to_num( data )
- return adminbrightness( id )
- }
- //-------------------- Admin brightness menu --------------------//
- public adminbrightness( id )
- {
- //-------------------- Access to the menu & prevent heap low --------------------//
- if( ~get_user_flags( id ) & ADMIN_ACCESS || !is_user_connected( id ) ) return 0
- new output[ 90 ], player = typemenu[ id ] ? RememberPlayer[ id ] : id
- new menu = menu_create( fmt( "\r[\w %s \r]\w Brightness adjuster for: \r%s", Prefix, typemenu[ id ] ? fmt( "%n", RememberPlayer[ id ] ) : "everyone" ), "sub_adminbrightness" )
- //-------------------- Organize the menu --------------------//
- if( SLights[ player ] != 0 || specialeffect == false ) formatex( output, charsmax( output ), Effectlist[ SLights[ player ] ][ effectname ] )
- else get_brightness_string( Lights[ player ][ 0 ], output )
- SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'z' ? menu_addtext2( menu, "\r1. \dLight" ) : menu_additem( menu, "Light" )
- SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'a' ? menu_addtext2( menu, "\r2. \dDark" ) : menu_additem( menu, "Dark" )
- SLights[ player ] == 0 && Lights[ player ][ 0 ] == 'm' ? menu_addtext2( menu, "\r3. \dNormal^n" ) : menu_additem( menu, "Normal^n" )
- SLights[ player ] != 0 || Lights[ player ][ 0 ] == 'z' ? menu_addtext2( menu, "\r4. \dCustom \r+" ) : menu_additem( menu, "Custom \r+" )
- SLights[ player ] != 0 || Lights[ player ][ 0 ] == 'a' ? menu_addtext2( menu, "\r5. \dCustom \r-^n" ) : menu_additem( menu, "Custom \r-^n" )
- !specialeffect ? menu_addtext2( menu, "\d6. \dSpecial effects^n" ) : menu_additem( menu, fmt( "%sSpecial effects^n", SLights[ id ] != 0 ? "\y" : "\d" ) )
- menu_addtext( menu, fmt( "\r<<< %s%s \r>>>", SLights[ id ] != 0 ? "\y" : "\d", output ) )
- menu_setprop( menu, MPROP_EXITNAME, "back" )
- menu_display( id, menu )
- return 1
- }
- public sub_adminbrightness( id, menu, item )
- {
- if( item == MENU_EXIT ) return typemenu[ id ] ? selectplayer( id ) : AdminOptions( id )
- new player = typemenu[ id ] ? RememberPlayer[ id ] : id
- if( item == 0 ) Lights[ player ][ 0 ] = 'z', SLights[ player ] = 0
- if( item == 1 ) Lights[ player ][ 0 ] = 'a', SLights[ player ] = 0
- if( item == 2 ) Lights[ player ][ 0 ] = 'm', SLights[ player ] = 0
- if( item == 3 && Lights[ player ][ 0 ]++ > 'z' ) Lights[ player ][ 0 ] = 'z'
- if( item == 4 && Lights[ player ][ 0 ]-- < 'a' ) Lights[ player ][ 0 ] = 'a'
- if( item == 5 )
- {
- //-------------------- Make sure the light set right - everyone --------------------//
- if( !typemenu[ id ] )
- {
- SLights[ player ]++
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) ) continue
- if( SLights[ player ] >= charsmax( Effectlist ) )
- {
- SLights[ player ] = 0
- set_light( i, Lights[ player ][ 0 ] )
- }
- else SLights[ i ] = SLights[ player ], set_light( i, Effectlist[ SLights[ player ] ][ effectid ] )
- }
- }
- //-------------------- Make sure the light set right - selected player --------------------//
- else
- {
- if( SLights[ player ]++ >= charsmax( Effectlist ) )
- {
- SLights[ player ] = 0
- set_light( player, Lights[ player ][ 0 ] )
- }
- else set_light( player, Effectlist[ SLights[ player ] ][ effectid ] )
- }
- return adminbrightness( id )
- }
- if( !typemenu[ id ] )
- {
- for( new i = 1; i <= get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) ) continue
- Lights[ i ][ 0 ] = Lights[ player ][ 0 ]
- set_light( i, Lights[ player ][ 0 ] )
- }
- }
- else set_light( player, Lights[ player ][ 0 ] )
- return adminbrightness( id )
- }
- //-------------------- Stocks - generate brightness as a string --------------------//
- stock get_brightness_string( input, output[] )
- {
- new pos = 0
- for( new i = 0; i < 26; i++ )
- {
- //------------- letters --------------//
- if( letterprecentage ) pos += formatex( output[ pos ], 90 - pos, ( i == input - 'a' ) ? "\y%c\d" : "%c", 'a' + i )
- //------------- precentage --------------//
- else if( i == input - 'a' )
- {
- pos = formatex( output[ pos ], 90 - pos, "\y%d%%\d", ( ( input - 'a' ) * 100 ) / 25 )
- break
- }
- }
- output[ pos ] = EOS
- }
- //-------------------- Stocks - set light --------------------//
- stock set_light( id, const light[] )
- {
- message_begin( MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, .player = id )
- write_byte( 0 )
- write_string( light )
- message_end()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement