liamknight24 Posted February 9, 2010 Share Posted February 9, 2010 hi i have made this script t try and save the "deaths" on the scoreboard but it dosent work, here it is function Quit(player) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local Deaths = getElementData ( source, "Deaths" ) if ( Deaths ) then setAccountData( playeraccount, "Deaths", Deaths ) end end end addEventHandler ( "onPlayerQuit", root, function() Quit() end ) function onPlayerConnect(player) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local Deaths = GetAccountData( playeraccount, "Deaths") if ( Deaths ) then setElementData ( source, Deaths ) end end end addEventHandler("onPlayerLogin", root, function () onPlayerConnect(source) end ) Link to comment
50p Posted February 9, 2010 Share Posted February 9, 2010 Why don't you check debug window or server console? I'm sure you will see an error message. Start debugging script.. most of the things people ask here are so simple to fix that can be fixed by debugging the script. Use "debugscript 3" command and you'll find out what's wrong with your code. - Use "debugscript 3" all the time, even when making simple scripts - Use outputChatBox/outputDebugString to show yourself what the code does. Put simple "outputChatBox( 'i am in onPlayerConnect function' )" inside your onPlayerConnect function, restart resource and rejoin the server. Can you see the message? What is wrong if you can't see it? The function is not called. Why? You probably didn't attach it to onPlayerConnect event. How simple was that? - getAccountData ~= GetAccountData - This is MTA not SA-MP. Function names start with lower case. I'll keep directing people to debug page on wiki until they'll understand how important debugging scripts is and how easy for them it is to fix the errors in their scripts without need to ask here and wait for people to reply. https://wiki.multitheftauto.com/wiki/Debugging Link to comment
Aibo Posted February 10, 2010 Share Posted February 10, 2010 and you have an error in setElementData, Deaths value goes as a key, and value is empty. should be setElementData(source, "Deaths", Deaths), like with setAccountdata. addEventHandler("onPlayerQuit", getRootElement(), function() local playeraccount = getPlayerAccount(source) if playeraccount then local Deaths = getElementData(source, "Deaths") if Deaths then setAccountData(playeraccount, "Deaths", Deaths) end end end ) addEventHandler("onPlayerLogin", getRootElement(), function() local playeraccount = getPlayerAccount(source) if playeraccount then local Deaths = getAccountData(playeraccount, "Deaths") if Deaths then setElementData(source, "Deaths", Deaths) end end end ) 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