Jump to content

[HELP] Not triggering server side event


..:D&G:..

Recommended Posts

Hello guys, I am trying to sync the player's animation from client side to server side, but the event is not triggered...

--Client

function startMiningSpot(hitPlayer) 
    if (hitPlayer == getLocalPlayer()) and (source == miningSpot) then 
        triggerServerEvent("syncMiningAnim", resourceRoot, hitPlayer, source) 
        outputChatBox("Message shows!") 
    end 
end 
addEventHandler( "onClientMarkerHit", getRootElement(), startMiningSpot) 

--Server

function syncMining(hitElement, marker) 
    exports.global:applyAnimation(hitElement, "chainsaw", "CSAW_1", -1, true, false, false) 
    setElementPosition(hitElement, getElementPosition(miningSpot)) 
    setPedRotation(hitElement, getElementData(miningSpot, "msRotation")) 
    outputChatBox("Don't show", hitElement) 
end 
addEvent("syncMiningAnim", true) 
addEventHandler("syncMiningAnim", getRootElement(), syncMining) 

I know it's kinda late for scripting but maybe I missed something? Because the message from server side doesn't show and the function doesn't give any errors... Maybe I'm too tired? xD

Thanks.

Link to comment

Try this

function startMiningSpot(hitPlayer) 
    if (hitPlayer == getLocalPlayer()) then 
        triggerServerEvent("syncMiningAnim", hitPlayer, source) 
    end 
end 
addEventHandler( "onClientMarkerHit", miningSpot, startMiningSpot) 

function syncMining(marker) 
    exports.global:applyAnimation(client, "chainsaw", "CSAW_1", -1, true, false, false) 
    setElementPosition(client, getElementPosition(marker)) 
    setPedRotation(client, getElementData(marker, "msRotation")) 
    outputChatBox("Don't show", client) 
end 
addEvent("syncMiningAnim", true) 
addEventHandler("syncMiningAnim", getRootElement(), syncMining) 

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