06.08.2010, 14:28
(
Последний раз редактировалось RyDeR`; 19.02.2012 в 21:24.
)
Info
Just a simple piece of code which you can to detect IP adresses.
It returns true/1 if it detects a ip otherwise false/0.
Code
Usage
Block advertisements:
Under OnPlayerText:
This will ban the player if he writes an IP adress like 78.22.66.22:7777 (doesn't matter which IP)
Just a simple piece of code which you can to detect IP adresses.
It returns true/1 if it detects a ip otherwise false/0.
Code
pawn Код:
stock stringContainsIP(const szStr[])
{
new
iDots,
i
;
while(szStr[i] != EOS)
{
if('0' <= szStr[i] <= '9')
{
do
{
if(szStr[i] == '.')
iDots++;
i++;
}
while(('0' <= szStr[i] <= '9') || szStr[i] == '.' || szStr[i] == ':');
}
if(iDots > 2)
return 1;
else
iDots = 0;
i++;
}
return 0;
}
Block advertisements:
Under OnPlayerText:
pawn Код:
if(stringContainsIP(text))
{
new
szMsg[128]
;
GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);
format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
SendClientMessageToAll(0xFF0000FF, szMsg);
Ban(playerid);
return 0;
}