Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Created by: Kutak Roland
- -- Help: Jankovics Patrik
- -- Local variables
- local DISALLOWED_ROW_NAMES = {password = true, username = true, serial = true, pos = true, int = true, dim = true}
- local connection = exports["kutak_mysql"]:getConnection()
- local infobox = exports["kutak_infobox"]
- -- Functions
- addEvent("register", true)
- addEventHandler("register", getRootElement(), function(username, password)
- dbQuery(function(qh, client, username, password)
- local result, affected = dbPoll(qh, 0)
- result = result[1]
- if (result) then
- if (result.username==username) then
- infobox:createServerBox(client, "Ezzel a felhasználónévvel már valaki regisztrált!", "alert")
- elseif (result.serial==getPlayerSerial(client)) then
- --infobox:createServerBox(client, "Már van egy karaktered!", "alert")
- end
- else
- dbExec(connection, "INSERT INTO accounts SET username = ?, password = ?, serial = ?", username, sha256(password), getPlayerSerial(client))
- end
- end, {client, username, password}, connection, "SELECT serial, username FROM accounts WHERE serial=? OR username=? LIMIT 1", getPlayerSerial(client), username)
- end)
- addEvent("loadchar", true)
- addEventHandler("loadchar", root, function(charid)
- dbQuery(function(qh, client)
- local result, aff, pos, intdim = dbPoll(qh, 0)
- if (aff>0) then
- for rowName, rowValue in pairs(result) do
- if not DISALLOWED_ROW_NAMES[rowName] then
- setElementData(client, "char:"..rowName, rowValue)
- elseif rowName == "pos" then
- pos = fromJSON(rowValue)
- elseif rowName == "intdim" then
- intdim = fromJSON(rowValue)
- end
- end
- --infobox:createServerBox(source, "Sikeres karakterválasztás!", "alert") TODO Kliensoldara
- setTimer(spawnPlayer, 3000, 1, client, Vector3(unpack(pos)), 0, skin, unpack(intdim))
- triggerClientEvent(thePlayer, "changepanel", thePlayer, "spawnPlayer")
- --[[
- TODO Klienshez betteni spawnPlayer changepanelhoz
- setTimer(function()
- setElementData(thePlayer, "showHUD", true)
- setElementData(thePlayer, "showScore", true)
- clearChat()
- showChat(thePlayer, true)
- end, 6000, 1)
- setTimer(function()
- setElementData(thePlayer, "showRadar", true)
- end, 8000, 1)
- ]]
- else
- infobox:createServerBox(source, "Túl sok a hekk!", "alert")
- end
- end, {client}, connection, "SELECT * FROM profiles WHERE id=? AND ownerid=? LIMIT 1", charid, getElementData(client, "acc:id"))
- end)
- addEvent("login", true)
- addEventHandler("login", getRootElement(), function(username, password)
- dbQuery(function(qh, client)
- local result, aff = dbPoll(qh, 0)
- if (aff>0) then
- for rowName, rowValue in pairs(result) do
- if not (DISALLOWED_ROW_NAMES[rowName]) then
- setElementData(client, "acc:"..rowName, rowValue)
- end
- end
- sendAvailableCharsListToClient(client)
- else
- infobox:createServerBox(source, "Hibás felhasználónév vagy jelszó!", "alert")
- end
- end, {client}, connection, "SELECT * FROM profiles WHERE username=? AND password=? LIMIT 1", username, sha256(password))
- end)
- addEvent("createProfile", true)
- addEventHandler("createProfile", root, function(name, weight, height, age, skin, avatar, company, logo)
- dbQuery(function(qh, client)
- local result, aff = dbPoll(qh, 0)
- if (aff==0) then
- if dbExec(connection, "INSERT INTO profiles SET name=?, weight=?, height=?, age=?, skin=?, avatar=?, company=?, logo=?, ownerid=?", name, weight, height, age, skin, avatar, company, logo, getElementData(client, "acc:id")) then
- sendAvailableCharsListToClient(client)
- end
- else
- exports["kutak_infobox"]:createServerBox("Ez a név már foglalt. Kérlek válassz másikat!", "alert")
- end
- end, {client}, connection, "SELECT * FROM profiles WHERE name = ?", name)
- end)
- function sendAvailableCharsListToClient(client)
- dbQuery(function(qh, client)
- triggerClientEvent(client, "setAvailableCharsList", client, dbPoll(qh, 0))
- end, {client}, connection, "SELECT * FROM profiles WHERE ownerid=?", getElementData(client, "acc:id"))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement