[Include] SiJ_Bank - MySQL based bank system!
#1

SiJ Bankv0.2
MySQL based bank system
Introduction
I've been scripting for 3 years now, and I've decided to release something too.
This is a Bank System include, that will help advanced scripters to add Bank System to their server (beginner scripters may just need to download a bank system's filterscript).
Currently it contains only 1 ATM (at SF Airport). I didn't have enough time to put more (you should add then yourself)
It uses G-sTyLeZzZ MySQL plugin and pVars.


Functions
  • SijBankConnect(playerid); - This goes under OnPlayerConnect(..) callback
  • SijBankDisconnect(playerid); - This goes under OnPlayerDisconnect(..) callback
  • SijBankDialog(playerid,dialogid,response,listitem, inputtext[]); - This goes under OnDialogResponse(..) callback
  • CreateBankAccount(playerid,pin[5],money); - Creates a new bank account (1 account per player!)
  • GetBankBalance(playerid); - Gets player's bank balance
  • SetBankPIN(playerid,PIN[5]); - Changes the bank PIN code (needed to use ATM)
  • GetBankPIN(playerid);
  • ShowBankDialog(playerid,type); - Shows the ATM dialog
  • IsLoggedToBank(playerid); - Checks if player is logged in to the ATM
  • LoginToBank(playerid,PIN[5]); - Logins to bank (returns 0 if PIN code is wrong; -1 if PIN code is invalid; 1 on success)
  • LogoutFromBank(playerid);
  • GiveBankMoney(playerid,amount); - Use this to add money to player's bank account (for online players)
  • GiveBankMoneyEx(cname[24],amount); - Use this to add money to player's bank account (for offline players, by using their username)
  • TakeBankMoney(playerid,amount);
  • TakeBankMoneyEx(cname[24],amount);
  • IsAtATM(playerid); - Checks if player is at ATM



Download
Download here! (v0.2)
Pastebin (v0.1) (use the link above to download the .inc file!)


Usage
Place these into your gamemode:

pawn Код:
//At the top:
#include <SiJ_Bank>

//Under OnPlayerConnect(...) callback:
SijBankConnect(playerid);

//Under OnPlayerDisconnect(...):
SijBankDisconnect(playerid);

//Under OnDialogResponse(...):
SijBankDialog(playerid,dialogid,response,listitem,inputtext);
Create a MySQL table (use this query):
Код:
CREATE TABLE `bank` (
	`username` VARCHAR(24) NOT NULL,
	`pin` INT(4) NOT NULL COMMENT 'May not be longer than 4 digits!',
	`balance` INT(10) NULL,
	UNIQUE INDEX `username` (`username`)
)
COMMENT='SiJ_Bank include'
COLLATE='utf8_general_ci'
ENGINE=MyISAM
ROW_FORMAT=DEFAULT
Add your own ATMs:
Create an ATM object in your favorite map editor, put it into your script, and add it's coordinates under
stock IsAtATM(playerid) at the include file.


Make ATM available to use
You can make this in many ways. I prefer using /ATM command:

pawn Код:
//Under OnPlayerCommandText(...):
    if(!strcmp(cmdtext,"/ATM",true))
    {
        if(IsAtATM(playerid))
        {
            ShowBankDialog(playerid,1);
        }
        else SendClientMessage(playerid,COLOR,"You should be near ATM to use this!");
    }
Bugs/Suggestions/Other Info
Changes in 0.2
  • Fixed all the bugs
  • Added CreateBankAccount(..) function (forgot to put it to 0.1)

Reply
#2

Looks awesome, i think i will use it.
Reply
#3

It looks good, nice job.
Reply
#4

Would be good if someone could test if it works
Reply
#5

You should hook callbacks: https://sampforum.blast.hk/showthread.php?tid=166016. The current state of having to manually place functions inside callbacks is messy in your script.

Furrthermore, you should never release scripts without testing them.
Reply
#6

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
You should hook callbacks: https://sampforum.blast.hk/showthread.php?tid=166016. The current state of having to manually place functions inside callbacks is messy in your script.
Well in my opinion hooking would make more mess than it currently is. Now you just need to copy 3 functions and place them into gamemode (you will need to use other functions in gamemode anyway, so it's not hard to add 3 extra functions).

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Furrthermore, you should never release scripts without testing them.
Tested already.
Reply
#7

It's not hard to set-up WAMP/XAMPP locally.
Reply
#8

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
It's not hard to set-up WAMP/XAMPP locally.
Yes, it's not.
Anyway I appreciate your feedback, and wanna hear something from someone else?
Reply
#9

v0.2 released!
Download: http://forum.urarcade.net/download/file.php?id=26
Changes:
All the bugs fixed.
Include tested - works.
Added new function CreateBankAccount(..) (forgot to put into 0.1)
Reply
#10

Old links are broken.
New download link for those who are interested:
[DOWNLOAD]
Reply
#11

Please Post a new link
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)