Jump to content

help with saving


liamknight24

Recommended Posts

can somebody please tell me how to save things like money im not asking anyone to script this for me i just want to know how to do it so i can save other things like the players skin and health i had a look an the mta wiki and found this:

---money

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, "money", playermoney )

end

end

function onPlayerlogin ( )

-- 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, "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 ( "onPlayerlogin", getRootElement ( ), onPlayerlogin )

i tried to edit it abit so it would work on login and not join but it dosent seem to work with join or login and im also using the logingui script if that will stop it but thanks anyway and also how will it know where to save it or will it automaticly save it to the accounts.xml??.

Link to comment

1. Please use [lua ][ /lua] (no spaces) tags and paste your code between them so it will look something like this:

addEventHandler ( "onPlayerlogin", getRootElement ( ), onPlayerlogin )

2. Your last line of the script (the one I showed here) is wrong... it's not "onPlayerlogin" it's "onPlayerLogin"

Edited by Guest
Link to comment
1. Please use
[ /lua] (no spaces) tags and paste your code between them so it will look something like this:
[lua]addEventHandler ( "onPlayerlogin", getRootElement ( ), onPlayerlogin )

2. Your last line of the script (the one I showed here) is wrong... it's not "onPlayerlogin" it's "onPlayerLogin"

so you mean change onPlayerlogin to onPlayerLogin i have just changed it but i cannot test if it works becouse now my player just spawns in the air instead of the logingui spawnpoint is this becouse the script is not in the logingui script it is in the gamemode folder and i added it to the meta.xml??

Link to comment

I dont think she means that. She means

---money
 
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, "money", playermoney )
end
end
 
function onPlayerlogin ( )
-- 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, "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 ( "onPlayerlogin", 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...