AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] client_cmd, print_chat MENU_EXIT problem (https://forums.alliedmods.net/showthread.php?t=237857)

Baws 03-30-2014 18:35

[Solved] client_cmd, print_chat MENU_EXIT problem
 
When i click 0 which is the exit, nothing of it happens. Any reason why?

Code:
#include < amxmodx > #include < amxmisc > new const g_szPlugin[ ]  = "Surf Help"; new const g_szVersion[ ] = "1.0"; new const g_szAuthor[ ]  = "Baws"; enum Color {         NORMAL = 1,         GREEN,         TEAM_COLOR,         GREY,         RED,         BLUE }; new const g_szLearnedSound[ ] = "sound/misc/learnedsurfing.wav"; new const g_szTitle[ ] = "Advanced Surf Help"; public plugin_init( ) {     register_plugin( g_szPlugin, g_szVersion, g_szAuthor )         register_clcmd( "say /surfhelp", "SurfHelpMenu" );     register_clcmd( "say_team /surfhelp", "SurfHelpMenu" );         register_dictionary( "SurfHelp.txt" ); } public SurfHelpMenu( id ) {     new hMenu = menu_create( "Surf Help Menu:", "SurfHelpMenu_Handler" );     menu_additem( hMenu, "Learn by: \rText", "", 0 );     menu_additem( hMenu, "Learn by: \rVideo", "", 0 );     menu_additem( hMenu, "\yStop The Video!", "", 0 );         menu_display( id, hMenu, 0 ); } public SurfHelpMenu_Handler( id, hMenu, item ) {     if( item == MENU_EXIT )     {         new szName[ 33 ];         get_user_name( id, szName, charsmax( szName ) );         client_print_color( id, NORMAL, "^3%s^1, you are now a good surfer. Ask questions to be even better. Good Luck!" );         client_cmd( id, "spk %s", g_szLearnedSound );                 menu_destroy( hMenu );         return PLUGIN_HANDLED;     }         switch( item )     {         case 0:         {             new Motd[ 2056 ], Len;             Len = formatex( Motd, charsmax( Motd ), "<html><head><style type=^"text/css^"><span style=^"color:#cdcccb;^">body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:d7d5d2;^"><strong>- Surf Help - </strong></span></p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>&nbsp;</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>To surf, jump or walk on to one of the curved walls <span style=^"color:#00ff00;^">(</span> Hereby referred to as " );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<span style=^"color:#ff0000;^">'</span>ramps<span style=^"color:#ff0000;^">'</span> <span style=^"color:#00ff00;^">)</span>.</p>^n" )             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>Then simply hold strafe <span style=^"color:#00ff00;^">(</span> Default are the <em><span style=^"color:#ff0000;^">A</span></em> and " );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<em><span style=^"color:#ff0000;^">D</span></em> keys <span style=^"color:#00ff00;^">)</span>. This will cause you to glide along the walls, or " );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<span style=^"color:#ff0000;^">'</span>surf<span style=^"color:#ff0000;^">'</span>.</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>While surfing, never press up, down, or crouch; pressing those will cause you to slide off the wall and fall, which,</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>in most surf maps, will cause you to get sent back to your spawn. To change direction <span style=^"color:#00ff00;^">(</span> In order to make it to the next ramp <span style=^"color:#00ff00;^">)</span>,</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>press the button for the direction you wish to go before flying off of your current ramp. Maps with water surfaces, allow you</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>to ski across them, while holding <span style=^"color:#00ff00;^">(</span> Duck <span style=^"color:#ff0000;^">+</span> Jump <span style=^"color:#00ff00;^">)</span> key together. Surfing takes practice, so don't be discouraged if you don't</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>get it right the first time.</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p>&nbsp;</p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p><span style=^"color:#ff0000;^">*</span> If you still got problems with surfing go watch the video by closing this screen and clicking #<span style=^"color:#00ff00;^">2</span>! <span style=^"color:#ff0000;^">*</span></p>^n" );             formatex( Motd[ Len ], charsmax( Motd ) - Len, "</span></body></html>" );             show_motd( id, Motd, g_szTitle )                 SurfHelpMenu( id );         }         case 1:         {             new Motd[ 1056 ], Len;             Len = formatex( Motd, charsmax( Motd ), "<html><head><style type=^"text/css^">body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">This video is brought to you by <em><strong>%s</strong></em>.</span></p>^n", g_szAuthor );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<h3 style=^"text-align: center;^"><span style=^"color:d7d5d2;^"><strong>Advanced Surfing Help Video</strong></span></h3>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">Note: Loading time depends on your internet speed.</span></p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">Make sure to follow these steps! Or you will end up in jail.</span></p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<pre><center><object type=^"application/x-shockwave-flash^" data=^"http://allied-gamers.com/player.swf^" height=^"200^" width=^"500^" quality=^"high^">^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<param name=^"movie^" value=^"http://allied-gamers.com/player.swf^">^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<param name=^"FlashVars^" value=^"backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x996600&amp;autostart=true&amp;volume=50&amp;file=http://www.youtube.com/watch?v=opdR6MVNIE4^">^n" );             formatex( Motd[ Len ], charsmax( Motd ) - Len, "</object></EMBED></OBJECT></pre></body></html>" );             show_motd( id, Motd, g_szTitle )             SurfHelpMenu( id );         }         case 2:         {             new Motd[ 386 ], Len;             Len = formatex( Motd, charsmax( Motd ), "<html><head><style type=^"text/css^">pre{color:#cdcccb;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body><center>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<b>Video Stopped.</b>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "This has been brought you by %s.^n", g_szAuthor );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "%s plugin is here to help you out.^n", g_szPlugin );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "Hope you learned something from this!^n" );             formatex( Motd[ Len ], charsmax( Motd ) - Len, "</center></body></pre></html>" );             show_motd( id, Motd, g_szTitle );                             SurfHelpMenu( id );         }     }         return PLUGIN_HANDLED; } client_print_color( id, Color:type, const msg[ ], { Float, Sql, Result, _ }:... ) {     static SayText;     if( !SayText )     SayText = get_user_msgid( "SayText" );     static message[ 256 ];     switch( type )     {         case GREEN: // Green         {             message[ 0 ] = 0x04;         }         case TEAM_COLOR: // Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).         {             message[ 0 ] = 0x03;         }         default: // Yellow.         {             message[ 0 ] = 0x01;         }     }     vformat( message[ 1 ], 251, msg, 4 );     message[ 192 ] = '^0';     if( id )     {         if( is_user_connected( id ) )         {             message_begin( MSG_ONE, SayText, { 0, 0, 0 }, id );             write_byte( id );             write_string( message );             message_end( );         }     }     else     {         static Players[ 32 ]; new Count, Index;         get_players( Players, Count );         for( new i = 0 ; i < Count ; i++ )         {             Index = Players[ i ];             message_begin( MSG_ONE, SayText, { 0, 0, 0 }, Index );             write_byte( Index );             write_string( message );             message_end( );         }     } } /*register_dictionary_colored( const iFile[ ] ) {     if( !register_dictionary( iFile ) )         return 0;     new iLangDir[ 128 ];     get_localinfo( "amxx_datadir", iLangDir, charsmax( iLangDir ) );     formatex( iLangDir, charsmax( iLangDir ), "%s/lang/%s", iLangDir, iFile );     new iTempFile = fopen( iLangDir, "rt" );     if( !iTempFile )     {         log_amx( "Failed to open: %s", iLangDir );         return 0;     }     new szBuffer[ 512 ], szLang[ 3 ], szKey[ 64 ], szTranslation[ 256 ], TransKey:iKey;     while( !feof( iTempFile ) )     {         arrayset( szBuffer, 0, sizeof szBuffer );         fgets( iTempFile, szBuffer, 511 );         trim( szBuffer );         if( szBuffer[ 0 ] == '[' )         {             strtok( szBuffer[ 1 ], szLang, 2, szBuffer, 1, ']' );         }         else if( szBuffer[ 0 ] )         {             strbreak( szBuffer, szKey, 63, szTranslation, 255 );             iKey = GetLangTransKey( szKey );                 if( iKey != TransKey_Bad )             {                 replace_all( szTranslation, 255, "!g", "^4" );                 replace_all( szTranslation, 255, "!t", "^3" );                 replace_all( szTranslation, 255, "!n", "^1" );                         AddTranslation( szLang, iKey, szTranslation[ 2 ] );             }         }     }     fclose( iTempFile );     return 1; }*/

Black Rose 03-30-2014 18:44

Re: client_cmd, print_chat MENU_EXIT problem
 
Code:

L 03/31/2014 - 00:41:55: String formatted incorrectly - parameter 4 (total 3)
L 03/31/2014 - 00:41:55: [AMXX] Displaying debug trace (plugin "test3.amxx")
L 03/31/2014 - 00:41:55: [AMXX] Run time error 25: parameter error
L 03/31/2014 - 00:41:55: [AMXX]    [0] test3.sma::client_print_color (line 147)
L 03/31/2014 - 00:41:55: [AMXX]    [1] test3.sma::SurfHelpMenu_Handler (line 50)

Code:
client_print_color( id, NORMAL, "^3%s^1, you are now a good surfer. Ask questions to be even better. Good Luck!" );
->
Code:
client_print_color( id, NORMAL, "^3%s^1, you are now a good surfer. Ask questions to be even better. Good Luck!", szName );

Baws 03-30-2014 19:26

Re: client_cmd, print_chat MENU_EXIT problem
 
Oh hell no... lol i really need to try and debug next time.. Captain Coder helped! <3 Thanks.


Another thing, the sound doesn't play. Why?
I tried changing it to wav mp3...etc and there's not errors like i debuged but nothing.

Latest code:

Code:
#include < amxmodx > #include < amxmisc > new const g_szPlugin[ ]  = "Surf Help"; new const g_szVersion[ ] = "1.0"; new const g_szAuthor[ ]  = "Baws"; enum Color {         NORMAL = 1,         GREEN,         TEAM_COLOR,         GREY,         RED,         BLUE }; new const g_szLearnedSound[ ] = "sound/misc/learnedsurfing.mp3"; new const g_szTitle[ ] = "Advanced Surf Help"; public plugin_init( ) {     register_plugin( g_szPlugin, g_szVersion, g_szAuthor )         register_clcmd( "say /surfhelp", "SurfHelpMenu" );     register_clcmd( "say_team /surfhelp", "SurfHelpMenu" );         register_dictionary( "SurfHelp.txt" ); } public SurfHelpMenu( id ) {     new hMenu = menu_create( "Surf Help Menu:", "SurfHelpMenu_Handler" );     menu_additem( hMenu, "Learn by: \rText", "", 0 );     menu_additem( hMenu, "Learn by: \rVideo", "", 0 );     menu_additem( hMenu, "\yStop The Video!", "", 0 );         menu_display( id, hMenu, 0 ); } public SurfHelpMenu_Handler( id, hMenu, item ) {     if( item == MENU_EXIT )     {         new szName[ 33 ];         get_user_name( id, szName, charsmax( szName ) );         client_print_color( id, NORMAL, "^3%s^1, you are now a good surfer. Ask questions to be even better. Good Luck!", szName );         client_cmd( id, "mp3 play %s", g_szLearnedSound );                 menu_destroy( hMenu );         return PLUGIN_HANDLED;     }         static Motd[ 4096 ], Len;         switch( item )     {         case 0:         {             Len = formatex( Motd, charsmax( Motd ), "<style type=^"text/css^"><!--.sty1 {color: #cdcccb;font-family: Arial, Helvetica, sans-serif;}--></style><body bgcolor=^"#000000^"><span class=^"sty1^"><strong><div align=^"center^">- Surf Help -</div></strong></span></p><table width=^"100%%^" border=^"1^"><table width=^"100%%^" border=^"1^">" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<tr><td><span class=^"sty1^">To surf, jump or walk onto one of the curved walls (hereby referted to as 'ramps'). Then simply hold strafe (Default are the A and D keys). This will cause you to glide along the walls, or &quot;surf&quot;. </span></td></tr>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<tr><td><span class=^"sty1^">While surfing, never press up, down, or crouch; pressing those will cause you to slide off the wall and fall, which, in most surf maps, will cause you to get sent back to your spawn. </span></td></tr>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<tr><td><span class=^"sty1^">To change direction (in order to make it to the next ramp), press the button for the direction you wish to go before flying off of your current ramp.</span></td></tr>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<tr><td><span class=^"sty1^">Surfing takes pratice, so don't be discouraged if you don't get it right the first time.</span></td></tr>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "</table><p align=^"center^"><span class=^"sty1^"><strong>Powered by %s</strong></span></p></body></html>", g_szPlugin );             show_motd( id, Motd, g_szTitle )                 SurfHelpMenu( id );         }         case 1:         {             Len = formatex( Motd, charsmax( Motd ), "<html><head><style type=^"text/css^">body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">This video is brought to you by <em><strong>%s</strong></em>.</span></p>^n", g_szAuthor );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<h3 style=^"text-align: center;^"><span style=^"color:d7d5d2;^"><strong>Advanced Surfing Help Video</strong></span></h3>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">Note: Loading time depends on your internet speed.</span></p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<p style=^"text-align: center;^"><span style=^"color:cdcccb;^">Make sure to follow these steps! Or you will end up in jail.</span></p>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<pre><center><object type=^"application/x-shockwave-flash^" data=^"http://allied-gamers.com/player.swf^" height=^"200^" width=^"500^" quality=^"high^">^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<param name=^"movie^" value=^"http://allied-gamers.com/player.swf^">^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<param name=^"FlashVars^" value=^"backcolor=0x000000&amp;frontcolor=0xCCCCCC&amp;lightcolor=0x996600&amp;autostart=true&amp;volume=50&amp;file=http://www.youtube.com/watch?v=opdR6MVNIE4^">^n" );             formatex( Motd[ Len ], charsmax( Motd ) - Len, "</object></EMBED></OBJECT></pre></body></html>" );             show_motd( id, Motd, g_szTitle )             SurfHelpMenu( id );         }         case 2:         {             Len = formatex( Motd, charsmax( Motd ), "<html><head><style type=^"text/css^">pre{color:#cdcccb;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body><center>" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "<b>Video Stopped.</b>^n" );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "This has been brought you by %s.^n", g_szAuthor );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "%s plugin is here to help you out.^n", g_szPlugin );             Len += formatex( Motd[ Len ], charsmax( Motd ) - Len, "Hope you learned something from this!^n" );             formatex( Motd[ Len ], charsmax( Motd ) - Len, "</center></body></pre></html>" );             show_motd( id, Motd, g_szTitle );                             SurfHelpMenu( id );         }     }         return PLUGIN_HANDLED; } client_print_color( id, Color:type, const msg[ ], { Float, Sql, Result, _ }:... ) {     static SayText;     if( !SayText )     SayText = get_user_msgid( "SayText" );     static message[ 256 ];     switch( type )     {         case GREEN: // Green         {             message[ 0 ] = 0x04;         }         case TEAM_COLOR: // Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).         {             message[ 0 ] = 0x03;         }         default: // Yellow.         {             message[ 0 ] = 0x01;         }     }     vformat( message[ 1 ], 251, msg, 4 );     message[ 192 ] = '^0';     if( id )     {         if( is_user_connected( id ) )         {             message_begin( MSG_ONE, SayText, { 0, 0, 0 }, id );             write_byte( id );             write_string( message );             message_end( );         }     }     else     {         static Players[ 32 ]; new Count, Index;         get_players( Players, Count );         for( new i = 0 ; i < Count ; i++ )         {             Index = Players[ i ];             message_begin( MSG_ONE, SayText, { 0, 0, 0 }, Index );             write_byte( Index );             write_string( message );             message_end( );         }     } } /*register_dictionary_colored( const iFile[ ] ) {     if( !register_dictionary( iFile ) )         return 0;     new iLangDir[ 128 ];     get_localinfo( "amxx_datadir", iLangDir, charsmax( iLangDir ) );     formatex( iLangDir, charsmax( iLangDir ), "%s/lang/%s", iLangDir, iFile );     new iTempFile = fopen( iLangDir, "rt" );     if( !iTempFile )     {         log_amx( "Failed to open: %s", iLangDir );         return 0;     }     new szBuffer[ 512 ], szLang[ 3 ], szKey[ 64 ], szTranslation[ 256 ], TransKey:iKey;     while( !feof( iTempFile ) )     {         arrayset( szBuffer, 0, sizeof szBuffer );         fgets( iTempFile, szBuffer, 511 );         trim( szBuffer );         if( szBuffer[ 0 ] == '[' )         {             strtok( szBuffer[ 1 ], szLang, 2, szBuffer, 1, ']' );         }         else if( szBuffer[ 0 ] )         {             strbreak( szBuffer, szKey, 63, szTranslation, 255 );             iKey = GetLangTransKey( szKey );                 if( iKey != TransKey_Bad )             {                 replace_all( szTranslation, 255, "!g", "^4" );                 replace_all( szTranslation, 255, "!t", "^3" );                 replace_all( szTranslation, 255, "!n", "^1" );                         AddTranslation( szLang, iKey, szTranslation[ 2 ] );             }         }     }     fclose( iTempFile );     return 1; }*/

Blizzard_87 03-30-2014 21:17

Re: client_cmd, print_chat MENU_EXIT problem
 
You need to precache the sound file first.

You could also remove that colour function if you update Amxx to latest Dev build 1.8.3 then it's included by default.

Baws 03-30-2014 21:47

Re: client_cmd, print_chat MENU_EXIT problem
 
Thanks! Captain yugi yu ?


Like i don't need that stock? Like update the studio right?

And is there any other way to put the sound without precaching it?

fysiks 03-30-2014 22:04

Re: client_cmd, print_chat MENU_EXIT problem
 
Quote:

Originally Posted by baws (Post 2118146)
Thanks! Captain yugi yu ?


Like i don't need that stock? Like update the studio right?

And is there any other way to put the sound without precaching it?

If a sound is not precached, nobody can play it.

Baws 03-30-2014 22:16

Re: client_cmd, print_chat MENU_EXIT problem
 
I see. Thanks.


All times are GMT -4. The time now is 06:01.

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