Guest User

login

a guest
May 10th, 2010
1,486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.75 KB | None | 0 0
  1. //*-----------------------------------------------------------------------------------------------------------------------------------------------------------*//
  2.  
  3. #include <a_samp>
  4. #include <Dini>
  5. #include <dudb>
  6. new pname[MAX_PLAYER_NAME];
  7. new banklogged[MAX_PLAYERS];
  8. new bankmoney[MAX_PLAYERS];
  9. #define COLOR_RED 0xFF0000AA
  10. #define COLOR_YELLOW 0xFFFF00AA
  11. #define COLOR_GREEN 0x00FF00AA
  12. #if defined FILTERSCRIPT
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.          CreatePickup(1239, 23, 1458.6437,-1011.8918,26.8438, -1);
  17.     print("/////////////////////////////////////////");
  18.     print("//     SIMPLE BANK SYSTEM BY SEAN5874   //");
  19.     print("//    Releasedate: 04-04-10           //");
  20.     print("///////////////////////////////////////");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     return 1;
  27. }
  28.  
  29. #endif
  30.  
  31. public OnPlayerDisconnect(playerid, reason)
  32. {
  33.     dini_IntSet(udb_encode(pname), "bankmoney", bankmoney[playerid]);
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerCommandText(playerid, cmdtext[])
  38. {
  39.     new cmd[256], idx, tmp[265], tmp2[256];
  40.     cmd = strtok(cmdtext, idx);
  41.     GetPlayerName(playerid, pname, sizeof(pname));
  42.     new string[128];
  43.     //register and login stuff
  44.     if (strcmp("/createaccount", cmdtext, true, 10) == 0)
  45.     {
  46.         new pincode; //creating the variable
  47.         tmp = strtok(cmdtext, idx);
  48.         if(!strlen(tmp)) //checks of the player dont forgot any variable
  49.         {
  50.             SendClientMessage(playerid, COLOR_RED, "USAGE: /createaccount [pincode]");
  51.             return 1;
  52.         }
  53.         pincode = strval(tmp); //'pincode' got saved in an TMP
  54.  
  55.         if (!dini_Exists(udb_encode(pname))) //checks of the player have already made an account
  56.         {
  57.             dini_Create(udb_encode(pname));
  58.             dini_IntSet(udb_encode(pname), "pincode", udb_hash(tmp)); //puts the pincode in the file
  59.             dini_IntSet(udb_encode(pname), "bankmoney", 0); // if you want to give the player a starters bonus, then add here an other number
  60.             SendClientMessage(playerid, COLOR_GREEN,"You have created new bank account! You can now log in.");
  61.             return 1;
  62.         }
  63.         else
  64.         {
  65.             SendClientMessage(playerid, COLOR_RED,"You have already a bank account!"); //if the player have already an bankaccount
  66.             return 1;
  67.         }}
  68.     if (strcmp("/loginaccount", cmdtext, true, 10) == 0)
  69.     {
  70.         new pincode; //creating the variable
  71.         tmp = strtok(cmdtext, idx);
  72.         if(banklogged[playerid] == 1) //checks if a player is logged in in his account
  73.         {
  74.             SendClientMessage(playerid, COLOR_RED, "You are already logged in!"); return 1;
  75.         }
  76.         if(!strlen(tmp)) //checks of the player dont forgot any variable
  77.         {
  78.             SendClientMessage(playerid, COLOR_RED, "USAGE: /loginaccount [pincode]");
  79.             return 1;
  80.         }
  81.         pincode = strval(tmp); //'pincode' got saved in an TMP
  82.         tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
  83.         if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
  84.         {
  85.             SendClientMessage(playerid, COLOR_RED, "You have entered a wrong pincode, try again!"); //if not...
  86.             return 1;
  87.         }
  88.         SendClientMessage(playerid, COLOR_GREEN, "You have logged in into your bankaccount!");//if yes...
  89.         banklogged[playerid] = 1;
  90.         return 1;
  91.     }
  92.            
  93.         //deposit, withdraw and balance cmd's
  94.     if(strcmp(cmd, "/deposit", true)==0)
  95.     {
  96.         new amount; //creating the variable
  97.         tmp = strtok(cmdtext, idx);
  98.         if(banklogged[playerid] == 0) //checks if a player is logged in in his account
  99.         {
  100.             SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
  101.         }
  102.         if(!strlen(tmp)) // checks of the player dont forgot any variable
  103.         {
  104.             SendClientMessage(playerid, COLOR_RED, "USAGE: /deposit [amount]"); return 1;
  105.         }
  106.         amount = strval(tmp); //'amount' got saved in an TMP
  107.  
  108.         new currentm = GetPlayerMoney(playerid);
  109.         if(currentm <= amount) //checks if the players current money is lower than the amount he want to deposit
  110.         {
  111.             SendClientMessage(playerid, COLOR_RED,"You can't deposit more money than you have!"); return 1;
  112.         }
  113.         if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// checks if the player at the bank
  114.         {
  115.             bankmoney[playerid] += amount; //money goes on the bank account
  116.             format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
  117.             SendClientMessage(playerid, COLOR_YELLOW, string);
  118.             GivePlayerMoney(playerid, -amount);
  119.             return 1;
  120.         }
  121.         else
  122.         {
  123.             SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; // if hes not at the bank...
  124.         }
  125.     }
  126.     if(strcmp(cmd, "/balance", true)==0)
  127.     {
  128.         if(banklogged[playerid] == 0) //checks if a player is logged in in his account
  129.         {
  130.             SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
  131.         }
  132.         if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438)) //check if the player is at the bank
  133.         {
  134.             format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]); //show the amount of money on the account
  135.             SendClientMessage(playerid, COLOR_YELLOW, string);
  136.             return 1;
  137.         }
  138.         else
  139.         {
  140.             SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; //if hes not at the bank
  141.         }
  142.     }
  143.     if(strcmp(cmd, "/withdraw", true)==0)
  144.     {
  145.         new wamount; //creating the variable
  146.         tmp = strtok(cmdtext, idx);
  147.         if(banklogged[playerid] == 0) // checks if a player is logged in in his account
  148.         {
  149.             SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
  150.         }
  151.         if(!strlen(tmp)) // checks of the player dont forgot any variable
  152.         {
  153.             SendClientMessage(playerid, COLOR_RED, "USAGE: /withdraw [amount]"); return 1;
  154.         }
  155.         wamount = strval(tmp); //'wamount' got saved in an TMP
  156.  
  157.         new bank = bankmoney[playerid];
  158.         if(bank <= wamount) // if a player tries to withdraw more money than he haves on his account...
  159.         {
  160.             SendClientMessage(playerid, COLOR_RED,"You can't withdraw more money than you have!"); return 1;
  161.         }
  162.         if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// check if the player is at the bank
  163.         {
  164.             bankmoney[playerid] -= wamount; //money is taken from the bank account
  165.             format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount); // show the amount of withdrawed money
  166.             SendClientMessage(playerid, COLOR_YELLOW, string);
  167.             GivePlayerMoney(playerid, wamount);// gives the player his money
  168.             return 1;
  169.         }
  170.         else
  171.         {
  172.             SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; //if hes not at the bank
  173.         }
  174.     }
  175.     return 0;
  176. }
  177.  
  178. //*-----------------------------------------------------------------------------------------------------------------------------------------------------------*//
Advertisement
Add Comment
Please, Sign In to add comment