Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Nihongo^ on Jul 07, 2023, 12:38 PM

Title: Alias not work with Nick name
Post by: Nihongo^ on Jul 07, 2023, 12:38 PM
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);
        }
    }
   
Title: Re: Alias not work with Nick name
Post by: habi on Jul 08, 2023, 01:45 PM
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.
Title: Re: Alias not work with Nick name
Post by: Nihongo^ on Jul 08, 2023, 01:55 PM
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
Title: Re: Alias not work with Nick name
Post by: 2b2ttianxiu on Jul 09, 2023, 06:58 PM
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)