Portal SAMP
[Ajuda] Ajuda a Converter - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Ajuda a Converter (/showthread.php?tid=4708)



Ajuda a Converter - Enila182 - 20/04/2024

Opa, to convertendo meu GM de dini para MySQL.
Chegou em uma parte que fiquei perdido

Código:
if(!strcmp(cmd, "/AgendarPuni", true))
    {
        if(pInfo[playerid][Admintrador] > 0)
        {
            tmp2 = strtok(cmdtext, idx);
            if(!strlen(tmp2))
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite: /AgendarPuni [NOME_CORRETO] [Tempo] [Motivo]");
                return 1;
            }
            format(MySQL, sizeof(MySQL), "Contas/%s.ini", tmp2);
            if(!fexist(MySQL))
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | Não existe nenhuma conta com esse nick !");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(! strlen(tmp))
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite: /AgendarPuni [NOME_CORRETO] [Tempo] [Motivo]");
                return 1;
            }
            new tempo = strval(tmp);
            if(tempo < 1 || tempo > 100)
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | Tempo somente de 1 à 100 leveis !");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' ' ))
            {
            idx++;
            }
            new offset = idx;
            new result[ 64 ];
            while (( idx < length ) && (( idx - offset ) < ( sizeof( result ) - 1 )))
            {
            result[ idx - offset ] = cmdtext[ idx ];
            idx++;
            }
            result[ idx - offset ] = EOS;
            if( !strlen( result ))
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite: /agendarpuni [Nick] [Tempo] [Motivo]");
                return 1;
            }
            format(string, sizeof(string), "| AGENDA | O(A) Admin %s[%d] agendou a punição de: %s por %d Leveis. ( Motivo: %s )",  PlayerName(playerid), playerid, tmp2, tempo, result);
            SendClientMessageToAll(0xFF0000AA, string);
            dini_Set(MySQL, "MotivoPunicao", result);
            dini_IntSet(MySQL, "Punidocop", tempo);//1 PunidoVezes
            dini_IntSet(MySQL, "Profissao", 0);
            tmp2[playerid] = dini_Int(MySQL, "PunidoVezes");
            dini_IntSet(MySQL, "PunidoVezes",tmp2[playerid] +1);
        } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Somente Corregedores podem usar esse comando!");
        return 1;
    }

OBS: tabela: jogador

------------
Código:
    if(strcmp(cmd, "/cadeia", true) == 0)
    {
        if(pInfo[playerid][Admintrador] > 0)
        {
              tmp = strtok(cmdtext, idx);

            if(!strlen(tmp))
            {
                   SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite /Cadeia [Nick] [Minutos] [Motivo]");
                   return 1;
            }
            new nick[25]; format(nick, sizeof(nick), "%s", tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                   SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite /Cadeia [Nick] [Minutos] [Motivo]");
                   return 1;
            }
            new tempo = strval(tmp);
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new motivo[30];
            while ((idx < length) && ((idx - offset) < (sizeof(motivo) - 1)))
            {
                motivo[idx - offset] = cmdtext[idx];
                idx++;
            }
            motivo[idx - offset] = EOS;
            if(!strlen(motivo))
            {
                 SendClientMessage(playerid, ERRO_BVR, "| ERRO | Digite /Cadeia [Nick] [Minutos] [Motivo]");
                 return 1;
            }
              if(tempo < 1 || tempo > 5000)
            {
                SendClientMessage(playerid, ERRO_BVR, "| ERRO | O tempo de puniçao deve ser entre 1 a 5000 minutos");
                   return 1;
            }
            foreach(Player, id)
            {
                if(new_strcmp(PlayerName(id), nick))
                {
                      PlayerInfo[id][pCadeia_Admin_Minutos] += tempo;
                     PlayerInfo[id][pCadeia_Admin_Segundos] = 1;
                    while(PlayerInfo[id][pCadeia_Admin_Minutos] > 60)
                      {
                          PlayerInfo[id][pCadeia_Admin_Minutos] -= 60;
                         PlayerInfo[id][pCadeia_Admin_Horas] ++;
                       }

                    format(MotivoPrisaoAdmin[id], 30, "%s", motivo);

                    /*--- Mandar Cadeia ---*/
                    new rand = random(sizeof(Cadeia_Federal_BVR));
                    SetPlayerPos(id, Cadeia_Federal_BVR[rand][0], Cadeia_Federal_BVR[rand][1], Cadeia_Federal_BVR[rand][2]);
                    SetPlayerInterior(id, 1);

                    for(new i; i < 2; i++) PlayerTextDrawShow(id, Carregando_Interior[id][i]);
                     TogglePlayerControllable(id, 0);
                      SetTimerEx("Descongelar", 5000, false, "i", id);

                      SetPlayerVirtualWorld(id, 1);
                    SetCameraBehindPlayer(id);
                       SetPlayerHealth(id, 100000);
                      SetPlayerArmour(id, 0);
                      ResetPlayerWeapons(id);
                      GameTextForPlayer(id, "~ n~ ~n~ ~w~Preso!", 1500, 0);
                    RemovePlayerAttachedObject(id, 7);
                    SetPlayerSpecialAction(id, SPECIAL_ACTION_NONE);
                    new StrPreso[35]; format(StrPreso, sizeof(StrPreso), "~g~~h~PRESO: ~w~%02d:%02d:%02d", PlayerInfo[id][pCadeia_Admin_Horas], PlayerInfo[id][pCadeia_Admin_Minutos], PlayerInfo[id][pCadeia_Admin_Segundos]);
                     PlayerTextDrawSetString(id, TextPresoP[id], StrPreso);
                    PlayerTextDrawShow(id, TextPresoP[id]);
                    TextDrawShowForPlayer(id, TextPreso);

                    format(string, sizeof(string), "| BVR-Admin | O(A) %s %s[%d] prendeu o(a) jogador(a) %s[%d] por %d minutos ( Motivo: %s )", Cargo_Admin_BVR(playerid), PlayerName(playerid), playerid, PlayerName(id), id, tempo, motivo);
                    SendClientMessageToAll(0x84FF00AA, string);

                    PlayerInfo[id][pVezes_Preso_Staff] ++;

                    if(PlayerInfo[id][pVezes_Preso_Staff] == 50)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 200*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 200 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 1 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 100)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 300*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 300 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 2 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 150)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 400*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 400 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 3 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 200)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 500*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 500 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 4 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 250)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 1000*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 1000 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 5 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 300)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 2000*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 2000 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 6 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    if(PlayerInfo[id][pVezes_Preso_Staff] == 350)
                    {
                        PlayerInfo[id][pCadeia_Admin_Minutos] += 3000*60;
                        format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 3000 minutos para o(a) jogador(a) %s[%d], totalizando em %d minutos ( Motivo: Nível 7 de Denuncias )", PlayerName(id), id, PlayerInfo[id][pCadeia_Admin_Minutos]);
                        SendClientMessageToAll(0xB0FF30AA, string);
                    }
                    return 1;
                }
            }
            format(MySQL, sizeof(MySQL), "Contas/%s.ini", nick);
            if(dini_Exists(MySQL))
            {
                   new PresoHoras = dini_Int(MySQL, "Cadeia_Admin_Horas");
                   new PresoMinutos = dini_Int(MySQL, "Cadeia_Admin_Minutos");
                new PresoSegundos = dini_Int(MySQL, "Cadeia_Admin_Segundos");
                  if(PresoSegundos <= 0)
                {
                    PresoSegundos = 1;
                }
                   //
                   PresoMinutos += tempo;
                  while(PresoMinutos > 60)
                {
                     PresoMinutos -= 60;
                       PresoHoras ++;
                   }

                   dini_FloatSet(MySQL, "Vida_Player", 99999.0);
                  dini_FloatSet(MySQL, "Colete_Player", 0.0);
                  dini_IntSet(MySQL, "Cadeia_Admin_Horas", PresoHoras);
                dini_IntSet(MySQL, "Cadeia_Admin_Minutos", PresoMinutos);
                 dini_IntSet(MySQL, "Cadeia_Admin_Segundos", PresoSegundos);
                  dini_Set(MySQL, "Cadeia_Admin_Motivo", motivo);

                format(string, sizeof(string), "| BVR-Admin | O(A) %s %s[%d] agendou a prisão do(a) jogador(a) %s por %d minutos ( Motivo: %s )", Cargo_Admin_BVR(playerid), PlayerName(playerid), playerid, nick, tempo, motivo);
                SendClientMessageToAll(0x84FF00AA, string);

                dini_IntSet(MySQL, "Vezes_Preso_Staff", dini_Int(MySQL, "Vezes_Preso_Staff")+ 1);

                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 50)
                {
                    dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 200);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 200 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 1 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 100)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 300);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 300 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 2 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 150)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 400);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 400 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 3 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 200)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 500);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 500 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 4 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                  }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 250)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 1000);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 1000 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 5 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 300)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 2000);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 2000 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 6 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
                if(dini_Int(MySQL, "Vezes_Preso_Staff") == 350)
                {
                       dini_IntSet(MySQL, "Cadeia_Admin_Minutos", dini_Int(MySQL, "Cadeia_Admin_Minutos")+ 3000);
                    format(string, sizeof(string), "| BVR-Admin | Foi aplicado mais 3000 minutos para o(a) jogador(a) %s, totalizando em %d minutos ( Motivo: Nível 7 de Denuncias )", nick, dini_Int(MySQL, "Cadeia_Admin_Minutos"));
                    SendClientMessageToAll(0xB0FF30AA, string);
                }
            } else {
                format(string, sizeof(string), "| ERRO | O nick '%s' não existe!", nick);
                   SendClientMessage(playerid, ERRO_BVR, string);
                   return 1;
            }
        } else SendClientMessage(playerid, ERRO_BVR, "| ERRO | Você não em permissão!");
        return 1;
    }
OBS: tabela: jogador


RE: Ajuda a Converter - White_Blue - 20/04/2024

Poderia destacar em qual parte você se perdeu?


RE: Ajuda a Converter - Enila182 - 20/04/2024

Somente nesses 2 códigos.


RE: Ajuda a Converter - xbruno1000x - 21/04/2024

A query SQL no da Cadeia:
Código:
format(MySQL, sizeof(MySQL), "UPDATE jogador SET Cadeia_Admin_Horas = Cadeia_Admin_Horas + %d, Cadeia_Admin_Minutos = Cadeia_Admin_Minutos + %d, Cadeia_Admin_Segundos = IF(Cadeia_Admin_Segundos <= 0, 1, Cadeia_Admin_Segundos), Cadeia_Admin_Motivo = '%s' WHERE Nickname = '%s'", tempo, tempo, motivo, nick);
mysql_tquery(MySQL);

A query SQL no AgendarPuni:
Código:
format(MySQL, sizeof(MySQL), "SELECT * FROM jogador WHERE Nickname = '%s'", tmp2);
mysql_tquery(MySQL);
format(MySQL, sizeof(MySQL), "UPDATE jogador SET MotivoPunicao = '%s', Punidocop = %d, Profissao = 0, PunidoVezes = PunidoVezes + 1 WHERE Nickname = '%s'", result, tempo, tmp2);
mysql_tquery(MySQL);

Recomendo que aproveite que está convertendo coisas e faça a conversão do STRCMP para ZCMD ou Pawn.CMD.