Jump to content

Another Scoreboard Problem [SOLVED]


Recommended Posts

Hey guys again. I got the system to work now I am just trying to update the scoreboard with the players load count when they login. It does not seem to show up on the scoreboard until a load is complete. Any help will be greatly appreciated.

s_login.lua

  
function loginHandler(password) 
    local account = getAccount(getPlayerName(source)) 
    if (account ~= false) then 
    local loggedIn = logIn(source, account, password) 
        if (loggedIn ~= false) then 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Welcome back "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 18, 11, 150) 
            triggerClientEvent("hideLoginWindow", source) 
        else 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Invalid password entered.", source) 
        end 
    else 
        if (password ~= "" and password ~= nil) then 
            local accountAdded = addAccount(getPlayerName(source), password) 
            if (accountAdded) then 
                outputChatBox("Thank you for registering "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 112, 0, 0) 
                outputChatBox("If you click 'Submit' again you can login.", source, 112, 0, 0) 
            end 
        else 
            outputChatBox("You must enter a password.", source) 
        end 
    end 
end 
addEvent("accLogReg", true) 
addEventHandler("accLogReg", root, loginHandler) 
  
function saveAccount() 
    local playerAcc = getPlayerAccount(source) 
    local playerCash = getPlayerMoney(source) 
    setAccountData(playerAcc, "hdt.cash", playerCash) 
end 
addEventHandler("onPlayerQuit", getRootElement(), saveAccount) 
  
function loadAccount() 
    local playerAcc = getPlayerAccount(source) 
    if (playerAcc) then 
        local playerCash = getAccountData(playerAcc, "hdt.cash") 
        local playerLoads = getAccountData(playerAcc, "hdt.loads") 
        if (playerCash) then 
            setPlayerMoney(source, playerCash) 
        end 
        if (playerLoads) then 
        setElemntData(source, "Completed Loads", playerLoads) 
        else 
            setElementData(source, "Completed Loads", 0) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), loadAccount) 
  

I think that is the only file that matters. If you don't think so let me know and I can get your more. Thanks.

Edited by Guest
Link to comment
  
  
function loginHandler(password) 
    local account = getAccount(getPlayerName(source)) 
    if (account ~= false) then 
    local loggedIn = logIn(source, account, password) 
        if (loggedIn ~= false) then 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Welcome back "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 18, 11, 150) 
            triggerClientEvent("hideLoginWindow", source) 
        else 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Invalid password entered.", source) 
        end 
    else 
        if (password ~= "" and password ~= nil) then 
            local accountAdded = addAccount(getPlayerName(source), password) 
            if (accountAdded) then 
                outputChatBox("Thank you for registering "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 112, 0, 0) 
                outputChatBox("If you click 'Submit' again you can login.", source, 112, 0, 0) 
            end 
        else 
            outputChatBox("You must enter a password.", source) 
        end 
    end 
end 
addEvent("accLogReg", true) 
addEventHandler("accLogReg", root, loginHandler) 
  
function saveAccount() 
    local playerAcc = getPlayerAccount(source) 
    local playerCash = getPlayerMoney(source) 
    setAccountData(playerAcc, "hdt.cash", playerCash) 
end 
addEventHandler("onPlayerQuit", getRootElement(), saveAccount) 
  
function loadAccount() 
    local playerAcc = getPlayerAccount(source) 
    if (playerAcc) then 
        local playerCash = getAccountData(playerAcc, "hdt.cash") 
        local playerLoads = getAccountData(playerAcc, "hdt.loads") 
        if (playerCash) then 
            setPlayerMoney(source, playerCash) 
        end 
        if (playerLoads) then 
        setElementData(source, "Completed Loads", playerLoads) 
        else 
            setElementData(source, "Completed Loads", 0) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), loadAccount) 
  
  

Link to comment
  
  
function loginHandler(password) 
    local account = getAccount(getPlayerName(source)) 
    if (account ~= false) then 
    local loggedIn = logIn(source, account, password) 
        if (loggedIn ~= false) then 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Welcome back "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 18, 11, 150) 
            triggerClientEvent("hideLoginWindow", source) 
        else 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox(" ", source) 
            outputChatBox("Invalid password entered.", source) 
        end 
    else 
        if (password ~= "" and password ~= nil) then 
            local accountAdded = addAccount(getPlayerName(source), password) 
            if (accountAdded) then 
                outputChatBox("Thank you for registering "..getPlayerName(source):gsub('#%x%x%x%x%x%x', '')..".", source, 112, 0, 0) 
                outputChatBox("If you click 'Submit' again you can login.", source, 112, 0, 0) 
            end 
        else 
            outputChatBox("You must enter a password.", source) 
        end 
    end 
end 
addEvent("accLogReg", true) 
addEventHandler("accLogReg", root, loginHandler) 
  
function saveAccount() 
    local playerAcc = getPlayerAccount(source) 
    local playerCash = getPlayerMoney(source) 
    setAccountData(playerAcc, "hdt.cash", playerCash) 
end 
addEventHandler("onPlayerQuit", getRootElement(), saveAccount) 
  
function loadAccount() 
    local playerAcc = getPlayerAccount(source) 
    if (playerAcc) then 
        local playerCash = getAccountData(playerAcc, "hdt.cash") 
        local playerLoads = getAccountData(playerAcc, "hdt.loads") 
        if (playerCash) then 
            setPlayerMoney(source, playerCash) 
        end 
        if (playerLoads) then 
        setElementData(source, "Completed Loads", playerLoads) 
        else 
            setElementData(source, "Completed Loads", 0) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), loadAccount) 
  
  

Thanks man. I didn't notice that spelling mistake I feel like such a noob now lol. My bad. But thanks again man.

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