Jump to content

[HELP] triggerServerEvent


Om.

Recommended Posts

somethings wrong with triggerServerEvent.

Code:

-- Client Side 
    -- Logs into account 
    addEventHandler ( 'onClientGUIClick', root, 
    function () 
        if (source == clickOnlogin) then 
            if username ~= nil or username ~= "" or password ~= nil or password ~= "" then 
            triggerServerEvent("loginPlayer", localPlayer, username, password) 
            else  
            outputChatBox("Please enter username & password") 
        end 
    end 
end 
) 
  
-- Server Side 
function loginPlayer(thePlayer, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
    logIn(thePlayer, account, password) 
    else 
        outputChatBox("Invalid username & password!", thePlayer, 255, 0, 0) 
        end 
    end 
    addEvent("loginPlayer", true) 
    addEventHandler("loginPlayer", getRootElement(), loginPlayer) 

Link to comment

remove "thePlayer" argument and replace it with client

  
function loginPlayer(username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
    logIn(client, account, password) 
    else 
        outputChatBox("Invalid username & password!", client, 255, 0, 0) 
        end 
    end 
    addEvent("loginPlayer", true) 
    addEventHandler("loginPlayer", getRootElement(), loginPlayer) 
  

Link to comment

try this , If you do not add guiGetText

addEventHandler ( 'onClientGUIClick', root,function () 
if (source == clickOnlogin) then 
if guiGetText (user) ~= "" and guiGetText (pass) ~= "" then 
triggerServerEvent("loginPlayer", localPlayer,guiGetText (user),guiGetText (pass)) 
else 
outputChatBox("Please enter username & password") 
end 
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...