SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/07/2018, 05:55 PM   #1
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,763
Reputation: 14
Default CMD: Trailer [Not facing the right way]

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

Code:
CMD:printtrailer(playerid, params[])
{
    SaveTrailers(GetPlayerVehicleID(playerid));
    SendClientMessageToAll(-1, "Saved this Trailer");
    return 1;
}
Code:
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);
}
__________________
Working on a Trucking Server from scratch.
There are cool features, like /workmenu /convoy /pay(When Police Officer asked you for a fine) and more etc.
DerickClark is offline   Reply With Quote
Old 11/07/2018, 05:59 PM   #2
Caessius
Little Clucker
 
Join Date: Jun 2018
Posts: 8
Reputation: 1
Default Re: CMD: Trailer [Not facing the right way]

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 Code:
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);
}
Caessius is offline   Reply With Quote
Old 11/07/2018, 06:00 PM   #3
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,763
Reputation: 14
Default Re: CMD: Trailer [Not facing the right way]

Quote:
Originally Posted by Caessius View Post
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.
__________________
Working on a Trucking Server from scratch.
There are cool features, like /workmenu /convoy /pay(When Police Officer asked you for a fine) and more etc.
DerickClark is offline   Reply With Quote
Old 11/07/2018, 06:01 PM   #4
Caessius
Little Clucker
 
Join Date: Jun 2018
Posts: 8
Reputation: 1
Default Re: CMD: Trailer [Not facing the right way]

Quote:
Originally Posted by DerickClark View Post
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.
Caessius is offline   Reply With Quote
Old 11/07/2018, 06:14 PM   #5
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,763
Reputation: 14
Default Re: CMD: Trailer [Not facing the right way]

Quote:
Originally Posted by Caessius View Post
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
__________________
Working on a Trucking Server from scratch.
There are cool features, like /workmenu /convoy /pay(When Police Officer asked you for a fine) and more etc.
DerickClark is offline   Reply With Quote
Old 11/07/2018, 06:17 PM   #6
Caessius
Little Clucker
 
Join Date: Jun 2018
Posts: 8
Reputation: 1
Default Re: CMD: Trailer [Not facing the right way]

Because you're getting the player's vehicle ID instead of trailers here @
pawn Code:
new trailerModel = GetVehicleModel(trailerID);
Could you show me how you create the trailer?
Caessius is offline   Reply With Quote
Old 11/07/2018, 06:20 PM   #7
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,763
Reputation: 14
Default Re: CMD: Trailer [Not facing the right way]

Quote:
Originally Posted by Caessius View Post
Because you're getting the player's vehicle ID instead of trailers here @
pawn Code:
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.
__________________
Working on a Trucking Server from scratch.
There are cool features, like /workmenu /convoy /pay(When Police Officer asked you for a fine) and more etc.
DerickClark is offline   Reply With Quote
Old 11/07/2018, 07:02 PM   #8
ItsRobinson
Big Clucker
 
ItsRobinson's Avatar
 
Join Date: Sep 2017
Posts: 72
Reputation: 9
Default Re: CMD: Trailer [Not facing the right way]

Quote:
Originally Posted by DerickClark View Post
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)));
__________________


ItsRobinson is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
False trailer health results when detaching trailer Correlli Bug Reports 2 13/02/2016 11:07 AM


All times are GMT. The time now is 02:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.