Jump to content
  • 0
GameAthar

open The requirement to verify the presence of the players name

Question

Posted (edited)

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)

Share this post


Link to post

7 answers to this question

Recommended Posts

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

Share this post


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)

Share this post


Link to post
  • 0
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)

Share this post


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!🥺

Share this post


Link to post
  • 0
1 minute ago, GameAthar said:

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

debug it? lol

Share this post


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
  • Recently Browsing   0 members

    No registered users viewing this page.

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