spoty Posted October 1, 2014 Share Posted October 1, 2014 hello i wanne make a drift database i have installed xampp but i realy dont know how to make a database and i wanne use it for save driftpoints can any body mayby help me alittel bit ? i would realy like it if you help me Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 Well, you seem new to sql databases. I suggest you start off with SQLite but none the less I'll show you how to create a database using phpmyadmin (should come with xampp if I remember correctly) 1. Navigate to http://localhost/security/xamppsecurity.php and fill in this section, it shouldn't have "current password". Then RESTART THE MYSQL SERVICE after you have set up your password 2. Now that you have your login details set up, navigate to http://localhost/phpmyadmin/ and login with username; root password; the password which you set. 3. Click the database tab and it should bring you here; Note; I have an older version of xampp. Then you type your database name and you're done. Question; why did you install xampp when you are just using the mysql service? Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 ok thnx but to make a database that saves the drift points i also need to script a database? Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: ok thnx but to make a database that saves the drift points i also need to script a database? You'll need to make a script which connects to your mySQL server and executes a query to save 'drift points'. Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 ok and how can i do that? i know how to make a mySQL script that conects to mySQL but the others i dont know Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 (edited) viewtopic.php?t=42067&f=148 Read that, next you would want to make a table with the following columns: accountname, drift points then you'd do something like local handler = mysql_connect("localhost", "root", "password", "database") local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") something like that, then on your register script you should make it insert them into the users table or whatever. Edited October 1, 2014 by Guest Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 okay thnx gonna read the topic and try to make something nice from it thnx Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: okay thnx gonna read the topic and try to make something nice from it thnx No problem, if you need anymore help then you can skype me: jaydancc Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 MagicMayhem said: https://forum.multitheftauto.com/viewtopic.php?t=42067&f=148Read that, next you would want to make a table with the following columns: accountname, drift points then you'd do something like local handler = mysql_connect("localhost", "root", "password", "database") local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") something like that, then on your register script you should make it insert them into the users table or whatever. so i need to put that into my register script? and what you mean whit that? the internal.db? Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: MagicMayhem said: https://forum.multitheftauto.com/viewtopic.php?t=42067&f=148Read that, next you would want to make a table with the following columns: accountname, drift points then you'd do something like local handler = mysql_connect("localhost", "root", "password", "database") local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") something like that, then on your register script you should make it insert them into the users table or whatever. so i need to put that into my register script? and what you mean whit that? the internal.db? No, that script wouldn't work alone, it's just to give you an idea of what you need to do. So you'd make a table called users in your mysql database, then in your register script you'd make it insert the user into the database/table. then when you want to update driftpoints you'd do local handler = mysql_connect("localhost", "root", "password", "database") local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") Or something simular. Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 okay so i need to make my own register lead to mySQL user table that i just created and now i have this error when i have maded the database for drift points ERROR: Couldn't parse config Driftdatabase.lua in resource drift Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 Could you send a snippet? Can't help you unless I see the code. If you don't want it shown publicly you can always inbox me. Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints local handler = mysql_connect("localhost", "root", "kolpol55", "arizonadrift") function aaa() dbQuery( myCallback, connection, "SELECT * FROM driftpoints" ) end function myCallback(qh) local result = dbPoll( qh, 0 ) -- Timeout doesn't matter here because the result will always be ready end mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") thats what i have now but its for now just testing Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints local handler = mysql_connect("localhost", "root", "kolpol55", "arizonadrift") function aaa() dbQuery( myCallback, connection, "SELECT * FROM driftpoints" ) end function myCallback(qh) local result = dbPoll( qh, 0 ) -- Timeout doesn't matter here because the result will always be ready end mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") thats what i have now but its for now just testing local driftpoints = driftpoints erm, you need to set that something. so you are trying to get driftpoints from internal.db? and about the error, could you post your meta.xml as well? Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 yes i am trying to get them from internal.db "NL|Spoty" version="1.0.0" type="script"/> i also have tryed to run driftdatabase.lua as server but then it wont run the drift resource Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 oh lol i see now what i did wrong Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: oh lol i see now what i did wrong should be Well atleast you managed to find the issue Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 hahaha ye first time i make this kinda fail lel never had it before but if i wanne take the drift score from internal.db how can i do that? Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: hahaha ye first time i make this kinda fail lel never had it before but if i wanne take the drift score from internal.db how can i do that? You'd use dbPoll and dbQuery local query = dbQuery ( housedb, "SELECT * FROM drift_points WHERE accountname = ''" .. accountherelol .. "" ) local result = dbPoll ( query, -1 ) local points = result[1]["points"] Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 MagicMayhem said: spoty said: hahaha ye first time i make this kinda fail lel never had it before but if i wanne take the drift score from internal.db how can i do that? You'd use dbPoll and dbQuery local query = dbQuery ( housedb, "SELECT * FROM drift_points WHERE accountname = ''" .. accountherelol .. "" ) local result = dbPoll ( query, -1 ) local points = result[1]["points"] so then it sould be something like this local accountname = getAccountName( getPlayerAccount( player ) ) local driftpoints = driftpoints local handler = mysql_connect("localhost", "root", "kolpol55", "arizonadrift") function aaa() dbQuery( myCallback, connection, "SELECT * FROM driftpoints" ) end function myCallback(qh) local result = dbPoll( qh, 0 ) -- Timeout doesn't matter here because the result will always be ready end local query = dbQuery ( housedb, "SELECT * FROM driftpoints WHERE accountname = ''" .. accountherelol .. "" ) local result = dbPoll ( query, -1 ) local points = result[1]["points"] mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") Link to comment
spoty Posted October 1, 2014 Author Share Posted October 1, 2014 hmm i have getting this error now [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [2014-10-01 18:23:17] ERROR: drift\Driftdatabase.lua:14: attempt to concatenate local 'accountname' (a boolean value) here is the script local accountname = getPlayerAccount( getPlayerAccount( source ) ) local driftpoints = driftpoints local handler = mysql_connect("localhost", "root", "", "arizonadrift") function aaa() dbQuery( myCallback, connection, "SELECT * FROM driftpoints" ) end function myCallback(qh) local result = dbPoll( qh, 0 ) -- Timeout doesn't matter here because the result will always be ready end local query = dbQuery ( housedb, "SELECT * FROM driftpoints WHERE accountname = '" .. accountname .. "' ") local result = dbPoll ( query, -1 ) local points = result[1]["points"] mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") Link to comment
Jaydan Posted October 1, 2014 Share Posted October 1, 2014 spoty said: hmm i have getting this error now [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2014-10-01 18:23:17] WARNING: drift\Driftdatabase.lua:1: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] [2014-10-01 18:23:17] ERROR: drift\Driftdatabase.lua:14: attempt to concatenate local 'accountname' (a boolean value) here is the script You need an event, how else is it supposed to get the player lol. https://wiki.multitheftauto.com/wiki/Se ... ing_Events so say you want to make it sync with the mysql database when a player joins, you' do handler = mysql_connect("localhost", "root", "", "arizonadrift") function playerJoined() local accountname = getPlayerAccount( getPlayerAccount( source ) ) local driftpoints = driftpoints local query = dbQuery ( database, "SELECT * FROM driftpoints WHERE accountname = '" .. accountname .. "' ") local result = dbPoll ( query, -1 ) local points = result[1]["points"] mysql_query(handler, "UPDATE users SET driftpoints = '" .. driftpoints .."' WHERE accountname = '" .. accountname .. "' ") end addEventHandler ( "onPlayerJoin", root, playerJoined ) 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