altmp / altv-issues

Issues and roadmap for alt:V project
92 stars 17 forks source link

Object .rot sync issue server-side #2251

Open dGxxxx opened 4 months ago

dGxxxx commented 4 months ago

Description of the problem

I don't know what exactly is wrong with the sync of the server-side rotation of the object. The rotation is only synced for the netOwner of the object.

https://streamable.com/ur0y69 https://streamable.com/ug1nuk

Reproduction steps

import * as alt from 'alt-server';
alt.on('playerConnect', handlePlayerConnect);

function degreesToRadians(degrees: number): number {
    // Normalize degrees within the range [0, 360)
    degrees = (degrees % 360 + 360) % 360;

    // Convert degrees to radians
    let radians = degrees * (Math.PI / 180);

    // Convert radians to the range [-π, π)
    if (radians > Math.PI) {
        radians -= 2 * Math.PI;
    }

    return radians;
}

function getRandomInt(min: number, max: number) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
};

function handlePlayerConnect(player: alt.Player) {
    player.model = 'mp_m_freemode_01'
    player.spawn(38.19486618041992, 859.3850708007812, 197.71343994140625, 0);
}

setTimeout(() => {
    let slotHeading = -1.8915420770645142;

    let a = new alt.Object('vw_prop_casino_slot_02a_reels', new alt.Vector3(36.19486618041992, 859.3850708007812, 197.71343994140625), new alt.Vector3(0, 0, slotHeading));
    a.collision =true;
    a.visible = true;

    alt.log(a.rot)
    a.frozen = true;

    alt.setTimeout(async () => {
        let tempRot1 = a.rot;
        let tempRot2 = a.rot;
        let tempRot3 = a.rot;

        alt.log(tempRot1.z);

        for (let i = 1; i <= 300; i++) {
            if (i < 180) {
                let rand = 0 + degreesToRadians(getRandomInt(0, 360))
                a.rot = new alt.Vector3(rand, tempRot1.y, tempRot1.z);
            }; 

            await alt.Utils.wait(10);
        };

        alt.log(a.rot);
    }, 5000)
}, 10000);

Expected behaviour

The rotation should be synced.

Additional context

No response

Operating system

Windows

Version

release & latest dev (16.0.0-dev.283)

Crashdump ID

No response

Confirmation of issue's presence

dGxxxx commented 4 months ago

Updated the issue with videos.