GamingTim Posted December 10, 2013 Posted December 10, 2013 I'm learning slowly but i'm trying to make this simple script to work, it didn't work but only showed me the "money" tab on the scoreboard but I don't get the player's money when they join also I wanted to save the player's money when they quit. here's the code and idk how to fix it. exports.scoreboard:addScoreboardColumn('Money') function GetPlayerMoney(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local GetPlayermoney = getAccountData(account,"GetPlayerMoney") if not GetPlayerMoney then setAccountData(account,"GetPlayerMoney",0) end end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local GetPlayerMoney = getAccountData(account,"GetPlayerMoney") if GetPlayerMoney then setElementData(source,"GetPlayerMoney",tostring(player)) else setElementData(source,"GetPlayerMoney",0) end end)
!#NssoR_) Posted December 10, 2013 Posted December 10, 2013 Try this .. Server Side # function Quit() local playeraccount = getPlayerAccount ( source ) if not playeraccount or isGuestAccount(playeraccount) then return end setAccountData ( playeraccount, "Money", getPlayerMoney ( source ) ) end addEventHandler("onPlayerQuit",root,Quit) function join(_,playerAccount) local playerMoney = getAccountData(playerAccount, "Money") setPlayerMoney ( source , playerMoney ) end addEventHandler( "onPlayerLogin", getRootElement(), join) I think the money automatically changes in the scorebord
GamingTim Posted December 10, 2013 Author Posted December 10, 2013 I used this but, it doesen't show anything on my scoreboard, not even the money "tab"
GamingTim Posted December 10, 2013 Author Posted December 10, 2013 Do you get errors on the debugscript? No errors
GamingTim Posted December 10, 2013 Author Posted December 10, 2013 exports.scoreboard:addScoreboardColumn('Money') function GetPlayerMoney(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local GetPlayermoney = getAccountData(account,"GetPlayerMoney") if not player then setAccountData(account,"GetPlayerMoney",0) end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local GetPlayerMoney = getAccountData(account,"GetPlayerMoney") if GetPlayerMoney then setElementData(source,"GetPlayerMoney",tostring(player)) else setElementData(source,"GetPlayerMoney",0) end end)
Castillo Posted December 10, 2013 Posted December 10, 2013 Well, obviously you didn't look for errors, since I found one the moment I seen the script, plus, the debugscript also shows it. function GetPlayerMoney(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local GetPlayermoney = getAccountData(account,"GetPlayerMoney") if not player then setAccountData(account,"GetPlayerMoney",0) end In that function, you got an 'end' missing.
Desaster Posted December 10, 2013 Posted December 10, 2013 functions always star without caps like this getPlayerMoney not GetPlayerMoney
Castillo Posted December 11, 2013 Posted December 11, 2013 He's not trying to use the getPlayerMoney native function, that's obvious.
TAPL Posted December 11, 2013 Posted December 11, 2013 What are you doing? if not player? wtf if the player does not exists then how the account will be exists? if not player then setAccountData(account,"GetPlayerMoney",0) end tostring(player)? is player even defined anywhere? setElementData(source,"GetPlayerMoney",tostring(player)) And then back to function GetPlayerMoney you're not using the function anywhere, you just used a variable called 'GetPlayerMoney'. Also you never set a data to the key 'Money'. And you never saved anything when the player quit from the server. This make no sense.
GamingTim Posted December 11, 2013 Author Posted December 11, 2013 I edited and added the stuff needed, does this still makes sense?| V exports.scoreboard:addScoreboardColumn('Money') addEventHandler("onPlayerQuit",root, function GetPlayerMoney(player) local account = getPlayerAccount(player) if isGuestAccount(account) then return end local getPlayermoney = getAccountData(account,"getPlayerMoney") if not player then setAccountData(account,"getPlayerMoney",0) end end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local getPlayerMoney = getAccountData(account,"getPlayerMoney") if getPlayerMoney then setElementData(source,"setPlayerMoney",tostring(player)) else setElementData(source,"setPlayerMoney",0) end end)
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