02.09.2008, 14:53
ip_strtok
What it does: strtok's IPs (e.g. "193.11.52.214" => "193" / "11" / "52" / "214")
Note: Minimum result string length must be 4.
Example:
Code:
What it does: strtok's IPs (e.g. "193.11.52.214" => "193" / "11" / "52" / "214")
Note: Minimum result string length must be 4.
Example:
pawn Код:
public OnPlayerConnect(playerid)
{
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
new idx, ip1[4], ip2[4];
ip1 = ip_strtok(ip, idx);
ip2 = ip_strtok(ip, idx);
new str[128];
format(str, sizeof(str), "*** %s's IP Range: %s.%s.*.*", ip1, ip2);
SendClientMessageToAll(0xFFFFFFFF, str);
}
pawn Код:
stock ip_strtok(const string[], &index)
{
new index2, result[4];
index2 = strfind(string, ".", false, index);
if (index2 == -1)
{
if (strlen(string) > index)
{
strmid(result, string, index, strlen(string), 30);
index = strlen(string);
}
return result;
}
if (index2 > (index + 29))
{
index2 = index + 29;
strmid(result, string, index, index2, 30);
index = index2;
return result;
}
strmid(result, string, index, index2, 30);
index = index2 + 1;
return result;
}