[Ajuda] problema com mysql
#1

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 Код:
[00:18:08] Passing query SELECT * FROM `ban_info` WHERE `nome` = Caio_Cold AND (`expire` = -1 OR `expire` > UNIX_TIMESTAMP()) | i
[00:18:08] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[00:18:08] Passing query SELECT * FROM `contas` WHERE `Nome` = 'Caio_Cold' | i
[00:18:08] ProcessQueryThread(xPlayerLogin) - Query was successful. (SELECT * FROM `contas` WHERE `Nome` = 'Caio_Cold')
[00:18:08] ProcessQueryThread(xPlayerLogin) - Data caching enabled.
[00:18:08] CMySQLHandler::StoreResult() - Result was stored.
[00:18:08] CMySQLHandler::FreeResult() - Result was successfully free'd.
[00:18:08] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[00:18:08] xPlayerLogin(i) - Threaded function called.
[00:18:08] >> cache_get_data( Connection handle: 1 )
[00:18:08] ProcessTick() - The cache has been cleared.
[00:19:40] >> mysql_query_callback( Connection handle: 1 )
[00:19:40] Passing query SELECT * FROM contas WHERE Nome = '
Caio_Cold' AND Senha = ('senha') LIMIT 1 | i
[00:19:40] ProcessQueryThread(VerificouLogin) - Query was successful. (SELECT * FROM contas WHERE Nome = '
Caio_Cold' AND Senha = ('senha') LIMIT 1)
[00:19:40] ProcessQueryThread(VerificouLogin) - Data caching enabled.
[00:19:40] CMySQLHandler::StoreResult() - Result was stored.
[00:19:40] CMySQLHandler::FreeResult() - Result was successfully free'
d.
[00:19:40] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[00:19:40] VerificouLogin(i) - Threaded function called.
[00:19:40] >> cache_get_data( Connection handle: 1 )
[00:19:40] >> cache_get_data( Connection handle: 1 )
[00:19:40] ProcessTick() - The cache has been cleared.
[00:20:00] >> mysql_query_callback( Connection handle: 1 )
[00:20:00] Passing query INSERT INTO `ban_info` (`nome`, `admin`, `reason`, `date`, `expire`) VALUES (Caio_Cold, 'Caio_Cold', 'Hack', UNIX_TIMESTAMP(), 1383189600) |
[00:20:00] >> mysql_query_callback( Connection handle: 1 )
[00:20:00] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[00:20:00] Passing query UPDATE `contas` SET `Admin`='5', `Matou`='0', `Morreu`='0', `Dinheiro`='2550' WHERE Nome='Caio_Cold' |
[00:20:00] ProcessQueryThread() - Query was successful. (UPDATE `contas` SET `Admin`='5', `Matou`='0', `Morreu`='0', `Dinheiro`='2550' WHERE Nome='Caio_Cold')
[00:20:00] ProcessQueryThread() - Data caching enabled.
[00:20:00] CMySQLHandler::StoreResult() - No data to store.
[00:20:01] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
comando /ban:

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;
}
Reply
#2

Ban_Apply:
pawn Код:
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);

Ban_Check:
pawn Код:
format(gstring, sizeof gstring, "SELECT * FROM `ban_info` WHERE `nome` = '%s' AND (`expire` = -1 OR `expire` > UNIX_TIMESTAMP())", Nome(playerid));
Reply
#3

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?
Reply
#4

Sгo timestamps.
Reply
#5

Quote:
Originally Posted by zPain
Посмотреть сообщение
Sгo timestamps.
hm.. qual seria o melhor modo com o timestamps ou gettime?
Reply
#6

gettime retorna uma timestamp. Esse sistema vai exibir a data do ocorrido e a data em que o registro expira corretamente.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)