[Include] JBank - Future Bank of SA-MP (Fast!)
#1

_Jake_'s Bank
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);
Creates a bank with specified id, checkpontid. const name is the name of the bank. bx, by and bz is the bank's/mapicon/label coordinate. cpsize is the checkpointsize. interior is optional set to 0. world is also optional set to 0. icon is optional set to 1. It enables MapIcon (Bank Icon) when Bank is created. label is also optional set to 1. It enables Label (with the Bank Name and the Bank ID). streamdistance. How far the bank can be seen, optional set to 10.0. Look the jbank.pwn from .rar for example.

Code:
native SaveBank(id, string, len);
id - the bank id to save in.
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);
id - the bank id to load in.
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);
Creates bank account.

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]);
playerid - The ID of the player who owns the account.
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);
Returns a integer results. The results is the current bank account balance of playerid.

Code:
native GetBPlayerPass(playerid, string[129], len);
Returns a string results. The result is the current playerid's bank account password.

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);
Set's playerid's bank account balance. This is the only function which you can deposit or withdraw by adding or subtracting the current balance (GetBPlayerBalance) and the inputted value. Look the jbank.pwn from .rar for example.

Code:
native ResetBPlayerBalance(playerid);
Reset's the playerid's bank account balance!

Code:
native SaveBankAccount(playerid, string[256], len, name[24]);
playerid - The owner of the bank account.
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);
fexist cannot detect the bank's id. So you need to use this.

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);
name - the name of bank account.
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;
}
Notices

• 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
Bugs or Suggestion

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.
Reply
#2

good work

certainly forgot to set the folder rescue.
pawn Code:
#define BankLocation "JBank/Banks/%i.ini"
#define BankALocation "JBank/Accounts/%s.ini"
could also post the job on pastebin for viewing
Reply
#3

Thank you.

UPDATED: There is some wrong code in the example script. SO i've to update the topic and the downloadlink.
Reply
#4

Nice and simple to use.
Good work Jake(Romel)
Reply
#5

Thanks.
Reply
#6

I forgot to tell you.
GetBPlayerPass, SetBPlayerPass, ResetBPlayerPass.
Requires to call LoadBankAccount first before calling these functions.
If you didn't call LoadBankAccount before using these functions.
These 3 functions will fail to do it's function.

Example how to do it:

pawn Code:
new accountstring[256];
LoadBankAccount(playerid, accountstring, 256, getName(playerid));
new buf[129];
GetBPlayerPass(playerid, buf, 129);
Reply
#7

Nice topic title. I like how it's possible to read it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)