Jump to content

[HELP] Client-Server Communication Wont work


Imposter

Recommended Posts

Hey guy, Its been a while since I've posted, i have a problem in this bit of code, when i press the "m" key, it opens the menu, which triggers the server, the server gets the client AccountName and sends it back to the client to view on the GUI, but it doesnt happen, the server finds the data, and outputs it, as I did that to test it, but the client doesnt seem to get triggered, here is the code. Thanks!

Server

  
addEvent("sendGUIData", true) 
function sendGUIData() 
local theAccount = getPlayerAccount(source) 
    if (theAccount) then 
        if isGuestAccount(getPlayerAccount(source)) then 
            outputChatBox("Please log in", source)  
        else 
            local theAccountName = getAccountName(getPlayerAccount(source)) 
            outputChatBox("Hello " .. theAccountName) 
            triggerClientEvent("setGUI", source, theAccountName) 
        end 
    end 
end 
addEventHandler("sendGUIData", getRootElement(), sendGUIData) 
  

Client

  
    local lp = getLocalPlayer() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    local windowWidth, windowHeight = 241, 324 
    local left = screenWidth/2 - windowWidth/2 
    local top = screenHeight/2 - windowHeight/2 
    userMenu = guiCreateWindow(left, top, windowWidth, windowHeight, "User Menu", false) 
    guiWindowSetSizable(userMenu, false) 
     
    tabPanel1 = guiCreateTabPanel(10, 75, 221, 241, false, userMenu) 
     
    tab1 = guiCreateTab("Info", tabPanel1) 
     
    label1 = guiCreateLabel(10, 10, 200, 16, "Account Name: ", false, tab1) 
    guiLabelSetHorizontalAlign(label1, "left", false) 
    guiLabelSetVerticalAlign(label1, "center") 
     
    label2 = guiCreateLabel(10, 30, 200, 16, "Account Registration: ", false, tab1) 
    guiLabelSetHorizontalAlign(label2, "left", false) 
    guiLabelSetVerticalAlign(label2, "center") 
     
    label3 = guiCreateLabel(10, 50, 200, 16, "Account ACL: ", false, tab1) 
    guiLabelSetHorizontalAlign(label3, "left", false) 
    guiLabelSetVerticalAlign(label3, "center") 
     
    label4 = guiCreateLabel(10, 70, 200, 16, "Player Rank: ", false, tab1) 
    guiLabelSetHorizontalAlign(label4, "left", false) 
    guiLabelSetVerticalAlign(label4, "center") 
     
    label5 = guiCreateLabel(10, 150, 200, 16, "Rank 1:", false, tab1) 
    guiLabelSetHorizontalAlign(label10, "left", false) 
    guiLabelSetVerticalAlign(label10, "center") 
     
    label6 = guiCreateLabel(10, 170, 200, 16, "Rank 2:", false, tab1) 
    guiLabelSetHorizontalAlign(label12, "left", false) 
    guiLabelSetVerticalAlign(label12, "center") 
     
    label7 = guiCreateLabel(10, 190, 200, 16, "Rank 3:", false, tab1) 
    guiLabelSetHorizontalAlign(label13, "left", false) 
    guiLabelSetVerticalAlign(label13, "center") 
     
    label8 = guiCreateLabel(10, 90, 200, 16, "Game Points: ", false, tab1) 
    guiLabelSetHorizontalAlign(label8, "left", false) 
    guiLabelSetVerticalAlign(label8, "center") 
     
    label9 = guiCreateLabel(10, 110, 200, 16, "Iris Points: ", false, tab1) 
    guiLabelSetHorizontalAlign(label9, "left", false) 
    guiLabelSetVerticalAlign(label9, "center") 
     
    tab2 = guiCreateTab("Cars", tabPanel1) 
     
    tab3 = guiCreateTab("Perks", tabPanel1) 
     
    tab4 = guiCreateTab("Options", tabPanel1) 
     
addEvent("setGUI", true) 
function setGUI(accountname) 
    outputChatBox(accountname) 
    guiSetText(label1, "Account Name: " .. accountname ) 
end 
addEventHandler("setGUI", resourceRoot, setGUI) 
  
function resourceStart () 
    guiSetVisible (userMenu, false) 
    bindKey("m", "down", menuShow)  
end 
addEventHandler("onClientResourceStart", resourceRoot, resourceStart) 
  
function menuShow() 
    visableornot = guiGetVisible (userMenu) 
    if (visableornot == true) then 
        guiSetVisible (userMenu, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        triggerServerEvent ("sendGUIData", getLocalPlayer()) 
        guiSetVisible (userMenu, true) 
        showCursor (true) 
    end 
end 
  

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