Jump to content

Multi Game Mode + mySQL


N9.Xzi

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...