Trailer Detect - 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: Trailer Detect (
/showthread.php?tid=655473)
Trailer Detect -
DerickClark - 22.06.2018
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;
}
Re: Trailer Detect -
Exhibit - 22.06.2018
https://sampwiki.blast.hk/wiki/GetVehicleTrailer
Re: Trailer Detect -
Private200 - 22.06.2018
You might also want to use "GetVehiclePos" while at it and the actual trailer model.
PHP код:
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.
Re: Trailer Detect -
DerickClark - 23.06.2018
Quote:
Originally Posted by Private200
You might also want to use "GetVehiclePos" while at it and the actual trailer model.
PHP код:
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.