23.02.2009, 19:16
IpCheck()
This functions guarantees that what they said was in fact an IP, and bans them.Function
pawn Код:
IpCheck(playerid, text[])
{
new var, pos, oldpos;
oldpos = strfind(text, ".", true);
if(strval(text[oldpos - 1]) == 0) return 1;
while((pos = strfind(text, ".", true, pos + 1)) != -1 && pos - oldpos <= 4)
{
var++;
if(strval(text[pos + 1]) == 0 || text[pos + 1] == ' ') return 1;
oldpos = pos;
if(var == 3 && (pos = strfind(text, ":", true, pos + 1)) != -1)
{
if(strval(text[pos + 1]) == 0 || text[pos + 1] == ' ') return 1;
BanEx(playerid, "Advertising");
return 0;
}
}
return 1;
}
pawn Код:
public OnPlayerText(playerid, text[])
{
IpCheck(playerid, text);
return 1;
}
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
IpCheck(playerid, text);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
IpCheck(playerid, cmdtext);
if(strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}