darkxdll

[FS]Bank System [v0.1]

Jul 24th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.91 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <dof2>
  4.  
  5. #define DIALOG_BANCO        2504
  6. #define PASTA_BANCO         "Banco/%s"
  7.  
  8.  
  9. enum infos
  10. {
  11.     cSaldo
  12. };
  13. new cBanco[MAX_PLAYERS][infos];
  14.  
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n----------------------------------------------");
  19.     print(" Sistema básico de banco (v0.1)  by Brunno      ");
  20.     print("----------------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     DOF2_Exit();
  27.     return 1;
  28. }
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     SendClientMessage(playerid,-1,">> Sistema de banco(v0.1) produzido por BrunnoVinicius <<");
  33.     return 1;
  34. }
  35.  
  36.  
  37.  
  38. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  39. {
  40.     if(dialogid == DIALOG_BANCO)
  41.     {
  42.         if(response)
  43.         {
  44.             if(listitem == 0)
  45.             {
  46.                 new string[200];
  47.                 format(string,sizeof(string),"Saldo Atual : %d \n \n \n \n \n Sistema de banco produzido por BrunnoVinicius",cBanco[playerid][cSaldo]);
  48.                 ShowPlayerDialog(playerid,DIALOG_BANCO+1,DIALOG_STYLE_MSGBOX,">>    Sistema de Banco (v0.1)    <<",string,"Ok","");
  49.                 return 1;
  50.             }
  51.             else if(listitem == 1)
  52.             {
  53.                 new string[200];
  54.                 format(string,sizeof(string),"Você tem %d em mãos \n Quantos você deseja depositar ? \n Valor na conta %d",GetPlayerMoney(playerid),cBanco[playerid][cSaldo]);
  55.                 ShowPlayerDialog(playerid,DIALOG_BANCO+2,DIALOG_STYLE_INPUT,">>    Sistema de Banco (v0.1)    <<",string,"Ok","Cancelar");
  56.                 return 1;
  57.             }
  58.             else if(listitem == 2)
  59.             {
  60.                 new string[200];
  61.                 format(string,sizeof(string),"Você tem %d em mãos \n Quantos você deseja sacar ? \n Valor na conta %d",GetPlayerMoney(playerid),cBanco[playerid][cSaldo]);
  62.                 ShowPlayerDialog(playerid,DIALOG_BANCO+3,DIALOG_STYLE_INPUT,">>    Sistema de Banco (v0.1)    <<",string,"Ok","Cancelar");
  63.                 return 1;
  64.             }
  65.         }
  66.     }
  67.     if(dialogid == DIALOG_BANCO+1)
  68.     {
  69.         if(response || !response)
  70.         {
  71.             ShowPlayerDialog(playerid,DIALOG_BANCO,DIALOG_STYLE_LIST,">>    Sistema de Banco (v0.1)    <<","Saldo\nDepositar\nSacar","Ok","Cancelar");
  72.             return 1;
  73.         }
  74.     }
  75.     if(dialogid == DIALOG_BANCO+2)
  76.     {
  77.         if(response)
  78.         {
  79.             if(strval(inputtext))
  80.             {
  81.                 if(GetPlayerMoney(playerid) < strval(inputtext)) return SendClientMessage(playerid,-1,"ERRO ! Você não tem está quantia");
  82.                 new string[200];
  83.                 new pname[MAX_PLAYER_NAME];
  84.                 new valor = strval(inputtext);
  85.                 GetPlayerName(playerid,pname,sizeof(pname));
  86.                 format(string,sizeof(string),PASTA_BANCO,pname);
  87.                 new money = DOF2_GetInt(string,"grana");
  88.                 DOF2_SetInt(string,"grana",money + valor);
  89.                 GivePlayerMoney(playerid,-valor);
  90.                 cBanco[playerid][cSaldo] += valor;
  91.                 DOF2_SaveFile();
  92.                 return 1;
  93.             }
  94.         }
  95.     }
  96.     if(dialogid == DIALOG_BANCO+3)
  97.     {
  98.         new string[200];
  99.         new pname[MAX_PLAYER_NAME];
  100.         GetPlayerName(playerid,pname,sizeof(pname));
  101.         format(string,sizeof(string),PASTA_BANCO,pname);
  102.         if(response)
  103.         {
  104.             if(strval(inputtext))
  105.             {
  106.                 if(DOF2_GetInt(string,"grana") < strval(inputtext)) return SendClientMessage(playerid,-1,"ERRO ! Você não tem está quantia");
  107.                 new valor = strval(inputtext);
  108.                 new money = DOF2_GetInt(string,"grana");
  109.                 DOF2_SetInt(string,"grana",money - valor);
  110.                 GivePlayerMoney(playerid,valor);
  111.                 cBanco[playerid][cSaldo] -= valor;
  112.                 DOF2_SaveFile();
  113.                 return 1;
  114.             }
  115.         }
  116.     }
  117.     return 1;
  118. }
  119. CMD:banco(playerid)
  120. {
  121.     new string[200];
  122.     new pname[MAX_PLAYER_NAME];
  123.     GetPlayerName(playerid,pname,sizeof(pname));
  124.     format(string,sizeof(string),PASTA_BANCO,pname);
  125.     if(!DOF2_FileExists(string))
  126.     {
  127.         DOF2_CreateFile(string);
  128.         DOF2_SetInt(string,"grana",0);
  129.         DOF2_SaveFile();
  130.         ShowPlayerDialog(playerid,DIALOG_BANCO,DIALOG_STYLE_LIST,">>    Sistema de Banco (v0.1)    <<","Saldo\nDepositar\nSacar","Ok","Cancelar");
  131.     }else
  132.     {
  133.         ShowPlayerDialog(playerid,DIALOG_BANCO,DIALOG_STYLE_LIST,">>    Sistema de Banco (v0.1)    <<","Saldo\nDepositar\nSacar","Ok","Cancelar");
  134.     }
  135.     return 1;
  136. }
Add Comment
Please, Sign In to add comment