SA-MP Forums Archive
[ayuda] GetPlayerIp... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [ayuda] GetPlayerIp... (/showthread.php?tid=370111)



[ayuda] GetPlayerIp... - OTACON - 19.08.2012

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.


Respuesta: [ayuda] GetPlayerIp... - Bu11Sh0t - 19.08.2012

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)



Respuesta: [ayuda] GetPlayerIp... - TheChaoz - 19.08.2012

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.