Check users under an IP Address
#1

Started it and at this point; I'm stuck



pawn Код:
forward checksamename(playerid);
public checksamename(playerid)
{
    new playeridIP[20];
    new rows = mysql_num_rows();
    GetPlayerIp(playerid, playeridIP, sizeof(playeridIP));
    namequery[300];
    format(namequery, sizeof(namequery), "SELECT `user` FROM `playerinfo` WHERE `IP` = '%s'", playeridIP);
    mysql_query(namequery);
    mysql_store_result();

    if(rows == 1) return 0;
    else if(rows > 1)
    {
        mysql_fetch_row(targetnames, "user");
    }
Long Story short, When a player connects, I will get his IP Address, check the table to see if there's more than 1 account associated with his IP Address. Then send the message to the admins saying he has 'another' account (another = the names of the other account/s)


How would I do that? I'm stuck.
Reply
#2

Umm..

If the rows are over 1 just loop through everyone, check their admin level and if it's above 1 send them a message that the player has another acc.
Also, which SQL plugin are you using?
Reply
#3

Quote:
Originally Posted by Mean
Посмотреть сообщение
Umm..

If the rows are over 1 just loop through everyone, check their admin level and if it's above 1 send them a message that the player has another acc.
I wan't to GET each name associated in the IP Address.
So to speak:

Player has been detected having multiple accounts (%s, %s)

The string as the players names in the ip.

EDIT: I'm using BlueG's MySQL Plugin R6
Reply
#4

I want to make the same thing, but in YINI. Its very helpful detecting cheaters or trollers.
Reply
#5

I hope a lot of this is real intuitive to you, I just reused a lot of the strings.

Just be sure to change parts of the code accordingly (hint: sendmessagetoadminsfunction)
pawn Код:
forward checksamename(playerid);
public checksamename(playerid)
{
    new playeridIP[24];
    GetPlayerIp(playerid, playeridIP, sizeof(playeridIP));
    new namequery[128];
    format(namequery, sizeof(namequery), "SELECT `user` FROM `playerinfo` WHERE `IP` = '%s'", playeridIP);
    mysql_query(namequery);
    mysql_store_result();
   
    GetPlayerName(playerid, playeridIP, sizeof(playeridIP));
    new
        rows = mysql_num_rows();

    if(rows) {
        format(namequery, sizeof(namequery), "User %s has the following accounts associated with his IP.", playeridIP);
        sendmessagetoadminsfunction(namequery);

        while(mysql_retrieve_row()) {
            mysql_get_field("user", playeridIP);

            sendmessagetoadminsfunction(playeridIP);
        }
    }

    mysql_free_result();
    return 1;
}
PS: in your original code, you used mysql_num_rows() before the result was even stored! Be careful with stuff like that
Reply
#6

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
PS: in your original code, you used mysql_num_rows() before the result was even stored! Be careful with stuff like that
Thanks for pointing that out. Tested your code and it works flawlessly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)