viewing paste IP Map Restriction | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
-   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;
    }
}
Viewed 1127 times, submitted by Emistry.