Business bugged.
#1

I have problem with my business here

- When i /buybiz which first business (1st biz i buy mean Biz1 [Owner] biz2 [un-owned]), it's working properly and none bugged. But when i buy the secondly business, it's going bug and i cannot even /mybiz.

- When i'm at my BIZ1 and when i type /mybiz, it's working properly and none bugged. But when i'm at my BIZ2, and use /mybiz it's say, you are not near your business.

Please help me..
Here is my /mybiz code

pawn Код:
CMD:mybiz(playerid, params[])
{
    for(new d = 0 ; d < MAX_BIZ; d++)
    {
        new idx = PlayerInfo[playerid][pVBiz];
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
        SetPVarInt(playerid, "mybiz", d);
        if(!IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not near your business!");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            ShowPlayerDialog(playerid,DIALOG_BIZMENU,DIALOG_STYLE_LIST,"BUSINESS ACCOUNT", "Balance\nWithdraw","Select","Cancel");
            return 1;
        }

    }

    return 1;
}
This one is my /buybiz command
pawn Код:
CMD:buybiz(playerid, params[])
{
    new string[128], done;
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    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][pAdmin] < 2) 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(GetPVarInt(playerid, "Cash") < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
                SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") -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), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], idx);
                UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
                SendClientMessage(playerid, COLOR_GREEN, " ========================================================[BUSINESS]========================================================");
                SendClientMessage(playerid, COLOR_YELLOW, " {00FF00}[{FFFFFF} Corgratulation, you have successfully bought a business {00FF00}]{FFFFFF}");
                SendClientMessage(playerid, COLOR_YELLOW, " {00FF00}[{FFFFFF} /lockbiz - Unlock/Lock your business {00FF00}]{FFFFFF}");
                SendClientMessage(playerid, COLOR_YELLOW, " {00FF00}[{FFFFFF} /mybiz - to look your business balance and withdraw money from your biz {00FF00}]{FFFFFF}");
                SendClientMessage(playerid, COLOR_YELLOW, " {00FF00}[{FFFFFF} Please type /help for more information {00FF00}]{FFFFFF}");
                SendClientMessage(playerid, COLOR_RED, " WARNING: PLEASE TAKE SCREENSHOT OF YOUR BUSINESS");
                SendClientMessage(playerid, COLOR_GREEN, " ==========================================================================================================================");
                format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
                Log("logs/business.log", string);
                idx = MAX_BIZ;
                done = 1;
                SaveBiz();
            }
            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;
}
Reply
#2

Well this is Someone else script because i know it , But i am gonna try to help, all you need is to Define
and add pBiz2 so you can Manage your second business ,just wait i ll post you the same script but with pBiz2
Reply
#3

Add pBiz2, under pBiz,
like this
Код:
enum pInfo
{
    pBiz,
    pBiz2,

};
Replace stock SaveChar(playerid) with this new one

Код:
stock SaveChar(playerid)
{
	if(IsPlayerConnected(playerid))
	{
        dini_IntSet(file, "Business", PlayerInfo[playerid][pBiz]);
        dini_IntSet(file, "Business", PlayerInfo[playerid][pBiz2]);
		dini_IntSet(file, "VBusiness", PlayerInfo[playerid][pVBiz]);
		dini_IntSet(file, "BizOwner", PlayerInfo[playerid][pOwner]);
	}
}
Replace stock LoadChar(playerid) with this new one

Код:
stock LoadChar(playerid)
{
    PlayerInfo[playerid][pBiz] = dini_Int(file, "Business");
    PlayerInfo[playerid][pBiz2] = dini_Int(file, "Business");
    PlayerInfo[playerid][pVBiz] = dini_Int(file, "VBusiness");
	PlayerInfo[playerid][pOwner] = dini_Int(file, "BizOwner");
}
Код:
public OnPlayerRegister(playerid, password[])

 format(var, 32, "Biz2=%d\n",PlayerInfo[playerid][pBiz2]);fwrite(hFile, var);
Код:
public OnPlayerStatsUpdate(playerid)

 format(var, 32, "Biz2=%d\n",PlayerInfo[playerid][pBiz2]);fwrite(hFile, var);
Код:
public OnPlayerLogin(playerid,password[])

if( strcmp( key , "Biz2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBiz2] = strval( val ); }
Код:
public OnPlayerOfflineLogin(playername[])
if( strcmp( key , "Biz2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[MAX_PLAYERS][pBiz2] = strval( val ); }
Код:
public OnPlayerOfflineSave(playername[])
format(var, 32, "Biz2=%d\n",PlayerInfo[MAX_PLAYERS][pBiz2]);fwrite(hFile, var);
Код:
CMD:bizhelp(playerid, params[])
{
   	if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS: {FFFFFF}/buybiz");
	if(PlayerInfo[playerid][pBiz]) SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS OWNER: {FFFFFF}/bizmenu /lockbiz /sellbiztomarket");
        if(PlayerInfo[playerid][pBiz2]) SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS OWNER: {FFFFFF}/bizmenu /lockbiz /sellbiztomarket");
	return 1;
}
Код:
CMD:mybiz(playerid, params[])
{
    for(new d = 0 ; d < MAX_BIZ; d++)
	{
        new idx = PlayerInfo[playerid][pVBiz];
     	if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pBiz2] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
        SetPVarInt(playerid, "bizmenu", d);
        
		if(IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            ShowPlayerDialog(playerid,DIALOG_BIZMENU,DIALOG_STYLE_LIST,"BUSINESS ACCOUNT", "Balance\nWithdraw","Select","Cancel");
        	return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz2]][bX], BizInfo[PlayerInfo[playerid][pBiz2]][bY], BizInfo[PlayerInfo[playerid][pBiz2]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            ShowPlayerDialog(playerid,DIALOG_BIZMENU,DIALOG_STYLE_LIST,"BUSINESS ACCOUNT", "Balance\nWithdraw","Select","Cancel");
        	return 1;
        }

	}

    return 1;
}
Код:
CMD:buybiz(playerid, params[])
{
	new string[128], done;
   	if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	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][pAdmin] < 2) 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(GetPVarInt(playerid, "Cash") < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
				SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") -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), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], 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.");
				format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
				Log("logs/business.log", string);
				idx = MAX_BIZ;
				done = 1;
				SaveBiz();
			}
		 	else if(PlayerInfo[playerid][pBiz]){
			    if(GetPVarInt(playerid, "Cash") < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
				SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") -BizInfo[idx][bPrice]);
				if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
				else PlayerInfo[playerid][pBiz2] = idx;
			    format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
			    format(string, sizeof(string), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], 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.");
				format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
				Log("logs/business.log", string);
				idx = MAX_BIZ;
				done = 1;
				SaveBiz();
			}

			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;
}
Reply
#4

Try this and report back if it works or not.
pawn Код:
CMD:mybiz(playerid, params[])
{
    for(new d = 0 ; d < MAX_BIZ; d++)
    {
        new idx = PlayerInfo[playerid][pVBiz];
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
        SetPVarInt(playerid, "mybiz", d);
        if(!IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not near your business!");
        }
        if(IsPlayerInRangeOfPoint(playerid, 1, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]) || IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
        {
            ShowPlayerDialog(playerid,DIALOG_BIZMENU,DIALOG_STYLE_LIST,"BUSINESS ACCOUNT", "Balance\nWithdraw","Select","Cancel");
        }

    }

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)