DigDim Posted March 30, 2020 Share Posted March 30, 2020 Hello guys, I'm new to Lua programming and I'm having trouble using the triggerClientEvent. What's wrong ? the "TagStaffInvisible" function on the client side is not called. Can someone help me ? Thanks. Server.Lua function onTagID_Teste(thePlayer) triggerClientEvent("onTagStaffInvisible", resourceRoot, thePlayer) outputChatBox ("Comando Funcionando", thePlayer) end addCommandHandler("tagid", onTagID_Teste) Client.Lua local TagAtiva = true; function TagStaffInvisible(thePlayer) outputChatBox ("function TagStaffInvisible Chamada", thePlayer) if (TagAtiva == true) then TagAtiva = false; table.remove(g_StreamedInPlayers, thePlayer) outputChatBox ("Sua tag id foi removida", thePlayer) elseif (TagAtiva == false) then TagAtiva = true; table.insert(g_StreamedInPlayers, thePlayer) outputChatBox ("Sua tag id foi setada", thePlayer) end end addEvent( "onTagStaffInvisible", true) addEventHandler( "onTagStaffInvisible", resourceRoot, TagStaffInvisible) Link to comment
The_GTA Posted March 30, 2020 Share Posted March 30, 2020 Hello DigDim, did you know that MTA's Lua functions require different arguments on client-side than on server-side despite being shared functions? outputChatBox ("function TagStaffInvisible Chamada", thePlayer) Here you have used "thePlayer" as second parameter to outputChatBox but that is wrong. You can just remove that parameter because it is executed on the client and on every client there is only one chatbox. Did you also know that you can use the /debugscript command in the MTA client to find out about errors in your script? 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