ArmedGuy Posted July 22, 2009 Share Posted July 22, 2009 Ok so Im Trying To Make a Script Where Players Data Gets Saved When They Leave Server and Their Data Gets Loaded When They login to an xml file... I Got The Whole Script Working Exept One Thing. When the server or the gamemode restarts the script cant find the xml file if something is saved in the playerstats.xml... heres the .lua local saveFile = xmlLoadFile ("playerstats.xml") function onPlayerQuit ( source ) outputChatBox( "Saving Data", source ) if ( saveFile ) then local subnode = xmlFindSubNode( saveFile, "users", 0 ) local playeraccount = getClientName ( source ) if ( playeraccount ) then local stats = xmlFindSubNode( subnode, "user."..playeraccount, 0 ) if ( stats ) then local subnodemoney = xmlFindSubNode( stats, "money", 0 ) local subnodeskin = xmlFindSubNode( stats, "skin", 0 ) local playermoney = getPlayerMoney ( source ) local playerskin = getPlayerSkin ( source ) local money = xmlNodeSetValue( subnodemoney, ""..playermoney ) local skin = xmlNodeSetValue( subnodeskin, ""..playerskin ) xmlSaveFile ( saveFile ) end end else outputChatBox("File Not Found", source ) end end function onPlayerJoin ( source ) outputChatBox("Loading Acc...", source ) if ( saveFile ) then local playeraccount = getClientName ( source ) if ( playeraccount ) then local subnode = xmlFindSubNode ( saveFile, "users", 0 ) local stats = xmlFindSubNode ( subnode, "user."..playeraccount, 0 ) if ( stats ) then local subnodemoney = xmlFindSubNode( stats, "money", 0 ) local subnodeskin = xmlFindSubNode( stats, "skin", 0 ) local playermoney = xmlNodeGetValue ( subnodemoney ) local playerskin = xmlNodeGetValue( subnodeskin ) if (( playermoney ) and ( playerskin )) then setPlayerMoney ( source, playermoney ) setPlayerSkin ( source, playerskin ) end else local stats = xmlCreateSubNode( subnode, "user."..playeraccount ) local subnode2 = xmlFindSubNode( subnode, "user."..playeraccount, 0 ) local playermoney = xmlCreateSubNode( subnode2, "money" ) local playerskin = xmlCreateSubNode ( subnode2, "skin" ) xmlSaveFile ( saveFile ) end end else outputChatBox("File Not Found", source ) end end addCommandHandler("loadacc", onPlayerJoin ) addCommandHandler ( "saveacc", onPlayerQuit ) and the .xml <playerstats> <users> </users> </playerstats> I seriously cant find the problem... and it dosent even give me errors someone know what the problem is? Link to comment
xArgonx Posted July 22, 2009 Share Posted July 22, 2009 i wanted to test your script but i got this: Bad ' client' pointer @ 'getPlayerName ' <1> Link to comment
Gamesnert Posted July 23, 2009 Share Posted July 23, 2009 So wait, what's the problem? If you restart the resource, data doesn't get saved? Or if you restart the resource your XML file gets wiped? Or something else? Link to comment
ArmedGuy Posted July 23, 2009 Author Share Posted July 23, 2009 Nope... Gamesnert... When I Have The .xml complerly clean, like i have it here on the website, and start the resource everything works perfect. Players gets saved and loaded and all. But when the server/the resource gets restarted, its like the script thats saves and loads player data cant find the .xml with the data. And the only way to fix that is to delete all players data inside the xml and restart the server. And i have no clue why. And Argon... what version did u run it on?... i have DP 2.3( and also i dont have a getPlayerName inside the script, i have getClientName xDxD) Link to comment
xArgonx Posted July 25, 2009 Share Posted July 25, 2009 because it did some changes: i wanted to let the script start onplayerjoin (instead of /loadacc) and onplayerquit (instead of /saveacc), but it doesn't work not data get saved and no data will load, maybe because i get an error attempt to getPlayerName (also for getPlayerUserName and getPlayerSerial) i don't know what to do... getClientName is not a updated command, so i do not use it.. 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