Jump to content

serial number [help]


Hugos

Recommended Posts

function ...()
	local username = getPlayerName(source)
	local qh_account = dbQuery(db, "SELECT * FROM accounts WHERE username=? LIMIT 1", username)
	local result_account = dbPoll(qh_account, -1)[1]
	if result_account then
	local serial = result_account.serial --serial in DB
    getPlayerSerial(source)
end
  

I have a feature where I get a serial number from the database (6 line) and recognize the player 's serial number at the moment (7 line). I need to compare whether the serial number is recorded in the database or if there is an empty string. If the line is empty - you need to add data (which I received in the 7 line), and if the serial number has already been recorded, I need to break it with the player number (if the number differs - output the text to the console
How to make it?

Link to comment
function ... ()
	local username = getPlayerName(source)
	local qh_account = dbQuery(db, "SELECT * FROM accounts WHERE username=(?) LIMIT 1", username)
	local result_account = dbPoll(qh_account,-1)[1]
	if ( result_account ) then
	local serial = tostring(result_account.serial)
	local userSerial = getPlayerSerial(source)
		if ( serial == userSerial ) then
			outputChatBox("Yes.",source)
			return
		else
			outputChatBox("No.",source)
			return
		end
	end
	return
end

The code you're using is kind different from the ones I use about databases, but this might work.
You just needed to set the serial from the db as a string and check if it's the same as the one from the player.

  • Thanks 1
Link to comment
2 hours ago, Erknneto said:

function ... ()
	local username = getPlayerName(source)
	local qh_account = dbQuery(db, "SELECT * FROM accounts WHERE username=(?) LIMIT 1", username)
	local result_account = dbPoll(qh_account,-1)[1]
	if ( result_account ) then
	local serial = tostring(result_account.serial)
	local userSerial = getPlayerSerial(source)
		if ( serial == userSerial ) then
			outputChatBox("Yes.",source)
			return
		else
			outputChatBox("No.",source)
			return
		end
	end
	return
end

The code you're using is kind different from the ones I use about databases, but this might work.
You just needed to set the serial from the db as a string and check if it's the same as the one from the player.

Thanks. Do not tell us how to save it to the database (how to add such a string)?

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...