SetObjectRot, etc.. does not work
#1

Bug: Functions
PHP код:
SetPlayerObjectRot(playeridobjectidFloat:RotXFloat:RotYFloat:RotZ); 
SetObjectRot(objectidFloat:RotXFloat:RotYFloat:RotZ); 
Action: No effect. As the team breaks in the call.

My script:
PHP код:
new car_weapon[1];
public 
OnPlayerCommandText(playeridcmdtext[])
{
    new 
msg[MAX_MSG_SIZE];
if (
strcmp("/arm"cmdtexttrue10) == 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(playerid188480.0,0.0,0.00.0,0.0,0.0500.0);
              
AttachPlayerObjectToVehicle(playeridcar_weapon[0], GetPlayerVehicleID(playerid), 0.0000,-1.5000,-0.50000.0,0.0,0.0);
            return 
1;
        }
    }
    if (
strcmp("/darm"cmdtexttrue10) == 0)
    {
        if(
IsValidObject(car_weapon[0])) DestroyObject(car_weapon[0]);
        else if(
IsValidPlayerObject(playeridcar_weapon[0])) DestroyPlayerObject(playeridcar_weapon[0]);
        return 
1;
    }
    if (
strcmp("/arm180"cmdtexttrue10) == 0)
    {
        new 
Float:rxFloat:ryFloat:rz;
        
//GetObjectRot(car_weapon[0], rx, ry, rz);
        
GetPlayerObjectRot(playeridcar_weapon[0], rxryrz);
        
        
format(msg256"GetObjRot (%d) xyz: %.1f,%.1f,%.1f"car_weapon[0], rxryrz);
        
SendClientMessage(playeridCOLOR_DEFAULTmsg);
        
        
//SetObjectRot(car_weapon[0], rx, 180.0, rz);
        //GetObjectRot(car_weapon[0], rx, ry, rz);
        
        
SetPlayerObjectRot(playeridcar_weapon[0], rx180.0rz);
        
GetPlayerObjectRot(playeridcar_weapon[0], rxryrz);
        
format(msg256"SetObjRot (%d) set_y 180.0 current_rot xyz: %.1f,%.1f,%.1f"car_weapon[0], rxryrz);
        return 
1;
    }
    if (
strcmp("/car"cmdtexttrue10) == 0)
    {
        new 
Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridx,y,z);
        
GetPlayerFacingAngle(playerida);
          new 
id CreateVehicle(400+random(212),x,y,za, -1,-160);
          
PutPlayerInVehicle(playeridid0);
        return 
1;
    }
        return 
0;

Reply
#2

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..
Reply
#3

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
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..
Thanks for answer.

Yes, I already knew that. But for some reason I have flashes model if ever to call AttachPlayerObjectToVehicle and client crashes.

How smoothly rotate the turret?
Reply
#4

Destroy - recreate - attach new one or
detach - reattach..
One of these should work but both aren't really smooth..
Reply
#5

Quote:
Originally Posted by NaS
Посмотреть сообщение
Destroy - recreate - attach new one or
detach - reattach..
One of these should work but both aren't really smooth..
Destroying and creation of updating - it is a bad method. But it is also checked.

I have found one method. Used connection: Object attached to + Object and is attached to + Vehicle
first object stops flashed

To turn have to use attaching.. Thanks @ikkentim
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)