12.05.2014, 21:19
PHP код:
stock kmsaver(id,vehicleid)
{
new
Float: OldPos [ MAX_PLAYERS ] [ 3 ] ,
Float: DistanceKM [ MAX_PLAYERS ] ;
OldPos [ id ] [ 0 ] = VehicleOPos [ id ] [ 0 ] ;
OldPos [ id ] [ 1 ] = VehicleOPos [ id ] [ 1 ] ;
OldPos [ id ] [ 2 ] = VehicleOPos [ id ] [ 2 ] ;
GetPlayerPos ( id , VehicleOPos [ id ] [ 0 ] , VehicleOPos [ id ] [ 1 ] , VehicleOPos [ id ] [ 2 ] ) ;
DistanceKM [ id ] = GetDistanceBetweenPoints1 ( OldPos [ id ] [ 0 ] , OldPos [ id ] [ 1 ] , OldPos [ id ] [ 2 ] , VehicleOPos [ id ] [ 0 ] , VehicleOPos [ id ] [ 1 ] , VehicleOPos [ id ] [ 2 ] ) ;
VehicleInfo[vehicleid][vMegtettUt] += DistanceKM [ id ] / 1000 ;
return 1;
}
PHP код:
forward Float:GetDistanceBetweenPoints1 ( Float: OldX , Float: OldY , Float: OldZ , Float: NewX , Float: NewY , Float: NewZ ) ;
public Float:GetDistanceBetweenPoints1 ( Float: OldX , Float: OldY , Float: OldZ , Float: NewX , Float: NewY , Float: NewZ ) {
return floatsqroot ( floatpower ( floatabs ( floatsub ( NewX , OldX ) ) , 2 ) + floatpower ( floatabs ( floatsub ( NewY , OldY ) ) , 2 ) +floatpower ( floatabs ( floatsub ( NewZ , OldZ ) ) , 2 ) ) ;
}
PHP код:
SetPVarInt(playerid, "kmsaver1", SetTimerEx("kmsaver", 100, true, "i", playerid));