19.11.2011, 13:36
(
Последний раз редактировалось forgottenkings; 20.11.2011 в 06:13.
)
Anti Advertizing System
Description:Hey guys this is just a simple anti ip advertizing system these is nothing less or more so enjoypawn Код:
#include <a_samp>
#define RED 0xE60000FF
stock IsNumeric(string[]) { for (new i = 0, j = strlen(string); i < j; i++) if (string[i] > '9' || string[i] < '0') return 0; return 1; }
public OnPlayerText(playerid, text[])
{
new word[256],Index;while(Index < strlen(text)) {
word = strtok(text,Index);
if(CheckAdv(word)==1){
new i=strfind(text,word),j=i+strlen(word)-1; text[i++]='[';
while(i<j) {text[i]='•';i++;}
text[j]=']';
Kick(playerid);
new string[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "Player %s (ID:%d) has been Kicked/Banned [Reason: IP Adverstiment]", pname, playerid);
SendClientMessageToAll(RED, string);
}
}
return 1;
}
stock CheckAdv(word[])
{
if(strlen(word)>22) return 0;
if(strfind(word,".", true)==-1) return 0;
new ip[5][256],index;
ip[0] = strtok(word,index,'.');
ip[1] = strtok(word,index,'.');
ip[2] = strtok(word,index,'.');
if(strfind(word,":",true)>0){
ip[3] = strtok(word,index,':');
if(strfind(word,",",true)>0) ip[4] = strtok(word,index,',');else ip[4] = strtok(word,index);
} else {
if(strfind(word,",",true)==strlen(word)) ip[3] = strtok(word,index,',');else ip[3] = strtok(word,index);
valstr(ip[4],0);
}
if(!IsNumeric(ip[0])||!IsNumeric(ip[1])||!IsNumeric(ip[2])||!IsNumeric(ip[3])||!IsNumeric(ip[4])
||!strlen(ip[0])||!strlen(ip[1])||!strlen(ip[2])||!strlen(ip[3])||!strlen(ip[4])
||(strval(ip[0])==192&&strval(ip[1])==168)
||(strval(ip[0])==172&&strval(ip[1])>=16&&strval(ip[1])<=31)
||strval(ip[0])==10||(strval(ip[0])==127&&strval(ip[1])==0&&strval(ip[2])==0&&strval(ip[3])==1)) return 0;
return 1;
}
strtok(string[],&idx,seperator = ' ')
{
new ret[128], i = 0, len = strlen(string);
while(string[idx] == seperator && idx < len) idx++;
while(string[idx] != seperator && idx < len)
{
ret[i] = string[idx];
i++;
idx++;
}
while(string[idx] == seperator && idx < len) idx++;
return ret;
}