2021-04-18, 06:04 PM
Sir im sorry i have problem if user selecting again the dynamic attached object. But how to fix the position stuck again?
On this script the object attached on vehicle will get stuck position
On this script the object attached on vehicle will get stuck position
Code:
public OnPlayerEditDynamicObject(playerid, STREAMER_TAG_OBJECT:objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
//public OnPlayerEditDynamicObject(playerid, STREAMER_TAG_OBJECT:objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
{
new Float:ofx, Float:ofy, Float:ofz;
new Float:ofaz, Float:finalx, Float:finaly;
new Float:px, Float:py, Float:pz, Float:roz;
new closestcar = GetClosestCar(playerid, INVALID_VEHICLE_ID);
//SendClientMessage(playerid, COLOR_RED, "Anda Sedang Mengedit DynamicObject.");
if(response == EDIT_RESPONSE_UPDATE && inEditingMode[playerid] == 1)
{
GetVehiclePos(closestcar, px, py, pz);
GetVehicleZAngle(closestcar, roz);
ofx = x-px;
ofy = y-py;
ofz = z-pz;
ofaz = rz-roz;
finalx = ofx*floatcos(roz, degrees)ꇼ*floatsin(roz, degrees);
finaly = -ofx*floatsin(roz, degrees)ꇼ*floatcos(roz, degrees);
SetDynamicObjectPos(objectid, finalx, finaly, ofz);
SetDynamicObjectRot(objectid, rx, ry, ofaz);
SendClientMessage(playerid, COLOR_RED, "Sir you have try to edit the dynamic object Position or Rotation now response updated.");
return 1;
}
if(response == EDIT_RESPONSE_UPDATE && inEditingMode[playerid] == 0)
{
SendClientMessage(playerid, COLOR_RED, "Sir you have try to edit but not on editing attached dynamic object Position or Rotation now response updated.");
return 1;
}
else if(response == EDIT_RESPONSE_CANCEL)
{
SendClientMessage(playerid, COLOR_RED, "Sir you have Cancel editing the DynamicObject.");
}
else if(response == EDIT_RESPONSE_FINAL && inEditingMode[playerid] == 1)
{
inEditingMode[playerid] = 0;
if (!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_RED, "Sir you need get in vehicle to edit the attached object");
GetVehiclePos(GetPlayerVehicleID(playerid), px, py, pz);
GetVehicleZAngle(GetPlayerVehicleID(playerid), roz);
ofx = x-px;
ofy = y-py;
ofz = z-pz;
ofaz = rz-roz;
finalx = ofx*floatcos(roz, degrees)ꇼ*floatsin(roz, degrees);
finaly = -ofx*floatsin(roz, degrees)ꇼ*floatcos(roz, degrees);
SendClientMessage(playerid, COLOR_RED, "Sir you succes edited DynamicObject on attached.");
AttachDynamicObjectToVehicle(objectid, closestcar, finalx, finaly, ofz, rx, ry, ofaz);
//SetDynamicObjectPos(objectid, x, y, z);
//SetDynamicObjectRot(objectid, rx, ry, rz);
new DynamicObjectInformation[500];
format(DynamicObjectInformation, sizeof(DynamicObjectInformation),
"ID Dynamic Object in gamemode %i, Coordinat: %f, %f, %f, Rotating in: %f, %f, %f)",
objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
SendClientMessage(playerid, COLOR_RED, DynamicObjectInformation);
SelectObject(playerid);
return 1;
//SelectObject(playerid);
}
else if(response == EDIT_RESPONSE_FINAL && inEditingMode[playerid] == 0)
{
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
SendClientMessage(playerid, COLOR_RED, "Sir you succes edited Non Attached DynamicObject.");
new DynamicObjectInformation[500];
format(DynamicObjectInformation, sizeof(DynamicObjectInformation),
"ID Dynamic Object in gamemode %i, Coordinat: %f, %f, %f, Rotating in: %f, %f, %f)",
objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
SendClientMessage(playerid, COLOR_RED, DynamicObjectInformation);
inEditingMode[playerid] = 1;
SelectObject(playerid);
return 1;
}
return 1;
}