12.04.2012, 14:05
No need to use a buffer there. strval will read until it reaches anything else than digits (a dot in this case).
Ex.:
Ex.:
pawn Код:
// Modified version from YSI/y_utils
stock GetIPFromString(const ip[])
{
new
ipv = strval(ip) << 24,
pos = 0;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 16;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]) << 8;
while (pos < 15 && ip[pos++] != '.') {}
ipv += strval(ip[pos]);
return ipv;
}