Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sistema de Calculadora By Badyx
- */
- #include <a_samp>
- new Cantidad1[MAX_PLAYERS];
- new Cantidad2[MAX_PLAYERS];
- new RFinal[MAX_PLAYERS];
- new RFinal2[MAX_PLAYERS];
- #define MiCantidad1 10000
- #define MiCantidad2 10001
- #define CalcularResultado 10002
- #if defined FILTERSCRIPT
- #else
- main() {}
- #endif
- public OnPlayerConnect(playerid)
- {
- Seteando(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Seteando(playerid);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/Calculadora", cmdtext, true, 10) == 0)
- {
- ShowPlayerDialog(playerid,MiCantidad1,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la primera cantidad","Aceptar","");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[300];
- new Uno = strval(inputtext);
- new Dos = strval(inputtext);
- if(dialogid == MiCantidad1 && response)
- {
- if(!strlen(inputtext))
- {
- SendClientMessage(playerid, -1, # No introduciste nada ¬¬);
- ShowPlayerDialog(playerid,MiCantidad1,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la primera cantidad","Aceptar","");
- return 1;
- }
- Cantidad1[playerid] = Uno;
- format(string, sizeof(string), # Cantidad %i, Uno);
- SendClientMessage(playerid, -1, string);
- ShowPlayerDialog(playerid,MiCantidad2,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la segunda cantidad","Aceptar","");
- return 1;
- }
- if(dialogid == MiCantidad2 && response)
- {
- if(!strlen(inputtext))
- {
- SendClientMessage(playerid, -1, # No introduciste nada ¬¬);
- ShowPlayerDialog(playerid,MiCantidad2,DIALOG_STYLE_INPUT,"Calculadora","Ingrese la segunda cantidad","Aceptar","");
- return 1;
- }
- Cantidad2[playerid] = Dos;
- format(string, sizeof(string), # Cantidad %i, Dos);
- SendClientMessage(playerid, -1, string);
- ShowPlayerDialog(playerid,CalcularResultado,DIALOG_STYLE_LIST,"Seleccione la operacion","Sumar\nRestar\nMultiplicar\nDividir","Confirmar","");
- return 1;
- }
- if(dialogid == CalcularResultado)
- {
- new Uno1 = Cantidad1[playerid];
- new Dos2 = Cantidad2[playerid];
- new Final = RFinal[playerid];
- new Final2 = RFinal[playerid];
- switch(listitem)
- {
- case 0://Suma
- {
- Final = Uno1;
- Final2 = Dos2;
- Final += Final2;
- format(string, sizeof(string), " El resultado de la suma de %i mas %i da como resultado %i", Uno1, Dos2,Final);
- SendClientMessage(playerid, -1, string);
- }
- case 1://resta
- {
- Final = Uno1;
- Final2 = Dos2;
- Final -= Final2;
- format(string, sizeof(string), # El resultado de la resta de %d menos %d da como resultado %d, Uno1, Dos2,Final);
- SendClientMessage(playerid, -1, string);
- }
- case 2://multiplicar
- {
- Final = Uno1;
- Final2 = Dos2;
- Final *= Final2;
- format(string, sizeof(string), # El resultado de la multiplicacion de %d por %d da como resultado %d, Uno1, Dos2,Final);
- SendClientMessage(playerid, -1, string);
- }
- case 3://Dividir
- {
- Final = Uno1;
- Final2 = Dos2;
- Final /= Final2;
- format(string, sizeof(string), # El resultado de la division de %d entre %d da como resultado %d, Uno1, Dos2,Final);
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- }
- return 1;
- }
- Seteando(playerid);
- return 1;
- }
- forward Seteando(playerid);
- public Seteando(playerid)
- {
- Cantidad1[playerid] = 0;
- Cantidad2[playerid] = 0;
- RFinal[playerid] = 0;
- RFinal2[playerid] = 0;
- return 1;
- }
- //============================================================================//
- // //
- // Final del Script //
- // //
- // Si te sirvio, respeta el trabajo del creador //
- // //
- //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment