Badyx

[Fs] Calculadora

Nov 8th, 2012
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.01 KB | None | 0 0
  1. /*
  2.         Sistema de Calculadora By Badyx
  3.                                                         */
  4. #include <a_samp>
  5. new Cantidad1[MAX_PLAYERS];
  6. new Cantidad2[MAX_PLAYERS];
  7. new RFinal[MAX_PLAYERS];
  8. new RFinal2[MAX_PLAYERS];
  9.  
  10. #define MiCantidad1         10000
  11. #define MiCantidad2         10001
  12. #define CalcularResultado   10002
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. #else
  17.  
  18. main()  {}
  19.  
  20. #endif
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     Seteando(playerid);
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerDisconnect(playerid, reason)
  29. {
  30.     Seteando(playerid);
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerCommandText(playerid, cmdtext[])
  35. {
  36.     if (strcmp("/Calculadora", cmdtext, true, 10) == 0)
  37.     {
  38.         ShowPlayerDialog(playerid,MiCantidad1,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la primera cantidad","Aceptar","");
  39.  
  40.         return 1;
  41.     }
  42.     return 0;
  43. }
  44.  
  45. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  46. {
  47.     new string[300];
  48.     new Uno = strval(inputtext);
  49.     new Dos = strval(inputtext);
  50.     if(dialogid == MiCantidad1 && response)
  51.     {
  52.     if(!strlen(inputtext))
  53.     {
  54.         SendClientMessage(playerid, -1, # No introduciste nada ¬¬);
  55.         ShowPlayerDialog(playerid,MiCantidad1,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la primera cantidad","Aceptar","");
  56.         return 1;
  57.     }
  58.     Cantidad1[playerid] = Uno;
  59.     format(string, sizeof(string), # Cantidad %i, Uno);
  60.     SendClientMessage(playerid, -1, string);
  61.     ShowPlayerDialog(playerid,MiCantidad2,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la segunda cantidad","Aceptar","");
  62.     return 1;
  63.     }
  64.  
  65.     if(dialogid == MiCantidad2 && response)
  66.     {
  67.     if(!strlen(inputtext))
  68.     {
  69.         SendClientMessage(playerid, -1, # No introduciste nada ¬¬);
  70.         ShowPlayerDialog(playerid,MiCantidad2,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la segunda cantidad","Aceptar","");
  71.         return 1;
  72.     }
  73.     Cantidad2[playerid] = Dos;
  74.     format(string, sizeof(string), # Cantidad %i, Dos);
  75.     SendClientMessage(playerid, -1, string);
  76.     ShowPlayerDialog(playerid,CalcularResultado,DIALOG_STYLE_LIST,"Seleccione la operacion","Sumar\nRestar\nMultiplicar\nDividir","Confirmar","");
  77.     return 1;
  78.     }
  79.  
  80.     if(dialogid == CalcularResultado)
  81.     {
  82.     new Uno1 = Cantidad1[playerid];
  83.     new Dos2 = Cantidad2[playerid];
  84.     new Final = RFinal[playerid];
  85.     new Final2 = RFinal[playerid];
  86.     switch(listitem)
  87.     {
  88.     case 0://Suma
  89.     {
  90.         Final = Uno1;
  91.         Final2 = Dos2;
  92.         Final += Final2;
  93.         format(string, sizeof(string), " El resultado de la suma de %i mas %i da como resultado %i", Uno1, Dos2,Final);
  94.         SendClientMessage(playerid, -1, string);
  95.     }
  96.     case 1://resta
  97.     {
  98.         Final = Uno1;
  99.         Final2 = Dos2;
  100.         Final -= Final2;
  101.         format(string, sizeof(string), # El resultado de la resta de %d menos %d da como resultado %d, Uno1, Dos2,Final);
  102.         SendClientMessage(playerid, -1, string);
  103.     }
  104.  
  105.     case 2://multiplicar
  106.     {
  107.         Final = Uno1;
  108.         Final2 = Dos2;
  109.         Final *= Final2;
  110.         format(string, sizeof(string), # El resultado de la multiplicacion de %d por %d da como resultado %d, Uno1, Dos2,Final);
  111.         SendClientMessage(playerid, -1, string);
  112.     }
  113.     case 3://Dividir
  114.     {
  115.         Final = Uno1;
  116.         Final2 = Dos2;
  117.         Final /= Final2;
  118.         format(string, sizeof(string), # El resultado de la division de %d entre %d da como resultado %d, Uno1, Dos2,Final);
  119.         SendClientMessage(playerid, -1, string);
  120.         return 1;
  121.     }
  122.     }
  123.     return 1;
  124.     }
  125.     Seteando(playerid);
  126.     return 1;
  127. }
  128.  
  129. forward Seteando(playerid);
  130. public Seteando(playerid)
  131. {
  132. Cantidad1[playerid] = 0;
  133. Cantidad2[playerid] = 0;
  134. RFinal[playerid] = 0;
  135. RFinal2[playerid] = 0;
  136. return 1;
  137. }
  138.  
  139.  
  140. //============================================================================//
  141. //                                                                            //
  142. //                            Final del Script                                //
  143. //                                                                            //
  144. //                Si te sirvio, respeta el trabajo del creador                //
  145. //                                                                            //
  146. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment