12.04.2013, 09:50
_Jake_'s Bank
Future Bank of SA-MP
Future Bank of SA-MP
Fast and Reliable!
Introduction
All we know there are many bank systems around there.
We know there are also Bank includes. This bank system might not use MySQL.
But this one uses the fastest INI writer. which is Y_INI. To create a checkpoint.
I use the one which is most used streamer today. Incognito's Streamer.
With both of them. I built a bank system in include!
Learning how to use JBank is easy. Why not try it?
Natives
Let me example all of them one by one.
Code:
native CreateBank(id, cpid, const name[128], Float:bx, Float:by, Float:bz, Float:cpsize, interior = 0, world = 0, icon = 1, label = 1, Float:streamdistances = 10.0);
Code:
native SaveBank(id, string, len);
string - the string to store the bank location from function.
len - The length of the string that should be stored.
Look the jbank.pwn from .rar for example
Code:
native LoadBank(id, cpid, string, len);
string - the string to store the bank location from function.
len - The length of the string that should be stored.
Look the jbank.pwn from .rar for example
Code:
native CreateBankAccount(playerid, string[256], len, name[24], password[129], balance = 0);
playerid - The ID of the player who will own the account.
string - the string to store the bank account location from function.
len - the length of the string that should be stored.
name - the maximum string size for name is 24. Which is for player name's only. It is not for custom names or number names.
password - the maximum string size for password is 129. Which is fits for Hashing passwords. You can also use non-hash passwords in this parameter. Look at jbank.pwn in the .rar.
balance - Balance is optional set to 0. The function of this parameter is to set's player's bank account balance.
Look the jbank.pwn from .rar for example.
Code:
native LoadBankAccount(playerid, string[256], len, name[24]);
string - The string to store the bank account location from the function.
len - the length of the string that should be stored.
name - the maximum string size of this parameter is once again 24. Which is only fits for player names (actually it is really designed for player name's!) Look the jbank.pwn from .rar for example.
Code:
native GetBPlayerBalance(playerid);
Code:
native GetBPlayerPass(playerid, string[129], len);
playerid - The one who owns the bank account.
string - The string to store the bank account password.
len - the length of the string that should be stored.
Look the jbank.pwn from .rar for example.
Code:
native SetBPlayerBalance(playerid, balance);
Code:
native ResetBPlayerBalance(playerid);
Code:
native SaveBankAccount(playerid, string[256], len, name[24]);
string - the string to store the bank account location from the function.
len - the length of the string that should be stored.
name - once again this parameters only holds up to string size 24. Which is only for names only.
Code:
native Bank_Location(id, string[256], len);
id - the bank id.
string - the string to store the bank account location from the function.
len - the length of the string that should be stored.
Code:
native BankAccount_Loc(name[24], string[256], len);
string - the string to store the bank account location from the function.
len - the length of the string that should be stored.
Example Script
If you're lazy to take a look the jbank.pwn in the filterscripts that included then here.
pawn Code:
// JBank [Debug] - [FS] by _Jake_ © 2013
#include <a_samp>
#include <jbank>
#define BANK 3298
#define BANK_W 3299
#define BANK_D 3300
#define BANK_L 3301
new BankString[256];
new AccountString[256];
public OnFilterScriptInit()
{
print("\nJBank [Debug] - [FS] by _Jake_ © 2013 Loaded!\n");
new location[256];
if(Bank_Location(0, location, 256))
{
LoadBank(0, 1, BankString, 256);
print("Loaded Example Bank!");
}
else
{
CreateBank(0, 1, "My Bank", 2028.4402,1543.8276,10.8203, 2.0, 0, 0, 1, 1, 10.0);
print("Created cause Test.ini doesn't exist!");
}
CreateBank(1, 2, "Xenia's Bank", 2029.3531,1547.9521,10.8203, 2.0, 0, 0, 1, 1, 10.0); //Bank 2 - without label and icon on. Checks if it collides the first bank!
return 1;
}
public OnFilterScriptExit()
{
print("\nJBank [Debug] - [FS] by _Jake_ © 2013 Unloaded!\n");
SaveBank(0, BankString, 256);
print("Bank Saved as Test.ini!");
return 1;
}
public OnPlayerEnterBank(playerid, bankid)
{
if(bankid == 1)
{
if(BankAccount_Loc(pName(playerid), AccountString, 256))
{
LoadBankAccount(playerid, AccountString, 256, pName(playerid));
SendClientMessage(playerid, -1, "Bank Account called!");
ShowPlayerDialog(playerid, BANK_L, DIALOG_STYLE_INPUT, "{FFFFFF}Bank Login", "{FFFFFF}JBank Login example!", "LogIn", "");
}
else
{
CreateBankAccount(playerid, AccountString, 256, pName(playerid), "example", 0);
SendClientMessage(playerid, -1, "Bank Account created!");
}
return 1;
}
else if(bankid == 2)
{
SendClientMessage(playerid, -1, "_Jake_'s girlfriend bank!");
return 1;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == BANK_L)
{
if(response)
{
new pass[129];
GetBPlayerPass(playerid, pass, 129);
if(strcmp(inputtext, pass, true) == 0)
{
LoadBankAccount(playerid, AccountString, 256, pName(playerid));
SendClientMessage(playerid, -1, "Logged in Bank!");
new str[256]; format(str, sizeof(str), "Balance: $%i", GetBPlayerBalance(playerid));
SendClientMessage(playerid, -1, str);
ShowPlayerDialog(playerid, BANK, DIALOG_STYLE_LIST, "Bank", "Withdraw\nDeposit\nReset Balance", "Choose", "");
}
else
{
SendClientMessage(playerid, -1, "Wrong Bank Password!");
}
}
}
if(dialogid == BANK)
{
if(response)
{
switch(listitem)
{
case 0: ShowPlayerDialog(playerid, BANK_W, DIALOG_STYLE_INPUT, "Withdraw", "Withdraw your money here!", "Withdraw", "");
case 1: ShowPlayerDialog(playerid, BANK_D, DIALOG_STYLE_INPUT, "Deposit", "Deposit your money here!", "Deposit", "");
case 2:
{
ResetBPlayerBalance(playerid);
SendClientMessage(playerid, -1, "Bank Balance resetted!");
SaveBankAccount(playerid, AccountString, 256, pName(playerid));
}
}
}
}
if(dialogid == BANK_W)
{
if(response)
{
LoadBankAccount(playerid, AccountString, 256, pName(playerid));
if(!isnumeric(inputtext)) return SendClientMessage(playerid, -1, "Numbers only!");
if(strval(inputtext) > GetBPlayerBalance(playerid)) return SendClientMessage(playerid, -1, "You dont have that amount of money on your bank!");
SetBPlayerBalance(playerid, GetBPlayerBalance(playerid) - strval(inputtext));
GivePlayerMoney(playerid, strval(inputtext));
new String[128];
format(String, sizeof String, "You withdrew $%i from your bank, and now got $%i on your bank left. ", strval(inputtext), GetBPlayerBalance(playerid));
SendClientMessage(playerid, -1, String);
SaveBankAccount(playerid, AccountString, 256, pName(playerid));
}
}
if(dialogid == BANK_D)
{
if(response)
{
LoadBankAccount(playerid, AccountString, 256, pName(playerid));
if(!isnumeric(inputtext)) return SendClientMessage(playerid, -1, "Numbers only!");
if(strval(inputtext) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "You dont have that amount of money on your pocket!");
SetBPlayerBalance(playerid, GetBPlayerBalance(playerid) + strval(inputtext));
GivePlayerMoney(playerid, -strval(inputtext));
new String[128];
format(String, sizeof String, "You deposit $%i from your bank, and now got $%i on your bank.", strval(inputtext), GetBPlayerBalance(playerid));
SendClientMessage(playerid, -1, String);
SaveBankAccount(playerid, AccountString, 256, pName(playerid));
}
}
return 1;
}
stock pName(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
• If you use this include. Your script might get a high amx size due some functions using 256 cell size strings. You might edit the include and make 256 cell to 128 cell. Check if the amx size is decreasing if it still not. You need to PM
me to fix this.
• To change the saving locations change the path of this.
Code:
#define BankLocation "JBank/Banks/%i.ini" //Location for Bank Saving #define BankALocation "JBank/Accounts/%s.ini" //Location for Bank Account Saving
Do you've discovered any bugs?. Post it right here and i will respond to your report.
Do you've any suggestions for next version?. Post it right here and i will respond to your suggestion.
Screenshot
My account's name is not renamed last time so the name of the include yet is RomBank but this has been fixed.
After i come back home.
Note the Bank ID 1 is not bug. The reason why it has no checkpoints loaded.
Because it is current using by Bank ID 0. That's how streamer works you know..
DL
JBank - Future Bank of SA-MP (v1.0)
JBank - Future Bank of SA-MP (v1.0) - Not recommend. Just used for checking the code.