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