WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 function onQuit () local data = getElementData(source,"LoggedIN") outputDebugString ( tostring ( data ) ) if ( data ) then local money = getPlayerMoney ( source ) local skin = getPedSkin ( source ) local health = getElementHealth ( source ) local int,dim = getElementInterior ( source ), getElementDimension ( source ) local x,y,z = getElementPosition (source) local inserting = dbExec ( connect, "INSERT INTO accounts ( money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,? )", money, skin, healt, x, y, z, int, dim ) if inserting then outputDebugString("Inserting successfull") else outputDebugString("Inserting failed.") end end end addEventHandler ("onPlayerQuit", root, onQuit) Check this out. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 (edited) @pa3ck: Yes i am . As you can see on this picture: @WhoAmI: I get an Error in the console : Edited March 3, 2014 by Guest Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 Are you sure if it is serverside script in meta? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 What the hell? Try to output elemnt after 1st lane outputChatBox ( getElementType ( source ) ) Link to comment
pa3ck Posted March 3, 2014 Share Posted March 3, 2014 I don't know much about SQLite browsers, but I can see a line there, 'username KRZO'. Try to update it instead of inserting and use WHERE. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 WTF. Now it outputted in the debug, INSERT SUCCESSFULL. So i think you solved the problem WhoAmI Thank you for that. Another Question. I have to specify a player , where he should insert the datas , right ? Can i make it like this : INSER INTO accounts (.....) VALUES(.....) WHERE (username) ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 dbExec ( "UPDATE tableName SET x=? WHERE username=?", x, username ) Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 No i mean i want to put those datas like money, skin, etc.. in . Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 Oh, so dbExec ( connect, "INSERT INTO accounts ( username, money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,?,? )", username, money, skin, healt, x, y, z, int, dim ) Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Nah, i mean lets say i have a guy who is registered and has now a Column with username and password. And i want to insert those datas into this specific player. How could i do that ? Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 But what does that x mean ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 dbExec ( "UPDATE tableName SET x=?, y=?, z=?, skin=? WHERE username=?", x, y, z, skin, username ) Do you understand now? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 You are welcome. Have fun with SQL. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Last Question, how should i get the username ? I know with triggering but can i trigger to a function where an event is already handled? Like triggerServerEvent("OnQuitPlayer", getLocalPlayer(),username) ? And than in Serverside: addEvent("OnQuitPlayer", true) addEventHandler("OnQuitPlayer", root, onQuit) ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 Well, I dont really know what you mean. You want get username from what? From database? You can get it in login function and saves into element data. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Well no i mean from the client-side . i get the username like that : local username = guiGetText(Username_edit) and trigger it. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Yeah works everything thank you. And what about getting the datas ?SELECT x, y,z, FROM accounts WHERE x=? AND y=? AND z=? ,... Like this ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 SELECT * FROM accounts WHERE username=? And then dbPoll, then you can download all records. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 SELECT * FROM accounts WHERE username=? And then dbPoll, then you can download all records. How do you mean that downloading all records ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 I mean all records from columns. This '*' means everything. But it will download a records where username is some player's username. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Oh, so he is downloading everything from the specific player , right ? And how can i use those datas to set them ? like x=data.x ? 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