Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local connection
- addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
- function ()
- local sqlDatas = exports.san_mysql:getSQLDatas()
- connection = dbConnect( "mysql", "dbname="..sqlDatas["database"]..";host="..sqlDatas["host"], sqlDatas["user"], sqlDatas["password"], "share=1" )
- if connection then
- outputServerLog("ADMINPANEL: Sikeres MySQL csatlakozas!")
- else
- outputServerLog("ADMINPANEL: Sikertelen MySQL csatlakozas!")
- end
- end
- )
- addEventHandler("onResourceStop", getResourceRootElement(getThisResource()),
- function ()
- if connection then
- destroyElement(connection)
- outputServerLog("ADMINPANEL: A resource sikeresen lekapcsolodott a MySQL adatbazisrol!")
- end
- end
- )
- --=================================================--
- mysql = exports.san_mysql
- function adminLoginServer(username, password)
- local source = client
- dbQuery(
- function (queryHandler)
- local result, numAffectedRows, errorMsg = dbPoll(queryHandler, 0)
- if numAffectedRows > 0 then
- triggerClientEvent(source, "loginAdminClient", source)
- else
- exports.san_infobox:addNotificationS(source, "Hibás felhasználónév/jelszó.", "error")
- end
- end,
- connection,
- "SELECT * FROM admins WHERE username = ? AND password = ?", username, password
- )
- end
- addEvent("adminLoginServer", true)
- addEventHandler("adminLoginServer", getRootElement(), adminLoginServer)
- addEvent("acceptPlayerLoginAdmins", true)
- addEventHandler("acceptPlayerLoginAdmins", getRootElement(), function(player)
- triggerClientEvent(player, "loginAdminClient", player)
- end)
- function createAdminAccount(thePlayer, command, username, password)
- if getElementData(thePlayer, "acc:admin") >= 7 then
- if not (username) or not (password) then
- outputChatBox("#acd373[SanMTA - Használat]: #ffffff/" .. command .. " [Felhasználónév] [Jelszó]", thePlayer, 255, 0, 0, true)
- else
- local query = dbExec(connection, "INSERT INTO admins SET username = ?, password = ?",username,password)
- if query then
- outputChatBox("#acd373[SanMTA - Admins]: #ffffffHozzáadva!", thePlayer, 255, 0, 0, true)
- else
- outputChatBox("#acd373[SanMTAg - Admins] #ffffffMySQL Hiba [#001-es kód]", thePlayer, 255, 0, 0, true)
- end
- end
- end
- end
- addCommandHandler("createadminaccount", createAdminAccount)
- function deleteAdminAccount(thePlayer, command, username)
- if getElementData(thePlayer, "acc:admin") >= 7 then
- if not (username) then
- outputChatBox("#acd373[SanMTA - Használat]: #ffffff/" .. command .. " [Felhasználónév]", thePlayer, 255, 0, 0, true)
- else
- local query = dbExec(connection, "DELETE FROM admins WHERE username=?",username)
- if query then
- outputChatBox("#acd373[SanMTA - Admins]: #ffffffKitörölve!", thePlayer, 255, 0, 0, true)
- else
- outputChatBox("#acd373[SanMTA - Admins] #ffffffMySQL Hiba [#002-es kód]", thePlayer, 255, 0, 0, true)
- end
- end
- end
- end
- addCommandHandler("deleteadminaccount", deleteAdminAccount)
- --================================================--
- --[[function sendMessageToPolice(text, number)
- for k, v in ipairs(getElementsByType("player")) do
- local count = getElementData(v, "groupCount")
- if count then
- for i=0, count-1 do
- local group = getElementData(v, "group_" .. i .. "")
- if group == 1 or group == 2 or group == 3 or group == 14 or group == 15 then
- outputChatBox("#598ED7[ExperianMTA - Rendőrség]: " .. text .. "", v, 255, 0, 0, true)
- end
- end
- end
- end
- end
- addEvent("sendMessageToPolice", true)
- addEventHandler("sendMessageToPolice", getRootElement(), sendMessageToPolice)--]]
- function getBansServer(playerSource)
- local bans = {}
- bans = {}
- local QueryEredmeny = dbPoll ( dbQuery( connection, "SELECT * FROM bans"), -1 )
- if (QueryEredmeny) then
- for k, v in ipairs(QueryEredmeny) do
- bans[#bans + 1] = {v["id"], v["accid"], v["serial"], v["time"], v["duration"], v["admin"], v["reason"], v["adminnick"], v["targetnick"]}
- end
- triggerClientEvent(root, "getBansClient", root, bans)
- end
- end
- addEvent("getBansServer", true)
- addEventHandler("getBansServer", getRootElement(), getBansServer)
- function getJailsServer(thePlayer, playerSource)
- local jails = {}
- jails = {}
- local QueryEredmeny = dbPoll ( dbQuery( connection, "SELECT * FROM adminjails"), -1 )
- if (QueryEredmeny) then
- for k, v in ipairs(QueryEredmeny) do
- jails[#jails + 1] = {v["id"], v["jailed_player"], v["jailed_ido"], v["jailed_reason"], v["jailed_ido"], v["jailed_idopontora"], v["jailed_admin"], v["jailed_player"]}
- end
- triggerClientEvent(root, "getJailsClient", root, jails)
- end
- end
- addEvent("getJailsServer", true)
- addEventHandler("getJailsServer", getRootElement(), getJailsServer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement