Jump to content

TriggerServerEvent for a single person


Lormateve

Recommended Posts

 

My question is how to send a data to the server in a personal way with the client, that is, without including all the clients.

Client side

function AAB (pia)
triggerServerEvent ("KnowAmount",  getLocalPlayer(), pia )
end

--======================================================================

Server Side

function KnowAmountFunction (pia)
outputChatBox ("AA") -- This show ALL Client, and that's what I want to avoid
  	
 	 if (pia == 1) then

	PasajENP = PasajENP_a1  -- This change for all players, and it should not be like that
	triggerClientEvent (client, "GotoClient", resourceRoot, PasajENP )

end end
addEvent( "KnowAmount", true )
addEventHandler( "KnowAmount", getRootElement(), KnowAmountFunction )

 

Link to comment
27 minutes ago, Gordon_G said:

Yeah, outputChatBox is showing for every client because you have to put the player argument after the string.

 

Take a look : outputChatBox

 

It's absolutely right, but it's not what I really need, what I wonder is how to make the condition only direct the player who started the trigger? That is to say that PasajENP = PasajENP_a1 is changed only to a player, do you understand?

Link to comment

hmmmm maybe like this ?

local PasajENP = {}
function KnowAmountFunction (pia)
outputChatBox ("AA") -- This show ALL Client, and that's what I want to avoid
    
     if (pia == 1) then

    PasajENP[client] = PasajENP_a1
    triggerClientEvent (client, "GotoClient", resourceRoot, PasajENP[client] )

end end
addEvent( "KnowAmount", true )
addEventHandler( "KnowAmount", getRootElement(), KnowAmountFunction )

this way you can make var for each player

  • Thanks 1
Link to comment

client variable = the client that called the event (wiki)

source variable = the element you defined in triggerServerEvent after event name

Try to use player element (source) instead of client element

local PasajENP = {}
function KnowAmountFunction (pia)
	outputChatBox ("AA",source) -- it will send to player who triggered this event
	if (pia == 1) then
		PasajENP[source] = PasajENP_a1
		triggerClientEvent (source, "GotoClient", source, PasajENP[source] )
	end
end
addEvent( "KnowAmount", true )
addEventHandler( "KnowAmount", getRootElement(), KnowAmountFunction )

@Lormateve

Edited by JeViCo
  • Like 2
Link to comment
11 hours ago, Simple. said:

hmmmm maybe like this ?


local PasajENP = {}
function KnowAmountFunction (pia)
outputChatBox ("AA") -- This show ALL Client, and that's what I want to avoid
    
     if (pia == 1) then

    PasajENP[client] = PasajENP_a1
    triggerClientEvent (client, "GotoClient", resourceRoot, PasajENP[client] )

end end
addEvent( "KnowAmount", true )
addEventHandler( "KnowAmount", getRootElement(), KnowAmountFunction )

this way you can make var for each player

From what I could see, it's working perfectly, thank you very much

 

I ended up using the source instead of the client, thanks to everyone!
 

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