joao2235

Help Me! [Error Script]

Recommended Posts

local animEnable = {}
local syncPlayers = {}

addCommandHandler("continencia",
	function(player)
		if ( getElementType ( player ) == "anim" ) then
        if ( not isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "VIP" ) ) ) then
		if (not animEnable[player]) then
			animEnable[player] = true
			triggerClientEvent(syncPlayers, "anim", player, true)
			outputChatBox("*Continência #00FF00ativada", player, 255, 255, 255, true)
		else
			animEnable[player] = false
			triggerClientEvent(syncPlayers, "anim", player, false)
			outputChatBox("*Continência #FF0000desativada", player, 255, 255, 255, true)
		end
	end
)

addEvent("onClientSync", true )
addEventHandler("onClientSync", resourceRoot,
    function()
        table.insert(syncPlayers, client)
		for player, enable in ipairs(animEnable) do
			if (enable) then
				triggerClientEvent(client, "anim", player, true)
			end
		end
    end 
)

addEventHandler("onPlayerQuit", root,
    function()
        for i, player in ipairs(syncPlayers) do
            if source == player then 
                table.remove(syncPlayers, i)
                break
            end 
        end
        if (animEnable[source] == true or animEnable[source] == false) then animEnable[source] = nil end
    end
)

I need to restrict this at "VIP" ACL. But it does not work. Someone can help me, pls. Thanks.

Submit error:

Client (Username Player) triggered serverside event onClientSync, but event is not added serverside.


 

Share this post


Link to post

Line 21 replace resourceRoot with root

Share this post


Link to post
local ifp = engineLoadIFP( "anim.ifp", "newAnimBlock" )

addEvent( "anim", true )
addEventHandler( "anim", root,
	function(enable)
		if (enable) then setPedAnimation(source, "newAnimBlock", "continencia", -1, true, false)
		else setPedAnimation(source)
		end		
	end
)

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        triggerServerEvent("onClientSync", resourceRoot)
	end
)

addEventHandler("onClientResourceStop", resourceRoot,
	function()
		if ifp then
			for _,player in ipairs(getElementsByType("player")) do
				local _, anim = getPedAnimation(player)
				if (anim == "continencia") then
					setPedAnimation(player)
				end
			end
			destroyElement(ifp)
		end
	end
)

 

21 minutes ago, N3xT said:

Line 21 replace resourceRoot with root

I did it. But not work.

Share this post


Link to post

Try to change the script order.

Serverside first, then clientside.

If that doesn't work then serverside has an syntax error or the script is not serverside.

Share this post


Link to post
5 hours ago, IIYAMA said:

Try to change the script order.

Serverside first, then clientside.

If that doesn't work then serverside has an syntax error or the script is not serverside.

Sorry, I am a beginner. Can u make a better explain ? 

Share this post


Link to post
3 hours ago, joao2235 said:

Sorry, I am a beginner. Can u make a better explain ? 

Open the meta.xml

Change the script order.

1. <script type="server" (or no type)

2. <script type="client"

Share this post


Link to post

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.