SetPlayerObjectRot(playerid, objectid, Float:RotX, Float:RotY, Float:RotZ);
SetObjectRot(objectid, Float:RotX, Float:RotY, Float:RotZ);
new car_weapon[1];
public OnPlayerCommandText(playerid, cmdtext[])
{
new msg[MAX_MSG_SIZE];
if (strcmp("/arm", cmdtext, true, 10) == 0)
{
if (IsPlayerInAnyVehicle(playerid)) {
//car_weapon[0] = CreateObject(18848, 0.0,0.0,0.0, 0.0,0.0,0.0, 500.0);
//AttachObjectToVehicle(car_weapon[0], GetPlayerVehicleID(playerid), 0.0000,-1.5000,-0.5000, 0.0,0.0,0.0);
car_weapon[0] = CreatePlayerObject(playerid, 18848, 0.0,0.0,0.0, 0.0,0.0,0.0, 500.0);
AttachPlayerObjectToVehicle(playerid, car_weapon[0], GetPlayerVehicleID(playerid), 0.0000,-1.5000,-0.5000, 0.0,0.0,0.0);
return 1;
}
}
if (strcmp("/darm", cmdtext, true, 10) == 0)
{
if(IsValidObject(car_weapon[0])) DestroyObject(car_weapon[0]);
else if(IsValidPlayerObject(playerid, car_weapon[0])) DestroyPlayerObject(playerid, car_weapon[0]);
return 1;
}
if (strcmp("/arm180", cmdtext, true, 10) == 0)
{
new Float:rx, Float:ry, Float:rz;
//GetObjectRot(car_weapon[0], rx, ry, rz);
GetPlayerObjectRot(playerid, car_weapon[0], rx, ry, rz);
format(msg, 256, "GetObjRot (%d) xyz: %.1f,%.1f,%.1f", car_weapon[0], rx, ry, rz);
SendClientMessage(playerid, COLOR_DEFAULT, msg);
//SetObjectRot(car_weapon[0], rx, 180.0, rz);
//GetObjectRot(car_weapon[0], rx, ry, rz);
SetPlayerObjectRot(playerid, car_weapon[0], rx, 180.0, rz);
GetPlayerObjectRot(playerid, car_weapon[0], rx, ry, rz);
format(msg, 256, "SetObjRot (%d) set_y 180.0 current_rot xyz: %.1f,%.1f,%.1f", car_weapon[0], rx, ry, rz);
return 1;
}
if (strcmp("/car", cmdtext, true, 10) == 0)
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
new id = CreateVehicle(400+random(212),x,y,z, a, -1,-1, 60);
PutPlayerInVehicle(playerid, id, 0);
return 1;
}
return 0;
}
Works as expected. SetPlayerObjectRot sets the rotation in world space, but you're attaching it to a vehicle. Instead, you need to call AttachPlayerObjectToVehicle again with a different rotation..
|
Destroy - recreate - attach new one or
detach - reattach.. One of these should work but both aren't really smooth.. |