Jump to content

help me to write server side script to this


sandun

Recommended Posts


local isLocalPlayerAnimating = false

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        triggerServerEvent ( "onCustomAnimationSyncRequest", resourceRoot, localPlayer )
    end

local function ReplacePedBlockAnimations ( player, ifpIndex )
    local customIfpBlockName = globalLoadedIfps [ ifpIndex ].blockName
    for _, animationName in pairs ( globalPedAnimationBlock.animations ) do 
        -- make sure that we don't replace a partial animation
        if not globalPedAnimationBlock.partialAnimations [ animationName ] then 
            engineReplaceAnimation ( player, "ped", animationName, customIfpBlockName, animationName )
        end
    end
end 

local frnP3IFP = engineLoadIFP("bd_fire.ifp","bdfire")
local parkourIFP = engineLoadIFP("parkour.ifp","parkourAnims")
local dancingIFP = engineLoadIFP("dancing.ifp","dancing")
local pedIFP = engineLoadIFP("ped.ifp","biganim")

bindKey("num_2","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "biganim", "dance6" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "biganim", "dance6" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_3","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "dancing", "dance3" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "dancing", "dance3" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_4","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "dancing", "dance4" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "dancing", "dance4" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_5","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "dancing", "dance5" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "dancing", "dance5" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_6","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "bdfire", "dance1" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "bdfire", "dance1" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_7","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "parkourAnims", "BckHndSpingBTuck" )
        if not isTimer(resetAnim6) then
        resetAnim6 = setTimer(setPedAnimation,3530,1,localPlayer,false)
        end
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "parkourAnims", "BckHndSpingBTuck" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_8","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "bdfire", "dance2" )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "bdfire", "dance2" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

--[[bindKey("num_8","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "parkourAnims", "BckHndSping" )
        if not isTimer(resetAnim7) then
        setTimer(setPedAnimation,3400,1,localPlayer,false)
        end
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "parkourAnims", "BckHndSping" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_9","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "parkourAnims", "CartWheel" )
        if not isTimer(resetAnim8) then
        setTimer(setPedAnimation,2930,1,localPlayer,false)
        end
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "parkourAnims", "CartWheel" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("num_div","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "parkourAnims", "FrntHndSpring" )
        if not isTimer(resetAnim9) then
        setTimer(setPedAnimation,2860,1,localPlayer,false)
        end
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "parkourAnims", "FrntHndSpring" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)

bindKey("nam_mul","down",
function ()
    if isLocalPlayerAnimating == false then
        setPedAnimation ( localPlayer, "parkourAnims", "HandPlant" )
        if not isTimer(resetAnim9) then
        setTimer(setPedAnimation,3600,1,localPlayer,false)
        end
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, "parkourAnims", "HandPlant" )
        isLocalPlayerAnimating = true
    elseif isLocalPlayerAnimating == true then
        setPedAnimation ( localPlayer, false )
        triggerServerEvent ( "onCustomAnimationSet", resourceRoot, localPlayer, false, false )
    end
end
)]]--

addEvent ("onClientCustomAnimationSyncRequest", true )
addEventHandler ("onClientCustomAnimationSyncRequest", root,
    function ( playerAnimations )
        for player, anims in pairs ( playerAnimations ) do 
            if isElement ( player ) then 
                if anims.current then 
                    setPedAnimation ( player, anims.current[1], anims.current[2] ) 
                end
                if anims.replacedPedBlock then 
                    ReplacePedBlockAnimations ( player, anims.replacedPedBlock )
                end
            end
        end 
    end 
)

addEvent ("onClientCustomAnimationSet", true )
addEventHandler ("onClientCustomAnimationSet", root,
    function ( blockName, animationName )
        if source == localPlayer then return end
        if blockName == false then 
            setPedAnimation ( source, false )
            return
        end 
        setPedAnimation ( source, blockName, animationName )
    end 
)

setTimer ( 
    function ()
        if isLocalPlayerAnimating then 
            if not getPedAnimation (localPlayer) then
                isLocalPlayerAnimating = false
                triggerServerEvent ( "onCustomAnimationStop", resourceRoot, localPlayer )
            end
        end
    end, 100, 0
)

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