Jump to content

Fix setAccountData


DakiLLa

Recommended Posts

we all know that setAccountData deletes all accounts in accounts.acl but there is difficult to find any account data base or make own, but a few people know how to make it. So, should be another ways to solve this problem.

post by lil Toady:

setAccountData deletes stuff if you set data on a guest account, so check if player's accounts is guest one before setting data? i use that on my server and never had problems

quick fix

_setAccoutData = setAccounData 
function setAccountData ( account, data, value ) 
  if ( not isGuestAccount ( account ) ) then 
    return _setAccountData ( account, data, value ) 
  end 
  return false 
end 

I have this:

function onQuit ( account, data, value ) 
    local account = getClientAccount ( source ) 
    if ( account ) then 
        if ( not isGuestAccount ( account ) ) then 
            local playermoney = getPlayerMoney ( source ) 
            return setAccountData ( account, "lvdm.money", playermoney ) 
        end 
        return false 
    end 
end 
  
function onJoin ( account, data, value ) 
    local account = getClientAccount ( source ) 
    if ( account ) then 
        if ( not isGuestAccount ( account )) then  
        local playermoney = getAccountData ( account, "lvdm.money" ) 
            if ( playermoney ) then 
                setPlayerMoney ( source, tonumber ( playermoney ) ) 
            end 
        end 
    end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement (), onQuit ) 
addEventHandler ( "onPlayerJoin", getRootElement (), onJoin ) 

but all the same this function deletes accounts. may be i have mistakes in this code..So, if help, guys, to find them, it will be really useful script for more people who make their own rpg game styles. If it's impossible to solve this stupid bug - hm..waiting for dp3...

Edited by Guest
Link to comment

maybe getAccountData deletes accounts as well? :)

e.g before you do getAccountData, check

if ( not isGuestAccount ( account ) ) then  

again?

I dunno, I ended up writing the datamanager resource as a replacement for get/set AccountData, not that I've used it myself as I moved onto sql lite and mysql.

Link to comment
This is soo strange :S, i never had any problems with getAccountData & setAccountData...

And now you do, or still don't? If you still don't, then... What the ****? (not the F word, the H word. A little more polite. :P)

Never tried it, not intending to. Have my own system improving every few whiles. :P

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