Jump to content
  • 0

limit chars per IP or MAC, but no limit on @autotrade merchants


Question

Posted

hi guys.

i have a problem.. i'm using this script...works fine, if 2 acc login, the last is kicked.

I need to identify the two accounts, but do not count the @AT merchants.

if i have 10 @at merchants, and 2 online accounts..only 2 online will be checked. and 1 kicked.

- script Only2perIP -1,{

OnPCLoginEvent:

if(getgmlevel()<=99){

end;

} else {

set .@name$, strcharinfo(0);

if (query_sql("SELECT login.account_id FROM login LEFT JOIN `char` ON login.account_id=`char`.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE

account_id="+getcharid(3)+") AND `char`.online=1", .@account_id) > 1) {

announce "Sorry, only 2 accounts per IP are allowed!", bc_self;

sleep 1000;

atcommand "@kick " + .@name$;

}

end;

}

}

sorry for my bad english..

tks.

16 answers to this question

Recommended Posts

  • 1
Posted

ok ...testing..

sorry for my bad explain...

one error now.

script error on npc/custom/oneperip.txt line 871

parse_callfunc: expected ')' to close argument list

866 : announce "esse eh o npc certo",8;

867 : sleep2 5000;

868 : getmapxy(.@amap$,.@mapx,.@mapy,0);

869 : if(.@amap$=="izlude") end;

870 : dispbottom "Sistema anti dual Mac ativado com sucesso!!";

* 871 : if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip='"+getcharip()+"' AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {

Posted

Here you go:

-	script	Only2perIP	-1,{
OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@myname$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip='"+getcharip()+"' AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 2) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@sameip, .@sameip +1;
	}
	if (.@sameip >= 2) {
		announce "Sorry, only 2 accounts per IP can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@myname$;
	}
}
end;
}

  • Upvote 1
Posted

if (getgmlevel() > 99) end;

Isn't 99 the maximum GM level? xD

Correct, this script only allows 2 active players per IP (not counting @autotrade).

So if everyone at a LAN house has the same public IP, only 2 can play.

I can be wrong but I remember those kind of sql ip checking scripts had problems with Internet Cafè's as well...

Posted

nothing happened, no errors , but dont work....i have 5 @at merchants and 2 accounts connected in same time...nobody is kicked.

Oh I thought you wanted to allow 2 active players, and the 3rd to login would be kicked.

Here is the edited script that only allows 1 active player per IP (no limit on @autotrade merchants).

-	script	Only1perIP	-1,{
OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@myname$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip='"+getcharip()+"' AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@sameip, .@sameip +1;
	}
	if (.@sameip >= 1) {
		announce "Sorry, only 1 accounts per IP can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@myname$;
	}
}
end;
}

Posted (edited)

humm..ok updating....

great job, worked well in the last update, thank you for the patience..

regards and thanks again.

nothing happened, no errors , but dont work....i have 5 @at merchants and 2 accounts connected in same time...nobody is kicked.

Oh I thought you wanted to allow 2 active players, and the 3rd to login would be kicked.

Here is the edited script that only allows 1 active player per IP (no limit on @autotrade merchants).

-	script	Only1perIP	-1,{
OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@name$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip='"+getcharip()+"' AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@sameip, .@sameip +1;
	}
	if (.@sameip >= 1) {
		announce "Sorry, only 1 accounts per IP can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@name$;
	}
}
end;
}

me again...

I actually have more players in lan house than I imagined, someone could change this query to read a field called last_mac,

would be the same system, only to read the last_mac not ip field.

once again sorry for my bad english.

Edited by eliandrotc
Posted (edited)
-	script	Only1perMAC	-1,{
OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@myname$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_mac=(SELECT last_mac FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@samemac, .@samemac +1;
	}
	if (.@samemac >= 1) {
		announce "Sorry, only 1 account per computer can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@myname$;
	}
}
end;
}

Edited by Brian
Posted (edited)

Brian, if he uses Harmony he can just edit the config file to reject mutli clients.

yes, I know, but I want to make two maps with dual client enabled.

-	script	Only1perMAC	-1,{
OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@name$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_mac=(SELECT last_mac FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@samemac, .@samemac +1;
	}
	if (.@samemac >= 1) {
		announce "Sorry, only 1 account per computer can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@name$;
	}
}
end;
}

@at merchants were kicked,

only one char can stay logged...no matter the @at.

when I connect two chars, the first to be kicked is at @

any idea???

tks.

Edited by eliandrotc
Posted (edited)

Thats because the script triggers upon login, it does the check right away :P. weird though, looking atit it should work fine.

OnPCLoginEvent:
if (getgmlevel() >= 99) end;
set .@name$, strcharinfo(0);
if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_mac=(SELECT last_mac FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1) {
	for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
		if (checkvending(.@name$[.@i]) != 2)
			set .@samemac, .@samemac +1;
	}
	if (.@samemac >= 1) {
		announce "Sorry, only 1 account per computer can be logged in at a time.", bc_self;
		sleep 1000;
		atcommand "@kick " + .@name$;
	}
}
end;
}

edit:

	if (.@samemac >= 1) {

is greater than or equal to one, thus will always kick the player :P. Also, doesn't it kick the player because .@name$ is also the Array name?

Edited by garet999
Posted (edited)
Also, doesn't it kick the player because .@name$ is also the Array name?

oops you're right, thanks garet!

Edited by Brian
fixed in previous posts

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...