Jump to content
  • 0

Please check my script. Thank you!


Aya

Question


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  125
  • Reputation:   2
  • Joined:  08/27/12
  • Last Seen:  


- script Dont_allow_2_clients -1,{

end;


OnPCLoginEvent:
query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP;
query_sql "INSERT INTO On_ip_table ("+@RIDIP+")";
query_sql "UPDATE On_ip_table SET ips_online = ips_online + 1 WHERE last_ip = "+@RIDIP+"";
query_sql "SELECT ips_online FROM on_ip_table WHERE last_ip = "+@RIDIP+"",@TIMESON;
if(@TIMESON >= 2) {
dispbotton "[staff]";
dispbotton strcharinfo(0)+" you can't log with two windows opened";
dispbotton "I need kick you now";
sleep2 5000; // Just to the player read.
atcommand "@kick "+strcharinfo(0);
}
end;

OnPCLogoutEvent:
query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP;
query_sql "UPDATE on_ip_table SET ips_online = 0 WHERE last_ip = "+@RIDIP+"";
end;

OnInit:
CREATE TABLE IF NOT EXISTS on_ip_table (last_ip varchar(100) NOT NULL default '',ips_online int(11) NOT NULL DEFAULT '0',PRIMARY KEY  (`last_ip`)) ENGINE=MyISAM AUTO_INCREMENT=2000000;// SET THE ENGINE MAKE THE TABLE BE ACESSED FASTER

}

Please check my script. This script SHOULD not allow players to log in using the same IP. Thank you! I made this script to prevent sandbox users. Thank you

Edited by Aya
Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  815
  • Reputation:   86
  • Joined:  10/26/12
  • Last Seen:  

("SELECT name, char.account_id, last_ip FROM `char` LEFT JOIN `login` ON login.account_id = char.account_id where name = '" + escape_sql(.@frnd$) + "'",.@chname$, .@account_id, .@flastip$);

btw instead using this just disable dual clients in diff

Link to comment
Share on other sites


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

Just saying, but you know that an IP contains "." right? Those are not numeric so you need "$" at the end of "@RIDIP" > "@RIDIP$"

Also

query_sql "INSERT INTO On_ip_table ("+@RIDIP+")"; 

is wrong, well as far as I know.

Correct format:

query_sql "INSERT INTO `On_ip_table` (`last_ip`) VALUES ('"+@RIDIP$+"')";

Note: " ` " is an habit of mine to use them always, official format. :I

Yours is the faster way :o, but well.

I noticed also that "dispbotton" is false written > "dispbottom"

Here is my version:

- script Dont_allow_2_clients -1,{

end;


OnPCLoginEvent:
query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP$;
// Checking if the IP isn't inserted into the On_ip_table
if(query_sql("SELECT `last_ip` FROM `On_ip_table` WHERE `last_ip` = '"+@RIDIP$+"'",.@ip_check$) == "")
// If not inserted yet, do it.....
query_sql "INSERT INTO On_ip_table (`last_ip` ) VALUES ('"+@RIDIP$+"')";
query_sql "UPDATE On_ip_table SET ips_online = ips_online + 1 WHERE last_ip = "+@RIDIP$+"";
query_sql "SELECT ips_online FROM on_ip_table WHERE last_ip = "+@RIDIP$+"",@TIMESON;
if(@TIMESON >= 2) {
dispbottom "[staff]";
dispbottom strcharinfo(0)+" you can't log with two windows opened";
dispbottom "I need kick you now";
sleep2 5000; // Just to the player read.
atcommand "@kick "+strcharinfo(0);
}
end;

OnPCLogoutEvent:
// No need for this line since the variable "@RIDIP$" will be cleared on logout or when you overwrite it,
// and I don't believe that the IP changes while being ingame 
//query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP$;
query_sql "UPDATE on_ip_table SET ips_online = 0 WHERE last_ip = "+@RIDIP$+"";
end;

OnInit:
CREATE TABLE IF NOT EXISTS on_ip_table (last_ip varchar(100) NOT NULL default '',ips_online int(11) NOT NULL DEFAULT '0',PRIMARY KEY  (`last_ip`)) ENGINE=MyISAM AUTO_INCREMENT=2000000;// SET THE ENGINE MAKE THE TABLE BE ACESSED FASTER

}

("SELECT name, char.account_id, last_ip FROM `char` LEFT JOIN `login` ON login.account_id = char.account_id where name = '" + escape_sql(.@frnd$) + "'",.@chname$, .@account_id, .@flastip$);

btw instead using this just disable dual clients in diff

That SQL code is in my opinion for people who have a better knowledge of MySQL.

The Diff is against Dual Clients, but what about when someone has 2 Computers? :o

Regards,

Chris

Edited by llchrisll
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  815
  • Reputation:   86
  • Joined:  10/26/12
  • Last Seen:  

Just saying, but you know that an IP contains "." right? Those are not numeric so you need "$" at the end of "@RIDIP" > "@RIDIP$"

Also

query_sql "INSERT INTO On_ip_table ("+@RIDIP+")"; 

is wrong, well as far as I know.

Correct format:

query_sql "INSERT INTO `On_ip_table` (`last_ip`) VALUES ('"+@RIDIP$+"')";

Note: " ` " is an habit of mine to use them always, official format. :I

Yours is the faster way :o, but well.

I noticed also that "dispbotton" is false written > "dispbottom"

Here is my version:

- script Dont_allow_2_clients -1,{

end;


OnPCLoginEvent:
query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP$;
// Checking if the IP isn't inserted into the On_ip_table
if(query_sql("SELECT `last_ip` FROM `On_ip_table` WHERE `last_ip` = '"+@RIDIP$+"'",.@ip_check$) == "")
// If not inserted yet, do it.....
query_sql "INSERT INTO On_ip_table (`last_ip` ) VALUES ('"+@RIDIP$+"')";
query_sql "UPDATE On_ip_table SET ips_online = ips_online + 1 WHERE last_ip = "+@RIDIP$+"";
query_sql "SELECT ips_online FROM on_ip_table WHERE last_ip = "+@RIDIP$+"",@TIMESON;
if(@TIMESON >= 2) {
dispbottom "[staff]";
dispbottom strcharinfo(0)+" you can't log with two windows opened";
dispbottom "I need kick you now";
sleep2 5000; // Just to the player read.
atcommand "@kick "+strcharinfo(0);
}
end;

OnPCLogoutEvent:
// No need for this line since the variable "@RIDIP$" will be cleared on logout or when you overwrite it,
// and I don't believe that the IP changes while being ingame 
//query_sql "SELECT last_ip FROM login WHERE account_id = "+getcharid(3)+"",@RIDIP$;
query_sql "UPDATE on_ip_table SET ips_online = 0 WHERE last_ip = "+@RIDIP$+"";
end;

OnInit:
CREATE TABLE IF NOT EXISTS on_ip_table (last_ip varchar(100) NOT NULL default '',ips_online int(11) NOT NULL DEFAULT '0',PRIMARY KEY  (`last_ip`)) ENGINE=MyISAM AUTO_INCREMENT=2000000;// SET THE ENGINE MAKE THE TABLE BE ACESSED FASTER

}

("SELECT name, char.account_id, last_ip FROM `char` LEFT JOIN `login` ON login.account_id = char.account_id where name = '" + escape_sql(.@frnd$) + "'",.@chname$, .@account_id, .@flastip$);

btw instead using this just disable dual clients in diff

That SQL code is in my opinion for people who have a better knowledge of MySQL.

The Diff is against Dual Clients, but what about when someone has 2 Computers? :o

Regards,

Chris

computer cafe/internet shops yeah o.o

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  125
  • Reputation:   2
  • Joined:  08/27/12
  • Last Seen:  

Well basically what I want to happen is to allow players who play in different computer sharing the same IP as far as concern for those who are in a Computer Shop. What I do not want is that when, someone is going to login using the SAME IP he is using, meaning this guy is using SandBoxie (A software that allows dual client even the diff is DISABLED MULTIPLE CLIENTS.)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I believe your request means your server needs to equip Harmony ...

rathena doesn't have this feature

http://rathena.org/board/topic/74823-limit-chars-per-ip-or-mac-but-no-limit-on-autotrade-merchants/#entry159618

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  125
  • Reputation:   2
  • Joined:  08/27/12
  • Last Seen:  

O okay! I just can't affor Harmony that's why I am making custom defenses for my server :D Thank you!

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...