Advertisement
Guest User

Banco em DOF2

a guest
Jan 14th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.89 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3.  
  4. public OnFilterScriptInit()
  5. {
  6.     print("\n--------------------------------------");
  7.     print(" Sistema de Banco Por FreeGells\n");
  8.     print(" Carregando...\n");
  9.     print("--------------------------------------\n");
  10.     Create3DTextLabel("Banco", -1, 2316.6208,-9.7189,26.7422, 20,0);
  11.     return 1;
  12. }
  13.  
  14.  
  15. public OnFilterScriptExit()
  16. {
  17.     print("\n--------------------------------------");
  18.     print(" Sistema de Banco Por FreeGells\n");
  19.     print(" Descarregando...\n");
  20.     print("--------------------------------------\n");
  21.  
  22.     DOF2_Exit ();
  23.  
  24.     return 1;
  25. }
  26.  
  27.  
  28. public OnPlayerCommandText(playerid, cmdtext[])
  29. {
  30.     new cmd[256], idx, tmp[256], Arquivo[256], Dinheiro, string[128];
  31.     cmd = strtok(cmdtext, idx);
  32.  
  33.     if(strcmp(cmd, "/depositar", true) == 0) {
  34.         if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.6208,-9.7189,26.7422)) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Você não está no Banco!");
  35.         {
  36.             tmp = strtok(cmdtext, idx);
  37.             if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Use: /Depositar [Quantia]");
  38.             Dinheiro = strval(tmp);
  39.             if(GetPlayerMoney(playerid)<Dinheiro) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Você não tem está quantia!");
  40.             {
  41.                 if(GetPlayerMoney(playerid) >= Dinheiro) {
  42.                     new n[MAX_PLAYER_NAME];
  43.                     GetPlayerName(playerid, n, sizeof(n));
  44.                     format(Arquivo, sizeof(Arquivo), "Banco/%s.txt", n);
  45.  
  46.                     if(DOF2_FileExists(Arquivo)) {
  47.                         DOF2_SetInt(Arquivo, "Saldo", DOF2_GetInt(Arquivo, "Saldo") +Dinheiro);
  48.                     }
  49.                     else if(!DOF2_FileExists(Arquivo)) {
  50.                         DOF2_CreateFile(Arquivo);
  51.                         DOF2_SetInt(Arquivo, "Saldo", Dinheiro);
  52.                     }
  53.                     format(string, sizeof(string), "[BANCO] Você depositou %d em sua conta, Saldo atual: %d", Dinheiro, DOF2_GetInt(Arquivo, "Saldo"));
  54.                     SendClientMessage(playerid, 0x5EAF03FF, string);
  55.                     GivePlayerMoney(playerid, -Dinheiro);
  56.                 }
  57.                 return 1;
  58.             }
  59.         }
  60.     }
  61.  
  62.     if(strcmp(cmd, "/sacar", true) == 0) {
  63.         if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.6208,-9.7189,26.7422)) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Você não está no Banco!");
  64.         {
  65.             tmp = strtok(cmdtext, idx);
  66.             if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA,"[ERRO] Use: /Sacar [Quantia]");
  67.             Dinheiro = strval(tmp);
  68.             {
  69.                 new n[MAX_PLAYER_NAME];
  70.                 GetPlayerName(playerid, n, sizeof(n));
  71.                 format(Arquivo, sizeof(Arquivo), "Banco/%s.txt", n);
  72.                 if(DOF2_FileExists(Arquivo)) {
  73.                     if(DOF2_GetInt(Arquivo, "Saldo") < Dinheiro) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Você não tem está quantia no Banco!");
  74.                     else if(DOF2_GetInt(Arquivo, "Saldo") >= Dinheiro) {
  75.                         DOF2_SetInt(Arquivo, "Saldo", DOF2_GetInt(Arquivo, "Saldo") -Dinheiro);
  76.                         format(string, sizeof(string), "[BANCO] Você retirou %d de sua conta bancaria, Saldo atual %d", Dinheiro, DOF2_GetInt(Arquivo, "Saldo"));
  77.                         SendClientMessage(playerid, 0x5EAF03FF, string);
  78.                         GivePlayerMoney(playerid, Dinheiro);
  79.                     }
  80.                 }
  81.             }
  82.             return 1;
  83.         }
  84.     }
  85.  
  86.     if(strcmp(cmd, "/saldo", true) == 0) {
  87.         if(!IsPlayerInRangeOfPoint(playerid, 1.0, 2316.6208,-9.7189,26.7422)) return SendClientMessage(playerid, 0xFFFFFFAA, "[ERRO] Você não está no Banco!");
  88.         {
  89.             new n[MAX_PLAYER_NAME];
  90.             GetPlayerName(playerid, n, sizeof(n));
  91.             format(Arquivo, sizeof(Arquivo), "Banco/%s.txt", n);
  92.             if(DOF2_FileExists(Arquivo)) {
  93.                 format(string, sizeof(string), "[BANCO] Seu Saldo atual é %d", DOF2_GetInt(Arquivo, "Saldo"));
  94.                 SendClientMessage(playerid, 0x5EAF03FF, string);
  95.             }
  96.             else if(!DOF2_FileExists(Arquivo)) {
  97.                 SendClientMessage(playerid, 0x5EAF03FF, "[BANCO] Seu Saldo atual é 0");
  98.             }
  99.             return 1;
  100.         }
  101.     }
  102.  
  103.     if(strcmp(cmd, "/cbanco", true) == 0) {
  104.         SendClientMessage(playerid, 0x5EAF03FF, "~~~~~~~~~~~~~~~~~~~~~ Comandos Banco ~~~~~~~~~~~~~~~~~~~~~");
  105.         SendClientMessage(playerid, 0xFFFFFFAA, "{5EAF03}»{FFFFFF} /Saldo - Checa o Saldo Bancario");
  106.         SendClientMessage(playerid, 0xFFFFFFAA, "{5EAF03}»{FFFFFF} /Sacar [Quantia] - Saca a quantia desejada");
  107.         SendClientMessage(playerid, 0xFFFFFFAA, "{5EAF03}»{FFFFFF} /Depositar [Quantia] - Deposita a quantia desejada");
  108.         SendClientMessage(playerid, 0x5EAF03FF, "~~~~~~~~~~~~~~~~~~~~~ Comandos Banco ~~~~~~~~~~~~~~~~~~~~~");
  109.         return 1;
  110.     }
  111.    
  112.     if(strcmp(cmd, "/creditosb", true) == 0) {
  113.         SendClientMessage(playerid, 0x5EAF03FF, "~~~~~~~~~~~~~~~~~~~~~ Creditos Banco ~~~~~~~~~~~~~~~~~~~~~");
  114.         SendClientMessage(playerid, 0xFFFFFFAA, "{5EAF03}»{FFFFFF} Creditos a FreeGells pelo sistema de Banco!");
  115.         SendClientMessage(playerid, 0x5EAF03FF, "~~~~~~~~~~~~~~~~~~~~~ Creditos Banco ~~~~~~~~~~~~~~~~~~~~~");
  116.         return 1;
  117.     }
  118.     return 0;
  119. }
  120.  
  121. strtok(const string[], &index)
  122. {
  123.     new length = strlen(string);
  124.     while ((index < length) && (string[index] <= ' '))
  125.     {
  126.         index++;
  127.     }
  128.  
  129.     new offset = index;
  130.     new result[20];
  131.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  132.     {
  133.         result[index - offset] = string[index];
  134.         index++;
  135.     }
  136.     result[index - offset] = EOS;
  137.     return result;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement