Trying to attach a trailer on my job system
#1

Hey people, today i tried for hours to attach a trailer for my job. He need to check on the waypoint if the trailer is attached. If it is not attached it have to say ''Trailer not attached'' and if the trailer is attached it have to give your payout etc. The vehicle id is 485 and trailer id is 606

I tried this code but after changing and testing it for hours i can figure out how it works.
Is here someone who knows how to fix this?

Код HTML:
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 485)
    {
                if(Info[playerid][Bagage] == 1)
                {
                        SetPlayerCheckpoint(playerid, 1857.0491,-2655.3923,13.5469, 8);
                        CreateVehicle(606,1861.7717,-2656.6096,13.2069,5.0111,1,78);
                        PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                        Info[playerid][Bagage] = 2;
                        return 1;
                }
                if(Info[playerid][Bagage] == 2)
                {
                        SetPlayerCheckpoint(playerid, 1921.4204,-2441.5576,13.5391, 8);
                        PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                        Info[playerid][Bagage] = 3;
                        return 1;
                }
                if(Info[playerid][Bagage] == 3)
                {
                        if(IsTrailerAttachedToVehicle(485))
                        {
                       printf("Vehicle %i has a trailer!", 485);
                        }
                        SendClientMessage(playerid, LIGHT_BLUE, "You need to attach the trailer!");
                        Info[playerid][Bagage] = 3;
                        return 0;
                }
                if(Info[playerid][Bagage] == 3)
                {
                        if(IsTrailerAttachedToVehicle(485))
                        DisablePlayerCheckpoint(playerid);
                        GameTextForPlayer(playerid, "~y~+$12000", 3000, 4);
                        SendClientMessage(playerid, LIGHT_BLUE, "You have recieved $12000 for finish this work!");
                        PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                        GivePlayerCash(playerid, 12000);
                        DetachTrailerFromVehicle(485);
                        Info[playerid][Bagage] = 0;
                        return 1;
                }
    }
        return 1;
Reply
#2

You need to use else if statements or use returns. The IsTrailerAttachedToVehicle function also uses vehicle IDs, not vehicle models. Example:
pawn Код:
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))
{
     // put code here
}
else SendClientMessage(playerid, -1, "You do not have a trailer attached!");
Or method 2:
pawn Код:
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))
{
      // put code here
      return 1;
}

SendClientMessage(playerid, -1, "You do not have a trailer attached.");
return 1;
}
Reply
#3

This is not how you use this function you need to use variables when creating vehicles so you know their id's.

Код:
if(IsTrailerAttachedToVehicle(485))

                if(Info[playerid][Bagage] == 3)
                {
                        if(IsTrailerAttachedToVehicle(485))
                        {
                       printf("Vehicle %i has a trailer!", 485);
                        }
                        SendClientMessage(playerid, LIGHT_BLUE, "You need to attach the trailer!");
                        Info[playerid][Bagage] = 3;
                        return 0;
                }
                if(Info[playerid][Bagage] == 3)
                {
                        if(IsTrailerAttachedToVehicle(485))
                        DisablePlayerCheckpoint(playerid);
                        GameTextForPlayer(playerid, "~y~+$12000", 3000, 4);
                        SendClientMessage(playerid, LIGHT_BLUE, "You have recieved $12000 for finish this work!");
                        PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                        GivePlayerCash(playerid, 12000);
                        DetachTrailerFromVehicle(485);
                        Info[playerid][Bagage] = 0;
                        return 1;
                }
That will never work either and this is just the basic stuff you are getting yourself in over your head that is for sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)