Trailer Detect
#1

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

https://sampwiki.blast.hk/wiki/GetVehicleTrailer
Reply
#3

You might also want to use "GetVehiclePos" while at it and the actual trailer model.

PHP код:
CMD:printtrailer(playeridparams[])
{
    new 
string[50], Float:tmpCoords[3], trailerIDvehicleid 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(trailerIDtmpCoords[0], tmpCoords[1], tmpCoords[2]); // get the position of the trailer
    
format(stringsizeof string"CreateVehicle(%d, %f, %f, %f, 0, -1, -1, 6000000);"trailerModeltmpCoords[0], tmpCoords[1], tmpCoords[2]);
    
SendClientMessageToAll(-1string);
    
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.
Reply
#4

Quote:
Originally Posted by Private200
Посмотреть сообщение
You might also want to use "GetVehiclePos" while at it and the actual trailer model.

PHP код:
CMD:printtrailer(playeridparams[])
{
    new 
string[50], Float:tmpCoords[3], trailerIDvehicleid 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(trailerIDtmpCoords[0], tmpCoords[1], tmpCoords[2]); // get the position of the trailer
    
format(stringsizeof string"CreateVehicle(%d, %f, %f, %f, 0, -1, -1, 6000000);"trailerModeltmpCoords[0], tmpCoords[1], tmpCoords[2]);
    
SendClientMessageToAll(-1string);
    
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)