Raised This Month: $ Target: $400
 0% 

[Request] Block same IP Connect to Server


Post New Thread Reply   
 
Thread Tools Display Modes
Mario AR.
Senior Member
Join Date: May 2011
Location: Lima, Perú
Old 07-10-2014 , 05:03   Re: [Request] Block same IP Connect to Server
Reply With Quote #21

Quote:
Originally Posted by Snitch View Post
I know, I saw the test you did.

But I get just KICK and I do not go in with two computers (same ip), and more children are getting the server and with one computer.
Do that happen only when your server is full? If yes, I think this might be problem: (Fix)
PHP Code:
#include <amxmodx>

new gIP[33];
#define gMaxplayers gIP[0]

public plugin_init() {
    
register_plugin("Kick players on same IP""1.0""[ --{-@ ]");

    
gMaxplayers get_maxplayers();
}

public 
client_disconnect(id)
    
gIP[id] = 0;

public 
client_connect(id) {
    
    static 
IP[16];
    
get_user_ip(idIPcharsmax(IP), 1);

    
gIP[id] = iIP(IP);

    for ( new 
<= gMaxplayers i++ ) {

        if ( 
== id )
            continue;

        if ( 
gIP[id] == gIP[i] ) {
            
server_cmd("kick #%d ^"Someone is already connected with your ip address!^""get_user_userid(id));
            break;
        }
    }
}

stock iIP(IP[]) {
    new 
posret;

    for ( new 
i++ ) {
        
ret |= str_to_num(IP[pos]) << ( ( ) * );
        
pos strfind(IP"."_pos) + 1;
    }
    
    return 
ret;


Last edited by YamiKaitou; 07-10-2014 at 06:47. Reason: derailing thread with pointless bickering
Mario AR. is offline
Old 07-10-2014, 05:24
Kia
This message has been deleted by YamiKaitou. Reason: derailing thread with pointless bickering
Old 07-10-2014, 05:26
fysiks
This message has been deleted by YamiKaitou. Reason: derailing thread with pointless bickering
Old 07-10-2014, 06:01
devilicioux
This message has been deleted by YamiKaitou. Reason: derailing thread with pointless bickering
Old 07-10-2014, 06:41
Mario AR.
This message has been deleted by YamiKaitou. Reason: derailing thread with pointless bickering
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 07-10-2014 , 18:13   Re: [Request] Block same IP Connect to Server
Reply With Quote #22

Quote:
Originally Posted by Mario AR. View Post
Do that happen only when your server is full? If yes, I think this might be problem: (Fix)
PHP Code:
#include <amxmodx>

new gIP[33];
#define gMaxplayers gIP[0]

public plugin_init() {
    
register_plugin("Kick players on same IP""1.0""[ --{-@ ]");

    
gMaxplayers get_maxplayers();
}

public 
client_disconnect(id)
    
gIP[id] = 0;

public 
client_connect(id) {
    
    static 
IP[16];
    
get_user_ip(idIPcharsmax(IP), 1);

    
gIP[id] = iIP(IP);

    for ( new 
<= gMaxplayers i++ ) {

        if ( 
== id )
            continue;

        if ( 
gIP[id] == gIP[i] ) {
            
server_cmd("kick #%d ^"Someone is already connected with your ip address!^""get_user_userid(id));
            break;
        }
    }
}

stock iIP(IP[]) {
    new 
posret;

    for ( new 
i++ ) {
        
ret |= str_to_num(IP[pos]) << ( ( ) * );
        
pos strfind(IP"."_pos) + 1;
    }
    
    return 
ret;

No. It happens that between 10-20 Online
Snitch is offline
Send a message via Skype™ to Snitch
Mario AR.
Senior Member
Join Date: May 2011
Location: Lima, Perú
Old 07-11-2014 , 00:08   Re: [Request] Block same IP Connect to Server
Reply With Quote #23

Try this:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "Block same IPs"
#define VERSION "0.1"
#define AUTHOR "Mario AR."

#pragma semicolon 1

new Trie:g_IPs;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
g_IPs TrieCreate();
}

public 
plugin_end()
    
TrieDestroy(g_IPs);

public 
client_connect(id)
{
    static 
szIP[16];
    
get_user_ip(idszIPcharsmax(szIP), 1);
    
    if (
TrieKeyExists(g_IPsszIP))
        
server_cmd("kick #%d ^"Someone is already connected with your ip address!^""get_user_userid(id));
    else
        
TrieSetCell(g_IPsszIP1);
}

public 
client_disconnect(id)
{
    static 
szIP[16];
    
get_user_ip(idszIPcharsmax(szIP), 1);
    
    
TrieDeleteKey(g_IPsszIP);


Last edited by Mario AR.; 07-11-2014 at 01:06. Reason: A cell can't contain an IP address.
Mario AR. is offline
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 07-11-2014 , 02:06   Re: [Request] Block same IP Connect to Server
Reply With Quote #24

Why Replace Code?
What is different in this code other?

Second code worked well, it blocked two computers from Internet

There was a problem it brings just KICK to children.

Last edited by Snitch; 07-11-2014 at 02:07.
Snitch is offline
Send a message via Skype™ to Snitch
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-11-2014 , 04:23   Re: [Request] Block same IP Connect to Server
Reply With Quote #25

We can't determine the age of the user. What are you talking about?
__________________
Black Rose is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 07-11-2014 , 04:51   Re: [Request] Block same IP Connect to Server
Reply With Quote #26

There is no reason to kick 2 players with the same IP as they have different SteamID
__________________
simanovich is offline
Old 07-11-2014, 04:53
Mario AR.
This message has been deleted by Mario AR.. Reason: Derailing thread with pointless bickering.
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 07-11-2014 , 04:54   Re: [Request] Block same IP Connect to Server
Reply With Quote #27

Well I will explain it like this:

1: The code you gave me (blocked two players connected from same ip)
@ Black Rose
Worked fine, but it gave me KICK, just from the server and I with one computer in Server

2: He asked me if it happens when the server is full = so no.

And now he gave another code that is similar to what you gave, so I ask if it still block if it's still like yours
And he changed the code.

@Simanovich = we no talking about Steam id Here.

Last edited by Snitch; 07-11-2014 at 04:54.
Snitch is offline
Send a message via Skype™ to Snitch
Mario AR.
Senior Member
Join Date: May 2011
Location: Lima, Perú
Old 07-11-2014 , 04:56   Re: [Request] Block same IP Connect to Server
Reply With Quote #28

Quote:
Originally Posted by Snitch View Post
Well I will explain it like this:

1: The code you gave me (blocked two players connected from same ip)
@ Black Rose
Worked fine, but it gave me KICK, just from the server and I with one computer in Server

2: He asked me if it happens when the server is full = so no.

And now he gave another code that is similar to what you gave, so I ask if it still block if it's still like yours
And he changed the code.

@Simanovich = we no talking about Steam id Here.
Try my code, I think the fail was to save the IPs as integers, since cells can't contain IPs (they're larger than the cell size)

Quote:
Originally Posted by simanovich View Post
There is no reason to kick 2 players with the same IP as they have different SteamID
Derailing thread with pointless bickering.
Mario AR. is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-11-2014 , 09:32   Re: [Request] Block same IP Connect to Server
Reply With Quote #29

Quote:
Originally Posted by Mario AR. View Post
Try my code, I think the fail was to save the IPs as integers, since cells can't contain IPs (they're larger than the cell size)
Since one cell is 32 bits and each number in an ip (0-255) turned into an integer will fit into an 8 bit range you can save one ip within one cell as long as the port is excluded.

If you read the number it will be completely different but if you bit shift it you can read the original IP as 4x integers.

Other than that I can't see much difference in my code and your edited one.

Quote:
Originally Posted by Snitch View Post
1: The code you gave me (blocked two players connected from same ip)
@ Black Rose
Worked fine, but it gave me KICK, just from the server and I with one computer in Server
I will do some testing when I get home. I have some theories.
__________________

Last edited by Black Rose; 07-11-2014 at 09:40.
Black Rose is offline
Mario AR.
Senior Member
Join Date: May 2011
Location: Lima, Perú
Old 07-11-2014 , 14:34   Re: [Request] Block same IP Connect to Server
Reply With Quote #30

Quote:
Originally Posted by Black Rose View Post
Since one cell is 32 bits and each number in an ip (0-255) turned into an integer will fit into an 8 bit range you can save one ip within one cell as long as the port is excluded.

If you read the number it will be completely different but if you bit shift it you can read the original IP as 4x integers.

Other than that I can't see much difference in my code and your edited one.



I will do some testing when I get home. I have some theories.
Mmm... you're right, I see...
Then try you version with fakemeta (FM_ClientConnect and FM_ClientDisconnect).
Mario AR. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode