Jump to content

Recommended Posts

Posted (edited)

Client-side:

mp.events.add({
    'entityStreamIn' : (entity) =>  {
        if(entity.type == 'player')
        {
          if (entity.hasVariable("animData")) {
            const value = entity.getVariable("animData");
            if (null != value) {
                const anim = value.split("%");
                loadAnimDict(anim[0], function() {
                    mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(anim[0], anim[1], 1, 0, -1, parseInt(anim[2]), 1, !1, !1, !1)
                })
            }
          }          
        }
    },
});


mp.events.addDataHandler("animData", function(a, b) {
    if (0 !== a.handle)
        if (null != b) {
            const c = b.split("%");
            loadAnimDict(c[0], function() {
                mp.players.exists(a) && 0 !== a.handle && (a.clearTasksImmediately(), a.taskPlayAnim(c[0], c[1], 1, 0, -1, parseInt(c[2]), 1, !1, !1, !1))
            })
        } //else a.clearTasksImmediately()
});

function loadAnimDict(a, b) {
    if (mp.game.streaming.hasAnimDictLoaded(a)) return void b();
    mp.game.streaming.requestAnimDict(a);
    let c = setInterval(function() {
        mp.game.streaming.hasAnimDictLoaded(a) && (clearInterval(c), b())
    }, 100)
}

Server-side:

player.playAnimation(dist, name, speed, flag);
player.setVariable("animData", `${dist}%${name}%${flag}`);

Stop animation:

player.playAnimation("rcmcollect_paperleadinout@","kneeling_arrest_get_up", 1, 33);
player.setVariable("animData", null);

 

Edited by PanaFive
  • Like 4
Posted
Am 14.4.2020 um 13:50 schrieb PanaFive:

Client-side:


mp.events.add({
    'entityStreamIn' : (entity) =>  {
        if(entity.type == 'player')
        {
          if (entity.hasVariable("animData")) {
            const value = entity.getVariable("animData");
            if (null != value) {
                const anim = value.split("%");
                loadAnimDict(anim[0], function() {
                    mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(anim[0], anim[1], 1, 0, -1, parseInt(anim[2]), 1, !1, !1, !1)
                })
            }
          }          
        }
    },
});


mp.events.addDataHandler("animData", function(a, b) {
    if (0 !== a.handle)
        if (null != b) {
            const c = b.split("%");
            loadAnimDict(c[0], function() {
                mp.players.exists(a) && 0 !== a.handle && (a.clearTasksImmediately(), a.taskPlayAnim(c[0], c[1], 1, 0, -1, parseInt(c[2]), 1, !1, !1, !1))
            })
        } //else a.clearTasksImmediately()
});

function loadAnimDict(a, b) {
    if (mp.game.streaming.hasAnimDictLoaded(a)) return void b();
    mp.game.streaming.requestAnimDict(a);
    let c = setInterval(function() {
        mp.game.streaming.hasAnimDictLoaded(a) && (clearInterval(c), b())
    }, 100)
}

Server-side:


player.playAnimation(dist, name, speed, flag);
player.setVariable("animData", `${dist}%${name}%${flag}`);

Stop animation:

player.playAnimation("rcmcollect_paperleadinout@","kneeling_arrest_get_up", 1, 33);
player.setVariable("animData", null);

 

where do I have to put the server-side in my script where it will be played or in a single script?

 

  • 7 months later...
Posted
В 14.04.2020 в 14:50, PanaFive сказал:

Client-side:


mp.events.add({
    'entityStreamIn' : (entity) =>  {
        if(entity.type == 'player')
        {
          if (entity.hasVariable("animData")) {
            const value = entity.getVariable("animData");
            if (null != value) {
                const anim = value.split("%");
                loadAnimDict(anim[0], function() {
                    mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(anim[0], anim[1], 1, 0, -1, parseInt(anim[2]), 1, !1, !1, !1)
                })
            }
          }          
        }
    },
});


mp.events.addDataHandler("animData", function(a, b) {
    if (0 !== a.handle)
        if (null != b) {
            const c = b.split("%");
            loadAnimDict(c[0], function() {
                mp.players.exists(a) && 0 !== a.handle && (a.clearTasksImmediately(), a.taskPlayAnim(c[0], c[1], 1, 0, -1, parseInt(c[2]), 1, !1, !1, !1))
            })
        } //else a.clearTasksImmediately()
});

function loadAnimDict(a, b) {
    if (mp.game.streaming.hasAnimDictLoaded(a)) return void b();
    mp.game.streaming.requestAnimDict(a);
    let c = setInterval(function() {
        mp.game.streaming.hasAnimDictLoaded(a) && (clearInterval(c), b())
    }, 100)
}

Server-side:


player.playAnimation(dist, name, speed, flag);
player.setVariable("animData", `${dist}%${name}%${flag}`);

Stop animation:

player.playAnimation("rcmcollect_paperleadinout@","kneeling_arrest_get_up", 1, 33);
player.setVariable("animData", null);

 

Thank you so much bro

  • 2 years later...
Posted

Since last ragemp update you need to change the code from PanaFive a little bit. 

 

On clientside use this dataHandler instead of PanaFive Datahandler:

 

 mp.events.addDataHandler('animData', (a, b) => {
        if (0 === a.handle) return;
        if (!b) {
            a.clearTasksImmediately();
            return;
        }
        const c = b.split('%');
        loadAnimDict(c[0], function () {
            if (mp.players.exists(a) && (0 !== a.handle)) {
                a.clearTasksImmediately();
                a.taskPlayAnim(
                    c[0], c[1],
                    1, 0, -1,
                    parseInt(c[2]),
                    1, !1, !1, !1,
                );
            }
        });
    });

 

Since xday wrote on discord that he will look into it, its possible that PanaFives Version is working tomorrow again.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...