Fixing Anti Advertisment - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Fixing Anti Advertisment (
/showthread.php?tid=249318)
Fixing Anti Advertisment -
xxjackoxx - 18.04.2011
Hi guys , I have spent a long time away from scripting , and Am having trouble getting my head back around to it..( arggh lol)
I am using this for anti advertise , its pretty old code
Код:
public OnFilterScriptInit()
{
print(" Anti Advertisment ");
return 1;
}
public OnFilterScriptExit() return 1;
public OnPlayerText(playerid, text[])
{
if(FindIP(text)) return kick4IP(playerid, text);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(FindIP(cmdtext)) return kick4IP(playerid, cmdtext);
return 0;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//FUCTION
FindIP(StrToChk[])
{
new IpLevel = 0;
for(new a = 0; a < strlen(StrToChk); a++) {
switch(IpLevel)
{
case 0:{
if(IsNum(StrToChk[a])) IpLevel++;
}
case 1, 2:{
if(IsNum(StrToChk[a])) IpLevel++;
else if(StrToChk[a] == '.') IpLevel = 4;
else IpLevel = 0;
}
case 3:{
if(StrToChk[a] == '.') IpLevel++;
else IpLevel = 0;
}
case 4:{
if(IsNum(StrToChk[a])) IpLevel++;
else IpLevel = 0;
}
case 5, 6:{
if(IsNum(StrToChk[a])) IpLevel++;
else if(StrToChk[a] == '.') IpLevel = 8;
else IpLevel = 0;
}
case 7:{
if(StrToChk[a] == '.') IpLevel++;
else IpLevel = 0;
}
case 8:{
if(IsNum(StrToChk[a])) IpLevel++;
else IpLevel = 0;
}
case 9, 10:{
if(IsNum(StrToChk[a])) IpLevel++;
else if(StrToChk[a] == '.') IpLevel = 12;
else IpLevel = 0;
}
case 11:{
if(StrToChk[a] == '.') IpLevel++;
else IpLevel = 0;
}
case 12:{
if(IsNum(StrToChk[a])) return 1;
else IpLevel = 0;
}
}
}
return 0;
}
IsNum(textchar)
{
if(textchar == '0') return 1;
if(textchar == '1') return 1;
if(textchar == '2') return 1;
if(textchar == '3') return 1;
if(textchar == '4') return 1;
if(textchar == '5') return 1;
if(textchar == '6') return 1;
if(textchar == '7') return 1;
if(textchar == '8') return 1;
if(textchar == '9') return 1;
return 0;
}
//END OF FUNCTION
I am trying to make it so that there can be exception ips , but I am not 100% sure on what to do.
Does anyone any tips or code to help me?
Cheers guys & have a good day.
Re: Fixing Anti Advertisment -
xxjackoxx - 19.04.2011
**bump**
Re: Fixing Anti Advertisment -
xxjackoxx - 19.04.2011
shameless self bump
Re: Fixing Anti Advertisment -
cessil - 20.04.2011
i created a stock called "IsNum" and when i cycle through each character in the string I use that and a check with .'s
this should help you get on the right path
pawn Код:
stock isnum(text[])
{
new str[2];
format(str,sizeof(str),"%s",text);
if(!strcmp(str,"0",false)) return 1;
if(strval(str[0]) == strval(str[1])) return 0;
if(strval(text) >= 1) return 1;
return 0;
}
Re: Fixing Anti Advertisment -
xxjackoxx - 21.04.2011
Thanks cessil , I will try that out.