I need help with bank system!
#1

So I followed the tutorial for bank system and I have one problem with it. So the problem is when player makes creditcard and in his pInfo saves that he has credit card as the integer 1 and if he doesnt it saves 0. Everything is working fine if the server is online but If I turn off the server and put it back on when i do /creditinfo which is the command for stats of your bank account it saids that I dont have creditcard and I need to buy one at the bank. Just tell me what code do u want me to paste and I will paste it.
Reply
#2

Storing it only to variables will not be saved. You're supposed to save it to player's data and load it on connect along with the rest of the data.
Reply
#3

Код:
enum pInfo
{
	pPass,
	pLevel,
	pSpawn,
	pAdmin,
	pSpol,
	pGodine,
	pPorijeklo,
	pNovac,
	pUbistva,
	pSmrti,
	CardOwner
}
Thats the enum and in that lower part CardOwner is if he have the card or not..

enum bInfo
{
   Owner[MAX_PLAYER_NAME],
   CardNumber,
   DepositedMoney
}
new BankInfo[MAX_PLAYERS][bInfo];

this is bInfo I think u understand what it is...

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;
}

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
}
EDIT:

Код:
OnPlayerConnect

   	 			if(fexist(BankDB(playerid))) INI_ParseFile(BankDB(playerid), "LoadBankInfo_%s", .bExtra = true, .extra = playerid);
    			if(PlayerInfo[playerid][CardOwner]==1) bInterest[playerid]=SetTimerEx("BankInterest",1440000,true,"i",playerid);//we set the timer IF the player has a card
Reply
#4

Do you check in OnPlayerConnect if the player's file exists and call INI_ParseFile to load them?
Do you open the file in OnPlayerDisconnect and write in it (INI_WriteInt -> for "CardNumber", "DespositedMoney")?
Reply
#5

Код:
You mean this?
GetPlayerName(playerid,pName,sizeof(pName));
		  PlayerInfo[playerid][CardOwner]=1;
		  new INI:PFile=INI_Open(UserPath(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);

this is how its saved in my script files path this is the BankInfo
[BankData]
Owner = Balta11
DepositedMoney = 0
CardNumber = 1001

and this is pInfo 
[data]
Password = 7BDA63A0179F8D40D1B2BDD82269FEBAC123ED7585D19C6AEFC2E0050AD067D7E6A8C9A9AAD8D09ED729565F52E54E50B1FD3734FADCAA308231394B6060F84
Novac = 10000
Admin = 0
Ubistva = 0
Smrti = 0
Level = 0
Godine = 5
Porijeklo = 0
Spol = 0
CardOwner = 1
Reply
#6

Okay, you save "CardOwner" to player's data correctly. In OnPlayerConnect, you'll need to call INI_ParseFile and load player's data (not BankInfo for that). I assume you already do but you forgot to read from "CardOwner" field and store it to the variable:
pawn Код:
INI_Int("CardOwner",PlayerInfo[playerid][CardOwner]);
Reply
#7

So yea u are right. Sorry for asking this dumb questions and making dumb mistakes I rly tried to figure this out but on mistakes we learn. And thaks for help I appriciate it
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)