Jump to content
  • 0

How to whitelist IPs in this script?


Question

Posted (edited)

Hello, I am using an IP check/kick script to prevent dual clienting on a certain map. My one problem is that i want to whitelist IPs that have been proven to be actually two individual players and not get kicked by dualing.

 

How to do that?

 

 
- script BG_Check_IP -1,{
OnInit:
    setmapflag "arena", mf_loadevent;
    end;
 
// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:
 
    // Only run for map "arena".
    if (strcharinfo(3) != "arena") end;
 
    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+getcharip()+"'",.@aid);
 
    // Passed check if only the attached player is returned.
    if (.@size < 2) end;
 
    // Check all online characters using the IP address if they are on a Battlegrounds map.
    set .@self, getcharid(3);
    for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
        if (.@aid[.@i] == .@self)
            continue;
        if (attachrid(.@aid[.@i])) {
            if (compare(strcharinfo(3),"arena")) {
                set .@name$, strcharinfo(0);
                attachrid(.@self);
                message strcharinfo(0),"Character "+.@name$+" is already present in this map with your IP. Kicking....";
                sleep2 2000;
    atcommand "@kick "+strcharinfo(0);
                end;
            }
        }
    }
 
    // Passed check.
    end;
}
Edited by Helena

4 answers to this question

Recommended Posts

Posted


- script BG_Check_IP -1,{

OnInit:

setmapflag "arena", mf_loadevent;

set .whitelist$, "| 127.0.0.1 | 127.0.0.2 | etc";

end;

// Trigger when a player enters a map with "loadevent" mapflag.

OnPCLoadMapEvent:

// Only run for map "arena".

if (strcharinfo(3) != "arena") end;

set .@my_ip$, getcharip();

if ( compare( .@my_ip$, .whitelist$ ) ) end;

// Get list of accounts with attached character's IP address.

set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+ .@my_ip$ +"'",.@aid);

// Passed check if only the attached player is returned.

if (.@size < 2) end;

// Check all online characters using the IP address if they are on a Battlegrounds map.

set .@self, getcharid(3);

for(set .@i,0; .@i<.@size; set .@i,.@i+1) {

if (.@aid[.@i] == .@self)

continue;

if (attachrid(.@aid[.@i])) {

if (compare(strcharinfo(3),"arena")) {

set .@name$, strcharinfo(0);

attachrid(.@self);

message strcharinfo(0),"Character "+.@name$+" is already present in this map with your IP. Kicking....";

sleep2 2000;

atcommand "@kick "+strcharinfo(0);

end;

}

}

}

// Passed check.

end;

}

Posted (edited)
 

 

-    script    BG_Check_IP    -1,{
OnInit:
    setmapflag "arena", mf_loadevent;
    set .whitelist$, "| 127.0.0.1 | 127.0.0.2 | etc";
    end;

// Trigger when a player enters a map with "loadevent" mapflag.
OnPCLoadMapEvent:

    // Only run for map "arena".
    if (strcharinfo(3) != "arena") end;
    
    set .@my_ip$, getcharip();
    if ( compare( .@my_ip$, .whitelist$ ) ) end;

    // Get list of accounts with attached character's IP address.
    set .@size, query_sql("SELECT `account_id` FROM `login` WHERE `last_ip` = '"+ .@my_ip$ +"'",.@aid);

    // Passed check if only the attached player is returned.
    if (.@size < 2) end;

    // Check all online characters using the IP address if they are on a Battlegrounds map.
    set .@self, getcharid(3);
    for(set .@i,0; .@i<.@size; set .@i,.@i+1) {
        if (.@aid[.@i] == .@self)
            continue;
        if (attachrid(.@aid[.@i])) {
            if (compare(strcharinfo(3),"arena")) {
                set .@name$, strcharinfo(0);
                attachrid(.@self);
                message strcharinfo(0),"Character "+.@name$+" is already present in this map with your IP. Kicking....";
                sleep2 2000;
    atcommand "@kick "+strcharinfo(0);
                end;
            }
        }
    }

    // Passed check.
    end;
}

 

 

Thank you sir Capuche, I'll try that! :)

 

That works great, is there a way to make it go per several maps? example: arena and prtg_cas01? I've tried to put "arena" || "prtg_cas01 but isn't working. >.<

 

Thank you so much!

Edited by Helena
Posted

That works great, is there a way to make it go per several maps? example: arena and prtg_cas01? I've tried to put "arena" || "prtg_cas01 but isn't working. >.<

 

Thank you so much!

 

Add multiple comparisons in the expression:

if (strcharinfo(3) != "arena" || strcharinfo(3) != "prtg_cas01") end;
Posted (edited)

Tried that but not working. How about the?: setmapflag "arena", mf_loadevent;

and the

if (compare(strcharinfo(3),"arena")) {

 

Maybe those need changing too?

 

 

That works great, is there a way to make it go per several maps? example: arena and prtg_cas01? I've tried to put "arena" || "prtg_cas01 but isn't working. >.<
 
Thank you so much!

 

Add multiple comparisons in the expression:

if (strcharinfo(3) != "arena" || strcharinfo(3) != "prtg_cas01") end;
Edited by Helena

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...