RikeBR Posted March 1, 2019 Share Posted March 1, 2019 Olá a todos. Estou com um problema na seguinte questão: ERROR: Server triggered clientside event updateChatList, but event is not added clientside Já li um tópico relacionado a este mesmo problema, porém não entendi muito bem ainda como resolver, alguém que poderia me ajudar nessa parte? clientside local showMyIcon = true local chattingPlayers = {} local drawDistance = 1000 local transicon = false local chatIconFor = {} local screenSizex, screenSizey = guiGetScreenSize() local guix = screenSizex * 0.1 local guiy = screenSizex * 0.1 local globalscale = 1 local globalalpha = .85 gChatting = false function chatCheckPulse() local chatState = isChatBoxInputActive() or isConsoleActive() if chatState ~= gChatting then if chatState then triggerServerEvent("playerChatting", getLocalPlayer()) else triggerServerEvent("playerNotChatting", getLocalPlayer()) end gChatting = chatState end setTimer( chatCheckPulse, 150, 1) end addEventHandler ( "onClientResourceStart", getRootElement(), chatCheckPulse ) addEventHandler ( "onPlayerJoin", getRootElement(), chatCheckPulse ) function showTextIcon() local playerx,playery,playerz = getElementPosition ( getLocalPlayer() ) for player, truth in pairs(chattingPlayers) do if (player == getLocalPlayer()) then if(not showMyIcon) then return end end if(truth) then local chatx, chaty, chatz = getElementPosition( player ) if(isPedInVehicle(player)) then chatz = chatz + .5 end local dist = getDistanceBetweenPoints3D ( playerx, playery, playerz, chatx, chaty, chatz ) if dist < drawDistance then if( isLineOfSightClear(playerx, playery, playerz, chatx, chaty, chatz, true, false, false, false )) then local screenX, screenY = getScreenFromWorldPosition ( chatx, chaty, chatz+1.2 ) local scaled = screenSizex * (1/(2*(dist+5))) *.85 local relx, rely = scaled * globalscale, scaled * globalscale guiSetAlpha(chatIconFor[player], globalalpha) guiSetSize(chatIconFor[player], relx, rely, false) if(screenX and screenY) then guiSetPosition(chatIconFor[player], screenX, screenY, false) guiSetVisible(chatIconFor[player], true) end end end end end end addEventHandler ( "onClientRender", getRootElement(), showTextIcon ) function updateList(newEntry, newStatus) chattingPlayers[newEntry] = newStatus if(not chatIconFor[newEntry]) then chatIconFor[newEntry] = guiCreateStaticImage(0, 0, guix, guiy, "chat.png", false ) end guiSetVisible(chatIconFor[newEntry], false) end addEvent("updateChatList", true ) addEventHandler ( "updateChatList", getRootElement(), updateList ) serverside addEvent("playerChatting", true ) addEvent("playerNotChatting", true ) addEvent("updateChatList", true ) function playerChatting() triggerClientEvent("updateChatList", getRootElement(), source, true) end function playerNotChatting() triggerClientEvent("updateChatList", getRootElement(), source, false) end addEventHandler("playerChatting", getRootElement(), playerChatting) addEventHandler("playerNotChatting", getRootElement(), playerNotChatting) addEventHandler ("onPlayerQuit", getRootElement(), playerNotChatting ) Link to comment
Other Languages Moderators Lord Henry Posted March 1, 2019 Other Languages Moderators Share Posted March 1, 2019 Não tem relação com seu erro, mas no client não se usa o evento onPlayerJoin. Pois o evento onClientResourceStart já é ativado quando o jogador entra no servidor e faz download desse resource. Link to comment
RikeBR Posted March 1, 2019 Author Share Posted March 1, 2019 Sim, eu estava fazendo um teste. Mas mesmo sem o onPlayerJoin ele ainda acusa o mesmo erro. Link to comment
[M]ister Posted March 1, 2019 Share Posted March 1, 2019 Adicione isso no seu client e remova a linha 17 do seu script server-side addEventHandler("onClientPlayerQuit", getRootElement(), function() triggerServerEvent("playerNotChatting", source) end ) 1 Link to comment
RikeBR Posted March 1, 2019 Author Share Posted March 1, 2019 21 minutes ago, MaligNos said: Adicione isso no seu client e remova a linha 17 do seu script server-side addEventHandler("onClientPlayerQuit", getRootElement(), function() triggerServerEvent("playerNotChatting", source) end ) O mesmo erro continua sendo acusado, acredito que o problema não seja no playerNotChatting Link to comment
[M]ister Posted March 1, 2019 Share Posted March 1, 2019 (edited) O erro é que no triggerClientEvent, o resource ainda não está disponivel no seu cliente (você está no download) Tente: -- cliente addEventHandler("onClientResourceStart", resourceRoot, function () triggerServerEvent ( "onClientDownloaded", localPlayer ) end ) addEventHandler("onClientPlayerQuit", getRootElement(), function() triggerServerEvent("playerNotChatting", source) end ) -- server addEvent( "onClientDownloaded", true ) addEventHandler( "onClientDownloaded", root, function() addEventHandler("playerChatting", client, playerChatting) addEventHandler("playerNotChatting", client, playerNotChatting) end ) * remova as linhas 15,16,17 Edited March 1, 2019 by MaligNos 1 Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 Só sei que nada sei Sócrates Tente: addEvent("playerChatting", true ) addEvent("playerNotChatting", true ) addEvent("updateChatList", true ) function playerChatting() triggerClientEvent(this, "updateChatList", getRootElement(), source, true) end function playerNotChatting() triggerClientEvent(this, "updateChatList", getRootElement(), source, false) end addEvent( "onClientDownloaded", true ) addEventHandler( "onClientDownloaded", root, function() addEventHandler("playerChatting", client, playerChatting) addEventHandler("playerNotChatting", client, playerNotChatting) end ) 1 Link to comment
RikeBR Posted March 2, 2019 Author Share Posted March 2, 2019 Agora sim funcionou! Obrigado pela ajuda @MaligNos 1 Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 14 minutes ago, RikeBR said: Agora sim funcionou! Obrigado pela ajuda @MaligNos Teste com algum player, diga para alguém escrever e tú vê se aparece o ícone (ainda tenho minhas dúvidas) 1 Link to comment
RikeBR Posted March 2, 2019 Author Share Posted March 2, 2019 Opa, verdade, o ícone só está aparecendo para o player que está digitando, o certo seria pra todos Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 Depois posso tentar pensar em algo melhor, mas aqui uma solução "porca" local clientOk = {} addEvent( "onClientDownloaded", true ) addEventHandler( "onClientDownloaded", resourceRoot, function() clientOk[client] = true end ) addEvent("playerChatting", true ) addEvent("playerNotChatting", true ) function updatePlayerChatting() for _,p in ipairs(getElementsByType("player")) do if (clientOk[p]) then triggerClientEvent(p, "updateChatList", getRootElement(), source, eventName == "playerChatting" and true or false) end end end addEventHandler("playerChatting", getRootElement(), updatePlayerChatting) addEventHandler("playerNotChatting", getRootElement(), updatePlayerChatting) addEventHandler("onPlayerQuit", root, function() clientOk[source] = nil end ) 1 Link to comment
RikeBR Posted March 2, 2019 Author Share Posted March 2, 2019 (edited) Blz, eu testei aqui e continua a mesma coisa, ele só aparece para o player, mas mesmo assim, vlw! Edited March 2, 2019 by RikeBR Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 29 minutes ago, RikeBR said: Blz, eu testei aqui e continua a mesma coisa, ele só aparece para o player, mas mesmo assim, vlw! Ué. Tente com esse: local clients = {} addEvent( "onClientDownloaded", true ) addEventHandler( "onClientDownloaded", resourceRoot, function() table.insert(clients, client) end ) addEvent("playerChatting", true ) addEvent("playerNotChatting", true ) function playerChatting() triggerClientEvent(clients, "updateChatList", getRootElement(), source, true) end function playerNotChatting() triggerClientEvent(clients, "updateChatList", getRootElement(), source, false) end addEventHandler("playerChatting", getRootElement(), updatePlayerChatting) addEventHandler("playerNotChatting", getRootElement(), updatePlayerChatting) addEventHandler("onPlayerQuit", root, function() for i,p in ipairs(clients) do if (p == source) then table.remove(clients, i) end end end ) 1 Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 29 minutes ago, MaligNos said: Ué. Tente com esse: local clients = {} addEvent( "onClientDownloaded", true ) addEventHandler( "onClientDownloaded", resourceRoot, function() table.insert(clients, client) end ) addEvent("playerChatting", true ) addEvent("playerNotChatting", true ) function playerChatting() triggerClientEvent(clients, "updateChatList", getRootElement(), source, true) end function playerNotChatting() triggerClientEvent(clients, "updateChatList", getRootElement(), source, false) end addEventHandler("playerChatting", getRootElement(), updatePlayerChatting) addEventHandler("playerNotChatting", getRootElement(), updatePlayerChatting) addEventHandler("onPlayerQuit", root, function() for i,p in ipairs(clients) do if (p == source) then table.remove(clients, i) end end end ) Troque na linha 4 resourceRoot por root, ou mude o seu client para: addEventHandler("onClientResourceStart", resourceRoot, function () triggerServerEvent ( "onClientDownloaded", resourceRoot ) end ) 1 Link to comment
RikeBR Posted March 2, 2019 Author Share Posted March 2, 2019 Bom, fiz exatamente como tu mandou, tentei algumas outras coisas e ele continua não funcionando, no debugscript 3 acusa o seguinte erro: Obs: server-side https://i.imgur.com/YaHikhn.png Link to comment
[M]ister Posted March 2, 2019 Share Posted March 2, 2019 9 minutes ago, RikeBR said: Bom, fiz exatamente como tu mandou, tentei algumas outras coisas e ele continua não funcionando, no debugscript 3 acusa o seguinte erro: Obs: server-side https://i.imgur.com/YaHikhn.png CTRL+ C e CTRL+V Troque as linhas 22 e 23 addEventHandler("playerChatting", getRootElement(), playerChatting) addEventHandler("playerNotChatting", getRootElement(), playerNotChatting) 1 Link to comment
RikeBR Posted March 2, 2019 Author Share Posted March 2, 2019 Agora sim, está tudo funcionando certo! Obrigado pela ajuda. 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