PDA

View Full Version : HELP /buybiz


Johnny_Robins
05/10/2012, 09:25 PM
Alright so basically in game after someone buys a business created by admins in game. They're able to use it until they log out. Once they log out it shows that they don't own it.


The Command:

CMD:buybiz(playerid, params[])
{
new string[128], done;
if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVBiz] && PlayerInfo[playerid][pDonateRank] >= 4) return SendClientMessage(playerid, COLOR_GREY, "You already own two businesses.");
if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pDonateRank] < 4) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
if(!strcmp("The State", BizInfo[idx][bOwner], false))
{
if(GetPlayerCash(playerid) < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
GivePlayerCash(playerid, -BizInfo[idx][bPrice]);
if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
else PlayerInfo[playerid][pBiz] = idx;
format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 1;
SaveBiz();
format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
idx = MAX_BIZ;
done = 1;
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
}
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
}
}
return 1;
}

Red_Dragon.
05/10/2012, 09:40 PM
You don't have any file that saves ? use a saving system like Y_INI or DINI or anything else

CmZxC
05/10/2012, 10:20 PM
Use tags to show code.

I also noticed the part of the code includes :

[pawn]SaveBiz();

Most likely, that is the source for the problem. Please show us the stock / public callback of it.