10.09.2012, 12:39
I can't impound a ownable car somehow, it keeps telling me "SERVER: You can't impound this vehicle." i think there's something wrong with GetClosestCar(); Could anyone help me out?
pawn Код:
COMMAND:impound(playerid, params[])
{
new price, ixx, key, veh, string[128];
if(!IsPlayerInRangeOfPoint(playerid, 5, 1603.4708,-1627.8629,13.5028)) return SCM(playerid, GREY, "SERVER: You are not at the impound point.");
if(!IsACop(playerid)) return SCM(playerid, GREY, "SERVER: You are not an Law Enforcement Officer.");
veh = GetClosestCar(playerid);
if(!IsAnOwnableCar(veh))
{
SendClientMessage(playerid, COLOR_GREY, "SERVER: You can't impound this vehicle.");
return 1;
}
if(sscanf(params, "d", price)) return SCM(playerid, GREY, "USAGE: /impound [price]");
if(price<1||price>7500){
SCM(playerid, GREY, "SERVER: Price can't be above $7500 or below $1.");
return 1;
}
key = VehicleOwned[veh];
new amount = price;
if(CarInfo[key][cInsur] == 0){
amount+=1000;
}
CarInfo[key][cImpounded] = 1;
CarInfo[key][cImpoundedPrice] = amount;
for(ixx=0;ixx<MAX_PLAYERS;ixx++){
if(PlayerInfo[ixx][pCarkey] == VehicleOwned[veh]||PlayerInfo[ixx][pCarkey2] == VehicleOwned[veh]||PlayerInfo[ixx][pCarkey3] == VehicleOwned[veh]){
break;
}
}
format(string,128,"[IMPOUND]: Your car has been impounded for $%i, Go to the city hall and use /payimpound to release it.",amount);
SendClientMessage(ixx,COLOR_LIGHTRED,string);
SetVehicleToRespawn(veh);
SendClientMessage(playerid, GREY, "SERVER: Vehicle impounded.");
format(string, sizeof(string), "SAPD: %s has impounded %s's vehicle.", RPN(playerid), RPN(ixx));
foreach(Player, i)
{
if(IsACop(i))
{
SendClientMessage(i, COLOR_BLUE, string);
}
}
return 1;
}
pawn Код:
public GetClosestCar(playerid)
{
if (!IsPlayerConnected(playerid))
{
return -1;
}
new Float:prevdist = 100000.000;
new prevcar;
for (new carid = 0; carid < MAX_VEHICLES; carid++)
{
new Float:dist = GetDistanceToCar(playerid,carid);
if ((dist < prevdist))
{
prevdist = dist;
prevcar = carid;
}
}
return prevcar;
}