Ridley
Community Administrator
- Messages
- 1,157
- Points
- 0
- Age
- 38
- Location
- Germany
- Discord
- Ridley#5102
- IRC Nickname
- Ridley
- Github
- ridley8819
- Emulator
- Client Version
- 2019-03-22
This function will check for players with the same IP on the same map.
In the sample, if it finds a player with the same IP on said map, you get warped back to prontera and kicked.
Note: Don't use it recklessly or else you spam your mapserver and might kill it.
function script char_same_unique_id {
.@my_map$ = getarg(0);
// get array of char names who are online from the same IP
query_sql "SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id " +
"WHERE last_ip=(SELECT last_ip FROM login WHERE account_id="+playerattached()+") AND online AND `char`.account_id!=" + playerattached(), .@name$;
// check each char, and see if they are on the map
for (.@i = 0; .@i < getarraysize(.@name$); .@i++) {
getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
if (.@map$ == .@my_map$)
return 1; // another char from this IP is already on that map
}
return 0; // no other chars from this IP are on that map
}
///////////////////////
// Example for usage //
///////////////////////
- script OnPCLoadMapEvent FAKE_NPC,{
OnInit:
setarray(.nodualmaps$[0], "schg_cas06", "schg_cas07", "schg_cas08", "arug_cas06", "arug_cas07", "arug_cas08", "bat_b03");
end;
OnPCLoadMapEvent:
getmapxy(.@map$, .@x, .@y, 0);
// -- BG Maps ---------------------------------
for (.@i = 0; .@i < getarraysize(.nodualmaps$); ++.@i) {
if (.@map$ == .nodualmaps$[.@i]) {
if (callfunc("char_same_unique_id", .nodualmaps$[.@i])) {
dispbottom("No dual clienting in BG please.");
warp("prontera",156,184);
atcommand("@kick " + strcharinfo(PC_NAME));
}
}
}
}
View attachment char_same_unique_id.txt
In the sample, if it finds a player with the same IP on said map, you get warped back to prontera and kicked.
Note: Don't use it recklessly or else you spam your mapserver and might kill it.
function script char_same_unique_id {
.@my_map$ = getarg(0);
// get array of char names who are online from the same IP
query_sql "SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id " +
"WHERE last_ip=(SELECT last_ip FROM login WHERE account_id="+playerattached()+") AND online AND `char`.account_id!=" + playerattached(), .@name$;
// check each char, and see if they are on the map
for (.@i = 0; .@i < getarraysize(.@name$); .@i++) {
getmapxy .@map$, .@x, .@y, 0, .@name$[.@i];
if (.@map$ == .@my_map$)
return 1; // another char from this IP is already on that map
}
return 0; // no other chars from this IP are on that map
}
///////////////////////
// Example for usage //
///////////////////////
- script OnPCLoadMapEvent FAKE_NPC,{
OnInit:
setarray(.nodualmaps$[0], "schg_cas06", "schg_cas07", "schg_cas08", "arug_cas06", "arug_cas07", "arug_cas08", "bat_b03");
end;
OnPCLoadMapEvent:
getmapxy(.@map$, .@x, .@y, 0);
// -- BG Maps ---------------------------------
for (.@i = 0; .@i < getarraysize(.nodualmaps$); ++.@i) {
if (.@map$ == .nodualmaps$[.@i]) {
if (callfunc("char_same_unique_id", .nodualmaps$[.@i])) {
dispbottom("No dual clienting in BG please.");
warp("prontera",156,184);
atcommand("@kick " + strcharinfo(PC_NAME));
}
}
}
}
View attachment char_same_unique_id.txt
Last edited by a moderator: