Noname20 Posted March 1, 2019 Posted March 1, 2019 Hi! I'm writeing a dashboard and it should write the admin lvl and the admin name, the admin name is working great, but when I get the data from the mysql database and I set it to an element data it's only gives a boolean value. SERVER SIDE: addEvent("adatokLekerdezese", true) addEventHandler("adatokLekerdezese", resourceRoot, function(serial) local queryHandler = dbQuery(con, 'SELECT * FROM accounts') local result = dbPoll(queryHandler, 500) local serial = getPlayerSerial(client) if (result) then if (#result > 0) then if (result[1]['serial'] == serial) then local adminSzint = setElementData(client, "admimlvl", tostring(result[1]['adminlvl'])) else end end end end ) CLIENT SIDE: local adminSzint = tostring(getElementData(localPlayer, "adminlvl"))
Dimos7 Posted March 1, 2019 Posted March 1, 2019 addEvent("adatokLekerdezese", true) addEventHandler("adatokLekerdezese", resourceRoot, function(serial) local queryHandler = dbQuery(con, 'SELECT * FROM accounts') local result = dbPoll(queryHandler, 500) local serial = getPlayerSerial(client) for num, row in paits(result) do if ( row.serial == serial) then setElementData(client, "admimlvl", tostring(row.adminlvl)) else end end end ) Try this 1
Noname20 Posted March 1, 2019 Author Posted March 1, 2019 Thanks! And what about this? This only place a number 0 or 1 to the database not the name. Why? function setAdminNick(thePlayer, commandName, targetPlayer, name) if getElementData(thePlayer, "fejlesztoBejelentkezve", true) then if not (targetPlayer) then outputChatBox("#F74B4B[Rendszer] #FFFFFF: Helyes használat : / " .. commandName .. " [Név / ID] [Admin név]", thePlayer, 255, 255, 255, true) else local targetPlayer, targetPlayerName = exports.Adminsystem:findPlayer(thePlayer, targetPlayer) local queryHandler = dbQuery(con, 'SELECT * FROM accounts') local result = dbPoll(queryHandler, 500) local ID = getElementData(thePlayer, "acc:id") for num, row in pairs(result) do if (row.id == ID) then local adminname = setElementData(targetPlayer, "adminnick", name) dbExec(con, "UPDATE accounts SET adminnick=?", adminname) outputChatBox("#F74B4B[Rendszer] #FFFFFF: Sikeresen beállítottad: #F74B4B" .. targetPlayerName:gsub("_"," ") .. " #FFFFFFadminisztrátori nevét : #F74B4B" ..getElementData(targetPlayer, "adminnick").. "#FFFFFF.", thePlayer, 255, 255, 255, true) end end end end end
Dimos7 Posted March 1, 2019 Posted March 1, 2019 function setAdminNick(thePlayer, commandName, targetPlayer, name) if getElementData(thePlayer, "fejlesztoBejelentkezve", true) then if not (targetPlayer) then outputChatBox("#F74B4B[Rendszer] #FFFFFF: Helyes használat : / " .. commandName .. " [Név / ID] [Admin név]", thePlayer, 255, 255, 255, true) else local targetPlayer, targetPlayerName = exports.Adminsystem:findPlayer(thePlayer, targetPlayer) local queryHandler = dbQuery(con, 'SELECT * FROM accounts') local result = dbPoll(queryHandler, 500) local ID = getElementData(thePlayer, "acc:id") for num, row in pairs(result) do if (row.id == ID) then local name = getPlayerName(targetPlayer) local adminname = setElementData(targetPlayer, "adminnick", name) dbExec(con, "UPDATE accounts SET adminnick=?", adminname) outputChatBox("#F74B4B[Rendszer] #FFFFFF: Sikeresen beállítottad: #F74B4B" .. targetPlayerName:gsub("_"," ") .. " #FFFFFFadminisztrátori nevét : #F74B4B" ..getElementData(targetPlayer, "adminnick").. "#FFFFFF.", thePlayer, 255, 255, 255, true) end end end end end Try this
Noname20 Posted March 1, 2019 Author Posted March 1, 2019 I want to set the name with the command but I forgot to place the addCommandHandler
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now