Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("mysqloo")
- local DATABASE_HOST = "localhost"
- local DATABASE_PORT = 3306
- local DATABASE_NAME = "hl2rp"
- local DATABASE_USERNAME = "root"
- local DATABASE_PASSWORD = ""
- local databaseObject = nil
- function rp.createmysqltables()
- local query1 = databaseObject:query("CREATE TABLE IF NOT EXISTS RP_CHARACTER ( id int(6) NOT NULL AUTO_INCREMENT, steamid text, name text, class text, age int(2), model text, faction text, inventory text, playergroup text, money int(9), x int(6), y int(6), z int(6), PRIMARY KEY (id)) ;")
- function query1.onSuccess(self)
- print( "Created character table" )
- end
- query1:start()
- local query1 = databaseObject:query("CREATE TABLE IF NOT EXISTS RP_CONFIG ( id int(6) NOT NULL AUTO_INCREMENT, conkey text, val text, PRIMARY KEY (id)) ;")
- function query1.onSuccess(self)
- print( "Created config table" )
- end
- query1:start()
- local query1 = databaseObject:query("CREATE TABLE IF NOT EXISTS RP_GROUPS ( id int(6) NOT NULL AUTO_INCREMENT, name text, owner text, admins text, upgrades text, bank text, PRIMARY KEY (id)) ;")
- function query1.onSuccess(self)
- print( "Created groups table" )
- end
- query1:start()
- end
- function rp.connect()
- databaseObject = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
- print(databaseObject)
- function databaseObject.onConnected(self)
- print( "Succesfully connected..." )
- end
- function databaseObject.onConnectionFailed(self, error)
- print( "Error when connecting to server... Error: "..error )
- end
- databaseObject:connect()
- end
- function rp.start()
- print( "Gamemode starting..." )
- print( "Connecting to mysql..." )
- rp.connect()
- print( "Creating mysql tables if they do not exist..." )
- rp.createmysqltables()
- /*
- local function ReceiveBasicConfig(res, stat, id)
- print("Loaded " .. #res .. " configuration values...")
- rp.config = {}
- for k,v in pairs(res) do
- rp.config[v[2]] = v[3]
- end
- end
- print( "Recieving configuration..." )
- tmysql.query("SELECT * FROM RP_CONFIG", ReceiveBasicConfig, 2)
- */
- end
- function GM:InitPostEntity()
- print("Gamemode initialized...")
- rp.start()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement