Alias not work with Nick name

Started by Nihongo^, Jul 07, 2023, 12:38 PM

Previous topic - Next topic

Nihongo^

I made a cmd for discord to retrieve the data of a player

Its works only when i put the UID and IP address but when i put the nick it said

 No player information found
i just want to merge all in one cmd ip uid and nick

!alias  <Nick/UID/IP>
case "alias":
    if (highestRole.GetLevel() < 2) sendMessage(channels["staffchat"], "You do not have permission to use this command.");
    else if (!text) sendMessage(channels["staffchat"], "**USAGE**: !" + cmd + " <Nick/UID/IP>");
    else {
        local b = "";
        local a = 0;

        // Search for players with the same UID
        local q1 = ::QuerySQL(db, "SELECT Name, IP FROM Alias WHERE UID='" + ::escapeSQLString(text) + "'");
        while (::GetSQLColumnData(q1, 0) != null) {
            if (b) {
                b = b + "\nName: " + ::GetSQLColumnData(q1, 0) + " | IP: " + ::GetSQLColumnData(q1, 1);
            } else {
                b = "Name: " + ::GetSQLColumnData(q1, 0) + " | IP: " + ::GetSQLColumnData(q1, 1);
            }
            ::GetSQLNextRow(q1);
            a++;
        }
        ::FreeSQLQuery(q1);

        // If no players with the same UID are found, search for players within the same subnet
        if (a == 0) {
            local q2 = ::QuerySQL(db, "SELECT Name, IP FROM Alias WHERE IP LIKE '" + ::escapeSQLString(text) + "%'");
            while (::GetSQLColumnData(q2, 0) != null) {
                if (b) {
                    b = b + "\nName: " + ::GetSQLColumnData(q2, 0) + " | IP: " + ::GetSQLColumnData(q2, 1);
                } else {
                    b = "Name: " + ::GetSQLColumnData(q2, 0) + " | IP: " + ::GetSQLColumnData(q2, 1);
                }
                ::GetSQLNextRow(q2);
                a++;
            }
            ::FreeSQLQuery(q2);
        }

        if (a >= 1) {
            embed.SetTitle("Player information for: " + text);
            embed.SetColor(0xE3554B);
            embed.SetDescription(b);
            sendEmbed(channels["staffchat"], embed);
        } else {
            sendMessage(channels["staffchat"], "No player information found for: " + text);
        }
    }
   

habi

Nihongo, you must learn what you are doing.
So check the code, what it is doing etc and give a try.
We help those who help themselves.

Nihongo^

Quote from: habi on Jul 08, 2023, 01:45 PMNihongo, you must learn what you are doing.
So check the code, what it is doing etc and give a try.
We help those who help themselves.
I understand i will check it

Thank you

2b2ttianxiu

UID1 it can same with different player
UID2 it can changed
IP starts two numbers
It's can query alias
(In Minecraft only IP can query, so IP startswith it in Minecraft found it)