26.02.2019, 09:42
You should write it more like that:
PHP код:
if (newkeys & KEY_CTRL_BACK)
{
if(PlayerInfo[playerid][pJob] != 8) return 1;
new veh = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) != 2 && GetVehicleModel(veh) != 525) return SCM(playerid, -1, "Nu esti in masina de mecanici.");
if(IsTrailerAttachedToVehicle(veh)) return DetachTrailerFromVehicle(veh),DisablePlayerCheckpoint(playerid),gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
new trailer = GetNearestTrailerFromPlayer(playerid,veh);
if(!CanBeTowed(trailer)) return SCM(playerid, -1, "Nu poti tracta acest tip de vehicul.");
if(IsAnOwnableCar(trailer)) return SCM(playerid,COLOR_WHITE,"Nu ai voie sa tractezi masini personale.");
if(TowAcc[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "Nu poti tracta atat de repede o masina, trebuie sa astepti 2 minute.");
AttachTrailerToVehicle(trailer, veh);
new rand = random(sizeof(TowCarCk));
SetPlayerCheckpoint(playerid, TowCarCk[rand][0],TowCarCk[rand][1],TowCarCk[rand][2], 6);
CP[playerid] = 34;
return 1;
}
stock CanBeTowed(trailer)
{
if(IsABike(trailer) || trailer == INVALID_VEHICLE_ID) return 0;
switch(GetVehicleModel(trailer))
{
case 448,525,461,462,463,468,471,521,522,523: return 0;
}
return 1;
}
stock GetNearestVehicleFromPlayer(playerid, v, Float:range=7.0)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x,y,z);
for(new i=GetVehiclePoolSize(); i!=0; i--)
{
if(i!=v && GetVehicleDistanceFromPoint(i, x,y,z) < range) return i;
}
return INVALID_VEHICLE_ID;
}