PHP код:
BlockIPs() {
new File:file = fopen("ips_bloqueados.txt", io_read), line[17];
if ( file ) {
while(fread(file, line)) {
BlockIpAddress(line, 60 * 1000);
printf("***** IP [%s] bloqueado!", line);
}
fclose(file);
}
return 1;
}
UnBlockIPs() {
new File:file = fopen("ips_bloqueados.txt", io_read), line[17];
if ( file ) {
while(fread(file, line)) {
UnBlockIpAddress(line);
}
fclose(file);
}
return 1;
}
// Fdelete was made by Sacky.
fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(strcmp(templine,line, true) == 0){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}
public OnGameModeInit() {
BlockIPs();
return 1;
}
CMD:addip(playerid, params[]) {
if ( !IsPlayerAdmin(playerid) || isnull(params) )
return 0;
new File:file = fopen("ips_bloqueados.txt", io_append);
if ( file ) {
new ip[25];
format(ip, sizeof(ip), "%s\r\n", params);
fwrite(file, ip);
fclose(file);
SendClientMessage(playerid, -1, "IP adicionado!");
}
return 1;
}
CMD:removeip(playerid, params[]) {
if ( !IsPlayerAdmin(playerid) || isnull(params) )
return 0;
fdeleteline("ips_bloqueados.txt", params);
SendClientMessage(playerid, -1, "IP desbloqueado!");
return 1;
}
CMD:reloadips(playerid) {
if ( !IsPlayerAdmin(playerid) )
return 0;
UnBlockIPs();
BlockIPs();
return 1;
}
Um pouco mais completo...
OBS: Nгo compilei, entгo podem ter erros.
OBSІ:Й necessбrio estar logado na RCON.
OBSі:Os IPs ficarгo bloqueados por 1 minuto, altere a seu agrado.