Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <sscanf2>
- #include <zcmd>
- //---------------
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_GREY 0x999999FF
- #define COLOR_YELLOW 0xFFFF00FF
- #define FILTERSCRIPT
- #define BANK_FILE "Bank/%s.ini"
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- //---------------
- enum pInfo
- {
- BankAcc,
- Bcash,
- Cash,
- BankPass,
- BankOpen,
- Card
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- public OnFilterScriptInit()
- {
- printf("\n=======================");
- printf("Bank System 1.0 by James_Carter");
- printf(">> Status: LOADED !");
- printf("=======================\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- printf("\n=======================");
- printf("Bank System 1.0 by James_Carter");
- printf(">> Status: UNLOADED !");
- printf("=======================\n");
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_SECONDARY_ATTACK))
- {
- if(IsPlayerInRangeOfPoint(playerid, 4.0,1464.1750,-1011.3233,26.8438))//BANK EXTERIOR
- {
- SetPlayerPos(playerid,2315.952880,-1.618174,26.742187);
- SetPlayerInterior(playerid,0);
- if(PlayerInfo[playerid][BankAcc] == 0)
- {
- SendClientMessage(playerid,COLOR_YELLOW,"[Bank]: You can create a bank account for free using /bankaccount !");
- }
- if(PlayerInfo[playerid][Card] == 0)
- {
- SendClientMessage(playerid,COLOR_YELLOW,"[Bank]: You can buy for 25.000$ your card using /card !");
- }
- }
- else if(IsPlayerInRangeOfPoint(playerid, 2.0,2315.952880,-1.618174,26.742187))//BANK INTERIOR
- {
- SetPlayerPos(playerid,1464.1750,-1011.3233,26.8438);
- PlayerInfo[playerid][BankOpen] = 0;
- SetPlayerInterior(playerid,0);
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME],file[128];
- GetPlayerName(playerid,name,sizeof(name));
- format(file,sizeof(file),BANK_FILE,name);
- if(!dini_Exists(file))
- {
- dini_Create(file);
- dini_IntSet(file,"BankAcc",PlayerInfo[playerid][BankAcc] = 0);
- dini_IntSet(file,"BankCash",PlayerInfo[playerid][Bcash] = 0);
- dini_IntSet(file,"Money",PlayerInfo[playerid][Cash] = 25000);
- dini_IntSet(file,"BankPassword",PlayerInfo[playerid][BankPass] = -1);
- dini_IntSet(file,"AccountOpen",PlayerInfo[playerid][BankOpen] = 0);
- dini_IntSet(file,"Card",PlayerInfo[playerid][Card] = 0);
- }
- else
- {
- PlayerInfo[playerid][BankAcc] = dini_Int(file,"BankAcc");
- PlayerInfo[playerid][Bcash] = dini_Int(file,"BankCash");
- PlayerInfo[playerid][Cash] = dini_Int(file,"Cash");
- PlayerInfo[playerid][BankPass] = dini_Int(file,"BankPassword");
- PlayerInfo[playerid][BankOpen] = dini_Int(file,"AccountOpen");
- PlayerInfo[playerid][Card] = dini_Int(file,"Card");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(PlayerInfo[playerid][BankAcc] == 0)
- {
- if(strval(inputtext) > 9999 || strval(inputtext) < 999) return ShowPlayerDialog(playerid,4,DIALOG_STYLE_INPUT,"Bank Account","Your password must contain only numbers and must have 4 characters !","Create","Cancel");
- else
- {
- PlayerInfo[playerid][BankAcc] = 1;
- PlayerInfo[playerid][BankOpen] = 1;
- PlayerInfo[playerid][BankPass] = strval(inputtext);
- SendClientMessage(playerid,COLOR_YELLOW,"[Info]: Bank account succesfully created !");
- SendClientMessage(playerid,COLOR_YELLOW,"Now you can withdraw or deposit money in the bank !");
- }
- }
- else return ShowPlayerDialog(playerid,5,DIALOG_STYLE_INPUT,"Bank Account","Please type your bank account password","Login","Cancel");
- }
- if(dialogid == 2)
- {
- if(!response)
- {
- PlayerInfo[playerid][BankOpen] = 0;
- }
- else
- {
- new file[128],tmp,name[MAX_PLAYER_NAME],str[128];
- GetPlayerName(playerid,name,sizeof(name));
- format(file,sizeof(file),BANK_FILE,name);
- tmp = dini_Int(file, "BankPassword");
- if(tmp != strval(inputtext)) return ShowPlayerDialog(playerid,5,DIALOG_STYLE_INPUT,"Bank Account","The password you entered is not correct !","Login","Cancel");
- else if(!response)
- {
- PlayerInfo[playerid][BankOpen] = 0;
- }
- else if(tmp == strval(inputtext))
- {
- format(str,sizeof(str),"[Info]: Password match,welcome dear {ff0000}%s{ffff00} at L.S. Central Bank.",name);
- SendClientMessage(playerid,COLOR_YELLOW,str);
- PlayerInfo[playerid][BankOpen] = 1;
- }
- }
- }
- if(dialogid == 3)
- {
- if(response)
- {
- if(listitem == 1)
- {
- if(GetPlayerMoney(playerid) >= 25000)
- {
- PlayerInfo[playerid][Card] = 1;
- new oldcash = GetPlayerMoney(playerid);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,oldcash-25000);
- SendClientMessage(playerid,COLOR_YELLOW,"[Info]: You have succesfully bought the card !");
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You don't have enough money !");}
- }
- if(listitem == 2)
- {
- if(PlayerInfo[playerid][Bcash] >= 25000)
- {
- PlayerInfo[playerid][Card] = 1;
- PlayerInfo[playerid][Bcash] -= 25000;
- SendClientMessage(playerid,COLOR_YELLOW,"[Info]: You have succesfully bought the A.T.M. card !");
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You don't have enough money !");}
- }
- }
- else if(!response) return SendClientMessage(playerid,COLOR_GREY,"[Bank]: You can come back everytime to get your card !");
- }
- return 1;
- }
- //---------------[Bank CMD's]---------------------------
- CMD:withdraw(playerid,params[])
- {
- new cash,bank;
- new string[128],name[MAX_PLAYER_NAME];
- if(PlayerInfo[playerid][BankAcc] == 1)
- {
- if(IsPlayerInRangeOfPoint(playerid,5.0,2316.6194,-9.9600,26.7422))
- {
- if(PlayerInfo[playerid][BankOpen] == 1)
- {
- if(sscanf(params,"i",bank)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: /withdraw [Amount]");
- else if(bank <= 0) return SendClientMessage(playerid,COLOR_GREY,"The minimun amount is 1$ !");
- else if(PlayerInfo[playerid][Bcash] < bank) return SendClientMessage(playerid,COLOR_GREY,"You don't have enough money !");
- else
- {
- GetPlayerName(playerid,name,sizeof(name));
- PlayerInfo[playerid][Bcash] -= bank;
- PlayerInfo[playerid][Cash] += bank;
- cash = GetPlayerMoney(playerid);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, cash+bank);
- format(string,sizeof(string),"[Info]:{FFFFFF} You have taken from your bank account {FFFF00}%d{009900}${FFFFFF}.",bank);
- SendClientMessage(playerid,COLOR_YELLOW,string);
- }
- }
- else{SendClientMessage(playerid,COLOR_GREY,"First request permission to withdraw money from bank account desk office by typing your bank password !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You must be inside the bank at withdraw desk office !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You don't have a bank account !");SendClientMessage(playerid,COLOR_GREY,"Go to {FFFF00}Los Santos Central Bank{B5B1B0} and create one.");}
- return 1;
- }
- CMD:deposit(playerid,params[])
- {
- new cash,bank;
- new string[128],name[MAX_PLAYER_NAME];
- if(PlayerInfo[playerid][BankAcc] == 1)
- {
- if(IsPlayerInRangeOfPoint(playerid,5.0,2316.6208,-12.7549,26.7422))
- {
- if(PlayerInfo[playerid][BankOpen] == 1)
- {
- if(sscanf(params,"i",bank)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: /deposit [Amount]");
- else if(bank <= 0) return SendClientMessage(playerid,COLOR_GREY,"The minimun amount is 1$ !");
- else if(PlayerInfo[playerid][Cash] < bank) return SendClientMessage(playerid,COLOR_GREY,"You don't have enough money !");
- else
- {
- GetPlayerName(playerid,name,sizeof(name));
- PlayerInfo[playerid][Bcash] += bank;
- PlayerInfo[playerid][Cash] -= bank;
- cash = GetPlayerMoney(playerid);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, cash-bank);
- format(string,sizeof(string),"[Info]:{FFFFFF} You have put in your bank account {FFFF00}%d{009900}${FFFFFF}.",bank);
- SendClientMessage(playerid,COLOR_YELLOW,string);
- }
- }
- else{SendClientMessage(playerid,COLOR_GREY,"First request permission to withdraw money from bank account desk office by typing your bank password !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You must be inside the bank at deposit desk office !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You don't have a bank account !");SendClientMessage(playerid,COLOR_GREY,"Go to {ffff00}Los Santos Central Bank{B5B1B0} and create one.");}
- return 1;
- }
- CMD:bankaccount(playerid,params[])
- {
- if(IsPlayerInRangeOfPoint(playerid,5.0,2309.0051,-2.3579,26.7422))
- {
- if(PlayerInfo[playerid][BankAcc] == 0)
- {
- ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Bank Account","Create your bank account by typing a password, and don't forget your password !","Create","Cancel");
- }
- else if(PlayerInfo[playerid][BankAcc] == 1)
- {
- ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Bank Account","Please type your bank account password","Login","Cancel");
- }
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You must be inside the bank at {ffff00}bank account desk office{B5B1B0} !");}
- return 1;
- }
- CMD:balance(playerid,params[])
- {
- new string[128];
- if(IsPlayerInRangeOfPoint(playerid,5.0,2308.8706,-13.2487,26.7422))
- {
- if(PlayerInfo[playerid][BankOpen] == 1)
- {
- SendClientMessage(playerid,COLOR_YELLOW,"|__________[Account Info]__________|");
- format(string,sizeof(string),"Money: {ffff00}%d{009900}$",PlayerInfo[playerid][Bcash]);
- SendClientMessage(playerid,COLOR_WHITE,string);
- }
- else{SendClientMessage(playerid,COLOR_GREY,"First request permission to check your account from {ffff00}bank account desk office{B5B1B0} by typing your bank {ffff00}password{B5B1B0} !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You must be inside the bank at {ffff00}balance computer{B5B1B0} !");}
- return 1;
- }
- CMD:card(playerid,params[])
- {
- if(IsPlayerInRangeOfPoint(playerid,5.0,2309.1914,-8.4871,26.7422))
- {
- if(PlayerInfo[playerid][BankAcc] == 1)
- {
- if(PlayerInfo[playerid][Card] == 0)
- {
- ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Bank Account [Card]]","|-----------------------------------[How do you will pay ?]-----------------------------------|\nBy cash\nBy bank account","Select","Cancel");
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You already have the card !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You don't have a bank account !");}
- }
- else{SendClientMessage(playerid,COLOR_GREY,"You must be inside the bank at {ffff00}card desk office{b5b1b0} !");}
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement