Jump to content

About set/getaccountdata


Recommended Posts

Posted
Edit "logic.lua" in the deathmatch resource. Add a save function using setAccountData in onGamemodeStop (before the data is removed, at ~ line 34) and onPlayerQuit. Then, with onGamemodeMapStart and onPlayerJoin, insert loading code, with getAccountData.

i've done that on "login server" script...bcuz initally i wanted to test a thing....btw i changed "money" with "Score" n i get this @ warning -.-

WARNING: login_serv.lua: Bad argument @ 'getElementData' - Line: 59

line is ...

local playerScore = getElementData ( player, "Score" ) it was local playermoney = getPlayerMoney ( source )

edit, k done....ITS source, "Score"

edit 2: i have this problem....score is saved...but sometimes...i modify resource and my "score.attuale" in acc.xml disappear and i lost my data!!

Posted
Could you post your Acl.xml and the Function ?

I cant download the Resource :|

ill do, right now i got bigger issue...

ERROR: Client triggered serverside event on4XLogin, but event is not added serverside

CLIENT

triggerServerEvent ( "on4XLogin", getRootElement(), localPlayer, guiGetText(LoginUsername), guiGetText(LoginPassword) )

Server

function on4XLogin ( player, user, pass )
local account = getAccount ( user, pass )
if ( account ~= false ) then
	if (logIn ( player, account, pass ) == true) then
 
 
	--local account = getPlayerAccount ( source )
 
	--if ( account ) then
           local playerScore = getAccountData ( account, "score.attuale" )
--		local playerLevel = getAccountData ( account, "Level" )
           -- 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 ( playerScore ) then
                 --setPlayerMoney ( source, playermoney )
			  setElementData ( player, "Score", playerScore )
--			  setElementData ( player, "Level.game", playerLevel )and  ( playerLevel )
           end
     --end
 
		triggerClientEvent ( "hideLoginWindow", getRootElement())
	else
		outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong.
	end
else
	outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong.
end
end

this issue appeared now...weird...<.<

Posted
addEvent("on4XLogin", true)
addEventHandler("on4XLogin", getRootElement(), on4XLogin)

i solved moving my script in logic.lua

levelexp = 20

Level = 1

local expamount

expamount = getElementData ( player, "Level" )*levelexp

Well i need these values...

may i put em on the top of the script?

expamount = getElementData ( player, "Level" )*levelexp----------------attempt to do art on boolean value...

Posted

playerScore = getElementData ( source, "Score" )
 levelexp = 20
 playerAsk = getElementData(source,"Level")*levelexp
 --playerAsk1 = playerAsk * levelexp  
  		 if  (playerScore >= playerAsk)  then

its simple u think....but WHY

doesnt work?

i kill and i get NO score, nothing...this thing ignores me...

While...If i use 400(a normal value) =< playerAsk WORKS

playerscore >= 400 WORKS

playerscore>=playerask(witout the "levelexp") WORKS

im becoming mad....ç_________________________________________________ç

regards

Posted

Anyone knows whats the way i risk to lose my account data? i mean server crashes for istance...or more example reported by u all

If server crashes during last game session i lost my data...is there any fix?

Posted
Anyone knows whats the way i risk to lose my account data? i mean server crashes for istance...or more example reported by u all

If server crashes during last game session i lost my data...is there any fix?

uhm.. if you do "setAccountData" its safe to crash the server after it..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
Anyone knows whats the way i risk to lose my account data? i mean server crashes for istance...or more example reported by u all

If server crashes during last game session i lost my data...is there any fix?

uhm.. if you do "setAccountData" its safe to crash the server after it..

There is a way to obtain that i save my stats every 5 min?

Posted
There is a way to obtain that i save my stats every 5 min?

setTimer

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
function my_saving_function(arg, arg2, arg3)
-- your saving stuff
end
 
setTimer(my_saving_function, 1000*60*5, 0, argument1, argument2, argument3) -- and so on

1000*60*5 ==>

1000ms = 1sec

1sec*60 = 1min

1min*5 = 5min

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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