12.10.2015, 06:35
you are doing all wrong, try like this:
PHP код:
CMD:towcar(playerid, params[]){
if (GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) return SendClientMessage(playerid, COLOR_GREY, "You have to be in TowCar to use this command.");
new Float:pX, Float : pY, Float : pZ;
GetPlayerPos(playerid, pX, pY, pZ);
new Float:vX, Float : vY, Float : vZ;
new Found = 0;
new vid = 0;
while ((vid<MAX_VEHICLES) && (!Found)) {
vid++;
GetVehiclePos(vid, vX, vY, vZ);
if ((floatabs(pX - vX)<7.0) && (floatabs(pY - vY)<7.0) && (floatabs(pZ - vZ)<7.0) && (vid != GetPlayerVehicleID(playerid))) {
Found = 1;
if (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) {
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
AttachTrailerToVehicle(vid, GetPlayerVehicleID(playerid));
SendClientMessage(playerid, 0xFFFF00AA, "Car towed!");
}
}
if (!Found) {
SendClientMessage(playerid, 0xFFFF00AA, "There is no car in range.");
}
return 1;
}