Quote:
Originally Posted by RyDeR`
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
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; }
Usage
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; }
This will ban the player if he writes an IP adress like 78.22.66.22:7777 (doesn't matter which IP)
|
This doesn't work if the player uses a command like /me, /do, /a etc.
How can I get it to work that way?