code is called many times - 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: code is called many times (
/showthread.php?tid=422312)
code is called many times -
ancezas - 13.03.2013
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 );
}
}
}
}
}
Re: code is called many times -
ancezas - 13.03.2013
bump
Re: code is called many times -
LarzI - 13.03.2013
Put
break; under SendClientMessage. This will stop (break) the loop.
Re: code is called many times -
psychopathe - 13.03.2013
already Use '' break;'' it breaks out of a loop, ending it prematurely