SrPattif Posted March 20, 2020 Share Posted March 20, 2020 (edited) Olá. Gostaria de enviar uma outputChatBox para um jogador que efetuou um comando client-side e deu um triggerServerEvent, ou seja, enviar uma mensagem via server-side, sendo que foi 'acionado' via client-side... Meu client-side: function greetingCommand ( commandName ) triggerServerEvent ( "onGreeting", resourceRoot, guiGetText ( GUIEditor.edit[1] ) ) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], greetingCommand, false ) Meu server-side: function greetingHandler ( message ) local data = getAccountData ( getAccount("database", "senha"), message ) if data then outputChatBox(getPlayerName( >>> O ELEMENTO DO JOGADOR VIRIA AQUI <<< ) else outputChatBox("Não achei :(") end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", resourceRoot, greetingHandler ) Edited March 20, 2020 by SrPattif Design Link to comment
Angelo Pereira Posted March 20, 2020 Share Posted March 20, 2020 Você pode utilizar : outputChatBox(getPlayerName(source)) Caso não funciona, é o que eu sempre faço é assim : Linha 2 Client. triggerServerEvent ( "onGreeting", getRootElement(), localPlayer, guiGetText ( GUIEditor.edit[1] ) ) Server. function greetingHandler ( source, message ) local data = getAccountData ( getAccount("database", "senha"), message ) if data then outputChatBox("Jogador : "..getPlayerName(source).."", source, 255, 255, 255, true) else outputChatBox("Não achei :(", source, 255,255,255, true) end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler ) Link to comment
main Posted March 20, 2020 Share Posted March 20, 2020 7 minutes ago, Angelo Pereira said: Linha 2 Client. triggerServerEvent ( "onGreeting", getRootElement(), localPlayer, guiGetText ( GUIEditor.edit[1] ) ) Server. function greetingHandler ( source, message ) local data = getAccountData ( getAccount("database", "senha"), message ) if data then outputChatBox("Jogador : "..getPlayerName(source).."", source, 255, 255, 255, true) else outputChatBox("Não achei :(", source, 255,255,255, true) end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler ) Não necessita do source como parâmetro no server-side -- CLIENT-SIDE triggerServerEvent ( "onGreeting", localPlayer, guiGetText ( GUIEditor.edit[1] ) ) -- SERVER-SIDE function greetingHandler ( message ) local data = getAccountData ( getAccount("database", "senha"), message ) if data then outputChatBox("Jogador : "..getPlayerName(source), source, 255, 255, 255, true) else outputChatBox("Não achei :(", source, 255,255,255, true) end end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler ) 1 Link to comment
Other Languages Moderators Lord Henry Posted March 21, 2020 Other Languages Moderators Share Posted March 21, 2020 (edited) Eu usaria root no lugar do getRootElement( ) só pra poupar alguns bits de tamanho. Da mesma forma que se usa localPlayer em vez de getLocalPlayer ( ) Edited March 21, 2020 by Lord Henry 1 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