- script IP_map_restriction -1,{
function set_map;
OnInit:
// set_map( "<mapname>",<max ip count> );
set_map( "bat_c01",2 );
set_map( "prontera",1 );
end;
OnPCLoadMapEvent:
// sleep2 1;
.@map$ = strcharinfo(3);
.@count = getd( ".ip_"+.@map$ );
if ( .@count > 0 ) {
query_sql( "SELECT `name` FROM `char` WHERE `online` > 0 AND `account_id` IN ( SELECT `account_id` FROM `login` WHERE `last_ip` = '"+@ip_address$+"' )",.@char_name$ );
.@name_size = getarraysize( .@char_name$ );
.@name$ = strcharinfo(0);
while ( .@i < .@name_size ) {
getmapxy( .@temp_map$,.@x,.@y,0,.@char_name$[.@i] );
if ( .@map$ == .@temp_map$ )
.@online++;
.@i++;
}
if ( .@online > .@count ) {
mes "Your can only have "+.@count+" char with same IP online at this map.";
close2;
warp "SavePoint",0,0;
}
}
end;
OnPCLoginEvent:
// sleep2 1;
@ip_address$ = escape_sql( getcharip() );
end;
function set_map {
.@map$ = getarg(0);
.@count = getarg(1);
if ( .@count && getmapusers( .@map$ ) >= 0 ) {
setd( ".ip_"+.@map$ ),.@count;
setmapflag .@map$,mf_loadevent;
}
return;
}
}