Jump to content

getAccountData help!


Recommended Posts

Hello everyone.

I am now working on a stats / ranking system for DD / DM

and now I want the money saved.

That can with getAccountData?

Now I have a script, but that does not piraterpg.money the file does not exist.

Now my question is, where should I place piraterpg.money

I thought the resources / (my resource) / piraterpg.money but that does not work.

can someone help me here with

Script:

function onPlayerQuit ( )
-- when a player leaves, store his current money amount in his account data
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playermoney = getPlayerMoney ( source )
setAccountData ( playeraccount, "piraterpg.money", playermoney )
end
end
 
function onPlayerJoin ( )
-- when a player joins, retrieve his money amount from his account data and set it
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playermoney = getAccountData ( playeraccount, "piraterpg.money" )
-- make sure there was actually a value saved under this key (check if playermoney is not false).
-- this will for example not be the case when a player plays the gametype for the first time
if ( playermoney ) then
setPlayerMoney ( source, playermoney )
end
end
end
 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin )

Regards Maarten123.

Oh yeah sorry for my bad english I'm Dutch

Link to comment

so you agree save the system for accaonteve that you must be registered to you for additional need you login and registraciski guid that simply forcing players to register (easy and fast)

login gui scripts

https://community.multitheftauto.com/index.html?p=resources&s=details&id=537

https://community.multitheftauto.com/index.html?p=resources&s=details&id=491

https://community.multitheftauto.com/index.html?p=resources&s=details&id=617

and made a small change to the second part of the script

local root = getRootElement()
addEventHandler("onPlayerLogin", root,
 function()
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playermoney = getAccountData ( playeraccount, "piraterpg.money" )
           if ( playermoney ) then
                 setPlayerMoney ( source, playermoney )
           end
      end
 end
)

Maybe you understand me

ps. if I sent something wrong sir please correct me I am new to this business

Link to comment
Hello everyone.

I am now working on a stats / ranking system for DD / DM

and now I want the money saved.

That can with getAccountData?

Now I have a script, but that does not piraterpg.money the file does not exist.

Now my question is, where should I place piraterpg.money

I thought the resources / (my resource) / piraterpg.money but that does not work.

can someone help me here with

Script:

...

Regards Maarten123.

Oh yeah sorry for my bad english I'm Dutch

The piraterpg.money is just a data key/identifier. Account data is saved in "\accounts.xml". Wiki should explain it clear enough.

"piraterpg." is added at the from of the key to make it more unique so that if other resources would replace "money" your money would not be overwritten since it's not saved as "money" but "piraterpg.money".

Link to comment

The piraterpg.money is just a data key/identifier. Account data is saved in "\accounts.xml". Wiki should explain it clear enough.

"piraterpg." is added at the from of the key to make it more unique so that if other resources would replace "money" your money would not be overwritten since it's not saved as "money" but "piraterpg.money".

ok, I understand that but where do I "piraterpg.money" places?

Link to comment

The piraterpg.money is just a data key/identifier. Account data is saved in "\accounts.xml". Wiki should explain it clear enough.

"piraterpg." is added at the from of the key to make it more unique so that if other resources would replace "money" your money would not be overwritten since it's not saved as "money" but "piraterpg.money".

ok, I understand that but where do I "piraterpg.money" places?

I have explained it to you in the previous post :roll:

Read some more about accounts...

https://wiki.multitheftauto.com/wiki/Account

Link to comment
ja maarten zou je willen :D btw zie mij maar niet als koekje xD

mpr owns (als je m wilt had je maar samen meoten doen xD

wij hebben cash save maarja je wou niet eens samendoen xD

(isnt that from wiki, its example not for race :D)

I think is not allowed to speak in other languages, if im wrong im sorry.

Link to comment

when you set something with setAccountData its stored in

/mods/deathmatch/accounts.xml

part of my account.xml:

<account name="CrazyLady" password="358e576e759axxxxxxxxxxxxxx" ip="xxx.22.63.xxx">
       <string_data bank.balance="0" />
   </account>

after you set piraterpg.money in your account in accounts.xml something like that will be added:

<account name="CrazyLady" password="358e576e759axxxxxxxxxxxxxx" ip="xxx.22.63.xxx">
       <string_data bank.balance="0" piraterpg.money="345435" />
   </account>

Clean now?

if not -> read

https://wiki.multitheftauto.com/wiki/Account

over and over until you get this

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