toribio

toribio

Sep 28th, 2008
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.53 KB | None | 0 0
  1.     if(!strcmp(cmd, "/stats", true))
  2.     {
  3.         new tmp[0x100], plid;
  4.         tmp = strtok(cmdtext, idx);
  5.         if(!strcmp(tmp, "?", true) && strlen(tmp))
  6.         {
  7.                 SendClientMessage(playerid, 0xFF0000AA, "Ajuda sobre comando \"/stats\":");
  8.                 SendClientMessage(playerid, 0xFFFFFFAA, "Use \"/stats\" somente para ver seus stats.");
  9.                 SendClientMessage(playerid, 0xFFFFFFAA, "Use \"/stats [playerid]\" ou \"/stats [nome]\" \
  10.             para ver os stats de algu�m conectado ou n�o.");
  11.                 return 1;
  12.         }
  13.         plid = strval(tmp);
  14.         if(!strlen(tmp))plid = playerid;
  15.         new pname[0x100];
  16.         if(isnumeric(tmp) && strlen(tmp))
  17.         {
  18.             if(IsPlayerConnected(plid))
  19.                 {
  20.                 GetPlayerName(plid, pname, sizeof pname);
  21.                 format(pname, sizeof pname, "%s.brazilian.championship.cer", pname);
  22.                 goto comando_stats;
  23.             } else {
  24.                 SendClientMessage(playerid, 0xFF0000AA, "Jogador n�o conectado/nome inv�lido!");
  25.             }
  26.         } else {
  27.             if(playerid == plid)GetPlayerName(playerid, tmp, sizeof tmp);
  28.             format(pname, sizeof pname, "%s.brazilian.championship.cer", tmp);
  29.             comando_stats:
  30.             if(dini_Exists(pname))
  31.             {
  32.                 new string[0x100], tempo, msegundos, nome[0x100];
  33.                 GetPlayerName(plid, nome, sizeof nome);
  34.                 format(string, sizeof string, "Stats de %s", nome);
  35.                 SendClientMessage(playerid, 0xFFF000AA, string);
  36.                 format(string, sizeof string, "Grana: %d Score: %d Vit�rias DM1: %d 1� lugar RACE1: %d \
  37.                 lugar RACE2: %d", dini_Int(pname, "grana"), dini_Int(pname, "score"),
  38.                 dini_Int(pname, "dm1wins"), dini_Int(pname, "race1wins"), dini_Int(pname, "race2wins"));
  39.                 SendClientMessage(playerid, 0xFFFFFFAA, string);
  40.                 tempo = dini_Int(pname, "race1bestscore");
  41.                 minutos = floatround(floatdiv(tempo, 60000), floatround_tozero);
  42.                 segundos = floatround(floatmul(floatdiv(tempo, 60000) - minutos, 60), floatround_tozero);
  43.                 msegundos = floatround(floatmul(floatmul(floatdiv(tempo,
  44.                 60000) - minutos, 60) - segundos, 1000), floatround_tozero);
  45.                 gindex = 0;
  46.                 while (segundos > 9)
  47.                 {
  48.                     segundos -= 0xA;
  49.                     gindex++;
  50.                 }
  51.                 new msec[0xA];
  52.                 if(msegundos < 10)format(msec, sizeof msec, "000%d", msegundos);
  53.                 if(msegundos > 9 && msegundos < 100)format(msec, sizeof msec, "00%d", msegundos);
  54.                 if(msegundos > 99 && msegundos < 1000)format(msec, sizeof msec, "0%d", msegundos);
  55.                 if(msegundos == 1000)format(msec, sizeof msec, "%d", msegundos);
  56.                 format(string, sizeof string, "Melhor tempo na RACE1: %d:%d%d:%s",
  57.                 minutos, gindex, segundos, msec);
  58.                 SendClientMessage(playerid, 0xFFFFFFAA, string);
  59.                 tempo = dini_Int(pname, "race2bestscore");
  60.                 minutos = floatround(floatdiv(tempo, 60000), floatround_tozero);
  61.                 segundos = floatround(floatmul(floatdiv(tempo, 60000) - minutos, 60), floatround_tozero);
  62.                 msegundos = floatround(floatmul(floatmul(floatdiv(tempo,
  63.                 60000) - minutos, 60) - segundos, 1000), floatround_tozero);
  64.                 gindex = 0;
  65.                 while (segundos > 9)
  66.                 {
  67.                     segundos -= 0xA;
  68.                     gindex++;
  69.                 }
  70.                 if(msegundos < 10)format(msec, sizeof msec, "000%d", msegundos);
  71.                 if(msegundos > 9 && msegundos < 100)format(msec, sizeof msec, "00%d", msegundos);
  72.                 if(msegundos > 99 && msegundos < 1000)format(msec, sizeof msec, "0%d", msegundos);
  73.                 if(msegundos == 1000)format(msec, sizeof msec, "%d", msegundos);
  74.                 format(string, sizeof string, "Melhor tempo na RACE2: %d:%d%d:%s",
  75.                 minutos, gindex, segundos, msec);
  76.                 SendClientMessage(playerid, 0xFFFFFFAA, string);
  77.             } else {
  78.                 SendClientMessage(playerid, 0xFF0000AA, "Nome inv�lido!");
  79.             }
  80.         }
  81.         return 1;
  82.     }
Add Comment
Please, Sign In to add comment