Advertisement
cesar_google

Simple Sistema Bancario

Nov 12th, 2013
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.15 KB | None | 0 0
  1. #if defined Parka_Creditos
  2.                              -=Sistema Bancario=-
  3.                                -=Version 1.0=-
  4.                                -=  11/2013  =-
  5.                             -=Scripter By Parka=-
  6.                       -=Por favor no remover creditos=-
  7.         Plagio: Copiar en lo sustancial obras ajenas, dándolas como propias.
  8. #endif
  9. #include <a_samp>
  10. #include <Dini>
  11.  
  12. #pragma unused strtok
  13. #define Deposito    0b1010000
  14. #define Retiro      0b1010001
  15.  
  16. new BancoInfo[MAX_PLAYERS];
  17. new ObtenerInformacion[MAX_PLAYERS];
  18. new PlayerText:BancoTextDraw[0b10];
  19.  
  20. static CuentaBancaria(playerid){
  21.     new string[0b100000],Name[0b11000];
  22.     GetPlayerName(playerid,Name,sizeof(Name));
  23.     format(string,sizeof(string),"%s.txt",Name);
  24.     return string;
  25. }
  26.  
  27. stock IsNumeric2(const string[]){
  28.     // Is Numeric Check 2
  29.     // ------------------
  30.     // By DracoBlue... handles negative numbers
  31.  
  32.     new length=strlen(string);
  33.     if (length==0) return false;
  34.     for (new i = 0; i < length; i++)
  35.     {
  36.       if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
  37.              || (string[i]=='-' && i!=0)                                             // A '-' but not first char.
  38.              || (string[i]=='+' && i!=0)                                             // A '+' but not first char.
  39.          ) return false;
  40.     }
  41.     if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
  42.     return true;
  43. }
  44.  
  45. forward VerificarPosicion();
  46. public VerificarPosicion(){
  47.     for(new i, t=GetMaxPlayers(); i<t; i++){
  48.         if(!IsPlayerInCheckpoint(i)){
  49.             if(IsPlayerInRangeOfPoint(i,8.0,2316.3550,-9.9246,26.7422)){
  50.                 SetPlayerCheckpoint(i,2316.3550,-9.9246,26.7422,1.0);
  51.                 ObtenerInformacion[i] = 0b1;
  52.                 return 0b1;
  53.             }
  54.         }
  55.     }
  56.     return 0b1;
  57. }
  58.  
  59. public OnFilterScriptInit(){
  60.     print("\n\t-=Sistema Bancario=- \
  61.     \n\t-=Version 1.0=- \
  62.     \n\t-=Scripter By Parka=- \
  63.     \n\t-=Por favor no remover creditos=-\n\n\n");
  64.     SetTimer("VerificarPosicion",1000,true);
  65.     return 0b1;
  66. }
  67.  
  68. public OnPlayerConnect(playerid){
  69.  
  70.     ObtenerInformacion[playerid]    = 0b0;
  71.     BancoInfo[playerid]             = 0b0;
  72.    
  73.     if(dini_Exists(CuentaBancaria(playerid))){
  74.         BancoInfo[playerid] =   dini_Int(CuentaBancaria(playerid),"Dinero");
  75.     }else{
  76.         dini_Create(CuentaBancaria(playerid));
  77.         dini_IntSet(CuentaBancaria(playerid),"Dinero",BancoInfo[playerid]);
  78.     }
  79.    
  80.     BancoTextDraw[0b0] = CreatePlayerTextDraw(playerid,315.000000, 192.000000, "Depositar");
  81.     PlayerTextDrawAlignment(playerid,BancoTextDraw[0b0], 2);
  82.     PlayerTextDrawBackgroundColor(playerid,BancoTextDraw[0b0], 255);
  83.     PlayerTextDrawFont(playerid,BancoTextDraw[0b0], 2);
  84.     PlayerTextDrawLetterSize(playerid,BancoTextDraw[0b0], 0.390000, 1.200000);
  85.     PlayerTextDrawColor(playerid,BancoTextDraw[0b0], -1);
  86.     PlayerTextDrawSetOutline(playerid,BancoTextDraw[0b0], 1);
  87.     PlayerTextDrawSetProportional(playerid,BancoTextDraw[0b0], 1);
  88.     PlayerTextDrawUseBox(playerid,BancoTextDraw[0b0], 1);
  89.     PlayerTextDrawBoxColor(playerid,BancoTextDraw[0b0], -205);
  90.     PlayerTextDrawTextSize(playerid,BancoTextDraw[0b0], 20.000000, 94.000000);
  91.     PlayerTextDrawSetSelectable(playerid,BancoTextDraw[0b0], 1);
  92.  
  93.     BancoTextDraw[0b1] = CreatePlayerTextDraw(playerid,315.000000, 210.000000, "Retirar");
  94.     PlayerTextDrawAlignment(playerid,BancoTextDraw[0b1], 2);
  95.     PlayerTextDrawBackgroundColor(playerid,BancoTextDraw[0b1], 255);
  96.     PlayerTextDrawFont(playerid,BancoTextDraw[0b1], 2);
  97.     PlayerTextDrawLetterSize(playerid,BancoTextDraw[0b1], 0.390000, 1.200000);
  98.     PlayerTextDrawColor(playerid,BancoTextDraw[0b1], -1);
  99.     PlayerTextDrawSetOutline(playerid,BancoTextDraw[0b1], 1);
  100.     PlayerTextDrawSetProportional(playerid,BancoTextDraw[0b1], 1);
  101.     PlayerTextDrawUseBox(playerid,BancoTextDraw[0b1], 1);
  102.     PlayerTextDrawBoxColor(playerid,BancoTextDraw[0b1], -205);
  103.     PlayerTextDrawTextSize(playerid,BancoTextDraw[0b1], 20.000000, 94.000000);
  104.     PlayerTextDrawSetSelectable(playerid,BancoTextDraw[0b1], 1);
  105.     return 0b1;
  106. }
  107.  
  108. public OnPlayerDisconnect(playerid, reason){
  109.     if(dini_Exists(CuentaBancaria(playerid))){
  110.         dini_IntSet(CuentaBancaria(playerid),"Dinero",BancoInfo[playerid]);
  111.     }
  112.     return 0b1;
  113. }
  114.  
  115. public OnPlayerCommandText(playerid, cmdtext[]){
  116.     if(!strcmp("/banco",cmdtext)){
  117.         SetPlayerPos(playerid,2305.8740,-16.1259,26.7496); GivePlayerMoney(playerid,100000);
  118.         return 0b1;
  119.     }
  120.     return 0b1;
  121. }
  122.  
  123. public OnPlayerEnterCheckpoint(playerid){
  124.     if(ObtenerInformacion[playerid] == 0b1){
  125.         SelectTextDraw(playerid,0xFFFF0055);
  126.         PlayerTextDrawShow(playerid, BancoTextDraw[0b0]);
  127.         PlayerTextDrawShow(playerid, BancoTextDraw[0b1]);
  128.         return 0b1;
  129.     }
  130.     return 0b1;
  131. }
  132.  
  133. public OnPlayerLeaveCheckpoint(playerid){
  134.     if(ObtenerInformacion[playerid] == 0b1){
  135.         ObtenerInformacion[playerid] = 0b0;
  136.  
  137.         CancelSelectTextDraw(playerid);
  138.         PlayerTextDrawHide(playerid, BancoTextDraw[0b0]);
  139.         PlayerTextDrawHide(playerid, BancoTextDraw[0b1]);
  140.  
  141.         DisablePlayerCheckpoint(playerid);
  142.         return 0b1;
  143.     }
  144.     return 0b1;
  145. }
  146.  
  147. public OnPlayerClickTextDraw(playerid, Text:clickedid){
  148.     if(clickedid == Text:INVALID_TEXT_DRAW){
  149.         PlayerTextDrawHide(playerid, BancoTextDraw[0b0]);
  150.         PlayerTextDrawHide(playerid, BancoTextDraw[0b1]);
  151.         return 1;
  152.     }
  153.     return 1;
  154. }
  155.  
  156. public OnPlayerClickPlayerTextDraw(playerid,PlayerText:playertextid){
  157.     if(playertextid == BancoTextDraw[0b0]){
  158.         ShowPlayerDialog(playerid,Deposito,DIALOG_STYLE_INPUT,"Banco","Por favor ingrese la cantidad de dinero\nA Depositar en el siguiente espacio","Aceptar","Cancelar");
  159.         for(new t;t<2;t++){PlayerTextDrawHide(playerid,BancoTextDraw[t]);}
  160.         CancelSelectTextDraw(playerid);
  161.         return 1;
  162.     }
  163.     if(playertextid == BancoTextDraw[0b1]){
  164.         ShowPlayerDialog(playerid,Retiro,DIALOG_STYLE_INPUT,"Banco","Por favor ingrese la cantidad de dinero\nA Retirar en el siguiente espacio","Aceptar","Cancelar");
  165.         for(new t;t<2;t++){PlayerTextDrawHide(playerid,BancoTextDraw[t]);}
  166.         CancelSelectTextDraw(playerid);
  167.         return 1;
  168.     }
  169.     return 1;
  170. }
  171.    
  172. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  173.     switch(dialogid){
  174.         case Deposito:{
  175.             if(response){
  176.                 new Valor = strval(inputtext);
  177.                 if(!IsNumeric2(inputtext)) return SendClientMessage(playerid,-1,"Error escribir solo numeros!");
  178.                 if(Valor > GetPlayerMoney(playerid)) return SendClientMessage(playerid,-1,"Error usted no tiene esa cantidad de dinero!");
  179.                 BancoInfo[playerid] += Valor;
  180.                 GivePlayerMoney(playerid,-Valor);
  181.                 new string[0b10000000];
  182.                 format(string,sizeof(string),"Usted deposito en su cuenta bancaria $%d ahora posee $%d en ella!",Valor,BancoInfo[playerid]);
  183.                 SendClientMessage(playerid,0xC0C0C0AA,string);
  184.             }
  185.         }
  186.         case Retiro:{
  187.             if(response){
  188.                 new Valor = strval(inputtext);
  189.                 if(!IsNumeric2(inputtext)) return SendClientMessage(playerid,-1,"Error escribir solo numeros!");
  190.                 if(Valor > BancoInfo[playerid]) return SendClientMessage(playerid,-1,"Error usted no tiene esa cantidad de dinero!");
  191.                 BancoInfo[playerid] -= Valor;
  192.                 GivePlayerMoney(playerid,Valor);
  193.                 new string[0b10000000];
  194.                 format(string,sizeof(string),"Usted retiro de su cuenta bancaria $%d ahora posee $%d en ella!",Valor,BancoInfo[playerid]);
  195.                 SendClientMessage(playerid,0xC0C0C0AA,string);
  196.             }
  197.         }
  198.     }
  199.     return 0b1;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement