code is called many times
#1

sometimes this code is called more then one time, i need that code calls one time

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if( GetPlayerState( playerid ) == PLAYER_STATE_PASSENGER )
    {
        if( GetVehicleModel( playerDB[ playerid ][ masina ] ) == 420 )
        {
            foreach( Player, i )
            {
                if( playerDB[ i ][ darbas ] == Taxi )
                {
                    if( GetPlayerState( i ) == PLAYER_STATE_DRIVER )
                    {
                        new msg[ 51 ], Float:zP[ 3 ];
                        GetPlayerPos( playerid, zP[ 0 ], zP[ 1 ], zP[ 2 ] );
                        new const sumoketaSuma = (( floatround ( floatabs ( zP[ 0 ] - playerDB[ playerid ][ PaskPoz ][ 0 ] ) ) + floatround( floatabs( zP[ 1 ] - playerDB[ playerid ][ PaskPoz ][ 1 ] )) + floatround( floatabs( zP[ 2 ] - playerDB[ playerid ][ PaskPoz ][ 2 ] ))) /3 ) /5;
                        GivePlayerMoneyA( playerid, -sumoketaSuma );
                        GivePlayerMoneyA( i, sumoketaSuma );
                        format( msg, 39, "Taksometras Jums įmuљė %d Lt." ,sumoketaSuma );
                        SendClientMessage( playerid, 0xFF0000FF, msg );
                        format( msg, 51, "Keleivis iљlipo, taksometras įmuљė %d Lt." ,sumoketaSuma );
                        SendClientMessage( i, 0xFF0000FF ,msg );
                    }
                }
            }
        }
    }
Reply
#2

bump
Reply
#3

Put break; under SendClientMessage. This will stop (break) the loop.
Reply
#4

already Use '' break;'' it breaks out of a loop, ending it prematurely
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)