Jump to content

MYSQL gives boolean value


Noname20

Recommended Posts

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"))

 

Link to comment
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 

  • Thanks 1
Link to comment

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

 

Link to comment
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 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...