=KoG=Rouche Posted May 13, 2014 Share Posted May 13, 2014 (edited) Hi all I explain my situation. I'm creating an userpanel with MySQL Database. Step By Step 1. When the player login (Go to 2 if already exist in DB else go to 1.1) 1.1 - Create the initialized tables in the Database and then go to 2 2. Read the data from database (serverside) and send the results clientside. 3. A triggered Clientside function add all the values from serverside to the Element (Player) with setElementData. setElementData(root,"temp.account",playerData.account) Right now can i use the getElementData(source,temp.account) both clientside and serverside ? 4. When the player quit i want to save datas to Database. (Serverside) dbExec(connect,"UPDATE Player (account) VALUES ('"..getElementData(source,"temp.account").."') Is it correct ? Thanks for your help. Edited May 14, 2014 by Guest Link to comment
Moderators IIYAMA Posted May 13, 2014 Moderators Share Posted May 13, 2014 You will get problems with that, to prevent errors: local theData = tostring(getElementData(source,"temp.account") or "") But the db, I can't help you want that. Link to comment
Karuzo Posted May 13, 2014 Share Posted May 13, 2014 Right now can i use the getElementData(source,temp.account) both clientside and serverside ?4. When the player quit i want to save datas to Database. (Serverside) dbExec(connect,"UPDATE Player (account) VALUES ('"..getElementData(source,"temp.account").."') Ofcourse you can use elementdatas client and server side. But i would only set it on server side, so client can only get the element data and not set it ( preventing cheats). and to your dbExec : You should write it like that to prevent mysql injections: local setacc = getElementData(source,"temp.account") dbExec(connect,"UPDATE Player SET account=?",setacc) Link to comment
=KoG=Rouche Posted May 13, 2014 Author Share Posted May 13, 2014 If i've more arguments it will work like that ? dbExec(connect,"UPDATE Player (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) SET (mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenBought=?) WHERE account = '"..quittingPlayerAccount.."'",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) Thanks for your Help. Link to comment
Karuzo Posted May 13, 2014 Share Posted May 13, 2014 No. dbExec(connect,"UPDATE Player SET mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenBought=? WHERE account =?",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought,quittingPlayerAccount) Link to comment
=KoG=Rouche Posted May 14, 2014 Author Share Posted May 14, 2014 It says it's not correct. What is my error ? dbExec(connect,"UPDATE Player (mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) SET mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenBought=? WHERE account =?",mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought,quittingPlayerAccount) Thanks. Link to comment
Moderators Citizen Posted May 14, 2014 Moderators Share Posted May 14, 2014 Hi allI explain my situation. I'm creating an userpanel with MySQL Database. Step By Step 1. When the player login (Go to 2 if already exist in DB else go to 1.1) 1.1 - Create the initialized tables in the Database and then go to 2 2. Read the data from database (serverside) and send the results clientside. 3. A triggered Clientside function add all the values from serverside to the Element (Player) with setElementData. setElementData(root,"temp.account",playerData.account) Right now can i use the getElementData(source,temp.account) both clientside and serverside ? Is it correct ? Thanks for your help. Almost, you have to use localPlayer instead of root to set the element data for the player. And yeah you will be able to use it on both sides. That being said, you can also set the element data for the player on the server side instead of triggering a client side function which will set the element data. Link to comment
Moderators Citizen Posted May 14, 2014 Moderators Share Posted May 14, 2014 No problem (If you want to avoid wrong answers from others, just post in the French sub-forum, I'm always available there ) Link to comment
=KoG=Rouche Posted May 21, 2014 Author Share Posted May 21, 2014 Its not working. Error Message : WARNING: @[gamemodes]/[race]/[addons]/panel/server.lua:75: dbExec fai led; (1064) You have an error in your SQL syntax; check the manual that correspo nds to your MySQL server version for the right syntax to use near 'account=0,mai l='none',bDay=0,bMonth='',bYear='',level='',VIP='',welcomeText='',a' at line 1 Code : dbExec(connect,"INSERT INTO Player VALUES account=?,mail=?,bDay=?,bMonth=?,bYear=?,level=?,VIP=?,welcomeText=?,achivementPoints=?,token=?,tokenbought=?",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) What's wrong ? Thanks. Link to comment
K4stic Posted May 21, 2014 Share Posted May 21, 2014 dbExec(connect,"INSERT INTO Player ( account, mail, bDay, bMonth, bYear, level, VIP, welcomeText, achivementPoints, token, tokenbought ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", account, mail, bDay, bMonth, bYear, level, VIP, welcomeText, achivementPoints, token, tokenbought) Link to comment
=KoG=Rouche Posted May 22, 2014 Author Share Posted May 22, 2014 I've another problem now But count seems to be correct 0.o Error : [12:02:57] WARNING: @[gamemodes]/[race]/[addons]/panel/server.lua:75: dbExec fai led; (1136) Column count doesn't match value count at row 1 Code : dbExec(connect,"INSERT INTO Player VALUES (?,?,?,?,?,?,?,?,?,?,?)",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) Thanks for your help. Link to comment
K4stic Posted May 22, 2014 Share Posted May 22, 2014 i was give you the correct code. the code that you give back now it's incorrect 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