SA-MP Forums Archive
CMD: Trailer [Not facing the right way] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD: Trailer [Not facing the right way] (/showthread.php?tid=656275)



CMD: Trailer [Not facing the right way] - DerickClark - 11.07.2018

When i use this command and added to the server. then i restart and the trailer not facing where i print it facing.

Код:
CMD:printtrailer(playerid, params[])
{
    SaveTrailers(GetPlayerVehicleID(playerid));
    SendClientMessageToAll(-1, "Saved this Trailer");
    return 1;
}
Код:
stock SaveTrailers(trailerID)
{

    new
        sz_Entry[128],
        File: fileHandle = fopen("trailers.txt", io_append),
        Float:tmpCoords[3];

    new trailerModel = GetVehicleModel(trailerID);
    GetVehiclePos(trailerID, tmpCoords[0], tmpCoords[1], tmpCoords[2]);
    format(sz_Entry, sizeof(sz_Entry), "Trailer - CreateVehicle(%d, %f, %f, %f, 0, -1, -1, 6000000);", trailerModel, tmpCoords[0], tmpCoords[1], tmpCoords[2]);
    fwrite(fileHandle, sz_Entry);
    return fclose(fileHandle);
}



Re: CMD: Trailer [Not facing the right way] - Caessius - 11.07.2018

You should save the facing Z angle. Save the value of GetVehicleZAngle and set that value again using SetVehicleZAngle.
So basically, you code will become:
pawn Код:
stock SaveTrailers(trailerID)
{

    new
        sz_Entry[128],
        File: fileHandle = fopen("trailers.txt", io_append),
        Float:tmpCoords[4];

    new trailerModel = GetVehicleModel(trailerID);
    GetVehiclePos(trailerID, tmpCoords[0], tmpCoords[1], tmpCoords[2]);
    GetVehicleZAngle(trailerID, tmpCoords[3]);
    format(sz_Entry, sizeof(sz_Entry), "Trailer - CreateVehicle(%d, %f, %f, %f, %f, 0, -1, -1, 6000000);", trailerModel, tmpCoords[0], tmpCoords[1], tmpCoords[2], tmpCoords[3]);
    fwrite(fileHandle, sz_Entry);
    return fclose(fileHandle);
}



Re: CMD: Trailer [Not facing the right way] - DerickClark - 11.07.2018

Quote:
Originally Posted by Caessius
Посмотреть сообщение
You should save the facing Z angle. Save the value of GetVehicleZAngle and set that value again using SetVehicleZAngle.
Will it works with trailer? edit: Testing it right now.


Edit again:

It seems like it works. but the trailer model printing the wrong number id.


Re: CMD: Trailer [Not facing the right way] - Caessius - 11.07.2018

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
Will it works with trailer?
I'm certainly not sure about it, but worth a try mate.. It's probably the only callback I'd use for working with facing angles related to vehicles.


Re: CMD: Trailer [Not facing the right way] - DerickClark - 11.07.2018

Quote:
Originally Posted by Caessius
Посмотреть сообщение
I'm certainly not sure about it, but worth a try mate.. It's probably the only callback I'd use for working with facing angles related to vehicles.
It worked but the only problem is. When i connect trailer to the truck. but it print the truck id. instead of trailer id


Re: CMD: Trailer [Not facing the right way] - Caessius - 11.07.2018

Because you're getting the player's vehicle ID instead of trailers here @
pawn Код:
new trailerModel = GetVehicleModel(trailerID);
Could you show me how you create the trailer?


Re: CMD: Trailer [Not facing the right way] - DerickClark - 11.07.2018

Quote:
Originally Posted by Caessius
Посмотреть сообщение
Because you're getting the player's vehicle ID instead of trailers here @
pawn Код:
new trailerModel = GetVehicleModel(trailerID);
Could you show me how you create the trailer?
I connect the truck to the trailer. and use /printtrailer then it will send the Trailer ID to the text file.


Re: CMD: Trailer [Not facing the right way] - ItsRobinson - 11.07.2018

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
I connect the truck to the trailer. and use /printtrailer then it will send the Trailer ID to the text file.
Nah you're sending the vehicle ID that the players driving and then getting the model of that ID, do this

SaveTrailers(GetVehicleTrailer(GetPlayerVehicleID( playerid)));