Does not save up on relog. -
benjaminjones - 22.03.2014
Dear, SA:MP players.
I have one weird bug. When a player type /buybiz on the business icon and succesfully purchase it, there is no problem. He is able to edit it/lock and such. When he log out and come back, he is still owner of the business but only on the 3DLABEL. It's saying [Owner: His Name]. When the player attempt to lock or edit the business, he is not able to do it because it's saying that he doesn't own a business.
I do not know which system I need to show you, so feel free to ask me and I will copy and post it here. I would appriciate all help. Thank you for the help.
Re: Does not save up on relog. -
Zeppo - 22.03.2014
Well, we need to see your user save and business save, depending on how you save your businesses.
Re: Does not save up on relog. -
Zeppo - 22.03.2014
For example, I save the business ID to the players enum. Maybe my command will help you:
pawn Код:
CMD:buybusiness(playerid, params[])
{
for(new i = 0; i < MAX_BUSINESS; i++)
{
if(!IsPlayerInRangeOfPoint(playerid, 3.0, BizInfo[i][bExtX],BizInfo[i][bExtY],BizInfo[i][bExtZ])) continue;
{
if(strcmp(BizInfo[i][bOwner], "For Sale!"))
{
SendClientMessage(playerid, COLOR_RED, "(INFO)"COL_WHITE" This business has already been purchased.");
return PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
}
if(PlayerInfo[playerid][pBusiness] != -1)
{
SendClientMessage(playerid, COLOR_RED, "(INFO)"COL_WHITE" You already own a business. Sell it before purchasing another.");
return PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
}
if(PlayerInfo[playerid][pCash] >= BizInfo[i][bPrice])
{
format(BizInfo[i][bOwner], MAX_PLAYER_NAME, "%s", GetPlayerNameEx(playerid)); //Sets him owner in Biz file.
PlayerInfo[playerid][pBusiness] = i;
SaveBiz(i);
DestroyDynamic3DTextLabel(BizLabel[PlayerInfo[playerid][pBusiness]]);
DestroyDynamicPickup(BizPickup[PlayerInfo[playerid][pBusiness]]);
LoadBusiness(i);
PlayerInfo[playerid][pCash] -= BizInfo[PlayerInfo[playerid][pBusiness]][bPrice];
SaveUser(playerid);
SendClientMessage(playerid, COLOR_GREEN, "(INFO) Congratulations on your purchase! For more help, use /bizhelp!");
return PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
}
else
{
SendClientMessage(playerid, COLOR_RED, "|-- You don't have enough money to purchase this business.");
}
}
}
SendClientMessage(playerid, COLOR_RED, "(INFO)"COL_WHITE" You're not in range of a business.");
PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
return 1;
}
Re: Does not save up on relog. -
benjaminjones - 22.03.2014
Alright here is the command for buying a business. Requested by Zeppo.
pawn Код:
CMD:buybiz(playerid, params[])
{
if(PlayerInfo[playerid][pBusiness] != INVALID_BUSINESS_ID) return SendClientMessageEx(playerid, COLOR_GREY, "You already own a business!");
for(new i = 0; i < sizeof(Businesses); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, Businesses[i][bExtPos][0], Businesses[i][bExtPos][1], Businesses[i][bExtPos][2]))
{
if (Businesses[i][bOwner] >= 1)
{
return SendClientMessageEx(playerid, COLOR_GREY, "This business is already owned!");
}
if (GetPlayerCash(playerid) < Businesses[i][bValue])
{
return SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough cash!");
}
GivePlayerCash(playerid, -Businesses[i][bValue]);
Businesses[i][bOwner] = GetPlayerSQLId(playerid);
strcpy(Businesses[i][bOwnerName], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
PlayerInfo[playerid][pBusiness] = i;
PlayerInfo[playerid][pBusinessRank] = 5;
SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the business help section!");
SaveBusiness(i);
OnPlayerStatsUpdate(playerid);
RefreshBusinessPickup(i);
new string[128];
format(string,sizeof(string),"%s (IP: %s) has bought business ID %d for $%d.", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid), i, Businesses[i][bValue]);
Log("logs/business.log", string);
return 1;
}
}
return SendClientMessageEx(playerid, COLOR_WHITE, "You're not near a business!");
}
Please inform me, if you need anything else and tell me where exactly can I find it.
Re: Does not save up on relog. -
benjaminjones - 22.03.2014
Quote:
Originally Posted by Anwarrex
How do you check whether he's an owner of a business or not?
|
I am checking if he is the owner by simple using some of the commands for business. For example I can give, /bizlock. It's saying that the player don't own a business. On the table of the business icon it's saying the player name but actually he don't own it.
Re: Does not save up on relog. -
benjaminjones - 23.03.2014
I am not sure, would you like to help me in fixing it mate?