Jump to content
×
×
  • Create New...
  • 0

The requirement to verify the presence of the players name


GameAthar

Question

Hello...

At first I apologize because my language is very bad but I will try to be clear.

 

I built a Quest that checks the players data but I did not manage to show an error name in the event that the player does not have a name in the "Players" database Now how do I get an error message if a player doesn't have a in the base?

 

I am using entry () which enables the player to write the player's name and verification has been fetched via the SQL query

 

 

player_search_check = mysql.direct_query("select name from player.player WHERE name = '"..player_search.."';")
table.foreachi(player_search_check,function(i,l) 
	if l[1] == '' then
		chat(" no player in the table ")
	else
		chat(" yes player is in the table ")
	end
	
end)
 
Edited by GameAthar
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
  • Premium
local _, player_search_check = mysql.direct_query(string.format("SELECT name FROM player.player WHERE name = '%s';", player_search));
if (player_search_check[1] ~= nil) then
	-- Player exists in the database.
else
	-- Player doesn't exist in the database.
end -- if/else

 

  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • 0
6 hours ago, Syreldar said:
local _, player_search_check = mysql.direct_query(string.format("SELECT name FROM player.player WHERE name = '%s';", player_search));
if (player_search_check[1] ~= nil) then
	-- Player exists in the database.
else
	-- Player doesn't exist in the database.
end -- if/else

 

 

wow, Now please, how do you i can print in chat or say? 

chat(" hi "..player_search_check[1]..".")

I tried to use the old methods of table but it didn't work without table
 

Edited by GameAthar
Link to comment
Share on other sites

  • 0
  • Premium
local _, player_search_check = mysql.direct_query(string.format("SELECT name FROM player.player WHERE name = '%s';", player_search));
if (player_search_check[1] ~= nil) then
	chat(string.format("Hello %s.", player_search_check[1].name))
	-- or..
	chat(string.format("Hello %s.", player_search)) -- Since the name exist and it will be the same.
else
	-- Player doesn't exist in the database.
end -- if/else

 

Edited by Syreldar

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • 0
On 7/1/2020 at 6:45 PM, Syreldar said:
local _, player_search_check = mysql.direct_query(string.format("SELECT name FROM player.player WHERE name = '%s';", player_search));
if (player_search_check[1] ~= nil) then
	chat(string.format("Hello %s.", player_search_check[1].name))
	-- or..
	chat(string.format("Hello %s.", player_search)) -- Since the name exist and it will be the same.
else
	-- Player doesn't exist in the database.
end -- if/else

 

I tried the but it does not work, and I don't know why!?

Link to comment
Share on other sites

  • 0
  • Premium
1 minute ago, GameAthar said:

I tried the but it does not work, and I don't know why!?

debug it? lol

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

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.


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.