Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- CREATE TABLE IF NOT EXISTS `max_ip_connect_map` (
- `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
- `last_ip` VARCHAR(100) NOT NULL DEFAULT '',
- `map` VARCHAR(11) NOT NULL DEFAULT 'ALL',
- `max` TINYINT(11) UNSIGNED NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM;
- */
- // Example
- // F_MaxIP( getcharip(),"ALL" ) --> check all maps
- // F_MaxIP( getcharip(),"payon" ) --> check only payon
- function script F_MaxIP {
- .@ip$ = getarg( 0,"" );
- .@target_map$ = getarg( 1,"ALL" );
- if ( .@ip$ != "" ) {
- query_sql( "SELECT `max` FROM `max_ip_connect_map` WHERE `last_ip` = '"+escape_sql( .@ip$ )+"' AND `map` = '"+escape_sql( .@target_map$ )+"' ", .@max );
- // default max limit if record not exist in database.
- if ( .@max <= 0 )
- .@max = 3;
- .@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$ );
- while ( .@i < .@aid_size ) {
- if ( !getmapxy( .@pc_map$,.@pc_x,.@pc_y,0,.@name$[.@i] ) )
- if ( !checkvending( .@name$[.@i] ) ) {
- .@count += ( .@pc_map$ == .@target_map$ || .@target_map$ == "ALL" );
- }
- .@i++;
- }
- return ( .@count < .@max );
- }
- return 1;
- }
- prontera,155,171,5 script Sample#check 757,{
- if ( F_MaxIP( getcharip(),"payon" ) ) {
- warp "payon",0,0;
- }
- else {
- mes "Max IP login reached. You cant enter this map.";
- close;
- }
- end;
- OnPCLoginEvent:
- .@ip$ = getcharip();
- if ( F_MaxIP( .@ip$ ) ) {
- if ( F_MaxIP( .@ip$,strcharinfo(3) ) )
- warp "SavePoint",0,0;
- }
- else {
- mes "Max IP login reached. You will be disconnected.";
- sleep2 5000;
- atcommand "@kick "+strcharinfo(0);
- end;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement