Jump to content

register login and accountdata system


MasterTobi

Recommended Posts

Hey,

if i use the getaccountdata and setaccountdata from wiki then i go on my server an use /register and /login they create my account to account.acl.

close Mta.

Then i edit account.acl piraterpg.money=100 save it

Open Mta and login to my server /login

the money is always still 0 :(

i dont no why :( can you help me?

or it gives a resource where create accounts whit data, /login, /register ?

THX

p.s.my English is bad

Link to comment
For account data, you can't modify it while the server is running.

but you can make a check, if account of any player is not guest, and then do what you want to do with accounts.

something like this: save player money when he leaves a server. And it's work great for me i dont have any problems with deleting accounts.

And dont use names of keys like "rpg.money" it deletes accounts too. I dont know why, so, use usual names of keys, like in my example.

     local account = getClientAccount ( source ) 
    local guest = isGuestAccount ( account ) 
    if ( guest ) then 
        outputDebugString ( "*" ..getClientName ( source ).. " has left server with guest account." ) 
    else 
        --Money 
        local money = getPlayerMoney ( source ) 
        if ( money ) then 
            setAccountData ( account, "money", money ) 
            outputDebugString ( "*" ..getClientName ( source ).. " has left server. Saving his data..OK!" ) 
        end 
    end 

Link to comment

hmhmhmhmhmhm

i changed it now, but if I log in he does not take over it from that account.acl

  
function onPlayerQuit ( ) 
  
      -- when a player leaves, store his current money amount in his account data 
      local playeraccount = getClientAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getPlayerMoney ( source ) 
            setAccountData ( playeraccount, "money", playermoney ) 
      end 
end 
  
function onPlayerJoin ( ) 
      -- when a player joins, retrieve his money amount from his account data and set it 
      local playeraccount = getClientAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "money" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) 
  

this does not function

someone can help me

Link to comment

the money must set when a player login not when he join

function onPlayerQuit ( ) 
      -- when a player leaves, store his current money amount in his account data 
      local playeraccount = getClientAccount ( source ) 
      -- check if the account is a guest account or not 
      if not isGuestAccount( playeraccount ) then 
            local playermoney = getPlayerMoney ( source ) 
            local suc = setAccountData ( playeraccount, "money", playermoney ) 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
  
function onPlayerLogin ( ) 
      -- when a player login, retrieve his money amount from his account data and set it 
      local playeraccount = getClientAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "money" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
      end 
end 
addEventHandler ( "onClientLogin", getRootElement ( ), onPlayerLogin ) 

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