Jump to content
  • 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 (see edit history)
Link to post

7 answers to this question

Recommended Posts

  • 0
  • Developer
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

? Premium Lua Developer ?

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying those who help them.

-Syreldar

Link to post
  • 0
Posted (edited)
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 (see edit history)
Link to post
  • 0
  • Developer
Posted (edited)
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 (see edit history)

? Premium Lua Developer ?

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying those who help them.

-Syreldar

Link to post
  • 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 post
  • 0
  • Developer
1 minute ago, GameAthar said:

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

debug it? lol

? Premium Lua Developer ?

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying those who help them.

-Syreldar

Link to post

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


×
×
  • Create New...

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.