TheGamingMann Posted August 27, 2014 Share Posted August 27, 2014 (edited) 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 August 27, 2014 by Guest Link to comment
lcd12321 Posted August 27, 2014 Share Posted August 27, 2014 Do u want to count players who is trying login? If yes use event onPlayerJoin on serverside Link to comment
TheGamingMann Posted August 27, 2014 Author Share Posted August 27, 2014 Not I am trying to update the players load count like deliver count when they login. Currently it does not update the score board so it stays blank until they deliver a load. Link to comment
Anubhav Posted August 27, 2014 Share Posted August 27, 2014 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
TheGamingMann Posted August 27, 2014 Author Share Posted August 27, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now