Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define pesticide_version "1.0.0"
- /*
- -------------------------------------------------------------------------------------
- The ©Pesticide Blacklist is a project by André "DeathOnaStick" Brandenburger
- By using and/or compiling this script you are aware of...
- ...that you are not allowed to use this script for illegal purposes
- ...that you are not allowed to ban innocent people when using this script
- ...that you are not allowed to connect to the URLs manually, except blacklist.pytalhost.net/index.php
- ...that you are not allowed to change this script, neither by adding or changing something, nor by adding codelines
- If you do not agree, you are neither allowed to compile this script, nor allowed to use it.
- Thank you for your understanding.
- Have Fun!
- -------------------------------------------------------------------------------------
- */
- /* ~ Settings ~ */
- #define ForceVerification
- #define ECHO_DATA
- /* ~ */
- #include <a_samp>
- #include <a_http>
- #include <pesticide>
- #pragma unused pesticide_Ban
- #pragma unused pesticide_BanEx
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_SYSTEM 0xEFEFF7AA
- /* Macros */
- #define PingServer();\
- pingvar=GetTickCount();\
- new PingAccess[100];\
- format(PingAccess, sizeof(PingAccess), "%s/pesticide.php?ping=1", pbServer);\
- HTTP(707, HTTP_GET, PingAccess, "", "OnPingResponse");
- #define Verify(%0);\
- new pIP[16];\
- GetPlayerIp(%0, pIP, sizeof(pIP));\
- new submitString[25+sizeof(pbServer)+sizeof(pIP)];\
- format(submitString, sizeof(submitString), "%s/pesticide.php?IP=%s",pbServer, pIP);\
- HTTP(%0, HTTP_GET, submitString, "", "UserVerification");
- #define SendBlacklistRequest(%0);\
- new submitString[100+MAX_PLAYER_NAME+2];\
- new PName[MAX_PLAYER_NAME];\
- GetPlayerName(%0, PName, sizeof(PName));\
- new PIP[16];\
- GetPlayerIp(%0, PIP, sizeof(PIP));\
- format(submitString, sizeof(submitString), "%s/pesticide.php?name=%s&IP=%s", pbServer, PName, PIP);\
- HTTP((85+%0), HTTP_GET, submitString, "", "ResponseOnRequest");
- /* ~ */
- new pingvar=0;
- new bool:connected=false;
- new pbServer[50]="blacklist.pytalhost.net";
- new pingtimerid;
- forward OnPingResponse(index, response_code, data[]);
- forward UserVerification(index, response_code, data[]);
- forward ResponseOnRequest(index, response_code, data[]);
- forward pesticide_force(playerid);
- forward pesticide_ping();
- forward pb_Ban(playerid, bool:ex, reason[]);
- public pb_Ban(playerid, bool:ex, reason[]){
- SendBlacklistRequest(playerid);
- }
- public OnPingResponse(index, response_code, data[])
- {
- #if defined ECHO_DATA
- printf("%s",data);
- #endif
- if(response_code!=200)
- {
- printf("#ERROR %i: Client could not connect to pb-Server.", response_code);
- printf("#ERROR %i: #-> Cannot access to Pesticide-Database.", response_code);
- connected=false;
- KillTimer(pingtimerid);
- pingtimerid=SetTimer("pesticide_Ping", 10*60*1000, false);
- }
- else
- {
- new entries=0, newestvers[10];
- sscanf(data, "p|isz", entries, newestvers);
- new v1, v2, v3;
- sscanf(newestvers, "p.iii", v1,v2,v3);
- new pseuv1,pseuv2,pseuv3;
- sscanf(pesticide_version, "p.iii", pseuv1,pseuv2,pseuv3);
- printf("#You are using Pesticide v.%s. Newest version: v.%i.%i.%i.", pesticide_version, v1,v2,v3);
- if(v1>pseuv1)
- {
- print("#Warning: Extremely important changes have been done with the newest version of (c)Pesticide!");
- print("#Warning: Please visit forum.sa-mp.com and search for pesticide \n#Warning: to find the download-link to the newest version.");
- print("#Warning: Alternatively you could also visit blacklist.pytalhost.com.");
- printf("%c", 7);
- }
- else if(v2>pseuv2)
- {
- print("#Warning: Major changes have been done with the newest version of (c)Pesticide.");
- print("#Warning: Please visit forum.sa-mp.com and search for pesticide \n#Warning: to find the download-link to the newest version.");
- print("#Warning: Alternatively you could also visit blacklist.pytalhost.com.");
- }
- else
- {
- if((v3<=pseuv3&&v2<=pseuv2&&v1<=pseuv1)||(v2<=pseuv2&&v1<=pseuv1)||(v1<=pseuv1))
- {
- print("#Your version of Pesticide is up to date.");
- }
- printf("#Pesticide: Database pinged with %i entries. Ping: %i",entries, GetTickCount()-pingvar);
- if(connected==false)
- {
- for(new i=0, tx=GetMaxPlayers(); i<=tx; i++)if(IsPlayerConnected(i))if(!IsPlayerNPC(i))
- {
- Verify(i);
- }
- connected=true;
- KillTimer(pingtimerid);
- pingtimerid=SetTimer("pesticide_Ping", 45*60*1000, false);
- }
- }
- }
- return 1;
- }
- public UserVerification(index, response_code, data[])
- {
- #if defined ECHO_DATA
- printf("%s",data);
- #endif
- if(response_code==200)
- {
- if(connected==false)
- {
- for(new i=0, tx=GetMaxPlayers(); i<=tx; i++)if(IsPlayerConnected(i))if(!IsPlayerNPC(i))if(i!=index)
- {
- Verify(i);
- }
- connected=true;
- }
- new amount, day, month, year;
- if (sscanf(data, "p|iiii", amount, day, month, year))
- {
- SendClientMessage(index, COLOR_SYSTEM, "This server is {C8400B}protected {EFEFF7}by Pesticide.");
- SendClientMessage(index, COLOR_SYSTEM, "Your connection information has been {33AA33}verified{EFEFF7}.");
- SetPVarInt(index, "pesticide_uservalid", 1);
- return 1;
- }
- else
- {
- new tday, tmonth, tyear, Sum, BDays=1;
- getdate(tyear, tmonth, tday);
- Sum=CalculateDaysBetweenDates(day,month,year,tday,tmonth,tyear);
- while(amount>0){
- BDays*=3;
- amount--;
- }
- if(BDays<=Sum)
- {
- SendClientMessage(index, COLOR_SYSTEM, "This server is {33AA33}protected {EFEFF7}by Pesticide.");
- SendClientMessage(index, COLOR_SYSTEM, "Your connection information has been {33AA33}verified{EFEFF7}.");
- SetPVarInt(index, "pesticide_uservalid", 1);
- return 1;
- }
- else
- {
- SendClientMessage(index, COLOR_SYSTEM, "This server is {33AA33}protected {EFEFF7}by Pesticide.");
- SendClientMessage(index, COLOR_SYSTEM, "Your connection information is {E31515}verified as banned{EFEFF7}.");
- SendClientMessage(index, COLOR_SYSTEM, "You are {4F4F4F}blacklisted{EFEFF7} from all (c){E31515}Pesticide{E31515}-Servers.");
- new pIP[16];
- GetPlayerIp(index, pIP, sizeof(pIP));
- printf("#Pesticide: Database-entry of %s verified by pb-Server. Connection rejected. ", pIP);
- return Kick(index);
- }
- }
- }
- else
- {
- SendClientMessage(index, COLOR_SYSTEM, "This server is {33AA33}protected {EFEFF7}by (c){E31515}Pesticide{E31515}.");
- SendClientMessage(index, COLOR_SYSTEM, "The (c){E31515}Pesticide{EFEFF7}-Blacklist is currently {E31515}offline{EFEFF7}.");
- connected=false;
- return 1;
- }
- }
- public ResponseOnRequest(index, response_code, data[])
- {
- #if defined ECHO_DATA
- printf("%s",data);
- #endif
- if(response_code==200)
- {
- if(strfind(data, "LREACHED")!=-1){print("#Pesticide: You have reached your blacklist limit.");print("#Pesticide: You can try again next hour.");}
- else if(strfind(data, "SINVALID")!=-1){print("#Pesticide: Your server has been marked as invalid.");print("#Pesticide: You cannot blacklist players anymore.\n#Pesticide: Connection rejected.");}
- else if(strfind(data, "1")!=-1)print("#Pesticide: Successfully sent a blacklist-request to Server.");
- else printf("Unknown Error: %s", data);
- }
- return 1;
- }
- public pesticide_ping()
- {
- PingServer();
- }
- public pesticide_force(playerid)
- {
- if(GetPVarInt(playerid, "pesticide_uservalid")!=1)
- {
- print("#!Pesticide: User-Verification timed out. Connection rejected. ~!!!~");
- SendClientMessage(playerid, COLOR_RED, "Warning: Verification timed out. Connection rejected.");
- return Kick(playerid);
- }
- else return 1;
- }
- public OnPlayerConnect(playerid)
- {
- #if defined ForceVerification
- if(connected==true)
- {
- SetPVarInt(playerid, "pesticide_timerid", SetTimerEx("pesticide_force", 3*60*1000, false, "i", playerid));
- }
- #endif
- Verify(playerid);
- }
- public OnPlayerDisconnect(playerid)
- {
- KillTimer(GetPVarInt(playerid, "pesticide_timerid"));
- }
- public OnFilterScriptInit()
- {
- print("\n\
- =========================(c)Pesticide==========================\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\
- ## (c)Pesticide-Filterscript and Database [FS LOADED] ##\n\
- ## by André \"DeathOnaStick\" Brandenburger ##\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\
- ===============================================================\n");
- PingServer();
- return 1;
- }
- sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {return format[0];}
- #pragma tabsize 4
- new formatPos = 0,stringPos = 0,paramPos = 2,paramCount = numargs(),delim = ' ';while (string[stringPos] && string[stringPos] <= ' '){stringPos++;}
- while (paramPos < paramCount && string[stringPos]){
- switch (format[formatPos++]){case '\0':{return 0;}case 'i', 'd':{
- new neg = 1,num = 0,ch = string[stringPos];if (ch == '-'){neg = -1;ch = string[++stringPos];}
- do{stringPos++;if ('0' <= ch <= '9'){num = (num * 10) + (ch - '0');}else {return -1;}}
- while ((ch = string[stringPos]) > ' ' && ch != delim);setarg(paramPos, 0, num * neg);}case 'h', 'x':{
- new num = 0,ch = string[stringPos];do{stringPos++;switch (ch){case 'x', 'X':{num = 0;continue;}case '0' .. '9':{num = (num << 4) | (ch - '0');}case 'a' .. 'f':{num = (num << 4) | (ch - ('a' - 10));}case 'A' .. 'F':{num = (num << 4) | (ch - ('A' - 10));}default:{return -1;}}}while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);}case 'c':{setarg(paramPos, 0, string[stringPos++]);}case 'f':{
- new changestr[16], changepos = 0, strpos = stringPos;while(changepos < 16 && string[strpos] && string[strpos] != delim){
- changestr[changepos++] = string[strpos++];}changestr[changepos] = '\0';setarg(paramPos,0,_:floatstr(changestr));}case 'p':{delim = format[formatPos++];continue;}case '\'':{
- new end = formatPos - 1,ch;while ((ch = format[++end]) && ch != '\'') {}if (!ch){
- return -1;}format[end] = '\0';if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1){
- if (format[end + 1]){return -1;}
- return 0;}format[end] = '\'';stringPos = ch + (end - formatPos);formatPos = end + 1;}case 'u':{
- new end = stringPos - 1,id = 0,bool:num = true,ch;while ((ch = string[++end]) && ch != delim){if (num){if ('0' <= ch <= '9'){id = (id * 10) + (ch - '0');}else{num = false;}}}
- if (num && IsPlayerConnected(id)){setarg(paramPos, 0, id);}else{
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';num = false;new name[MAX_PLAYER_NAME];id = end - stringPos;foreach (Player, playerid){GetPlayerName(playerid, name, sizeof (name));if (!strcmp(name, string[stringPos], true, id)){
- setarg(paramPos, 0, playerid);num = true;break;}}if (!num){
- setarg(paramPos, 0, INVALID_PLAYER_ID);}string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }stringPos = end;}case 's', 'z':{
- new i = 0,ch;if (format[formatPos]){
- while ((ch = string[stringPos++]) && ch != delim){
- setarg(paramPos, i++, ch);}if (!i){return -1;}}else{while ((ch = string[stringPos++])){
- setarg(paramPos, i++, ch);}}stringPos--;setarg(paramPos, i, '\0');}default:{continue;}}
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' '){stringPos++;}
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' ')){
- stringPos++;}paramPos++;}do{if ((delim = format[formatPos++]) > ' '){
- if (delim == '\''){while ((delim = format[formatPos++]) && delim != '\'') {}}else if (delim != 'z'){return delim;}}}
- while (delim > ' ');return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement