Sugerencia: cambiale la extensiуn al archivo, los sistemas de archivos INI usan esa extensiуn y se pueden mezclar.
|
// Sistema para bloquear a usuarios /bloquear.
// Crйditos: Toggle (Ner0x)
/***** ] Includes [ *****/
#include <a_samp>
//#include <filemanager>
/***** ] Defines [ *****/
#define ROSA 0xC2A2DAAA
#define BLANCO 0xFFFFFFFF
/***** ] New's [ ******/
new File:archivo;
/***** ] OnPlayerConnect [ *****/
public OnPlayerConnect(playerid)
{
new IP[16];
new string[256];
GetPlayerIp(playerid,IP,sizeof(IP));
format(string, sizeof(string), "Bloqueados/%d.ini", IP);
if(fexist(string))
{
SendClientMessage(playerid, 0xFF0000FF, "Esta IP estб bloqueada. Por lo tanto usted no podrб jugar aqui.");
SendClientMessage(playerid, 0xFF0000FF, "Si quiere mбs informaciуn acuda a nuestro foro.");
Kick(playerid);
}
return 1;
}
/***** ] OnPlayerCommandText [ *****/
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, giveplayerid;
new Nombre[MAX_PLAYER_NAME], giveplayername[MAX_PLAYER_NAME];
new IP[16];
GetPlayerName(playerid, Nombre, sizeof(Nombre));
new string[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/bloquear", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, BLANCO, "Use: /bloquear [ID del Jugador]");
return 1;
}
//dir_create("Bloqueados");
giveplayerid = strval(tmp);
GetPlayerIp(giveplayerid, IP, sizeof(IP));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
if(IsPlayerAdmin(playerid))
{
if(IsPlayerConnected(playerid))
{
new str[256];
format(str, sizeof(str), "Bloqueados/%d.ini", IP);
archivo = fopen(str, io_write);
if(archivo)
{
format(str,sizeof(str), "Este usuario ha sido bloqueado por algun motivo.");
fwrite(archivo, str);
fclose(archivo);
}
Kick(giveplayerid);
format(string, sizeof(string), "La IP %d de %s ha sido bloqueada por el Administrador: %s.", giveplayername, IP, Nombre);
SendClientMessageToAll(0xFF0000FF,string);
printf("%s",string);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "ID Invalida.");
}
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "No estбs autorizado a usar el comando.");
}
return 1;
}
return 0;
}
/***** ] Strtok [ *****/
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
if(strcmp(cmd,"/banip",true)==0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_GRAD1,"[INFO]: /BanIP [IP]");
return 1;
}
format(string,sizeof(string),"banip %s",tmp);
SendRconCommand(string);
SendRconCommand("reloadbans");
SendClientMessage(playerid,COLOR_GRAD1,"Has baneado la IP");
return 1;
}