nick1995 Posted August 20, 2012 Share Posted August 20, 2012 What is wrong with this code: local djPed = createPed (47,1984.86975,1526.91504,12.82) setPedRotation (djPed, 0) setPedAnimation(djPed, "DANCING", "dnce_M_c") Link to comment
Lloyd Logan Posted August 20, 2012 Share Posted August 20, 2012 function newPed (name) createPed (47,1984.86975,1526.91504,12.82) setPedRotation (djPed, 0) setPedAnimation(djPed, "DANCING", "dnce_M_c") end Try that, pal Link to comment
nick1995 Posted August 20, 2012 Author Share Posted August 20, 2012 Thanks for your reaction. If i do that, the ped doesn't show up Link to comment
Vision Posted August 20, 2012 Share Posted August 20, 2012 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
DiSaMe Posted August 20, 2012 Share Posted August 20, 2012 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
nick1995 Posted August 21, 2012 Author Share Posted August 21, 2012 Now i have one ped frozen and one ped dancing? The peds are together. Link to comment
DiSaMe Posted August 21, 2012 Share Posted August 21, 2012 Did you read and try to understand my post or did you copy and paste the code? Link to comment
nick1995 Posted August 21, 2012 Author Share Posted August 21, 2012 Yeah but i don't understand it good... I think you mean, if you go away and come back, the ped is not dancing anymore and there is a new ped. Link to comment
DiSaMe Posted August 21, 2012 Share Posted August 21, 2012 Did you read the code and try to understand what exactly it does? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now