Advertisement
Emistry

[RO] max ip map connection

Dec 21st, 2015
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1.  
  2. /*
  3.  
  4.     CREATE TABLE IF NOT EXISTS `max_ip_connect_map` (
  5.         `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  6.         `last_ip` VARCHAR(100) NOT NULL DEFAULT '',
  7.         `map` VARCHAR(11) NOT NULL DEFAULT 'ALL',
  8.         `max` TINYINT(11) UNSIGNED NOT NULL DEFAULT '0',
  9.         PRIMARY KEY (`id`)
  10.     ) ENGINE=MyISAM;
  11.  
  12. */
  13.  
  14. // Example
  15. // F_MaxIP( getcharip(),"ALL" )   --> check all maps
  16. // F_MaxIP( getcharip(),"payon" ) --> check only payon
  17.  
  18. function    script  F_MaxIP {
  19.     .@ip$ = getarg( 0,"" );
  20.     .@target_map$ = getarg( 1,"ALL" );
  21.    
  22.     if ( .@ip$ != "" ) {
  23.         query_sql( "SELECT `max` FROM `max_ip_connect_map` WHERE `last_ip` = '"+escape_sql( .@ip$ )+"' AND `map` = '"+escape_sql( .@target_map$ )+"' ", .@max );
  24.         // default max limit if record not exist in database.
  25.         if ( .@max <= 0 )
  26.             .@max = 3;
  27.            
  28.         .@aid_size = query_sql( "SELECT`account_id`,`name` FROM `char` WHERE `online` = 1 AND `account_id` IN (  SELECT `account_id` FROM `login` WHERE `last_ip` = '"+escape_sql( .@ip$ )+"' )",.@aid,.@name$ );
  29.         while ( .@i < .@aid_size ) {
  30.             if ( !getmapxy( .@pc_map$,.@pc_x,.@pc_y,0,.@name$[.@i] ) )
  31.                 if ( !checkvending( .@name$[.@i] ) ) {
  32.                     .@count += ( .@pc_map$ == .@target_map$ || .@target_map$ == "ALL" );   
  33.                 }
  34.             .@i++;
  35.         }
  36.         return ( .@count < .@max );
  37.     }
  38.     return 1;
  39. }
  40.  
  41.  
  42. prontera,155,171,5  script  Sample#check    757,{
  43.  
  44.     if ( F_MaxIP( getcharip(),"payon" ) ) {
  45.         warp "payon",0,0;
  46.     }
  47.     else {
  48.         mes "Max IP login reached. You cant enter this map.";
  49.         close;
  50.     }
  51.     end;
  52.    
  53.     OnPCLoginEvent:
  54.         .@ip$ = getcharip();
  55.         if ( F_MaxIP( .@ip$ ) ) {
  56.             if ( F_MaxIP( .@ip$,strcharinfo(3) ) )
  57.                 warp "SavePoint",0,0;
  58.         }
  59.         else {
  60.             mes "Max IP login reached. You will be disconnected.";
  61.             sleep2 5000;
  62.             atcommand "@kick "+strcharinfo(0);
  63.             end;
  64.         }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement