Jump to content

Enviar elemento usuário pelo triggerServerEvent


Recommended Posts

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 by SrPattif
Design
Link to comment

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

 

  • Like 1
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...