[ayuda] GetPlayerIp...
#1

Buenas A todos, Kisiera saber como podria poner ke GetPlayerIp chequee si uan ip es mayor o igua o menor o igual, ejemplo:

if(ip >= "128.0.0.0" || ip <= "255.255.255.255")

Hay estaria, pero mi problema esta ke GetPlayerIp lo tengo ke poner en strcmp y no se me ocurre como ubicarlo alli :S

Desde Ya muchas Gracias.
Reply
#2

Creo que seria separar el string en nъmeros normales con la funciуn 'token_by_delim' (que se usa en gl_commons) y hacer lo mismo que haces:

pawn Код:
if(numero1 >= 128 && numero2 >= 0 && numero3 >= 0 && numer4 >= 0)
Reply
#3

Puedes utilizar la funcion de JernejL:
pawn Код:
// please note that this is NOT a perfect inet_aton function, but you will not be able to output the number as a unsigned integer as pawn uses signed int32 only.
// (by specification the returned type of inet_aton should be UNSIGNED int 32)
// example conversion failures:
// 127.0.0.1 -> 2130706433
// 128.68.103.132 -> -2143000700

stock inet_aton(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;
}
y comparar con los valores obtenidos para evitar el transpaso y comparacion de strcmp que seria algo diferente y menos optimo.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)