View difference between Paste ID: fPTs6Fwa and FJRhXEYz
SHOW: | | - or go back to the newest paste.
1
/ / Bank system by OzSasson iRaiDeN
2
# include <a_samp>
3
# include <YSI\y_ini>
4
# include <YSI\y_commands>
5
6
/ / ======== [ Define ] ========
7
8
# define DIALOG_BANK (random (200))
9
# define DIALOG_DEPOSIT (random (300))
10
# define DIALOG_WITHDRAW (random (100))
11
# define MAX_DEPOSIT (1000000000)
12
# define MAX_WITHDRAW (500000)
13
14
/ / ====== [ News ] ========
15
16
enum pInfo
17
{
18-
    pBankAccount ,
18+
	pBankAccount ,
19-
    pAccountdata
19+
	pAccountdata
20
}
21
22
new PlayerInfo [MAX_PLAYERS] [pInfo],
23
gName [MAX_PLAYERS] [MAX_PLAYER_NAME +1],
24
szString [256];
25
26
public OnPlayerConnect (playerid)
27
{
28-
    INI_ParseFile (gAccountFile (playerid), "LoadUser_% s",. BExtra = true,. Extra = playerid);
28+
	INI_ParseFile (gAccountFile (playerid), "LoadUser_% s",. BExtra = true,. Extra = playerid);
29-
    if (! PlayerInfo [playerid] [pAccountdata])
29+
	if (! PlayerInfo [playerid] [pAccountdata])
30-
    {
30+
	{
31-
        new INI: File = INI_Open (gAccountFile (playerid));
31+
		new INI: File = INI_Open (gAccountFile (playerid));
32-
        INI_WriteInt (File, "BankAccount", 0);
32+
		INI_WriteInt (File, "BankAccount", 0);
33-
        INI_WriteInt (File, "DataSaved", 1);
33+
		INI_WriteInt (File, "DataSaved", 1);
34-
        INI_Close (File);
34+
		INI_Close (File);
35
	}
36-
    return GetPlayerName (playerid, gName [playerid], MAX_PLAYER_NAME +1), 1;
36+
	return GetPlayerName (playerid, gName [playerid], MAX_PLAYER_NAME +1), 1;
37
}
38
39
public OnPlayerDisconnect (playerid, reason)
40
{
41-
    new INI: File = INI_Open (gAccountFile (playerid));
41+
	new INI: File = INI_Open (gAccountFile (playerid));
42-
    INI_WriteInt (File, "BankAccount", PlayerInfo [playerid] [pBankAccount]);
42+
	INI_WriteInt (File, "BankAccount", PlayerInfo [playerid] [pBankAccount]);
43-
    INI_WriteInt (File, "Datasaved", PlayerInfo [playerid] [pAccountdata]);
43+
	INI_WriteInt (File, "Datasaved", PlayerInfo [playerid] [pAccountdata]);
44-
    INI_Close (File);
44+
	INI_Close (File);
45-
    return 1 ;
45+
	return 1 ;
46
}
47
48
YCMD: bank (playerid, params [], help)
49
{
50-
# pragma unused help
50+
	# pragma unused help
51-
ShowPlayerDialog (playerid, DIALOG_BANK, DIALOG_STYLE_LIST, "Bank", "Deposit - control \ nWithdraw - Remove \ nBalance - Balance " , "Cancel" , "Select " ) ;
51+
	ShowPlayerDialog (playerid, DIALOG_BANK, DIALOG_STYLE_LIST, "Bank", "Deposit - control \ nWithdraw - Remove \ nBalance - Balance " , "Cancel" , "Select " ) ;
52
}
53
54
public OnDialogResponse (playerid, dialogid, response, listitem, inputtext [])
55
{
56-
if (dialogid == DIALOG_BANK)
56+
	if (dialogid == DIALOG_BANK)
57
	{
58-
if ( ! response ) return 0;
58+
		if ( ! response ) return 0;
59-
if ( response )
59+
		if ( response )
60
		{
61-
switch (listitem)
61+
			switch (listitem)
62
			{
63-
case 1: ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
63+
				case 1: ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
64-
case 2: ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
64+
				case 2: ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
65-
case 3 :
65+
				case 3 :
66
				{
67-
format (szString, 50, "Your Balance:% d", PlayerInfo [playerid] [pBankAccount]);
67+
					format (szString, 50, "Your Balance:% d", PlayerInfo [playerid] [pBankAccount]);
68-
ShowPlayerDialog (playerid, 123, DIALOG_STYLE_MSGBOX, "Balance", szString, " Cancel" , "OK " ) ;
68+
					ShowPlayerDialog (playerid, 123, DIALOG_STYLE_MSGBOX, "Balance", szString, " Cancel" , "OK " ) ;
69
				}
70
			}
71
		}
72
	}
73-
if (dialogid == DIALOG_DEPOSIT)
73+
	if (dialogid == DIALOG_DEPOSIT)
74
	{
75-
if ( ! response ) return 0;
75+
		if ( ! response ) return 0;
76-
if ( response )
76+
		if ( response )
77
		{
78-
if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
78+
			if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", " Please enter the amount " , "Cancel" , " control " ) ;
79-
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 " ) ;
79+
			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 " ) ;
80-
format (szString, 256, " You can deposit up to % d", MAX_DEPOSIT);
80+
			format (szString, 256, " You can deposit up to % d", MAX_DEPOSIT);
81-
if (strval (inputtext)> MAX_DEPOSIT) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " control " ) ;
81+
			if (strval (inputtext)> MAX_DEPOSIT) return ShowPlayerDialog (playerid, DIALOG_DEPOSIT, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " control " ) ;
82-
GivePlayerMoney (playerid,-strval (inputtext));
82+
			GivePlayerMoney (playerid,-strval (inputtext));
83-
PlayerInfo [playerid] [pBankAccount] + = strval (inputtext);
83+
			PlayerInfo [playerid] [pBankAccount] + = strval (inputtext);
84-
SendClientMessage (playerid, -1, " Deposition successfully " ) ;
84+
			SendClientMessage (playerid, -1, " Deposition successfully " ) ;
85-
 }
85+
		}
86-
 }
86+
	}
87-
 if (dialogid == DIALOG_WITHDRAW && response)
87+
	if (dialogid == DIALOG_WITHDRAW && response)
88-
 {
88+
	{
89-
 if ( ! response ) return 0;
89+
		if ( ! response ) return 0;
90-
if ( response )
90+
		if ( response )
91
		{
92-
 if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
92+
			if (! strlen (inputtext)) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Withdraw", " Please enter the amount " , "Cancel" , " pull " ) ;
93-
 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 " ) ;
93+
			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 " ) ;
94-
 format (szString, 256, " You can pull up to % d", MAX_WITHDRAW);
94+
			format (szString, 256, " You can pull up to % d", MAX_WITHDRAW);
95-
 if (strval (inputtext)> MAX_WITHDRAW) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " pull " ) ;
95+
			if (strval (inputtext)> MAX_WITHDRAW) return ShowPlayerDialog (playerid, DIALOG_WITHDRAW, DIALOG_STYLE_INPUT, "Deposit", szString, " Cancel" , " pull " ) ;
96-
 GivePlayerMoney (playerid, strval (inputtext));
96+
			GivePlayerMoney (playerid, strval (inputtext));
97-
 PlayerInfo [playerid] [pBankAccount] - = strval (inputtext);
97+
			PlayerInfo [playerid] [pBankAccount] - = strval (inputtext);
98-
 SendClientMessage (playerid, -1, " You pulled successfully " ) ;
98+
			SendClientMessage (playerid, -1, " You pulled successfully " ) ;
99-
 }
99+
		}
100
	}
101-
return 1 ;
101+
	return 1 ;
102
}
103
104
forward public LoadUser_data (playerid, name [], value []);
105
public LoadUser_data (playerid, name [], value [])
106
{
107-
    INI_Int ("BankAccount", PlayerInfo [playerid] [pBankAccount]);
107+
	INI_Int ("BankAccount", PlayerInfo [playerid] [pBankAccount]);
108-
    INI_Int ("Datasaved", PlayerInfo [playerid] [pAccountdata]);
108+
	INI_Int ("Datasaved", PlayerInfo [playerid] [pAccountdata]);
109-
    return 1 ;
109+
	return 1 ;
110
}
111
112
stock gAccountFile (playerid)
113
{
114-
    new gFile [50];
114+
	new gFile [50];
115-
    format (gFile, 50, "/ Users /% s.ini", gName [playerid]);
115+
	format (gFile, 50, "/ Users /% s.ini", gName [playerid]);
116-
    return gFile ;
116+
	return gFile ;
117
}