Advertisement
Chip7

[FS] FilterScript Sistema de Banco

Jun 26th, 2012
1,125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.84 KB | None | 0 0
  1. /*VISITE NOSSO SITE: http://www.sampknd.com/
  2.   SAMP KND MELHOR BLOG DE SAMP DO BRASIL
  3. */
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <Bini>
  8.  
  9. #define DCRIARCONTA 142
  10. #define DSENHACONTA 143
  11. #define DSENHA 144
  12. #define DSACAR 145
  13. #define DDEPOSITAR 146
  14. #define DSENHADEPOSITAR 147
  15. #define DSENHACONFIRMAR 148
  16. #define DMUDARSENHA 149
  17. #define DSALDO 150
  18. #define DTRANSFERIR 151
  19. #define DTRANSFERIRNUMERO 152
  20. #define DTRANSFERIRVALOR 153
  21. #define DINFO 154
  22.  
  23. new nome[MAX_PLAYER_NAME];
  24. new arquivo[49];
  25. new string[128];
  26. enum PP
  27. {
  28.     Conta,
  29.     Numero,
  30.     Depositado,
  31.     Senha
  32. }
  33. new BancoInfo[MAX_PLAYERS][PP];
  34.  
  35. public OnFilterScriptInit()
  36. {
  37.     CreateObject(2942, 1550.5789794922, -1669.7015380859, 13.204420089722, 0, 0, 270);
  38.     CreateObject(2942, 1550.6994628906, -1681.2255859375, 13.204420089722, 0, 0, 270);
  39.     return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44.     return 1;
  45. }
  46. public OnPlayerConnect(playerid)
  47. {
  48.     Carregar(playerid);
  49.     return 1;
  50. }
  51. public OnPlayerDisconnect(playerid, reason)
  52. {
  53.     Salvar(playerid);
  54.     return 1;
  55. }
  56. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  57. {
  58.     if(dialogid == DSENHA)
  59.     {
  60.         if(response)
  61.         {
  62.         new Gustavo = strval(inputtext);
  63.         if(Gustavo != BancoInfo[playerid][Senha]) return SendClientMessage(playerid,0xFF0000AA,"Senha Incorreta!");
  64.         ShowPlayerDialog(playerid,DSACAR,DIALOG_STYLE_INPUT,"Sacar","Digite a Quantidade a ser Sacada","Sacar","Cancelar");
  65.         }
  66.     }
  67.     if(dialogid == DSENHACONFIRMAR)
  68.     {
  69.         if(response)
  70.         {
  71.         new Gustavo = strval(inputtext);
  72.         if(Gustavo != BancoInfo[playerid][Senha]) return SendClientMessage(playerid,0xFF0000AA,"Senha Incorreta!");
  73.         ShowPlayerDialog(playerid,DMUDARSENHA,DIALOG_STYLE_INPUT,"Mudar Senha","Digite a Sua Nova Senha","Ok","Cancelar");
  74.         }
  75.     }
  76.     if(dialogid == DMUDARSENHA)
  77.     {
  78.         if(response)
  79.         {
  80.         new Gustavo = strval(inputtext);
  81.         format(string,50,"Senha Mudada a %i",Gustavo);
  82.         SendClientMessage(playerid,0x008000AA,string);
  83.         BancoInfo[playerid][Senha] = Gustavo;
  84.         Salvar(playerid);
  85.         }
  86.     }
  87.     if(dialogid == DSACAR)
  88.     {
  89.         if(response)
  90.         {
  91.         new Gustavo = strval(inputtext);
  92.         if(Gustavo > BancoInfo[playerid][Depositado]) return SendClientMessage(playerid,0xFF0000AA,"Voce nao tem tudo isso na sua conta do banco");
  93.         GivePlayerMoney(playerid,Gustavo);
  94.         BancoInfo[playerid][Depositado] -= Gustavo;
  95.         format(string,60,"Voce Sacou $%d",Gustavo);
  96.         SendClientMessage(playerid,-1,string);
  97.         Salvar(playerid);
  98.         }
  99.     }
  100.     if(dialogid == DDEPOSITAR)
  101.     {
  102.         if(response)
  103.         {
  104.         new Gustavo = strval(inputtext);
  105.         if(Gustavo > GetPlayerMoney(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce nao tem tudo isso");
  106.         GivePlayerMoney(playerid,-Gustavo);
  107.         BancoInfo[playerid][Depositado] += Gustavo;
  108.         Salvar(playerid);
  109.         format(string,50,"Voce depositou $%i",Gustavo);
  110.         SendClientMessage(playerid,-1,string);
  111.         }
  112.     }
  113.     if(dialogid == DSALDO)
  114.     {
  115.         if(response)
  116.         {
  117.         new Gustavo = strval(inputtext);
  118.         if(Gustavo != BancoInfo[playerid][Senha]) return SendClientMessage(playerid,0xFF0000AA,"Senha Incorreta!");
  119.         format(string,100,"o Seu Saldo Bancario e de $%d",BancoInfo[playerid][Depositado]);
  120.         SendClientMessage(playerid,-1,string);
  121.         }
  122.     }
  123.     if(dialogid == DSENHADEPOSITAR)
  124.     {
  125.         if(response)
  126.         {
  127.         new Gustavo = strval(inputtext);
  128.         if(Gustavo != BancoInfo[playerid][Senha]) return SendClientMessage(playerid,0xFF0000AA,"Senha Incorreta!");
  129.         ShowPlayerDialog(playerid,DDEPOSITAR,DIALOG_STYLE_INPUT,"Depositar","Digite a Quantidade a ser Depositada","Depositar","Cancelar");
  130.         }
  131.     }
  132.     if(dialogid == DTRANSFERIR)
  133.     {
  134.         if(response)
  135.         {
  136.         new Gustavo = strval(inputtext);
  137.         if(Gustavo != BancoInfo[playerid][Senha]) return SendClientMessage(playerid,0xFF0000AA,"Senha Incorreta!");
  138.         ShowPlayerDialog(playerid,DTRANSFERIRNUMERO,DIALOG_STYLE_INPUT,"Numero da Conta","Digite o Numero da conta na qual voce quer Transferir","Ok","Cancelar");
  139.         }
  140.     }
  141.     if(dialogid == DTRANSFERIRNUMERO)
  142.     {
  143.         if(response)
  144.         {
  145.             SetPVarInt(playerid, "ReceptorDeposito", strval(inputtext));
  146.             ShowPlayerDialog(playerid, DTRANSFERIRVALOR, DIALOG_STYLE_INPUT, "Depósito bancário", "Digite o valor à ser depositado", "Ok", "Cancelar");
  147.         }
  148.     }
  149.     if(dialogid == DTRANSFERIRVALOR)
  150.     {
  151.         if(response)
  152.         {
  153.         new Gustavo = strval(inputtext);
  154.         if(BancoInfo[playerid][Depositado] < Gustavo) return SendClientMessage(playerid,-1,"Voce Nao tem tudo isso na sua conta");
  155.         new receptor = GetPVarInt(playerid, "ReceptorDeposito");
  156.  
  157.         for(new i = 0; i < MAX_PLAYERS; i++)
  158.  
  159.         {
  160.             if(receptor == BancoInfo[i][Numero]) //Esse [numero] é o numero da conta do cara
  161.             {
  162.                 DeletePVar(playerid, "ReceptorDeposito");
  163.                 BancoInfo[i][Depositado] += Gustavo;
  164.                 BancoInfo[playerid][Depositado] -= Gustavo;
  165.                 format(string,50,"Voce Transferiu $%d",Gustavo);
  166.                 SendClientMessage(playerid,-1,string);
  167.                 break;
  168.             }
  169.         }
  170.  
  171.         }
  172.     }
  173.  
  174.     if(dialogid == DCRIARCONTA)
  175.     {
  176.         if(response)
  177.         {
  178.         ShowPlayerDialog(playerid,DSENHACONTA,DIALOG_STYLE_INPUT,"Criar Conta No Banco","Digite Uma Senha para criar sua Conta no Banco","Sim","Não");
  179.         }
  180.     }
  181.     if(dialogid == DSENHACONTA)
  182.     {
  183.         if(response)
  184.         {
  185.         new NConta = 1000 + random(999999);
  186.         new Gustavo = strval(inputtext);
  187.         BancoInfo[playerid][Numero] = NConta;
  188.         BancoInfo[playerid][Senha] = Gustavo;
  189.         BancoInfo[playerid][Conta] = 1;
  190.         SendClientMessage(playerid,0x008000AA,"Conta Criada Com Sucesso!,use /ajudabanco para ver os comandos");
  191.         GetPlayerName(playerid,nome,24);
  192.         format(arquivo, sizeof(arquivo),"Banco/%s.ini", nome);
  193.         INI_Create(arquivo);
  194.         INI_Open(arquivo);
  195.         INI_WriteInt("Senha",Gustavo);
  196.         INI_WriteInt("Numero",NConta);
  197.         INI_WriteInt("Conta",BancoInfo[playerid][Conta]);
  198.         INI_WriteInt("Depositado",0);
  199.         INI_Save();
  200.         INI_Close();
  201.         format(string,50,"O Numero da sua Conta é: %d",BancoInfo[playerid][Numero]);
  202.         SendClientMessage(playerid,-1,string);
  203.         }
  204.     }
  205.     return 1;
  206. }
  207. /*MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  208. MMMMMMMMMMMMMMMMMMMMMMM| Comandos do Bank System |MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  209. MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM*/
  210. CMD:saldo(playerid,params[])
  211. {
  212. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  213. if(BancoInfo[playerid][Conta] == 0) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao tem Uma Conta!");
  214. ShowPlayerDialog(playerid,DSALDO,DIALOG_STYLE_INPUT,"Digite Sua Senha","Digite Sua Senha Para Poder ver o seu Saldo","Ok","Cancelar");
  215. return 1;
  216. }
  217. CMD:criarconta(playerid,params[])
  218. {
  219. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  220. if(BancoInfo[playerid][Conta] >= 1) return SendClientMessage(playerid,-1,"Voce ja tem Uma Conta!");
  221. ShowPlayerDialog(playerid,DCRIARCONTA,DIALOG_STYLE_MSGBOX,"Criar Conta No Banco","Ola,Voce Deseja Criar uma conta no Banco?","Sim","Não");
  222. return 1;
  223. }
  224. CMD:sacar(playerid,params[])
  225. {
  226. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  227. if(BancoInfo[playerid][Conta] == 0) return ShowPlayerDialog(playerid,DCRIARCONTA,DIALOG_STYLE_MSGBOX,"Conta no Banco","Voce nao tem uma conta no Banco,Deseja Criar Uma?","Sim","Não");
  228. ShowPlayerDialog(playerid,DSENHA,DIALOG_STYLE_INPUT,"Digitar Senha","Digite a Sua Senha Para Poder Sacar","Ok","Cancelar");
  229. return 1;
  230. }
  231. CMD:depositar(playerid,params[])
  232. {
  233. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  234. if(BancoInfo[playerid][Conta] == 0) return ShowPlayerDialog(playerid,DCRIARCONTA,DIALOG_STYLE_MSGBOX,"Conta no Banco","Voce nao tem uma conta no Banco,Deseja Criar Uma?","Sim","Não");
  235. ShowPlayerDialog(playerid,DSENHADEPOSITAR,DIALOG_STYLE_INPUT,"Digitar Senha","Digite a Sua Senha Para Poder Depositar","Ok","Cancelar");
  236. return 1;
  237. }
  238. CMD:mudarsenha(playerid,params[])
  239. {
  240. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  241. if(BancoInfo[playerid][Conta] == 0) return ShowPlayerDialog(playerid,DCRIARCONTA,DIALOG_STYLE_MSGBOX,"Conta no Banco","Voce nao tem uma conta no Banco,Deseja Criar Uma?","Sim","Não");
  242. ShowPlayerDialog(playerid,DSENHACONFIRMAR,DIALOG_STYLE_INPUT,"Digitar Senha","Digite a Sua Senha Atual Para poder Muda-la","Ok","Cancelar");
  243. return 1;
  244. }
  245. CMD:fecharconta(playerid,params[])
  246. {
  247. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  248. if(BancoInfo[playerid][Conta] == 0) return SendClientMessage(playerid,-1,"Voce nao tem conta,ou ja fechou ou ainda nao criou.");
  249. GivePlayerMoney(playerid,BancoInfo[playerid][Depositado]);
  250. BancoInfo[playerid][Conta] = 0;
  251. SendClientMessage(playerid,-1,"Conta fechada!");
  252. Salvar(playerid);
  253. return 1;
  254. }
  255. CMD:transferir(playerid,params[])
  256. {
  257. if(!IsPlayerInBank(playerid)) return SendClientMessage(playerid,0xFF0000AA,"Voce Nao Esta em um Banco!");
  258. if(BancoInfo[playerid][Conta] == 0) return ShowPlayerDialog(playerid,DCRIARCONTA,DIALOG_STYLE_MSGBOX,"Conta no Banco","Voce nao tem uma conta no Banco,Deseja Criar Uma?","Sim","Não");
  259. ShowPlayerDialog(playerid,DTRANSFERIR,DIALOG_STYLE_INPUT,"Transferir dinheiro","Coloque a Sua Senha do Banco para poder Transferir","Ok","Cancelar");
  260. return 1;
  261. }
  262. CMD:info(playerid,params[])
  263. {
  264. if(BancoInfo[playerid][Conta] == 0) return SendClientMessage(playerid,-1,"Voce nao tem Conta ainda");
  265. format(string,128,"Numero da Conta: %d",BancoInfo[playerid][Numero]);
  266. ShowPlayerDialog(playerid,DINFO,DIALOG_STYLE_MSGBOX,"Informaçoes de Sua Conta",string,"Ok","");
  267. return 1;
  268. }
  269.  
  270. CMD:ajudabanco(playerid,params[])
  271. {
  272. SendClientMessage(playerid,-1,"___________________________________________________________________");
  273. SendClientMessage(playerid,0x008000AA,"/saldo,/criarconta,/sacar,/depositar,/mudarsenha,/fecharconta /info");
  274. SendClientMessage(playerid,-1,"___________________________________________________________________");
  275. return 1;
  276. }
  277. forward IsPlayerInBank(playerid);
  278. public IsPlayerInBank(playerid)
  279. {
  280.     if(IsPlayerInRangeOfPoint(playerid,1.3,1550.5789794922, -1669.7015380859, 13.204420089722)) return 1; //Caixa eletronico em Frente a DP
  281.     else if(IsPlayerInRangeOfPoint(playerid,1.3,1550.6994628906, -1681.2255859375, 13.204420089722)) return 1;  //Caixa eletronico em Frente a DP
  282.     return 0;
  283. }
  284. stock Salvar(playerid)
  285. {
  286.     format(arquivo, sizeof(arquivo),"Banco/%s.ini", nome);    
  287.     INI_Open(arquivo);
  288.     INI_WriteInt("Senha",BancoInfo[playerid][Senha]);
  289.     INI_WriteInt("Numero",BancoInfo[playerid][Numero]);
  290.     INI_WriteInt("Conta",BancoInfo[playerid][Conta]);
  291.     INI_WriteInt("Depositado",BancoInfo[playerid][Depositado]);
  292.     INI_Save();
  293.     INI_Close();
  294.     return 1;
  295. }
  296. stock Carregar(playerid)
  297. {
  298.     GetPlayerName(playerid,nome,24);
  299.     format(arquivo, sizeof(arquivo),"Banco/%s.ini", nome);
  300.     if(!fexist(arquivo)) return 0x1;
  301.     INI_Open(arquivo);
  302.     BancoInfo[playerid][Senha] = INI_ReadInt("Senha");
  303.     BancoInfo[playerid][Numero] = INI_ReadInt("Numero");
  304.     BancoInfo[playerid][Conta] = INI_ReadInt("Conta");
  305.     BancoInfo[playerid][Depositado] = INI_ReadInt("Depositado");
  306.     INI_Close();
  307.     return 1;
  308. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement