Problem with cycle 'for'
#1

Hey i have big problem with business cycle: Why is my cycle is always an ID 0

pawn Код:
if( dialogid == GUI_VERSLAS_PARDUOTI_ID )
    {
        if( response )
        {
            if( listitem == 0 )
            {
                for( new ID=0; ID < MAX_BUSSINES; ID++ )
                {

                    new
                        String[ 200 ]
                    ;

                    format           ( String, sizeof( String ),
                    ""HEX_ZALIA" [ + ] "HEX_BALTA" Pardavėte savo verslą (Gauti pinigai uћ parduotą verslą: %d)" , ( floatround( SERVERIO_VERSLAI[ ID ][ Verslo_Kaina ] * 0.08 ) ) );
                    SendClientMessage( playerid, -1, String );

                    GivePlayerMoney( playerid, ( floatround( SERVERIO_VERSLAI[ ID ][ Verslo_Kaina ] * 0.8 ) ) );
                   
                    new
                        DINI[ 128 ]
                    ;
                    format( SERVERIO_VERSLAI[ ID ][ Verslo_Savininkas ], MAX_PLAYER_NAME,"Nera");
                    format  ( DINI, 20 , "Verslai/%d.ini" ,ID );
                   
                    dini_Set( DINI,"Savininkas" , "Nera" );

             printf("%d", ID);
                   
                    new
                        Str[ 100 ]
                    ;
                    format               ( Str, sizeof( Str ), "Savininkas: %s\nVerslo Pavadinimas: %s", SERVERIO_VERSLAI[ ID ][ Verslo_Savininkas ], SERVERIO_VERSLAI[ ID ][ Verslo_Pavadinimas ] );
                    Update3DTextLabelText( SERVERIO_VERSLAI[ ID ][ TextLabel1 ], 0x21DD00FF, Str );

                    Biudzetas( 6, ( floatround( SERVERIO_VERSLAI[ ID ][ Verslo_Kaina ] * 0.1 ) ) );break;
                }
            }
and print Bussines id=0

what's it's wrong?
Reply
#2

Well you're breaking the loop at the end which would stop it after It's done with 0.

pawn Код:
Biudzetas( 6, ( floatround( SERVERIO_VERSLAI[ ID ][ Verslo_Kaina ] * 0.1 ) ) );break;
Reply
#3

Okay, but if I delete break; then print ID 56,57,58,59 ... to 198 and I need to print 1,2,3
Reply
#4

Quote:
Originally Posted by RenisiL
Посмотреть сообщение
Okay, but if I delete break; then print ID 56,57,58,59 ... to 198 and I need to print 1,2,3
Yeah but if you break it like that you stop the loop after 0.

Hard to see what you're trying to do as the script is in some foreign language.
Reply
#5

Yes, what to do? that to print 1,2,3...
Reply
#6

Quote:
Originally Posted by RenisiL
Посмотреть сообщение
Yes, what to do? that to print 1,2,3...
What does your script do? What are you trying to achieve?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)