Jump to content

[HELP]I want to stop player animation


BenceDev

Recommended Posts

Hi everyone!

I'm making a medic system that can revive another player.

So i want to stop the player animation.

I saw on wiki and forum the solution setPedAnimation(source) then i used it but the animation is not stopped and i got a error.

Debugscript 3:
WARNING: [Core]\cz_injury\revive.lua:57: Bad argument @ 'setPedAnimation' [Expected element at argument 1, got nil]


This is my revive.lua (server sided):
 

function reviveFunction()
    if (getElementData(testped, "playerDown") == true) then
        local thePlayerElem = getElementType(source)
        if(thePlayerElem == "player") then
            setPedAnimation(source, "bomber", "bom_plant_loop", -1, true, false, true, false, 150)
            setTimer(function()
                setPedAnimation(testped)
                setElementHealth(testped, 50)
                setPedAnimation(player) -- this is what stop the player animation
            end, 10000, 1)
        end
    end
end
addEvent("startRevive",true)
addEventHandler("startRevive", getRootElement(), reviveFunction)


Thanks for all reply! :)

Link to comment

hello welcome to the forum i checked your code and made some changes, you didn't edit the timer to source,you can test.

function reviveFunction()
    if (getElementData(testped, "playerDown") == true) then
        local thePlayerElem = getElementType(source)
        if(thePlayerElem == "player") then
            setPedAnimation(source, "bomber", "bom_plant_loop", -1, true, false, true, false, 150)
            setTimer(function(source)
                setPedAnimation(testped)
                setElementHealth(testped, 50)
                setPedAnimation(source)
            end, 10000, 1, source) -- pass source to timer
        end
    end
end
addEvent("startRevive",true)
addEventHandler("startRevive", getRootElement(), reviveFunction)

have a nice day.

  • Like 1
Link to comment
3 minutes ago, Shady1 said:

hello welcome to the forum i checked your code and made some changes, you didn't edit the timer to source,you can test.

function reviveFunction()
    if (getElementData(testped, "playerDown") == true) then
        local thePlayerElem = getElementType(source)
        if(thePlayerElem == "player") then
            setPedAnimation(source, "bomber", "bom_plant_loop", -1, true, false, true, false, 150)
            setTimer(function(source)
                setPedAnimation(testped)
                setElementHealth(testped, 50)
                setPedAnimation(source)
            end, 10000, 1, source) -- pass source to timer
        end
    end
end
addEvent("startRevive",true)
addEventHandler("startRevive", getRootElement(), reviveFunction)

have a nice day.

Thank you for the reply.
Your change is working good.

Thanks for the help!
@Shady1

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