sqlite count() - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sqlite count() (
/showthread.php?tid=632503)
sqlite count() -
GoldenLion - 15.04.2017
Hi, I'm creating a namechange dialog and I don't want the player to be able to change his name if it's used already, but it's not working for some reason. This is the part which is not working:
Код:
new query[100], DBResult:result;
format(query, sizeof(query), "SELECT COUNT(*) FROM accounts WHERE Name = 'q' COLLATE NOCASE", inputtext);
result = db_query(database, query);
if (db_get_field_int(result, 0)) ShowPlayerDialog(playerid, DIALOG_CHANGE_NAME, DIALOG_STYLE_INPUT, "Change Name", "That name is already in use by someone else.\nPlease type your new desired name below:", "Change", "Cancel");
so basically it returns 0 rows while there is actually a row with the name I'm trying to set for myself. What's the problem?
EDIT: lol i'm stupid it has to be %q
Re: sqlite count() -
Nero_3D - 15.04.2017
sorry, didn't saw the edit
Re: sqlite count() -
AndreiWow - 15.04.2017
Not sure if it works but did you try count(id)?
So if it finds any ID with the name that the player entered it means that the name is used