• MYSQL Check
    3 replies, posted
Basically, I'm storing the players SteamID and Rank to a database with this code: [lua] function FirstJoinMysql( ply ) local query1 = databaseObject:query("SELECT * FROM Players WHERE SteamID = '" .. ply:SteamID() .. "'") print(ply:SteamID()) query1.onSuccess = function(q) if not checkQuery(q) then local query2 = databaseObject:query("INSERT INTO Players(SteamID, Rank) VALUES ('" .. ply:SteamID() .. "', " .. 0 .. ")") // else create the bugger print(ply:SteamID()) query2.onSuccess = function(q) print("Created you!") end query2.onError = function(q,e) print("something went wrong") end query2:start() else print("You are already created!") end end query1.onError = function(q,e) print("something went wrong when checking") end query1:start() end hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", FirstJoinMysql ) [/lua] This was taken from the wiki (Which is horrible and he explains jack shit). I'm basically needing to know how to check the database and how to check individual rows in the table. Ill be doing: [lua] function Firstspawn( ply ) //MYSQL code to read from the rank row to check there rank, and if it's 1 then pl:Addmoney(100) or something like that. end hook.Add( "PlayerSpawn", "PlayerSpawn", Firstspawn ) [/lua] Any help is appreciated.
You should learn about MySQL queries.
[QUOTE=Chessnut;34599500]You should learn about MySQL queries.[/QUOTE] That's what I was wanting to do from the wiki, however there is one tutorial that just paste's a load of crap and does not explain. I was kind of asking if someone could link me something, I wasn't asking anyone to do it for me. Thanks anyway.
[url]http://www.w3schools.com/sql/default.asp[/url]
Sorry, you need to Log In to post a reply to this thread.