Advertisement
Churros69

Exemplo Carregamento

Apr 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.14 KB | None | 0 0
  1. /* Esse é um exemplo para criar carregamentos: Haveriam 4 variáveis, Produto, PosCarregamento e MsgCarregamento e ContCarregamento.
  2. Funcionaria da seguinte maneira: No comando /criarcarreg iria ir para um dialog onde você informaria o nome do produto, após isso o nome do local e o sistema iria pegar suas coordenadas. Após isso o nome do produto seria gravado no vetor Produto[0], o local no MsgCarregamento[0] e o PosCarregamento[0][1] a posição X, PosCarregamento[0][2] a posição Y, PosCarregamento[0][3] a posição Z. Após isso o ContCarregamento soma +1 e vai para a posição 1, fazendo com que na posição 0 dos vetores existente estejam armazenados os dados do carregamento anterior, e quando quiser adicionar outro ele irá ser armazenado nas posições [1], e assim em diante. No comando /listarcarreg é possível ver quais produtos foram criados e seus respectivos carregamentos, e no /poscarreg podem ser vistos suas coordenadas. (Isso é o que está feito no sistema abaixo)
  3. Caso fizesse o comando /t poderia usar o vetor dos produtos para saber quais existem e onde eles podem ser carregados, e caso selecionados pegar as coordenadas de sua respectiva posição. Também poderia expandir para colocar mais de 1 produto no mesmo local, criar para o descarregamento, etc. Teria também que colocar para salvar as variáveis em texto. */
  4.  
  5. // ================================================== //
  6.  
  7. new Produto[50][50];
  8. new Float: PosCarregamento[100][4];
  9. new MsgCarregamento[50][100];
  10. new ContCarregamento = 0;
  11.  
  12. #define Dialog_Trabalho 48
  13. #define Dialog_CarregamentoP 49
  14. #define Dialog_CarregamentoN 50
  15.  
  16. // ================================================== //
  17. CMD:criarcarreg (playerid, params[])
  18. {
  19.     ShowPlayerDialog(playerid, Dialog_Trabalho, DIALOG_STYLE_LIST, "{ffffff}Editor rotas", "Criar carregamento\nCriar descarregamento\n", "Selecionar", "Fechar");
  20.     return 1;
  21. }
  22.  
  23. CMD:listarcarreg (playerid, params[])
  24. {
  25.     new msgProd[100], msg[1000];
  26.     if (ContCarregamento == 0){
  27.         SendClientMessage(playerid, 0xffff00, "Não há carregamentos criados");
  28.     }
  29.     else{
  30.         for (new i = 0; i < ContCarregamento; i++){
  31.             format(msgProd, sizeof(msgProd), "[%d] - Produto: %s | Nome: %s\n", i, Produto[i], MsgCarregamento[i]);
  32.             strins(msg, msgProd, strlen(msg));
  33.             ShowPlayerDialog(playerid, 8484, DIALOG_STYLE_MSGBOX, "Carregamentos existentes", msg, "Ok", "");
  34.         }
  35.     }
  36.     return 1;
  37. }
  38.  
  39. CMD:poscarreg (playerid, params[])
  40. {
  41.     new Coords[100], msg[1000];
  42.     if (ContCarregamento == 0){
  43.         SendClientMessage(playerid, 0xffff00, "Não há carregamentos criados");
  44.     }
  45.     else{
  46.         for (new i = 0; i < ContCarregamento; i++){
  47.             format(Coords, sizeof(Coords), "[%d] - X: %f | Y: %f | Z: %f\n", i, PosCarregamento[i][1], PosCarregamento[i][2], PosCarregamento[i][3]);
  48.             strins(msg, Coords, strlen(msg));
  49.             ShowPlayerDialog(playerid, 8484, DIALOG_STYLE_MSGBOX, "Coords dos Carregamentos", msg, "Ok", "");
  50.         }
  51.     }
  52.     return 1;
  53. }
  54.  
  55. // ================================================== //
  56. switch(dialogid){
  57.    
  58.     case Dialog_Trabalho:
  59.     {
  60.         if (response)
  61.         {
  62.             if (listitem == 0)
  63.             {
  64.                 ShowPlayerDialog(playerid, Dialog_CarregamentoP, DIALOG_STYLE_INPUT,"{ffff00}Criar carregamento", "Informe o produto:\n", "Continuar", "Fechar");
  65.             }
  66.         }
  67.     }
  68.  
  69.     case Dialog_CarregamentoP:
  70.     {
  71.         if (response)
  72.         {
  73.             strunpack(Produto[ContCarregamento], inputtext);
  74.             ShowPlayerDialog(playerid, Dialog_CarregamentoN, DIALOG_STYLE_INPUT,"{ffff00}Criar carregamento", "Informe o nome do carregamento:\n", "Continuar", "Fechar");
  75.         }
  76.     }
  77.    
  78.     case Dialog_CarregamentoN:
  79.     {
  80.         if (response)
  81.         {
  82.             strunpack(MsgCarregamento[ContCarregamento], inputtext);
  83.             GetPlayerPos(playerid, PosCarregamento[ContCarregamento][1], PosCarregamento[ContCarregamento][2], PosCarregamento[ContCarregamento][3]);
  84.             ContCarregamento += 1;
  85.             new Msg[100];
  86.             strins(Msg,"{ff0000}Carregamento criado com sucesso!\n",strlen(Msg));
  87.             return ShowPlayerDialog(playerid,8484, DIALOG_STYLE_MSGBOX, "Info Carregamento",Msg, "Fechar", "");
  88.         }
  89.     }
  90. }
  91.  
  92. // ================================================== //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement