CMD: Trailer [Not facing the right way]
#1

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);
}
Reply
#2

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);
}
Reply
#3

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.
Reply
#4

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.
Reply
#5

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
Reply
#6

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?
Reply
#7

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.
Reply
#8

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)));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)