Jump to content
  • 0

IP check on battlegrounds


EnigmatiCDreaM

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

Ok, so simply saying I would like to add an IP checker for Battlegrounds (the one already included in rAthena's SVN) to prevent people from dual clienting while using battlegrounds. I know it should be a simple code but I got no clue on how to start writing it(or even write it fully for that matter) and I'm guessing that script would be general and can be implemented in any event/npc/map?

Thank you ~

Link to comment
Share on other sites

11 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

The most practical way I can think of is making all the registration NPCs call an IP check function, which would do something like this:

// callfunc "Check_IP","<map_name>";
function    script    Check_IP    {

   // Get list of accounts with attached character's IP address.
   set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);

   // Passed check if only the attached player is returned.
   if (.@size < 2) return;

   // Check all online characters using the IP address if they're on the given map.
   set .@self, getcharid(3);
   for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
       if (attachrid(.@aid[.@i])) {
           if (strcharinfo(3) == getarg(0)) {
               set .@name$, strcharinfo(0);
               attachrid(.@self);
               mes "Character "+.@name$+" is already logged into Battlegrounds with your IP.";
               close;
           }
       }
   }
   attachrid(.@self);

   // Passed check.
   return;
}

Note that you can't do an SQL query on `last_map` since that field doesn't update in real time.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

making all the registration NPCs call an IP check function

Edit: Ah, after looking at the scripts, it looks like this is more complicated than I'd thought. There's no way (with scripts, at least) to obtain lists of players in an area, as all the waitingrooms are on the same map.

An easy alternative is to check when a player warps to bat_room if a dual-client is on any Battlegrounds map (either a match or bat_room), and kick them appropriately. That script you would only need to add once:

-    script    BG_Check_IP    -1,{
OnInit:
   setmapflag "bat_room", mf_loadevent;
   end;

// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:

   // Only run for map "bat_room".
   if (strcharinfo(3) != "bat_room") end;

   // Get list of accounts with attached character's IP address.
   set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);

   // Passed check if only the attached player is returned.
   if (.@size < 2) end;

   // Check all online characters using the IP address if they are on a Battlegrounds map.
   set .@self, getcharid(3);
   for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
       if (.@aid[.@i] == .@self)
           continue;
       if (attachrid(.@aid[.@i])) {
           if (compare(strcharinfo(3),"bat_")) {
               set .@name$, strcharinfo(0);
               attachrid(.@self);
               message strcharinfo(0),"Character "+.@name$+" is already logged into Battlegrounds with your IP.";
               sleep2 2000;
               warp "SavePoint",0,0;
               end;
           }
       }
   }

   // Passed check.
   end;
}

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  02/16/17
  • Last Seen:  

Can someone help how to add  that script. Im new on scripting. Please help. :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  154
  • Reputation:   6
  • Joined:  04/26/12
  • Last Seen:  

just disable multiple windows then. o.o

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

That would give restriction to dual clienting which is something i want enabled.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

The most practical way I can think of is making all the registration NPCs call an IP check function, which would do something like this:

// callfunc "Check_IP","<map_name>";
function	script	Check_IP	{

// Get list of accounts with attached character's IP address.
set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);

// Passed check if only the attached player is returned.
if (.@size < 2) return;

// Check all online characters using the IP address if they're on the given map.
set .@self, getcharid(3);
for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
	if (attachrid(.@aid[.@i])) {
		if (strcharinfo(3) == getarg(0)) {
			set .@name$, strcharinfo(0);
			attachrid(.@self);
			mes "Character "+.@name$+" is already logged into Battlegrounds with your IP.";
			close;
		}
	}
}
attachrid(.@self);

// Passed check.
return;
}

Note that you can't do an SQL query on `last_map` since that field doesn't update in real time.

Appreciate your help Euphy, thank you very much!

To add the script, should i add it like a normal custom script? or does it have any special way of adding it.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Add it like you would any other script.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

I will try it tonight then, thank you very much!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

Add it like you would any other script.

Hey Euphy, Would I need to restart the server? I just loaded the script and tried KVM BG, i could dual client, It didnt tell me that my character is logged in from another IP.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  12/11/12
  • Last Seen:  

making all the registration NPCs call an IP check function

Edit: Ah, after looking at the scripts, it looks like this is more complicated than I'd thought. There's no way (with scripts, at least) to obtain lists of players in an area, as all the waitingrooms are on the same map.

An easy alternative is to check when a player warps to bat_room if a dual-client is on any Battlegrounds map (either a match or bat_room), and kick them appropriately. That script you would only need to add once:

-	script	BG_Check_IP	-1,{
OnInit:
setmapflag "bat_room", mf_loadevent;
end;

// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:

// Only run for map "bat_room".
if (strcharinfo(3) != "bat_room") end;

// Get list of accounts with attached character's IP address.
set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);

// Passed check if only the attached player is returned.
if (.@size < 2) end;

// Check all online characters using the IP address if they are on a Battlegrounds map.
set .@self, getcharid(3);
for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
	if (.@aid[.@i] == .@self)
		continue;
	if (attachrid(.@aid[.@i])) {
		if (compare(strcharinfo(3),"bat_")) {
			set .@name$, strcharinfo(0);
			attachrid(.@self);
			message strcharinfo(0),"Character "+.@name$+" is already logged into Battlegrounds with your IP.";
			sleep2 2000;
			warp "SavePoint",0,0;
			end;
		}
	}
}

// Passed check.
end;
}

It works great! Appreciate the help! Thank you again Euphy !

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

OnInit:
    setmapflag "bat_room", mf_loadevent;
    end;

// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:

    // Only run for map "bat_room".
    if (strcharinfo(3) != "bat_room") end;

    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);

    // Passed check if only the attached player is returned.
    if (.@size < 2) end;

    // Check all online characters using the IP address if they are on a Battlegrounds map.
    set .@self, getcharid(3);
    for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
        if (.@aid[.@i] == .@self)
            continue;
        if (attachrid(.@aid[.@i])) {
            if (compare(strcharinfo(3),"bat_")) {
                set .@name$, strcharinfo(0);
                attachrid(.@self);
                message strcharinfo(0),"Character "+.@name$+" is already logged into Battlegrounds with your IP.";
                sleep2 2000;
                warp "SavePoint",0,0;
                end;
            }
        }
    }

    // Passed check.
    end;
}

 

I tried this script and change "bat_room" to "guild_vs2" but after I reload/load it, It doesn't work ~ 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...