Jump to content

My ped doesn't dance


nick1995

Recommended Posts

This one create a ped when the resource starts

function thePed( name ) 
  local djPed = createPed ( 47, 1984.86975, 1526.91504, 12.82 ) 
  setPedRotation ( djPed, 0 ) 
  setPedAnimation( djPed, "DANCING", "dnce_M_c" ) 
end 
addEventHandler("onResourceStart", root, thePed) 

Link to comment

The problem about peds is that they don't keep animation data when they're streamed out for the client. This is the easiest workaround:

local djPed = createPed (47,1984.86975,1526.91504,12.82) 
setPedRotation (djPed, 0) 
setTimer(setPedAnimation,1000,1,djPed, "DANCING", "dnce_M_c") 

This will apply animation 1 second after the ped has been created. During this time, the ped is likely to be streamed in for the player. But if you go far away, the ped will be streamed out and won't perform the animation when you go back. This is a more reliable way to make him dance:

Server-side script:

local djPed = createPed (47,1984.86975,1526.91504,12.82) 
setPedRotation (djPed, 0) 
setElementID(djPed, "djPed") 

Client-side script:

function initPed() 
    local djPed = getElementByID("djPed") 
    addEventHandler("onClientElementStreamIn", djPed, makePedDance) 
end 
addEventHandler("onClientResourceStart", resourceRoot, initPed) 
  
function makePedDance() 
    setPedAnimation(source, "DANCING", "dnce_M_c") 
end 

The server itself doesn't make the ped dance. Instead, it sets an identifier which the client uses to get the ped element. Then it makes the ped perform animation every time it's streamed in.

Link to comment

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...