Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- / / Bank system by OzSasson iRaiDeN
- # include <a_samp>
- # include <YSI\y_ini>
- # include <YSI\y_commands>
- / / ======== [ Define ] ========
- # define DIALOG_BANK (random (200))
- # define DIALOG_DEPOSIT (random (300))
- # define DIALOG_WITHDRAW (random (100))
- # define MAX_DEPOSIT (1000000000)
- # define MAX_WITHDRAW (500000)
- / / ====== [ News ] ========
- enum pInfo
- {
- pBankAccount ,
- pAccountdata
- }
- new PlayerInfo [MAX_PLAYERS] [pInfo],
- gName [MAX_PLAYERS] [MAX_PLAYER_NAME +1],
- szString [256];
- public OnPlayerConnect (playerid)
- {
- INI_ParseFile (gAccountFile (playerid), "LoadUser_% s",. BExtra = true,. Extra = playerid);
- if (! PlayerInfo [playerid] [pAccountdata])
- {
- new INI: File = INI_Open (gAccountFile (playerid));
- INI_WriteInt (File, "BankAccount", 0);
- INI_WriteInt (File, "DataSaved", 1);
- INI_Close (File);
- }
- return GetPlayerName (playerid, gName [playerid], MAX_PLAYER_NAME +1), 1;
- }
- public OnPlayerDisconnect (playerid, reason)
- {
- new INI: File = INI_Open (gAccountFile (playerid));
- INI_WriteInt (File, "BankAccount", PlayerInfo [playerid] [pBankAccount]);
- INI_WriteInt (File, "Datasaved", PlayerInfo [playerid] [pAccountdata]);
- INI_Close (File);
- return 1 ;
- }
- YCMD: bank (playerid, params [], help)
- {
- # pragma unused help
- ShowPlayerDialog (playerid, DIALOG_BANK, DIALOG_STYLE_LIST, "Bank", "Deposit - control \ nWithdraw - Remove \ nBalance - Balance " , "Cancel" , "Select " ) ;
- }
- public OnDialogResponse (playerid, dialogid, response, listitem, inputtext [])
- {
- if (dialogid == DIALOG_BANK)
- {
- if ( ! response ) return 0;
- if ( response )
- {
- switch (listitem)
- {
- case 1: ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
- case 2: ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
- case 3 :
- {
- format (szString, 50, "Your Balance:% d", PlayerInfo [playerid] [pBankAccount]);
- ShowPlayerDialog (playerid, 123, DIALOG_STYLE_MSGBOX, "Balance", szString, " Cancel" , "OK " ) ;
- }
- }
- }
- }
- if (dialogid == DIALOG_DEPOSIT)
- {
- if ( ! response ) return 0;
- if ( response )
- {
- if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
- if (GetPlayerMoney (playerid) <strval (inputtext)) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " you do not have the amount requested , please type a new amount " , "Cancel" , " control " ) ;
- format (szString, 256, " You can deposit up to % d", MAX_DEPOSIT);
- if (strval (inputtext)> MAX_DEPOSIT) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " control " ) ;
- GivePlayerMoney (playerid,-strval (inputtext));
- PlayerInfo [playerid] [pBankAccount] + = strval (inputtext);
- SendClientMessage (playerid, -1, " Deposition successfully " ) ;
- }
- }
- if (dialogid == DIALOG_WITHDRAW && response)
- {
- if ( ! response ) return 0;
- if ( response )
- {
- if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
- if (PlayerInfo [playerid] [pBankAccount]> = strval (inputtext)) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " you do not have the amount requested , please type a new amount " , "Cancel" , " pull " ) ;
- format (szString, 256, " You can pull up to % d", MAX_WITHDRAW);
- if (strval (inputtext)> MAX_WITHDRAW) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " pull " ) ;
- GivePlayerMoney (playerid, strval (inputtext));
- PlayerInfo [playerid] [pBankAccount] - = strval (inputtext);
- SendClientMessage (playerid, -1, " You pulled successfully " ) ;
- }
- }
- return 1 ;
- }
- forward public LoadUser_data (playerid, name [], value []);
- public LoadUser_data (playerid, name [], value [])
- {
- INI_Int ("BankAccount", PlayerInfo [playerid] [pBankAccount]);
- INI_Int ("Datasaved", PlayerInfo [playerid] [pAccountdata]);
- return 1 ;
- }
- stock gAccountFile (playerid)
- {
- new gFile [50];
- format (gFile, 50, "/ Users /% s.ini", gName [playerid]);
- return gFile ;
- }
Advertisement
Add Comment
Please, Sign In to add comment