Advertisement
Deaderik

ATM bankový systém

Feb 10th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.07 KB | Gaming | 0 0
  1. #include <a_samp>
  2.  
  3. new ATMData[MAX_PLAYERS][3];
  4.  
  5. const ATM_DIALOG = 1;
  6.  
  7. public OnPlayerCommandText(playerid, cmdtext[])
  8. {
  9.     if (!strcmp(cmdtext, "/atm", true))
  10.     {
  11.         ShowATMDialog(playerid);
  12.         return 1;
  13.     }
  14.     if (!strcmp(cmdtext, "/account", true))
  15.     {
  16.         ShowAccountBalance(playerid);
  17.         return 1;
  18.     }
  19.     return 0;
  20. }
  21.  
  22. public ShowATMDialog(playerid)
  23. {
  24.     ShowPlayerDialog(playerid, ATM_DIALOG, DIALOG_STYLE_INPUT, "Bankomat", "Zadejte částku, kterou chcete vložit nebo vybrat:", "Potvrdit", "Zrušit");
  25.     return 1;
  26. }
  27.  
  28. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  29. {
  30.     if (dialogid == ATM_DIALOG)
  31.     {
  32.         if (response)
  33.         {
  34.             new Float:amount = strtofloat(inputtext);
  35.             if (amount > 0)
  36.             {
  37.                 if (listitem == 0)
  38.                 {
  39.                     // Vkládání peněz
  40.                     GivePlayerMoney(playerid, amount);
  41.                     SendClientMessage(playerid, COLOR_GREEN, "Úspěšně jste vložili peníze do banky.");
  42.                 }
  43.                 else
  44.                 {
  45.                     // Vybrání peněz
  46.                     if (GetPlayerMoney(playerid) >= amount)
  47.                     {
  48.                         GivePlayerMoney(playerid, -amount);
  49.                         SendClientMessage(playerid, COLOR_GREEN, "Úspěšně jste vybrali peníze z banky.");
  50.                     }
  51.                     else
  52.                     {
  53.                         SendClientMessage(playerid, COLOR_RED, "Nemáte dostatek peněz na účtu.");
  54.                     }
  55.                 }
  56.             }
  57.             else
  58.             {
  59.                 SendClientMessage(playerid, COLOR_RED, "Zadejte platnou částku.");
  60.             }
  61.         }
  62.         return 1;
  63.     }
  64.     return 0;
  65. }
  66.  
  67. public ShowAccountBalance(playerid)
  68. {
  69.     new Float:balance = GetPlayerMoney(playerid);
  70.     format(string, sizeof(string), "Stav vašeho účtu: $%.2f", balance);
  71.     SendClientMessage(playerid, COLOR_WHITE, string);
  72.     return 1;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement