people who good with dini -
GoldZoroGrab - 01.01.2013
hey guys
i made when player buy stocks for his business it increase in scriptfile, but 2 problems i need help with them
1. for example i bought 1600 stocks, then i bought 10 stocks, in the script files it will be 10 stocks
2. yeah it's saved in scriptfile but it isn't getting loaded after restart
CODE:
pawn Код:
if(playerinbiz(playerid))
{
if(strcmp(text,"5",true)==0)
{
if(BusinessInfo[GetPlayerBusinessID(playerid)][BizBalance]>=400)
{
BusinessInfo[GetPlayerBusinessID(playerid)][BizBalance] -=400;
GivePlayerMoneyEx(playerid, -400);
SendClientMessage(playerid, Green, "You have purchased 800 stocks for your business and paid $400");
BusinessInfo[GetPlayerBusinessID(playerid)][BizStock] += 800;
}
else SendClientMessage(playerid, COLOR_RED, "You don't have enough money in your business account to buy this amount of stocks.");
}
else if(strcmp(text,"6", true)==0)
{
if(BusinessInfo[GetPlayerBusinessID(playerid)][BizBalance]>=800)
{
BusinessInfo[GetPlayerBusinessID(playerid)][BizBalance] -=800;
GivePlayerMoneyEx(playerid, -800);
SendClientMessage(playerid, Green, "You have purchased 1600 stocks for your business and paid $800");
BusinessInfo[GetPlayerBusinessID(playerid)][BizStock] += 1600;
}
else SendClientMessage(playerid, COLOR_RED, "You don't have enough money in your business account to buy this amount of stocks.");
}
format(ffile,sizeof(ffile),"Business/%i.ini",GetPlayerBusinessID(playerid));
dini_Set(ffile, "BizStock",BusinessInfo[GetPlayerBusinessID(playerid)][BizStock]);
format(ffile,sizeof(ffile),"Business/%i.ini",GetPlayerBusinessID(playerid));
dini_Set(ffile, "BizBalance",BusinessInfo[GetPlayerBusinessID(playerid)][BizBalance]);
return 0;
}
Re: people who good with dini -
papedo - 01.01.2013
pawn Код:
if(playerinbiz(playerid))
{
new pBiz = GetPlayerBusinessID(playerid);
format(ffile,sizeof(ffile),"Business/%i.ini",pBiz);
BusinessInfo[pBiz][BizStock] = dini_Int(ffile, "BizStock");
BusinessInfo[pBiz][BizBalance] = dini_Int(ffile, "BizBalance");
if(strcmp(text,"5",true)==0)
{
if(BusinessInfo[pBiz][BizBalance]>=400)
{
BusinessInfo[pBiz][BizBalance] -=400;
GivePlayerMoneyEx(playerid, -400);
SendClientMessage(playerid, Green, "You have purchased 800 stocks for your business and paid $400");
BusinessInfo[pBiz][BizStock] += 800;
}else SendClientMessage(playerid, COLOR_RED, "You don't have enough money in your business account to buy this amount of stocks.");
}
else if(strcmp(text,"6", true)==0)
{
if(BusinessInfo[pBiz][BizBalance]>=800)
{
BusinessInfo[pBiz][BizBalance] -=800;
GivePlayerMoneyEx(playerid, -800);
SendClientMessage(playerid, Green, "You have purchased 1600 stocks for your business and paid $800");
BusinessInfo[pBiz][BizStock] += 1600;
}else SendClientMessage(playerid, COLOR_RED, "You don't have enough money in your business account to buy this amount of stocks.");
}
dini_IntSet(ffile, "BizStock",BusinessInfo[pBiz][BizStock]);
dini_IntSet(ffile, "BizBalance",BusinessInfo[pBiz][BizBalance]);
return 0;
}
Re: people who good with dini -
GoldZoroGrab - 01.01.2013
it's stell not loading the stocks and prices of the businesses
when i restart they get lost
but other stats of businesses are saved and loaded excelent exept the balance of business and its stocks
ANY HELp?
Re: people who good with dini -
papedo - 01.01.2013
put this in OnGameModeInit( )
pawn Код:
for(new pBiz = 0; pBiz < MAX_BUSINESS; pBiz++)
{
new ffile[32],pBiz;
format(ffile,32,"Business/%i.ini",pBiz);
BusinessInfo[pBiz][BizStock] = dini_Int(ffile, "BizStock");
BusinessInfo[pBiz][BizBalance] = dini_Int(ffile, "BizBalance");
}
and replace MAX_BUSINESS with limit of your business
Re: people who good with dini -
GoldZoroGrab - 01.01.2013
Thx bro it worked
+REP