Max Registrations From IP
#1

Hey guys, i know i've been here alot this night, but i wonder..
I've tried something which used to work but somehow no longer does.
I made a check, to see how much accounts a player has registered under ip X
If it contained more than 3 rows with the same IP the player was kicked.
However it no longer works, it doesn't function anymore

Код:
forward OnRegistrationCheck(playerid);
Код:
public OnRegistrationCheck(playerid)
{
      if(cache_get_row_count() >= 3) 
      {
      SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Server]:{ffffff} You have reached the max registered accounts on this IP, please use your previous account.");
      Kick(playerid);
  }
      return 1;
}
Код:
public OnAccountCheck(playerid)
{
        new rows, fields;
        cache_get_data(rows, fields, mysql);
        if(rows)
        {
                cache_get_field_content(0, "IP", IP[playerid], mysql, 16);
                new newIP[16];
                GetPlayerIp(playerid, newIP, 16);
                IsPlayerRegisterd[playerid] = 1;
                {
                        (!strlen(IP[playerid]) || strcmp(IP[playerid], newIP, true));
                        cache_get_field_content(0, "Password", pData[playerid][Password], mysql, 129);
                        pData[playerid][ID] = cache_get_field_content_int(0, "ID");
                        ShowPlayerDialog(playerid, dLOGIN, DIALOG_STYLE_PASSWORD, "Login", "In order to play, you need to login", "Login", "Quit");
                }
        }
        else
        {
        			 new pIP[16], query[72];
					 GetPlayerIp(playerid, pIP, sizeof(pIP));
					 mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `IP` = '%s'", pIP);
					 mysql_tquery(mysql, query, "OnRegistrationCheck", "s", playerid);
                	 ShowPlayerDialog(playerid, dREGISTER, DIALOG_STYLE_PASSWORD, "Register", "In order to play, you need to register.", "Register", "Quit");
        }

        return 1;
}
Is it because the IP is fetched as a string?
Reply
#2

playerid is a integer not string, should be "i"
pawn Код:
"OnRegistrationCheck", "s", playerid);
Reply
#3

^ What he said.

Also if you only want to count something you should use the COUNT() aggregate function. Sending over the entire resultset (possibly containing hundreds of rows) is more resource intensive and therefore slower. The COUNT() function will always give 1 row with 1 column with 1 value that contains the number of rows. Even if the count is 0.
Reply
#4

Seems that it has helped however, its kicking me before i get the message lol.
Reply
#5

pawn Код:
forward OnRegistrationCheck(playerid, delay);
public OnRegistrationCheck(playerid, delay)
{
    if(delay == 0)
    {
        if(cache_get_row_count() >= 3)
        {
            SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Server]:{ffffff} You have reached the max registered accounts on this IP, please use your previous account.");
            SetTimerEx("OnRegistrationCheck",400,false,"ii",playerid,1); // kick must be delayed few ms
        }
    }
    else
    {
        Kick(playerid);
    }
    return 1;
}
+
in tquery

pawn Код:
"OnRegistrationCheck", "ii", playerid,0);
you should search delayed Kick/Ban include
Reply
#6

Thanks Jeff, ill do that
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)