PDA

View Full Version : Trailer Detect


DerickClark
22/06/2018, 03:20 AM
How can i detect a trailer? when attach. /printtrailer and get x,y,z while attach.

CMD:printveh(playerid, params[])
{
new string[50];
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string, sizeof(string), "CreateVehicle(vehicleid,%f,%f,%f,0,-1, -1, 6000000);", x, y, z);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid,-1,"Saved");
return 1;
}

Exhibit
22/06/2018, 12:14 PM
http://wiki.sa-mp.com/wiki/GetVehicleTrailer

Private200
22/06/2018, 01:12 PM
You might also want to use "GetVehiclePos" while at it and the actual trailer model.

CMD:printtrailer(playerid, params[])
{
new string[50], Float:tmpCoords[3], trailerID, vehicleid = GetPlayerVehicleID(playerid); // get the id of the vehicle the player is driving
trailerID = GetVehicleTrailer(vehicleid); // get the ID of the trailer attached to the current vehicle
new trailerModel = GetVehicleModel(trailerID); // get the model of the trailer
GetVehiclePos(trailerID, tmpCoords[0], tmpCoords[1], tmpCoords[2]); // get the position of the trailer
format(string, sizeof string, "CreateVehicle(%d, %f, %f, %f, 0, -1, -1, 6000000);", trailerModel, tmpCoords[0], tmpCoords[1], tmpCoords[2]);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid,-1,"Saved");
return 1;
}

This is fully converted to work with trailers only, thus I renamed it to "printtrailer".

EDIT: I think the trailer position is not fully synced in-game; not sure but worth a try. Someone correct me on this.

DerickClark
23/06/2018, 05:08 AM
You might also want to use "GetVehiclePos" while at it and the actual trailer model.

CMD:printtrailer(playerid, params[])
{
new string[50], Float:tmpCoords[3], trailerID, vehicleid = GetPlayerVehicleID(playerid); // get the id of the vehicle the player is driving
trailerID = GetVehicleTrailer(vehicleid); // get the ID of the trailer attached to the current vehicle
new trailerModel = GetVehicleModel(trailerID); // get the model of the trailer
GetVehiclePos(trailerID, tmpCoords[0], tmpCoords[1], tmpCoords[2]); // get the position of the trailer
format(string, sizeof string, "CreateVehicle(%d, %f, %f, %f, 0, -1, -1, 6000000);", trailerModel, tmpCoords[0], tmpCoords[1], tmpCoords[2]);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid,-1,"Saved");
return 1;
}

This is fully converted to work with trailers only, thus I renamed it to "printtrailer".

EDIT: I think the trailer position is not fully synced in-game; not sure but worth a try. Someone correct me on this.

Thank you. it worked.