quando eu digito o comando /ban [id] [motivo] [dias] ai mostra a menssagem que fui banido porem nao estб inserindo no banco de dados e no mysql_log.txt mostra isso:
pawn Код:
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][Admin] < 4) return SendClientMessage(playerid, 0xff0000ff, "(!) Aзгo exclusiva de administradores.");
new targetid, reason[64], days = -1;
if(sscanf(params, "us[64]I(-1)", targetid, reason, days))
{
SendClientMessage(playerid, 0x32cd32ff, "CMD: /ban <id/nome> <motivo> <dias>");
SendClientMessage(playerid, 0x32cd32ff, "Para banir por tempo indeterminado, nгo digite os dias ou coloque \"-1\".");
return true;
}
Ban_Apply(targetid, Nome(playerid), reason, days);
return true;
}
//publics '-'
public Ban_Apply(playerid, admin[], reason[], time)
{
if (time != -1) time *= 86400;
format(gstring, sizeof gstring, "INSERT INTO `ban_info` (`nome`, `admin`, `reason`, `date`, `expire`) VALUES (%s, '%s', '%s', UNIX_TIMESTAMP(), %d)", Nome(playerid), admin, reason, time != -1 ? gettime() + time : time);
mysql_function_query(xConexao, gstring, false, #, #);
if (time == -1) format(gstring, sizeof gstring, "AdmCmd: %s foi banido por tempo indeterminado pelo admin %s. (%s)", Nome(playerid), admin, reason);
else format(gstring, sizeof gstring, "AdmCmd: %s foi banido por %02d dias pelo admin %s. (%s)", Nome(playerid), (time / 86400), admin, reason);
SendClientMessageToAll(0xff0000ff, gstring);
Kick(playerid);
return true;
}
public Ban_Check(playerid)
{
format(gstring, sizeof gstring, "SELECT * FROM `ban_info` WHERE `nome` = %s AND (`expire` = -1 OR `expire` > UNIX_TIMESTAMP())", Nome(playerid));
mysql_function_query(xConexao, gstring, true, "r@Ban_Check", "i", playerid);
return true;
}
public r@Ban_Check(playerid)
{
new rows, fields;
cache_get_data(rows, fields, xConexao);
if (rows)
{
SendClientMessage(playerid, -1, "Foram encontrados registros ativos de ban em sua conta.");
SendClientMessage(playerid, -1, "Verifique as ocorrкncias e busque uma revisгo caso necessбrio.");
new admin[25], reason[64], Time:date,Time:expire,tm<tmTime>;
cache_get_field_content(0, "admin", admin, xConexao);
cache_get_field_content(0, "reason", reason, xConexao);
cache_get_field_content(0, "date", gstring, xConexao);
date = Time:strval(gstring);
localtime(date, tmTime);
strftime(gstring, sizeof gstring, "%d/%m/%Y аs %X", tmTime);
format(gstring, sizeof gstring, "%s, aplicado pelo administrador %s.", gstring, admin);
SendClientMessage(playerid, -1, gstring);
format(gstring, sizeof gstring, "Motivo: %s", reason);
SendClientMessage(playerid, -1, gstring);
cache_get_field_content(0, "expire", gstring, xConexao);
expire = Time:strval(gstring);
if (_:expire != -1)
{
localtime(expire, tmTime);
strftime(gstring, sizeof gstring, "%d/%m/%Y аs %X", tmTime);
format(gstring, sizeof gstring, "Expira em %s", gstring);
SendClientMessage(playerid, -1, gstring);
}
else
{
SendClientMessage(playerid, -1, "Nгo hб um prazo determinado para expirar.");
}
Kick(playerid);
}
else
{
SendClientMessage(playerid, -1, "Nenhum registro encontrado, tenha um bom jogo!");
TogglePlayerSpectating(playerid, false);
//SpawnPlayer(playerid);
}
return true;
}
ele inseriu mais nas colunas date e expire estб assim: date 1380600316 expire 1383192316 й normal isso eu bani por 30 dias pra testa rsrs o certo nгo seria date 1/10/2013 expire 1/11/2013?
hm.. qual seria o melhor modo com o timestamps ou gettime?
retorna uma timestamp. Esse sistema vai exibir a data do ocorrido e a data em que o registro expira corretamente.