Problem with cycle 'for' - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with cycle 'for' (
/showthread.php?tid=298553)
Problem with cycle 'for' -
RenisiL - 21.11.2011
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?
Re: Problem with cycle 'for' -
Elorreli - 21.11.2011
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;
Re: Problem with cycle 'for' -
RenisiL - 21.11.2011
Okay, but if I delete break; then print ID 56,57,58,59 ... to 198 and I need to print 1,2,3
Re: Problem with cycle 'for' -
Elorreli - 21.11.2011
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.
Re: Problem with cycle 'for' -
RenisiL - 21.11.2011
Yes, what to do? that to print 1,2,3...
Re: Problem with cycle 'for' -
Elorreli - 21.11.2011
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?