Code: CMD:objekkendaraan(playerid, params[])
{
//SetPlayerArmour(playerid, Float:70.1);
//pakaiarmour[playerid] = 1; // kondisi sedang pakai armour
//SetPlayerAttachedObject(playerid, 3, 19515, 1 , 0.096999,0.058999,0.012999,4.199995,0.999981,8.800023,1.000000,1.221000,0.797000, 0xFFFFA500, 0xFFFFA500);
//EditAttachedObject(playerid, 3);
//contohdikendaraan = CreateDynamicObject(18649, 0,0,0,0,0,0);
//CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1, priority = 0)
//CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD, STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1, priority = 0)
contohdikendaraan = CreateDynamicObject(18649, Float:0.0, Float:0.0, Float:0.0, Float:0.0, Float:0.0, Float:0.0, 0, 0, -1, Float:20.0,Float:20.0, -1, 0);
SendClientMessage(playerid, COLOR_GREEN, "Anda pasang neon hijau.");
//SetDynamicObjectMaterialText(tmpobjid, 0, "Pesawat Putu", 130, "Arial", 70, 1, 0xFFFFFFFF, 0x00000000, 1);
//SetDynamicObjectMaterialText(STREAMER_TAG_OBJECT contohdikendaraan, 0, "Solusi", 130, "Arial", 70, 1,? 0xFFFFFFFF, 0, 1);
//AttachObjectToVehicle(objectid, vehicleid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:RotX, Float:RotY, Float:RotZ)
pInfo[playerid][pNeon] = AttachDynamicObjectToVehicle( contohdikendaraan, GetPlayerVehicleID(playerid));
? /*
? Float:0.0, // kanan kiri
? Float:-2.0, // kedepan
? ? Float:0.0, // ke atas
? ? Float:2.0, Float:0.0, Float:0.0);
? */
//AttachDynamicObjectToVehicle(STREAMER_TAG_OBJECT objectid, vehicleid, Float:offsetx, Float:offsety, Float:offsetz, Float:rx, Float:ry, Float:rz)
//EditPlayerObject(playerid, objectid);
//RemovePlayerFromVehicle(playerid);
//EditAttachedObject(playerid, idterttach);
//EditObject(playerid, contohdikendaraan);
//contohdikendaraan = false;
? //Streamer_SetIntData(STREAMER_TYPE_OBJECT, contohdikendaraan, E_STREAMER_ATTACHED_VEHICLE, 2);
//Streamer_SetFloatData(
? //SetDynamicObjectMaterial(contohdikendaraan, 0, 10765, "airportgnd_sfse", "white", -256);
EditDynamicObject(playerid, contohdikendaraan);
? Streamer_Update(playerid);
//EditDynamicObject(playerid, pInfo[playerid][pNeon]);
//EditAttachedObject(playerid, contohdikendaraan);
return 1;
}
You need to explain more about what you want to do.
Sorry sir. If i eddit my function, what need to add more for editing dynamic object attached to vehicle?
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);
{
//SendClientMessage(playerid, COLOR_RED, "Anda Sedang Mengedit DynamicObject.");
if(response == EDIT_RESPONSE_UPDATE)
{
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
//SendClientMessage(playerid, COLOR_RED, "Anda Sedang Update DynamicObject.");
}
else if(response == EDIT_RESPONSE_CANCEL)
{
SendClientMessage(playerid, COLOR_RED, "Sir you have Cancel editing the DynamicObject.");
}
else if(response == EDIT_RESPONSE_FINAL)
{
SetDynamicObjectPos(objectid, x, y, z);
SetDynamicObjectRot(objectid, rx, ry, rz);
SendClientMessage(playerid, COLOR_RED, "Sir you succes edited DynamicObject.");
new lokasidynamicobject[500];
format(lokasidynamicobject, sizeof(lokasidynamicobject),
"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, lokasidynamicobject);
SelectObject(playerid);
}
return 1;
}
I have a bug if the object selected and edited than that dynamic object cant to move, just stucking with his float.
2021-04-17, 07:39 PM
(This post was last modified: 2021-04-17, 07:41 PM by Radical.)
An example how to attach a object to vehicle correctly :
Code: new inEditingMode[MAX_PLAYERS];
CMD:test(playerid, params[])
{
if (inEditingMode[playerid] || !IsPlayerInAnyVehicle(playerid))
return 1;
new objectid, Float:VehPos[3];
GetVehiclePos(GetPlayerVehicleID(playerid), VehPos[0], VehPos[1], VehPos[2]);
objectid = CreateDynamicObject(11701, VehPos[0], VehPos[1], VehPos[2], 0, 0, 0);
EditDynamicObject(playerid, objectid);
inEditingMode[playerid] = 1;
return 1;
}
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
if(response == EDIT_RESPONSE_UPDATE)
{
return 1;
}
if(response == EDIT_RESPONSE_FINAL && inEditingMode[playerid])
{
inEditingMode[playerid] = 0;
if (!IsPlayerInAnyVehicle(playerid))
return 0;
new Float:ofx, Float:ofy, Float:ofz;
new Float:ofaz, Float:finalx, Float:finaly;
new Float:px, Float:py, Float:pz, Float:roz;
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, 0x58ACFAFF, "The object attached to your vehicle.");
AttachDynamicObjectToVehicle(objectid, GetPlayerVehicleID(playerid), finalx, finaly, ofz, rx, ry, ofaz);
}
return 1;
}
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
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;
}
Sorry, Sir. do you know how to select which object type is attached or not to vehicle? Because if you edit an attached dynamic object, the position cannot be edited again, sir?
|