Posts: 1,150
Threads: 16
Joined: Oct 2009
Reputation:
0
shouldn't it be Kick(playerid); ?
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by Jakku
I have a total blackout in GetPlayerIp. I wrote this:
pawn Код:
new ip[16]; GetPlayerIp(playerid, ip, sizeof(ip)); if(!strcmp(ip, "85.76.*.*")) { Kick(); }
Somehow, it doesn't take effect. Maybe I have a wrong syntax with the IP or something?
|
You can't use wildcards in strcmp().
pawn Код:
new ip[32];
GetPlayerIp(playerid, ip, sizeof(ip));
if( strfind( ip, "85.76", true, 0 ) != -1 )
{
// They're on the 85.76.*.* range (we're checking the string (ip) from cell 0 to the last cell used in the substring.
Kick( playerid );
}
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by Zeex
Try this:
pawn Код:
if (strcmp(ip, "85.76", false, 5) == 0) // 5 means that strcmp compares only first 5 characters which are "85.76" { Kick(playerid); }
Quote:
Originally Posted by Freddo [BINMAN
]
pawn Код:
new ip[32]; GetPlayerIp(playerid, ip, sizeof(ip)); if( strfind( ip, "85.76", true, 0 ) != -1 ) { // They're on the 85.76.*.* range (we're checking the string (ip) from cell 0 to the last cell used in the substring. Kick( playerid ); }
|
Then *.*.85.76 will also match, and *.85.76.* too
|
Position (optional) The offset to start searching from.
for strfind, it's starting from 0.
Posts: 549
Threads: 20
Joined: Jan 2010
Reputation:
0
OMG, lames! Freddo was first, who posted working code!