VehiculosInfo[vehicleid][cObjetoToy][0] = modelid;
VehiculosInfo[vehicleid][cObjetoToy][0] = CreateDynamicObject(VehiculosInfo[vehicleid][cToy][0], x,y,z,0.0,0.0,0.0, 0, 0);
ObjetoGuardar[playerid] = 11;
IDObjetoGuardar[playerid] = 0;
EditDynamicObject(playerid, VehiculosInfo[vehicleid][cObjetoToy][0]);
new vehicleid = GetPlayerVehicleID(playerid);
VehiculosInfo[vehicleid][cPosToy][0] = x;
VehiculosInfo[vehicleid][cPosToy][1] = y;
VehiculosInfo[vehicleid][cPosToy][2] = z;
VehiculosInfo[vehicleid][cPosToy][3] = rx;
VehiculosInfo[vehicleid][cPosToy][4] = ry;
VehiculosInfo[vehicleid][cPosToy][5] = rz;
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
DestroyDynamicObject(VehiculosInfo[vehicleid][cObjetoToy][IDObjetoGuardar[playerid]]);
VehiculosInfo[vehicleid][cObjetoToy][IDObjetoGuardar[playerid]] = CreateDynamicObject(VehiculosInfo[vehicleid][cToy][IDObjetoGuardar[playerid]], VehiculosInfo[vehicleid][cPosToy][0], VehiculosInfo[vehicleid][cPosToy][1], VehiculosInfo[vehicleid][cPosToy][2], VehiculosInfo[vehicleid][cPosToy][3], VehiculosInfo[vehicleid][cPosToy][4], VehiculosInfo[vehicleid][cPosToy][5], 0, 0);
AttachDynamicObjectToVehicle(VehiculosInfo[vehicleid][cObjetoToy][IDObjetoGuardar[playerid]], vehicleid, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
new Float
![]() ![]() ![]() ![]() Float:finalx, Float:finaly, Float ![]() ![]() ![]() GetVehiclePos(vehicle, px, py, pz); GetVehicleZAngle(vehicle, roz); ofx = x-px; ofy = y-py; ofz = z-pz; ofaz = rz-roz; finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees); finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees); use CreatePlayerObject or CreateObject when you click finish then execute these codes and attachobjecttovehicle |
new Float:ofx, Float:ofy, Float:ofz, Float:ofaz,Float:finalx, Float:finaly, Float:px, Float:py, Float:pz, Float:roz;
GetVehiclePos(vehicleid, px, py, pz);
GetVehicleZAngle(vehicleid, roz);
ofx = x-px;
ofy = y-py;
ofz = z-pz;
ofaz = rz-roz;
finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees);
finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees);
AttachDynamicObjectToVehicle(VehiculosInfo[vehicleid][cObjetoToy][IDObjetoGuardar[playerid]], vehicleid, ofx, ofy, ofz, ofaz, finalx, finaly);
else if(response == EDIT_RESPONSE_UPDATE) { new Float:tmpx, Float:tmpy, Float:tmpz; new refindex = GetCarObjectRefIndex(ObjectData[CurrObject[playerid]][oAttachedVehicle], CurrObject[playerid]); tmpx = x - AVEditPos[playerid][0]; tmpy = y - AVEditPos[playerid][1]; tmpz = z - AVEditPos[playerid][2]; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][COX][refindex] = tmpx; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][COY][refindex] = tmpy; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][COZ][refindex] = tmpz; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][CORX][refindex] = rx; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][CORY][refindex] = ry; CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][CORZ][refindex] = rz; SetVehicleZAngle(CarData[ObjectData[CurrObject[playerid]][oAttachedVehicle]][CarID], 0.0); UpdateAttachedVehicleObject(ObjectData[CurrObject[playerid]][oAttachedVehicle], refindex, VEHICLE_ATTACH_UPDATE); }
UpdateAttachedVehicleObject(carindex, refindex, type) { if(type == VEHICLE_ATTACH_UPDATE) { Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_OFFSET_X, CarData[carindex][COX][refindex]); Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_OFFSET_Y, CarData[carindex][COY][refindex]); Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_OFFSET_Z, CarData[carindex][COZ][refindex]); Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_R_X, CarData[carindex][CORX][refindex]); Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_R_Y, CarData[carindex][CORY][refindex]); Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], E_STREAMER_ATTACH_R_Z, CarData[carindex][CORZ][refindex]); } else if(type == VEHICLE_REATTACH_UPDATE) { refindex = GetCarObjectRefIndex(carindex, refindex); AttachDynamicObjectToVehicle(ObjectData[CarData[carindex][CarObjectRef][refindex]][oID], CarData[carindex][CarID], CarData[carindex][COX][refindex], CarData[carindex][COY][refindex], CarData[carindex][COZ][refindex], CarData[carindex][CORX][refindex], CarData[carindex][CORY][refindex], CarData[carindex][CORZ][refindex] ); } UpdateObject3DText(CarData[carindex][CarObjectRef][refindex], false); return 1; }
This is never going to work right you need to do a number of things to do this correctly.
|
tmpx = x - AVEditPos[playerid][0]; tmpy = y - AVEditPos[playerid][1]; tmpz = z - AVEditPos[playerid][2];