Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined REMOTE_CHAT
- ********************************************************************************
- * ANTI INCOMING CONECCTION FLOOD 1.0 BY DANIEL-92 *
- * Copyright © 2014 [Daniel-92 / [92]Daniel / (=Maxell=)] *
- * This file is provided as is (no warranties). *
- ********************************************************************************
- #endif
- #include <a_samp>
- //------------------------------------------------------------------------------
- #define JOIN_FLOD_TIME 6 //Tiempo en segundos que se tomará como incoming connection flood
- #define MAX_JOIN_FLOOD 10 //Máximo de joins dentro del tiempo definido arriba antes de que se aplique el baneo
- //* Si hay 10 mensajes en la consola dentro de 6 segundos se aplica el baneao
- new
- DB:JoinFloodDataBase,
- jf_string[164],last_clear;
- public OnFilterScriptInit() {
- JoinFloodDataBase = db_open("JoinFloodDataBase.db");
- db_query(JoinFloodDataBase,"CREATE TEMP TABLE IF NOT EXISTS Join_Flood \
- (`ID` INTEGER PRIMARY KEY AUTOINCREMENT,`REMOTE_CLIENT` TEXT,`GRANULARITY` NUMERIC)"
- );
- last_clear = gettime()+60*5;
- }
- public OnFilterScriptExit() {
- db_close(JoinFloodDataBase);
- }
- public OnIncomingConnection(playerid, ip_address[], port) {
- format(jf_string,sizeof(jf_string),"\
- SELECT COUNT(ID) AS TOTAL FROM `Join_Flood` WHERE `REMOTE_CLIENT` = '%s' \
- AND `GRANULARITY`+"#JOIN_FLOD_TIME" > %d ORDER BY ID DESC LIMIT "#MAX_JOIN_FLOOD"",ip_address,gettime()
- );
- new DBResult:result = db_query(JoinFloodDataBase,jf_string);
- db_get_field_assoc(result,"TOTAL",jf_string,sizeof(jf_string));
- db_free_result(result);
- if(strval(jf_string) >= MAX_JOIN_FLOOD) {
- format(jf_string,sizeof jf_string,"banip %s",ip_address); //Formateamos el comando rcon
- SendRconCommand(jf_string); //Mandamos el comando rcon
- BlockIpAddress(ip_address,60*1000*30); //Bloqueamos la ip por 30 minutos (Funcion nativa de la 0.3z R2)
- }
- else if(gettime() > last_clear) {
- db_free_result(db_query(JoinFloodDataBase,"DELETE FROM Join_Flood"));
- last_clear = gettime()+60*10;
- }
- else {
- format(jf_string,sizeof(jf_string),"INSERT INTO Join_Flood (REMOTE_CLIENT,GRANULARITY) VALUES ('%s','%d')",ip_address,gettime());
- db_free_result(db_query(JoinFloodDataBase,jf_string));
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment