Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local remaining
- local connection = {}
- function init ( res )
- if res == getThisResource() then
- connection = exports["saw_mysql"]:getConnection()
- end
- end
- addEventHandler ( "onResourceStart", getRootElement(), init )
- addEvent ( "checkRes", true )
- addEventHandler ( "checkRes", root, function ( width )
- if width < 1024 then
- kickPlayer( client, "Minimum felbontás: 1024 x 768." )
- end
- end)
- local owners = {
- ['6E338887A77346CAD4260BE4E52AEBA4']=true; -- ExTasY
- ['6891CDE528817C917FD3EE0E684EABE4']=true; -- Balu
- }
- function loginS ( felhasz, jelszo, thePlayer )
- local qh = dbQuery( connection, "SELECT * FROM account WHERE user = ?", felhasz)
- local serial1 = getPlayerSerial(client)
- local result = dbPoll ( qh, -1 )
- dbFree( qh )
- local count = 0
- local pw
- u = nil
- pw = nil
- if result == nil then
- exports.srp_box:createSmallNotification(client,"A bejelentkezés nem biztonságos!\nKérlek jelezd a vezetőség felé!", 3)
- return
- end
- if result then
- for _, row in ipairs ( result ) do
- u = string.lower(row["user"])
- pw = string.lower(row["password"])
- id = row["id"]
- acc = row["id"]
- admin = row["admin"]
- helper = row["helper"]
- banned = row["banned"]
- bwarn = tonumber ( row["warn"] )
- anick = row["anick"]
- serial = row["serial"]
- serialChange = row["serialChange"]
- end
- if u == nil or u == "" then
- if not owners [ getPlayerSerial ( client ) ] then
- exports.srp_box:createSmallNotification(client,"Az általad megadott felhasználónév nem létezik.\n(Ellenőrizd, nincs-e bekapcsolva a Caps Lock.)", 1)
- return
- end
- end
- if serialChange == 1 then
- local exec = dbExec ( connection, "UPDATE `account` SET `serialChange` = 0, `serial` = ? WHERE id = ?",serial1, id )
- elseif not (serial == serial1) then
- if not owners [ getPlayerSerial ( client ) ] then
- exports.srp_box:createSmallNotification(client,"Ez a felhasználónév nem a te számitógépedhez van társitva.", 1)
- return
- end
- end
- if owners[ getPlayerSerial ( client ) ] then
- if u == nil then
- exports.srp_box:createSmallNotification(client,"Főnök, ez a felhasználónév nem létezik!", 1)
- return
- end
- end
- if pw ~= string.lower(md5(jelszo)) then
- if not owners [ getPlayerSerial ( client ) ] then
- exports.srp_box:createSmallNotification(client,"Az általad megadott jelszó helytelen.\(Ellenőrizd, nincs-e bekapcsolva a Caps Lock.)", 1)
- return
- end
- end
- if tonumber ( banned ) and banned == 1 then
- kickPlayer(client,"SoulGaming", "Account zárolva!")
- return
- end
- if tonumber ( bwarn ) then
- setElementData(thePlayer, "bwarn", warn)
- end
- setElementData(source, "username", u)
- setElementData(source, "accountID", id)
- setElementData(source, "anick", anick)
- setElementData(source, "banned", 0)
- setElementData(source, "adminlevel", admin)
- setElementData(source, "helperlevel", helper)
- if ( helper ~= 0 ) then
- setElementData(source, "adminduty", 1)
- end
- selectChar(thePlayer)
- end
- end
- addEvent( "loginS", true )
- addEventHandler( "loginS", root, loginS )
- function selectChar(source)
- local accid = getElementData(source,"accountID")
- local qh = dbQuery( connection, "SELECT * FROM `character` WHERE `acc`=? LIMIT 1", accid)
- local result, lineNumber = dbPoll ( qh, -1 )
- if(result) then
- local ip = getPlayerIP ( source )
- local serial = getPlayerSerial ( source )
- local time = getRealTime()
- local rTimestemp = time.timestamp
- local username = getElementData(source, "username")
- if (username == "") then username = "root" end
- if(lineNumber > 0) then
- for _, rows in ipairs( result ) do
- level = rows["level"]
- xp = rows["xp"]
- ehseg = rows["ehseg"]
- szomj = rows["szomj"]
- kid = rows["id"]
- skin = rows["skin"]
- x = rows["x"]
- y = rows["y"]
- z = rows["z"]
- rz = rows["rz"]
- nevve = rows["nev"]
- inti = rows["inti"]
- dim = rows["dim"]
- jail = rows["jail"]
- adminjail_time = rows["adminjail_time"]
- adminjail_reason = rows["adminjail_reason"]
- adminjail_by = rows["adminjail_by"]
- adminjail_timestamp = rows["adminjail_timestamp"]
- characcepted = rows["accepted"]
- group_member = rows["group_member"]
- group_leader = rows["group_leader"]
- group_rank = rows["group_rank"]
- end
- setElementModel(source, skin)
- setElementData(source, "characterID", kid)
- setElementData(source, "ehseg", ehseg)
- setElementData(source, "szomj", szomj)
- setElementData(source, "level", level)
- setElementData(source, "xp", xp)
- setElementData(source, "spawnPos", x..","..y..","..z)
- setElementData(source, "inti", inti)
- setElementData(source, "dim", dim)
- setElementData(source, "name2", nevve )
- setElementData(source, "adminduty", 0)
- setElementData(source, "jail", jail )
- setElementData(source, "nowtick", adminjail_time )
- setElementData(source, "jailreason", adminjail_reason )
- setElementData(source, "jailedby", adminjail_by )
- setElementData(source, "jailedat", adminjail_timestamp )
- setElementData(source, "characcepted", characcepted )
- triggerClientEvent(source, "chooseCharacter", source)
- setPlayerName(source, string.gsub(getElementData(source, "name2"), " ", "_"))
- dbExec( connection, "INSERT INTO connections SET name=?, ip=?, serial=?, time=?, type=2", getPlayerName ( source ), ip, serial, rTimestemp)
- exports.srp_global:sendAdminMessage ( 1, "[SRP - Admin]:#FFFFFF " ..string.gsub(getPlayerName ( source ), "_", " ").. " (" .. username ..") bejelentkezett a szerverre.", 0, 153, 255, true )
- else
- triggerClientEvent(source, "createChar", source)
- exports.srp_global:sendAdminMessage ( 1, "[SRP - Admin]:#FFFFFF " ..string.gsub(getPlayerName ( source ), "_", " ").. " (" .. username ..") bejelentkezett a szerverre.", 0, 153, 255, true )
- end
- end
- end
- function registerS ( felhasz, jelszo, jelszo2, email )
- if string.len(felhasz) < 4 then
- exports.srp_box:createSmallNotification(client,"Felhasználónév minimum 4 karakter legyen!", 1)
- return
- elseif string.len(jelszo) < 5 then
- exports.srp_box:createSmallNotification(client,"Jelszó minimum 5 karakter legyen!", 1)
- return
- elseif not string.find(email, "@") then
- exports.srp_box:createSmallNotification(client,"Kérlek valós e-mail címet adj meg.", 1)
- return
- elseif not jelszo == jelszo2 then
- exports.srp_box:createSmallNotification(client,"A két jelszó nem egyezik meg.", 1)
- return
- end
- local qh = dbQuery( connection, "SELECT * FROM `account`")
- local result = dbPoll ( qh, -1 )
- serial = getPlayerSerial(client)
- if result then
- for _, row in ipairs ( result ) do
- if row["user"] == felhasz then
- exports.srp_box:createSmallNotification(client,"Ez a felhasználónév már foglalt! ( "..felhasz.." )", 3)
- return
- elseif row["serial"] == serial then
- if not owners [ getPlayerSerial ( client ) ] then
- exports.srp_box:createSmallNotification(client,"Már regisztráltál erről a számitógépről egy felhasználót!", 3)
- return
- end
- end
- end
- end
- exports.srp_box:createSmallNotification(client,"Sikeres regisztrácó! Kérlek lépj be! ( "..felhasz.." )", 3)
- triggerClientEvent ( client, "regSuccesC", client)
- local qhh = dbExec( connection, "INSERT INTO account SET user = ?, password = ?, email = ?, pp = 0, serial = ?", felhasz, string.lower(md5(jelszo)), string.lower(email), serial)
- if qhh == false then
- exports.srp_box:createSmallNotification(client,"Sikertelen regisztrácó?! WUT??\n Kérlek keress fel egy fejlesztőt!", 3)
- return
- end
- end
- addEvent( "registerS", true )
- addEventHandler( "registerS", root, registerS )
- function succes(client)
- triggerClientEvent ( client, "loginSuccesC", client)
- setElementData(client, "logged", true, true)
- fadeCamera(client, true)
- triggerClientEvent ( client, "loginSuccesC2", client)
- end
- addEvent("checkPlayerBanState", true)
- addEventHandler("checkPlayerBanState", getRootElement(),
- function()
- local serial = getPlayerSerial(source)
- local query = dbQuery(connection,"SELECT * FROM bans WHERE serial=?",serial)
- local qh = dbPoll(query, -1)
- local playerSerial, timeStamp, bannedBy, reason
- if tonumber(#qh) > 0 then
- for k, data in ipairs (qh) do
- playerSerial = data["serial"]
- timeStamp = tonumber(data["timestamp"])
- bannedBy = data["bannedby"]
- reason = data["reason"]
- acc = data["acc"]
- end
- else
- triggerClientEvent(source, "loginPanel", source)
- return
- end
- dbFree(query)
- local time = getRealTime()
- local rTimestemp = time.timestamp
- if rTimestemp >= timeStamp then
- dbExec(connection,"DELETE FROM `bans` WHERE `serial`=?",serial)
- dbExec( connection, "UPDATE `account` SET `banned` = 0 WHERE `id` = ?", acc)
- triggerClientEvent(source, "loginPanel", source)
- return
- end
- triggerClientEvent(source, "onBanRender", source, playerSerial, timeStamp, bannedBy, reason)
- end
- )
- function onSaveLoginData ( )
- local name = getPlayerName ( source )
- local ip = getPlayerIP ( source )
- local serial = getPlayerSerial ( source )
- local time = getRealTime()
- local rTimestemp = time.timestamp
- dbExec( connection, "INSERT INTO connections SET name=?, ip=?, serial=?, time=?, type=1", name, ip, serial, rTimestemp)
- setElementData( source, "spawned", 0 )
- end
- addEventHandler ( "onPlayerJoin", getRootElement(), onSaveLoginData)
- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement