GTA Közösség - A magyar GTA fórum

San Andreas Multiplayer (SA-MP) => SA-MP: Szerverfejlesztés => A témát indította: Gamestar - 2011. Szeptember 02. - 19:58:50

Cím: IP szûrõ
Írta: Gamestar - 2011. Szeptember 02. - 19:58:50
Írtam egy függvényt, mellyel a szövegen belül elvileg elég jól meg lehet találni az IP helyét. Mellékeltem egy szkriptet is.
ipfind
Paraméterek:
 

Visszatérés:
 

 
stock ipfind(const string[], start = 0, &iplen = -1)
{
new
    pos = -1,
ch = start,
Float:nums = 0,
Float:dots = 0;
while(string[ch++])
{
    if(string[ch] == \'\\0\' || string[ch] == \' \')
{
   continue;
}
if(\'0\' <= string[ch] <= \'9\')
{
    if(pos < 0)
   {
      pos = ch;
   }
   if(dots >= 3)
   {
       iplen = ch - pos;
   }
   nums++;
   if(nums > 3)
   {
            if(floatround(nums / dots) < 2)
      {
          nums = 0;
           dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
   }
   continue;
}
else if(string[ch] == \'.\')
{
   if(nums > 0)
   {
      dots++;
      if(dots > 3)
      {
          nums = 0;
            dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
      if(nums > 3)
      {
         if((floatround(nums / dots) < 2))
          {
              nums = 0;
              dots = 0;
            pos = -1;
            iplen = -1;
            continue;
         }
      }
   }
   else
   {
       if(dots > 0)
       {
           nums = 0;
            dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
   }
   continue;
}
else
{
           if(0 < nums < 8 || 0 < dots < 3)
    {
         nums = 0;
          dots = 0;
      pos = -1;
      iplen = -1;
            }
            continue;
        }
}
if(nums >= 8)
{
if(floatround(nums / dots) < 2)
{
    nums = 0;
     dots = 0;
   pos = -1;
   iplen = -1;
}
}
else
{
    nums = 0;
dots = 0;
pos = -1;
iplen = -1;
}
if(iplen) iplen++;
return pos;
}

 
Szkript:
[pawn]// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
// ipfind függvényt ide másold
stock replacestring(source[], string1[], string2[])
{
new
    pos;
    pos = strfind(source, string1);
while(pos != -1)
{
   strdel(source, pos, pos + strlen(string1));
   strins(source, string2, pos, strlen(string2));
   pos = strfind(source, string1);
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new
    len,
   pos = ipfind(text, 0, len);
if(pos > -1)
{
    new
        ip[32];
   strmid(ip, text, pos, pos + len, sizeof(ip));
   replacestring(text, ip, \"[REKLÁM NINCS]\");
}
return 1;
}[/pawn]
Cím: IP szûrõ
Írta: mcdcadam - 2011. Szeptember 02. - 20:07:45
szép munka :P
GRT GRT..
Ment a +! :D
Cím: IP szûrõ
Írta: herban - 2011. Szeptember 03. - 00:48:11
hasznos jó lett
Cím: IP szûrõ
Írta: ]_[Opel_[ - 2011. Szeptember 03. - 07:00:14
Szép Munka! :D Grat! ;D
Cím: IP szûrõ
Írta: JackBronson - 2011. Szeptember 05. - 16:32:03
Ha nem baj én eszt felhasználom  :P
Am jólett gratulálok.