[Tutorial] Advanced YINI BankSystem(DataBase+Timers explanations)!!!
#1

Introduction


OK, so this is my first tutorial, so please take it easy, thanks. Here are the features of the bank system:

1)Score request for buying card
2)Deposit/Withdraw/Transfer option
3)Card Number
4)Bank Interest
5)CardInfo check through command

Resources


ZCMD-Special thanks to Zeex
Y_INI-Special thanks to ******
sscanf-Special thanks to ******

Basic Scripting


I was thinking not to add this, because the tutorial is about the bank system, yet here is the code for the building, I won't be giving much explanation about this, because this is NOT part of the actual tutorial/code.

pawn Код:
new ebank; //enter bank
new exbank; //exit bank

public OnPlayerPickUp(playerid,pickupid)
{
    if(pickupid==exbank)
    {
       SetPlayerPos(playerid,-1706.7177,785.8370,25.1731);
       SetPlayerInterior(playerid,0);
    }
    if(pickupid==ebank)
    {
       SetPlayerPos(playerid,2315.952880,-1.618174,26.742187);
       SetPlayerInterior(playerid,0);
    }
   return 1;
}
OK, so that is the bank code(entering/exiting building), wich is San Fierro based, so I am kidnly asking newbies not to come up with requests like change it to LS/LV. Thanks in advance.

Actual Scripting


OK, so here comes the actual code. First of all, you should know that for saving the data we will need a DataBase. OK, we will do that, but first we must define the path(folder in wich each player's bank file will save). DataBase related files, if you are using any other DB system than MySQL, should be located in scriptfiles. First step is to go in the scriptfiles folder and create a folder BankDB. (IT IS very important, YOU DO NOT have to forget this!) OK, now we're good. But we have to define that path in our gamemode, at top, also:
pawn Код:
#define bPATH "/BankDB/%s.ini"
Instead of bPATH you could have used any other name you wished, but I wanted to be very sugesstive, bPATH as BankPath. I think you have realised that BankDB is actually the name of the folder you have created. But, maybe you do not know what %s means. Well that "%s" stands for string, and in the actual DataBase, the player's file will be saved and named after the player's name. But, how to create a file inside that folder, with THE player's name?We need a stock, also on top of your gamemode, under the define of the path.
pawn Код:
stock BankDB(playerid)
{
   new string[128],pName[MAX_PLAYER_NAME];//we defined the variable that will store the player's name
   GetPlayerName(playerid,pName,sizeof(pName));//we get the name
   format(string,sizeof(string),bPATH,pName);//we format the file for the player
   return string;//this will return his name,because we actually stored in the string the player's name
}
When this stock is called, if there's no bank-file associated with the player, the file will be created, else it'll be opened and ready to be modified. BUT, how will we store the player's bank data? We need a specific variable for every feature, BUT, also, for every player. We will store his name, his cardnumber, and his deposited money. We will need an enumaration for that.

pawn Код:
enum bInfo
{
   Owner[MAX_PLAYER_NAME],
   CardNumber,
   DepositedMoney
}
That's good, but we need it for every player, right? Here it goes, of course we need to use MAX_PLAYERS:
pawn Код:
new BankInfo[MAX_PLAYERS][bInfo];//this will make the bank features available, and we will actually store the variables through BankInfo for each player
Without that actually, the DataBase would be a total mess. In fact it wouldn't even work. OK, so you understood hopefully the fact that we will store into BankInfo through the enum variables the player's bank data. BUT, how do we load it. We need a load function made with Y_INI. First we need to forward the function, and only after that script it. Normally the format of an Y_INI load function used for loading multiple params and data for the player looks like:

pawn Код:
forward Load_FileTag(playerid,name[],value[]);
public Load_FileTag(playerid,name[],value[]);
{
    return 1;
}
Well, now the question is what do you need to change? ONLY the FileTag wich is defined by you. In order to understand what I mean, I will show you how the DataBase will look, so you can see the file tag:
Код:
[BankData]//the actual tag
Owner = [LSCS]Eddie
DepositedMoney = 49750
CardNumber = 1000
The tag is the same for all files, just that obviusly the owner/card number/deposited ammount is different for everyone.
Good, so, now that you saw the format of a load function, here it goes our bank-data loading function:
pawn Код:
forward LoadBankInfo_BankData(playerid,name[],value[]);

public LoadBankInfo_BankData(playerid,name[],value[])//you can see that the tag is BankData(like inside the file)
{
   INI_String("Owner",BankInfo[playerid][Owner],24);//we will need to load the stored
   INI_Int("CardNumber",BankInfo[playerid][CardNumber]);//the card number will be stored
   INI_Int("DepositedMoney",BankInfo[playerid][DepositedMoney]);//the ammount of deposited ammount stored
   return 1;
}
OK, so that's pretty much all about the loading function, but what we did was only "defining" the code, the actual loading is done when the player connects:
pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(BankDB(playerid))) INI_ParseFile(BankDB(playerid), "LoadBankInfo_%s", .bExtra = true, .extra = playerid);//THIS is the actual loading
 return 1;
}
Basically when the player connects, the piece of code checks if there's a file with his name in the folder BankDB, therefor he has a bank account and a card, so we have data to load. Now we need a variable for the player, a variable wich I'd like to call CardOwner. The variable will tell us if he has a card(1 he has a card, 0 he hasn't). Supossingly that you have pInfo in your script, add to your enum this:
pawn Код:
enum pInfo
{
   CardOwner
}
So that's all, BTW, don't forget that when the player connects, if HE IS registering, make that variable 0:
pawn Код:
PlayerInfo[playerid][CardOwner]=0;
ONLY if he's registering. Saving that variable will be done in the player's ACCOUNT file, and not BANK file, so it's up to you. YET, if you read this tutorial, it means you have used Y_INI to make the Register system, obviusly. OK, so the DataBase MAY be called over. Almost over. What you need now is to create a file inside the scriptfiles folder, an INI file called "ABankNum.ini". We will see later what that stands for. Open it and paste this inside:
Код:
[NextBNumber]
CurrentCardNum = 1000
We will see later what that stands for...

Coding the features


ALMOST all the banks system I've seen were using commands. Let's use something a bit advanced, pickups and dialogs. OK, for instance we define them. Once again, I WILL use very suggestive names, so you will understand what's all about, hopefully, for NOT understanding the very suggestive names, you must be a really bad english speaker, I don't think that a really bad english speaker would be able to read tutorials in english sections.
pawn Код:
#define DIALOG_DEPOSITM 18
#define DIALOG_WITHDRAWM 19
#define DIALOG_BUYCARD 20
#define DIALOG_CARDINFO 21
#define DIALOG_CARDCHECK 22
#define DIALOG_TRANSFERM 23

new DepositMoney;
new WithDrawMoney;
new BuyCard;
new TransferMoney;
new tShow[MAX_PLAYERS];//we will see later what this stands for
Now you may see a dialog that probably you don't know what it stands for, WELL, that's CARDCHECK. Through that dialog you insert your friend's card number, and it checks for its existence, if the card number exists and the player is connected, the TRANSFERM dialog will pop-up, where you can insert the ammount you wish to transfer. OK, now creating the pickups. Obviusly, we wouldn't like them to be buggy, and by that, I mean, we wouldn't like the dialogs to show, if the player has no card, okay, so far so cool, we can fix it, by the variable cardOwner we defined earlier .
pawn Код:
OnPlayerPickUpPickUp(playerid,pickupid)
{
        if(pickupid==TransferMoney)
    {
        if(PlayerInfo[playerid][CardOwner]==1)
        {
           if(tShow[playerid]==0)
           {
             tShow[playerid]=1;
             ShowPlayerDialog(playerid,DIALOG_CARDCHECK,DIALOG_STYLE_INPUT,"International Bank of SA","Insert your firend's card number:","OK","Cancel");
           }
        }
    }
    if(pickupid==DepositMoney)
    {
      if(PlayerInfo[playerid][CardOwner]==1)
      {
         ShowPlayerDialog(playerid,DIALOG_DEPOSITM,DIALOG_STYLE_INPUT,"International Bank of SA","Insert the ammount of money you wish to deposit:","OK","Cancel");
      }
    }
    if(pickupid==WithDrawMoney)
    {
      if(PlayerInfo[playerid][CardOwner]==1)
      {
        ShowPlayerDialog(playerid,DIALOG_WITHDRAWM,DIALOG_STYLE_INPUT,"International Bank of SA","Insert the ammount of money you wish to withdraw","OK","Cancel");
      }
    }
    if(pickupid==BuyCard)
    {
        ShowPlayerDialog(playerid,DIALOG_BUYCARD,DIALOG_STYLE_MSGBOX,"International Bank of San Andreas","Do you want to buy a card,in order to open a bank account(500$)?","Yes","No");
    }
  return 1;
}
Well, you might have noticed the tShow variable usage. Well, that's because I don't want dialogs to overwrite. Wich dialogs you may be asking. Remeber that I said when you transfer money, a card number check dialog will pop-up first AND THEN the transfer dialog. These 2 will overwrite :P. If the tShow[playerid] variable is 0,then the card check dialog will show, if it's 1, it won't show anymore, because it means that the actual transfer dialog is shown for the player. If the card number exists, then as mentioned before, we proceed to showing the actual transfer dialog, BUT WE MAKE the tShow[playerid] variable 1. DO NOT FORGET to make it 0, when the player connects. OK, so now do you remeber that thingy about the "ABankNum.ini" file? Well the aim of that file is to store the next card number wich will be associated with the next player who buys a card. The loading code is a lot easier, we just need a variable that will store the card number, and the function to store it, then we will load it, when the player buys a card:
pawn Код:
new cNum;//the variable to store the card number in
INI:ABankNum[NextBNumber](name[], value[])
{
   INI_Int("CurrentCardNum",cNum);//the storage
   return 0;
}
Great, now here comes the dialog codes, wich must be added on OnDialogReponse, of course, BTW, I am sorry I did not change the dialog IDs, I am already tired, so please change it to your next dialog IDs, anyway I am sure you have other dialogs also, and you understand. FIRST, the buying card feature. BUT BEFORE THIS, we must define a timer, wich will give a 10000$ bank interest each 24 minutes. When the player acquires a card, the timer starts.
pawn Код:
new bInterest[MAX_PLAYERS];//the specific timer for each player
forward BankInterest(playerid);//this function will execute the code when the timer is over,and then repeats the timer
Good, that is set, BUT, next, if he has a card, we would need to start the timer, when the player CONNECTS, for that matter, I will add to the code the tShow[playerid], wich I said we must make it 0.
pawn Код:
OnPlayerConnect(playerid)
{
   tShow[playerid]=0;
   //NOW I DO suposse,that when the player logs in,you parse(load) his pFile,AND now,therefor,something more will be loaded :D,and that is PlayerInfo[playerid][CardOwner],so here we go
   if(fexist(YOURPlayerDataPath(playerid)))
   {
       //your loading function(OBVIUSLY,because you loaded the info,we will know the value of PlayerInfo[playerid][CardOwner]
       if(PlayerInfo[playerid][CardOwner]==1) bInterest=SetTimerEx("BankInterest",1440000,true,"i",playerid);//we set the timer IF the player has a card
    }
  return 1;
}
OK, now the timer function code:
pawn Код:
public BankInterest(playerid)
{
    BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]+10000;//the player receives 10k
    new INI:bFile=INI_Open(BankDB(playerid));//we open the player's bank file
    INI_SetTag(bFile,"BankData");//we set the tag
    INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//we modify the variable
    INI_Close(bFile);//we close the file
    SendClientMessage(playerid,COLOR_YELLOW,"Bank interest received!");//we tell the player that now he's richer
    return 1;
}
And the timer will repeat, meaning that he will recevie again 10k after another 24 minutes. *NOTE*: There is another way to set the timer rather than the one I showed you, and that is, when you check the existence of player's bank file. The real reason why I used a variable CardOwner is so the player won't be able to buy 2 cards, AND, why I set the timer that way? I want you to really understand Y_INI DataBases. HERE comes, finnaly, the dialogs code, we start with buying a card, of course :

pawn Код:
if(dialogid==20)
  {
     if(response==0) return SendClientMessage(playerid,COLOR_RED,"Action aborted!");
     if(response==1)
     {
       if(GetPlayerScore(playerid)>=30)//the score request
       {
        if(PlayerInfo[playerid][CardOwner]==0)//if he doesn't have a card
        {
          SendClientMessage(playerid,COLOR_GREEN,"You have succesfully bhought a bank card,and now have an account on your name opened in this bank!");
          SendClientMessage(playerid,COLOR_GREEN,"In order to acces the informations of your card anytime you want,use /cardinfo");
          INI_Load("ABankNum.ini");//WE LOAD THE CardNumber association file
          GivePlayerMoney(playerid,-500);//we take te price of the card
          BankInfo[playerid][CardNumber]=cNum;//as you should remeber I wanted to store the cardnumber in cNum
          new INI:cInfo=INI_Open("ABankNum.ini");//now I open the file that stores the next card number
          INI_SetTag(cInfo,"NextBNumber");//I set the tag
          INI_WriteInt(cInfo,"CurrentCardNum",cNum+1);//I increment the number(if the actual player's cardnumber is 1000,the next one will be 1001
          INI_Close(cInfo);
          BankInfo[playerid][DepositedMoney]=0;//he receives no deposited bonus because I am a bad guy :D
          new pName[24];
          GetPlayerName(playerid,pName,sizeof(pName));
          PlayerInfo[playerid][CardOwner]=1;
          new INI:PFile=INI_Open(Accounts(playerid));//FIRST WE OPEN HIS ACCOUNT file
          INI_SetTag(PFile,"Data");//we set the tag
          INI_WriteInt(PFile,"CardOwner",PlayerInfo[playerid][CardOwner]);//we tell the DataBase that he now HAS a card
          INI_Close(PFile);//we close the file
          format(BankInfo[playerid][Owner],24,"%s",pName);
          new INI:bFile=INI_Open(BankDB(playerid));//NOW we open his Bank DataBase file(actually,because he's buying card,we're creating IT,as the file DOES NOT exist
          INI_SetTag(bFile,"BankData");//we set the tag
          INI_WriteString(bFile,"Owner",BankInfo[playerid][Owner]);//we store the owner
          INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//we store the deposited ammount
          INI_WriteInt(bFile,"CardNumber",BankInfo[playerid][CardNumber]);//we store his card number
          INI_Close(bFile);
          bInterest[playerid]=SetTimerEx("BankInterest",1440000,true,"i",playerid);//we set the timer FOR THE specific player
        }
        else SendClientMessage(playerid,COLOR_RED,"You already own a card!Type /cardinfo for more!");
       }
       else SendClientMessage(playerid,COLOR_RED,"You need at least 30 score to buy a card!");
    }
  }
As you have noticed, I set the bInterest timer when the player bhought the card, because we couldn't have started the timer earlier, as he didn't own a card so far. From now on, when he connects the timer WILL start, because he now HAS a card. We continue with the deposit AND withdraw function. First, deposit:
pawn Код:
if(dialogid==18)
  {
    if(response==0) return SendClientMessage(playerid,COLOR_RED,"Action aborted!");
    if(response==1)
    {
       if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Invalid ammount!");//player is able to insert ONLY numbers
       else
       {
         new DepositAmmount=strval(inputtext);//this is how we get the number he inserted through the dialog
         new CurrentAmmount=GetPlayerMoney(playerid);//we get his money
         if(DepositAmmount>CurrentAmmount) return SendClientMessage(playerid,COLOR_RED,"You don't have that much money one you!");//if he has 20,and tries to deposit 21,he won't be able
         else
         {
           new INI:bFile=INI_Open(BankDB(playerid));//else we open his DataBase
           INI_SetTag(bFile,"BankData");//we set the tag
           BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]+DepositAmmount;//we modify the deposit variable by adding to it the number inserted through the dialog
           INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//and of course we store it
           INI_Close(bFile);//then we close the file
           GivePlayerMoney(playerid,-DepositAmmount);//BUT the player looses the deposited ammount(he had 40$,deposited 20$,now he has 20$)
           SendClientMessage(playerid,COLOR_YELLOW,"Succesfully deposited money into account,type /cardinfo for more!");
         }
       }
    }
  }
Great, we're almost over. We continue with the withdraw function, wich is ALMOST the same as the deposit function, just that instead of addition, we have substraction. And instead of checking the ammount of money the player has on him, we check the ammount of DEPOSITED money, so if he has 1000$ deposited,and tries to withdraw 1200$, it will return an error :P.

pawn Код:
if(dialogid==19)
  {
    if(response==0) return SendClientMessage(playerid,COLOR_RED,"Action aborted!");
    if(response==1)
    {
       if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Invalid ammount!");
       else
       {
         new WithDrawAmmount=strval(inputtext);
         if(WithDrawAmmount>BankInfo[playerid][DepositedMoney]) return SendClientMessage(playerid,COLOR_RED,"You don't have that much money in bank,type /cardinfo for more!");
         else
         {
               BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]-WithDrawAmmount;//when he substracted the respective ammount,then his deposited ammount has changed,of course
           new INI:bFile=INI_Open(BankDB(playerid));//we open the DataBase
           INI_SetTag(bFile,"BankData");//we set the tag
           INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//we STORE the new deposited ammount
           INI_Close(bFile);//we close the file
           GivePlayerMoney(playerid,WithDrawAmmount);//we provide him with the required money
           new string[256];
           format(string,sizeof(string),"Succesfully withdrawed %d$!",WithDrawAmmount);//I formated a string to inform the player how much he has withdrawed
           SendClientMessage(playerid,COLOR_YELLOW,string);
         }
       }
    }
  }
That's great, we're ALMOST done, here goes the transfer function. As mentioned before, it's actually made of 2 dialogs. First one check(through a loop), if any of the players connected does have the inserted card number, else it'll return an error. OTHERWISE, the code will proceed to the second dialog, the actual TRANSFER dialog, where you need to insert the transfer ammount, and so on, here we go:
pawn Код:
new transferplayer;//this will store the playerid's wich has the inserted card number
  if(dialogid==22)
  {
    if(response==0) return SendClientMessage(playerid,COLOR_RED,"Action aborted!");
    if(response==1)
    {
      if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Invalid card number!");//again,he can only insert a numeric value in order to avoid bugs/errors
      else
      {
         new cardnum;
         cardnum=strval(inputtext);
         new OK=0;//this variable will tell us if there's any player with the inserted card number(1 YES,0 NO)
         for(new i=0;i<MAX_PLAYERS;i++)//we start the loop
         {
             if(BankInfo[i][CardNumber]==cardnum)//we check the players cardnumber,if it's the same as the inserted one
             {
                transferplayer=i;//if yes,we store his ID,into the variable defined earlier
                OK=1;//we make the OK variable 1(THERE IS SOMEONE with the inserted card)
                break;//we stoop the loop
             }
         }
         if(OK==0) SendClientMessage(playerid,COLOR_RED,"Your friend is not connected or card number is invalid!");
         else
         {
             ShowPlayerDialog(playerid,DIALOG_TRANSFERM,DIALOG_STYLE_INPUT,"International Bank of SA","Insert the ammount of money you wish to transfer:","OK","Cancel");//we show the ACTUAL TRANSFER dialog
         }
      }
    }
  }
OK, so that was pretty simple, it may seem complicated but being provided with the required explanations makes it a lot easier, right? Here comes the transfer dialog, BUT FIRST, you might be wondering why I have defined the transferplayer variable OUTSIDE the card check dialog. Because we need it for the transfer dialog, because we need to open the "transferplayer" (wich is actually a normal player id) DataBase and modify HIS deposited ammount of money.
pawn Код:
if(dialogid==23)
  {
     if(response==0) return SendClientMessage(playerid,COLOR_RED,"Action canceled!");
     if(response==1)
     {
        if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Invalid ammount of money!");
        else
        {
            new transmoney;
            transmoney=strval(inputtext);//so we get the inserted ammount wich the player wishes to transfer
            if(transmoney>BankInfo[playerid][DepositedMoney]) {SendClientMessage(playerid,COLOR_RED,"You don't have that much money on bank!");tShow[playerid]=0;//the variable that stops the dialogs from overwriting is now 0,because it's like he exited the pickup ;)}//BUT,if his deposited ammount is smaller than the inserted ammount,then he won't be able to transfer money anymore
            else
            {
               BankInfo[playerid][DepositedMoney]=BankInfo[playerid][DepositedMoney]-transmoney;//first we modify the actual player's deposited ammount
               new INI:bFile=INI_Open(BankDB(playerid));//we open his file
               INI_SetTag(bFile,"BankData");//we set the tag
               INI_WriteInt(bFile,"DepositedMoney",BankInfo[playerid][DepositedMoney]);//we store the new deposited ammount
               INI_Close(bFile);//we close the file
               BankInfo[transferplayer][DepositedMoney]=BankInfo[transferplayer][DepositedMoney]+transmoney;//NOW we modify the deposited ammount OF the player that the money has been transfered TO
               new INI:bFile2=INI_Open(BankDB(transferplayer));//we open HIS DataBase
               INI_SetTag(bFile2,"BankData");//we set the tag
               INI_WriteInt(bFile2,"DepositedMoney",BankInfo[transferplayer][DepositedMoney]);//we store the new ammount
               INI_Close(bFile2);//and we close his file
               new pName[24],pName2[24];//variables to store the player's name
               GetPlayerName(transferplayer,pName2,sizeof(pName2));
               GetPlayerName(playerid,pName,sizeof(pName));
               new string[256],string2[256];//informative messages
               format(string,sizeof(string),"Succesfully transfered %d$ to %s!",transmoney,pName2);//we format the message wich will look like "Succesfully transfered 20$ to John"
               SendClientMessage(playerid,COLOR_GREEN,string);//we inform the player
               PlayerPlaySound(playerid,1057,0,0,0);
               format(string2,sizeof(string2),"%s has succesfully transfered you %d$!",pName,transmoney);//again,informative messages
               SendClientMessage(transferplayer,COLOR_GREEN,string2);
               PlayerPlaySound(transferplayer,1057,0,0,0);//just a confirmation sound
               tShow[playerid]=0;//again we make the variable that prevents dialogs from overwriting 0
            }
        }
    }
 }
OK, so, NOW, here comes, FINNALY, the last thing in this tutorial, THE checking command:
pawn Код:
COMMAND:cardinfo(playerid,params[])
{
    if(PlayerInfo[playerid][CardOwner]==0) return SendClientMessage(playerid,COLOR_RED,"You don't have a bank card,go buy one for ONLY 500$!");
    else
    {
       new string[128];
       format(string,sizeof(string),"Card Owner:%s\nCard Number:%d\nDeposited Money:%d\n\n IBSA-POWER to you!",BankInfo[playerid][Owner],BankInfo[playerid][CardNumber],BankInfo[playerid][DepositedMoney]);//we format the string wich will contain the player's bank data
       ShowPlayerDialog(playerid,DIALOG_CARDINFO,DIALOG_STYLE_MSGBOX,"International Bank of SA",string,"OK","Cancel");//this is the infromative dialog
    }
 return 1;
}
And, in the end, here goes the dialog that shows you the bank info:
pawn Код:
if(dialogid==21)
  {
    if(response==0||response==1) return SendClientMessage(playerid,COLOR_GREEN,"Enjoy the power brought to you by IBSA(International Bank of San Andreas)!");//sends the same message,no matter what button the player pressed :P
  }
So, this is it, my first advanced tutorial is over! Please, again, take it easy! Thanks, I hope you like it, I am out .
Reply
#2

Nice tutorial but not explained much.The things are not explained that would be important to newbies.Anyways nice tutorial.
Reply
#3

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
Nice tutorial but not explained much.The things are not explained that would be important to newbies.Anyways nice tutorial.
OK,thanks,BUT,honestly,how can you say that I didn't explained much,I explained everything that was to be explained,plus I gave examples,etc.,and it's an advanced tutorial,it's more like for intermediaries then Rockies,so :P,I kinda think that you don't understand something :P,and that's why you said I didn't explain too much
Reply
#4

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
OK,thanks,BUT,honestly,how can you say that I didn't explained much,I explained everything that was to be explained,plus I gave examples,etc.,and it's an advanced tutorial,it's more like for intermediaries then Rockies,so :P,I kinda think that you don't understand something :P,and that's why you said I didn't explain too much
I knew everything about this ,but I didn't knew that it was an advanced tutorial,sorry,I thought that you were trying to give this tutorial to newbies, anyways nice tutorial keep it up.This will help more people except newbies

One more thing that I wanted a explanation on this part,and how you edit this in the following codes.

pawn Код:
new cNum;//the variable to store the card number in
INI:ABankNum[NextBNumber](name[], value[])
{
   INI_Int("CurrentCardNum",cNum);//the storage
   return 0;
}
Reply
#5

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
I knew everything about this ,but I didn't knew that it was an advanced tutorial,sorry,I thought that you were trying to give this tutorial to newbies, anyways nice tutorial keep it up.This will help more people except newbies

One more thing that I wanted a explanation on this part,and how you edit this in the following codes.

pawn Код:
new cNum;//the variable to store the card number in
INI:ABankNum[NextBNumber](name[], value[])
{
   INI_Int("CurrentCardNum",cNum);//the storage
   return 0;
}
That's the way to work with an INI file that doesn't have any parametres that are player-related.Basically,I only want to store a number into that file,increment it when a player buys a card,and read the number from the file.I use the cNum variable to store the number that is readen FROM the file(ABankNum.ini),then I save it into the player's bank data(BankInfo[playerid][CardNumber]).After that I increment the number,because if the current player has the card number 1005,the next player will have the card number 1006.To load a SIMPLE INI file,you just need the function
pawn Код:
INI_Load(FileName.ini);
Reply
#6

Okay okay now I understand,thanks +rep.
Reply
#7

Hi! Nice tutorial I have 1 error:
Код:
error 033: array must be indexed (variable "bInterest")
Error is here
Код:
 if(PlayerInfo[playerid][CardOwner]==1) bInterest =SetTimerEx("bInterest",1440000,true,"i",playerid);//we set the timer IF the player has a card
Can someone help? :/
Reply
#8

Why not use brackets for the second part?But wait for the owner of the tutorial so you don't mess up with something.
Reply
#9

another great Tutorial !
nice tutorial cjgogo..
Reply
#10

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
another great Tutorial !
nice tutorial cjgogo..
Thanks!
Reply
#11

Thanks man, you helped alot
Reply
#12

Fuck i have 26 errors
Can i get full code? pastebin or something like that
I want that awesome bank system and understand something
Reply
#13

Quote:
Originally Posted by Coder_
View Post
Fuck i have 26 errors
Can i get full code? pastebin or something like that
I want that awesome bank system and understand something
Clearly you have missed something,BUT,I am not blaiming neither you nor myself.When trying to follow a tutorial,you need to read it for about 2-3 times,because,even if it's very well explained,it's just like in-school,as the teacher syays:"No matter how smart you are,read the lesson more than 1 time".Thanks for considering this Bank-System awesome,but,you'd better post the errors,and if I can fix the errors,I'll provde you with the required explanations,so you can understand the BankSystem better .
Reply
#14

He missed a closing bracket somewhere is the script,so not your fault Cigogo,it is his fault.
Reply
#15

Made the thread more readable. It had no spaces between punctuations wich probably made it very annoying . And people claimed it's a good tutorial. It was written 3 years ago, and my english was not perfect by then. Not that now it is now xD. I also mispelled the word "ammount". It's obviously amount. Thought I'd bump this because I've got a few messages from certain newbies claiming that it helped them a lot.
Reply
#16

I have a problem here.
CardNumber is set to 0 when i check into the BankInfo ini file. ( same for /cardinfo )

PHP Code:
new cNum;
INI:ABankNum[NextBNumber](name[], value[])
{
   
INI_Int("CurrentCardNum",cNum);
   return 
0;

PHP Code:
BankInfo[playerid][CardNumber]=cNum;
              new 
INI:cInfo=INI_Open("ABankNum.ini");
              
INI_SetTag(cInfo,"NextBNumber");
              
INI_WriteInt(cInfo,"CurrentCardNum",cNum+1);
              
INI_Close(cInfo); 
with the codes above, everything should be working fine ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)