N9.Xzi Posted January 25, 2016 Share Posted January 25, 2016 Hey guys, i'm having script with connecting to mySQL, need help with making data base, have this: dbHandler = dbConnect("mysql","dbname=numbernine;host=localhost","root","") addEvent("registerNewPlayer",true) addEventHandler("registerNewPlayer", root, function(player, name, pw) outputDebugString("K") local query = dbQuery(dbHandler,"SELECT * FROM accounts WHERE name = ?", name) local row = dbPoll(query,-1) if #row == 0 then local exec = dbExec(dbHandler,"INSERT INTO accounts (name) VALUES(?)", name) if exec then local carlights = {buy = "false", color = "none", policelights = "false"} local headlights = {buy = "false", color = "none", pulsating = "false", policelights = "false"} local rims = {buy = "false", typ = "none" } local skin = {buy = "false", model = "none" } local lights = {buy = "false", model = "none"} local rainbowlights = {buy = "false", enable = "false"} local vehicleskin = {buy = "false", model = "none"} local exec2 = dbExec(dbHandler,"UPDATE accounts SET password = ?,\ serial = '"..getPlayerSerial(player).."',\ grank = 0,\ points = 0,\ money = 0,\ dmtts = 0,\ dmwins = 0,\ ddwins = 0,\ shooterwins = 0,\ shooterrockets = 0,\ shooterkills = 0,\ bombwins = 0,\ racewins = 0,\ racetts = 0,\ trialwins = 0,\ trialtts = 0,\ playtime = 0,\ donator = 0,\ team = 0,\ freetokens = 0,\ carlights = '"..toJSON(carlights).."',\ headlights = '"..toJSON(headlights).."',\ mapsplayed = 0,\ rims = '"..toJSON(rims).."',\ skin = '"..toJSON(skin).."',\ serverjoined = 0,\ mapsbought = 0,\ lightskin = '"..toJSON(lights).."',\ rainbowlights = '"..toJSON(rainbowlights).."',\ vehicleskin = '"..toJSON(vehicleskin).."' WHERE name = ?", md5(pw), name) if exec2 then triggerClientEvent(player,"removeLoginPanel",root) triggerClientEvent(player,"startSelectionMode",root) triggerClientEvent(player,"addNotification",root,"Account successfully created", 1) bindKey(player,"F1","down",function() startSelection(player) end) end end else triggerClientEvent(player,"addNotification",root,"Accountname exists", 2) end dbFree(query) end) What im need making in SQL file database for working this? Give me example for SQL. Need help, please. Link to comment
KariiiM Posted January 25, 2016 Share Posted January 25, 2016 You need a server to connect with mysql, if you don't have , change it to sqlite, Link to comment
N9.Xzi Posted January 26, 2016 Author Share Posted January 26, 2016 You need a server to connect with mysql, if you don't have , change it to sqlite, I have the data base mySQL, im wanna to get example with making tables: id, rank... etc... Link to comment
tosfera Posted January 26, 2016 Share Posted January 26, 2016 That's basic SQL knowledge; CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), ); as stated here on the w3schools site; http://www.w3schools.com/sql/sql_create_table.asp Link to comment
KariiiM Posted January 26, 2016 Share Posted January 26, 2016 Example: this example will create a table when the resource start. addEventHandler ("onResourceStart", resourceRoot, function () dbExec ( connection,"CREATE TABLE IF NOT EXISTS myTable (column1 TEXT, column2 INT)" ) end) Also, read the link that tosfera posted for you to learn more about SQL, and try to practice that on dbFunctions. 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