CMD:megtankol(playerid, params[])
{
if(pInfo[playerid][pFrakcio] == SZERELO || pInfo[playerid][pFrakcio] == SZFONOK)
{
if(pInfo[playerid][pMoney] >= 120)
{
new Float: vX, Float: vY, Float: vZ;
new VehID = GetClosestCar(playerid);
GetVehiclePos(VehID, vX, vY, vZ);
if(!IsPlayerInRangeOfPoint(playerid, 3.5, vX, vY, vZ)) return SendClientMessage(playerid, PIROS, \"Nincs a közeledben jármű!\");
cmd_me(playerid, \"megtankolt egy járművet.\");
MilyenUzemAnyag(VehID);
pInfo[playerid][pMoney] -= 120;
}
else
{
SendClientMessage(playerid, PIROS, \"Nincs elég pénzed! (120$)\");
}
}
else
{
SendClientMessage(playerid, PIROS, \"Nem vagy Szerelő\");
}
return 1;
}
stock GetClosestCar( playerid )
{
new iMax=INVALID_VEHICLE_ID, Float:dis, Float:dMax = float( 10000 ), Float:PlayerPos[ 3 ], Float:VehiclePos[ 3 ];
GetPlayerPos( playerid, PlayerPos[ 0 ], PlayerPos[ 1 ], PlayerPos[ 2 ] );
for( new x = 0; x < MAX_VEHICLES; x++ )
{
GetVehiclePos( x, VehiclePos[ 0 ], VehiclePos[ 1 ], VehiclePos[ 2 ] );
for( new j = 0; j < 3; j++ ) PlayerPos[ j ] -= VehiclePos[ j ];
dis = floatsqroot( ( ( PlayerPos[ 0 ] * PlayerPos[ 0 ] ) + ( PlayerPos[ 1 ] * PlayerPos[ 1 ] ) + ( PlayerPos[ 2 ] * PlayerPos[ 2 ] ) ) );
if( dis < dMax )
{
dMax = dis,
iMax = x;
}
}
return iMax;
}