How to tow a car?
#2

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) != && 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(playeridCOLOR_GREY"Nu poti tracta atat de repede o masina, trebuie sa astepti 2 minute.");
                
    
AttachTrailerToVehicle(trailerveh);
    new 
rand random(sizeof(TowCarCk));
    
SetPlayerCheckpoint(playeridTowCarCk[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(playeridvFloat:range=7.0)
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playeridx,y,z);
    for(new 
i=GetVehiclePoolSize(); i!=0i--)
    {
        if(
i!=&& GetVehicleDistanceFromPoint(ix,y,z) < range) return i;
    }
    return 
INVALID_VEHICLE_ID;

Reply


Messages In This Thread
How to tow a car? - by Longover - 25.02.2019, 17:48
Re: How to tow a car? - by Kaliber - 26.02.2019, 09:42
Re: How to tow a car? - by Longover - 27.02.2019, 14:35

Forum Jump:


Users browsing this thread: 1 Guest(s)