SA-MP Forums Archive
commands bug or interior? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: commands bug or interior? (/showthread.php?tid=428065)



commands bug or interior? - ajam123 - 04.04.2013

I have problem here, please anyone help me? when i buy my biz, and type /vault inside the business, it said " you are no own business ". Does somethings wrong with my script below? :

pawn Код:
CMD:vault(playerid, params[])
{
    new value, string[128];
    new idx = PlayerInfo[playerid][pBiz];
    if(PlayerInfo[playerid][pBiz] == 0 && PlayerInfo[playerid][pVBiz] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
    if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
    if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
    {
        idx = PlayerInfo[playerid][pVBiz];
        if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
    }
    if(sscanf(params, "s[32]", params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault [option]");
        SendClientMessage(playerid, COLOR_GREY, "OPTIONS: withdraw | deposit")
        return 1;
    }
    if(!strcmp(params, "withdraw", false, 8))
    {
        if(sscanf(params, "s[32]i", params, value))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault withdraw [amount]");
            format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
            SendClientMessage(playerid, COLOR_GREY, string);
            return 1;
        }
        if(value > BizInfo[idx][bMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money in your business vault.");
        BizInfo[idx][bMoney] -= value;
        GivePlayerCash(playerid, value);
        format(string, sizeof(string), "* %s has withdrawn money from their business vault.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        format(string, sizeof(string), " You have withdrawn $%d from your business vault, amount left: $%d", value, BizInfo[idx][bMoney]);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }
    else if(!strcmp(params, "deposit", false, 7))
    {
        if(sscanf(params, "s[32]i", params, value))
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault deposit [amount]");
            format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
            SendClientMessage(playerid, COLOR_GREY, string);
            return 1;
        }
        if(value > GetPlayerCash(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money on you.");
        BizInfo[idx][bMoney] += value;
        GivePlayerCash(playerid, -value);
        format(string, sizeof(string), "* %s has deposited money to their business vault.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        format(string, sizeof(string), " You have deposited $%d to your business vault, current amount: $%d", value, BizInfo[idx][bMoney]);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }
    return 1;
}



Re: commands bug or interior? - DaRk_RaiN - 04.04.2013

That's a variable fail i guess (condition).
pawn Код:
if(PlayerInfo[playerid][pBiz] == 0 && PlayerInfo[playerid][pVBiz] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
//The pBiz should be set to one.
Use this temperary command to set the Biz to one, after using it try the "vaulut command"
pawn Код:
CMD:bizset(playerid, params[])
{
    PlayerInfo[playerid][pVBiz] = 1;
    return 1;
}



Re: commands bug or interior? - ajam123 - 04.04.2013

Can you make it full fixed? I can't understand


Re: commands bug or interior? - judothijs - 04.04.2013

At your /buybiz command you need to put
pawn Код:
PlayerInfo[playerid][pVBiz] = 1;



Re: commands bug or interior? - ajam123 - 04.04.2013

here is my /buybiz system :

pawn Код:
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_GREEN, " Type /bizlock to open your business. /bizhelp for more infomations.");
                BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 1;
                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;
}



Re: commands bug or interior? - ajam123 - 05.04.2013

bump help.


Re: commands bug or interior? - cessil - 05.04.2013

you've been given the answer, this isn't a script request section