=KoG=Rouche Posted April 28, 2014 Share Posted April 28, 2014 (edited) Hi all, Here is a part of my "Userpanel" script. I try to retrieve player's datas into variables. Is it better to keep these variables clientside (what i did) or keep this in a table serverside ? I mean ... most of the variables can be edited when server is running. Last question : when must i save the datas to mysql ? When a player quit or with a timer ? Serverside : -- Retrieve Datas from Player table dataQuery = dbQuery(connect, "SELECT * FROM Player WHERE nickname = '"..account.."'") resultPlayer = dbPoll(dataQuery, -1) playerDatas = resultPlayer[1] triggerClientEvent("onReadData",rootElement,playerDatas) Clientside : function calledByReadData(datas) local account = datas.nickname local password = datas.password local mail = datas.mail local day = datas.day local month = datas.month local year = datas.year local level = datas.level local VIP = datas.VIP local welcomeText = datas.welcomeText outputDebugString("Test pseudo = "..account.." !") --like : -- local money = datas.money or 0 -- local playtime = datas.playtime or 0 --for example. end addEvent("onReadData",true) addEventHandler("onReadData",calledByReadData) Edited May 13, 2014 by Guest Link to comment
Karuzo Posted April 28, 2014 Share Posted April 28, 2014 Why don't you just set element datas? And when to save? I would save when the player leaves. Link to comment
TAPL Posted April 28, 2014 Share Posted April 28, 2014 addEventHandler("onReadData",calledByReadData) Should be: addEventHandler("onReadData", root, calledByReadData) And here you must use sendTo argument or it will be root by default which mean it will send the data to all clients. triggerClientEvent("onReadData",rootElement,playerDatas) I'll assume that the player you want send to him the data is source: triggerClientEvent(source, "onReadData", root, playerDatas) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now