Advertisement
GranaT3

[Practica] Mini sistema de log

Nov 30th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.80 KB | None | 0 0
  1. #define DIALOG_LOG 20000
  2. #define DIALOG_MSJ 25000
  3.  
  4.  
  5. enum Logs
  6. {
  7.     Chat_1[140],
  8.     Chat_2[140],
  9.     Chat_3[140]
  10. };
  11. new ChatLog[Logs];
  12.  
  13.  
  14.  
  15. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  16. {
  17.     switch(dialogid)
  18.     {
  19.         case DIALOG_LOG:
  20.         {
  21.             if(!response) return 1;
  22.  
  23.             switch(listitem)
  24.             {
  25.                 case 0:
  26.                 {  
  27.                     if(isnull(ChatLog[Chat_1]))
  28.                     {
  29.                         SendClientMessage(playerid, -1, "Está vacio");
  30.                     }
  31.                     else
  32.                     {
  33.                         new cadena[140];
  34.                         format(cadena,sizeof(cadena),"{CF0CDD}%s",ChatLog[Chat_1]);
  35.                         ShowPlayerDialog(playerid, DIALOG_MSJ, DIALOG_STYLE_MSGBOX, "Mensaje",cadena, "Ok", "");
  36.                     }
  37.                 }
  38.  
  39.                 case 1:
  40.                 {
  41.                     if(isnull(ChatLog[Chat_2]))
  42.                     {
  43.                         SendClientMessage(playerid, -1, "Está vacio");
  44.                     }
  45.                     else
  46.                     {
  47.                        new cadena2[140];
  48.                        format(cadena2,sizeof(cadena2),"{CF0CDD}%s",ChatLog[Chat_2]);
  49.                        ShowPlayerDialog(playerid, DIALOG_MSJ, DIALOG_STYLE_MSGBOX, "Mensaje", cadena2, "Ok", "");
  50.                     }
  51.                 }
  52.  
  53.                 case 2:
  54.                 {
  55.                     if(isnull(ChatLog[Chat_3]))
  56.                     {
  57.                         SendClientMessage(playerid, -1, "Está vacio");
  58.                     }
  59.                     else
  60.                     {
  61.                         new cadena3[140];
  62.                         format(cadena3,sizeof(cadena3),"{CF0CDD}%s",ChatLog[Chat_3]);
  63.                         ShowPlayerDialog(playerid, DIALOG_MSJ, DIALOG_STYLE_MSGBOX, "Mensaje", cadena3, "Ok", "");
  64.                     }
  65.                 }
  66.              }
  67.  
  68.  
  69.         }
  70.     }
  71.  
  72.     return 1;
  73. }
  74.  
  75. CMD:verlogs(playerid,params[])
  76. {  
  77.     new cadena[340];
  78.     format(cadena,sizeof(cadena),"\n[1]- %s \n[2]- %s \n[3]- %s",ChatLog[Chat_1],ChatLog[Chat_2],ChatLog[Chat_3]);
  79.     ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_LIST, "Tu lista de logs", cadena, "Abrir", "Cancelar");
  80.  
  81.     return 1;
  82. }
  83.  
  84. CMD:crearlog(playerid,params[])
  85. {
  86.     new msj[140];
  87.     if(!sscanf(params,"s[140]",msj))   
  88.     {
  89.         if(isnull(ChatLog[Chat_1]) && 100 <= sizeof(msj))
  90.         {
  91.             ChatLog[Chat_1] = msj;
  92.             SendClientMessage(playerid, -1, "{CF0CDD}[+] {FFFFFF}Te quedan 2 espacios más");
  93.         }
  94.         else if (isnull(ChatLog[Chat_2]) &&  100 <= sizeof(msj))
  95.         {
  96.             ChatLog[Chat_2] = msj;
  97.             SendClientMessage(playerid, -1, "{CF0CDD}[+] {FFFFFF}Te queda 1 espacio más");
  98.         }
  99.         else if (isnull(ChatLog[Chat_3]) && 100 <= sizeof(msj))
  100.         {
  101.             ChatLog[Chat_3] = msj;
  102.             SendClientMessage(playerid, -1, "{CF0CDD}[+] {FFFFFF}Esté era tu último espacio lbre ");
  103.         }
  104.         else
  105.         {
  106.             SendClientMessage(playerid, -1, "{CF0CDD}[+] {FFFFFF}Todos los espacios están llenos");
  107.         }
  108.  
  109.        
  110.     }
  111.  
  112.     else
  113.     {
  114.         SendClientMessage(playerid, -1, "use /crearlog[text]");
  115.     }
  116.  
  117.     return 1;
  118. }
  119.  
  120. CMD:borrarlog(playerid,params[])
  121. {
  122.     new slot;
  123.     if(sscanf(params, "i",slot))
  124.     return SendClientMessage(playerid, -1, "Útiliza /borrarlog [1-3]");
  125.  
  126.     switch(slot)
  127.     {
  128.         case 1: ChatLog[Chat_1] = 0;
  129.         case 2: ChatLog[Chat_2] = 0;
  130.         case 3: ChatLog[Chat_3] = 0;
  131.     }
  132.  
  133.     return 1;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement