Jump to content

triggerClientEvent only to who triggered the ServerEvent


Recommended Posts

Howdy!

I'm building a UCP and I've a strange problem.

My script is something like this:

  
addEventHandler("onClientGUIClick", modifyAccount, function() local thePlayer = localPlayer triggerServerEvent("getDetails", root) end) 
  

^ The first part works fine, the server gets the right details and outputs the correct results, the problem is it outputs them to EVERYONE, meaning if one clicks the respective button, entire server will be shown the GUI. The server event is here:

  
    function getTheirDetails() 
        local ucpMail = getAccountData(getPlayerAccount(client), "ucpMail") or "E-Mailul acestui cont nu a fost setat!" 
        local ucpUser = getAccountName(getPlayerAccount(client)) or "Nu esti logat!" 
        triggerClientEvent("onResults", root, ucpMail, ucpUser) 
    end 
    addEvent("getDetails", true) 
    addEventHandler("getDetails", root, getTheirDetails) 
  

I want to know how to triggerClientEvent back to the 'client' ? I tried getPlayerFromName and triggerClientEvent("onResults", client, ucpMail, ucpUser) but it didn't work.

Link to comment
  
--client 
triggerServerEvent("getDetails", localPlayer,localPlayer) 
--server 
  
    function getTheirDetails(lp) 
        local ucpMail = getAccountData(getPlayerAccount(client), "ucpMail") or "E-Mailul acestui cont nu a fost setat!" 
        local ucpUser = getAccountName(getPlayerAccount(client)) or "Nu esti logat!" 
        triggerClientEvent(lp,"onResults", lp, ucpMail, ucpUser) 
    end 
    addEvent("getDetails", true) 
    addEventHandler("getDetails", root, getTheirDetails) 
  
  

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