Position bug in my Dynamic Business System
#1

Hi there, I am making a business system, just did the first test and everything except one things works fine.
The restocking.

It tells me that im not near a business when I try to restock it,

VIDEO to explain:

[ame="http://www.youtube.com/watch?v=GTyQv-beBBk"]CLICK[/ame]


Restocking code:

pawn Код:
CMD:sellprods(playerid, params[])
{
    for(new b= 0; b < sizeof(BizzInfo); b++)
    {
    format(file6, sizeof(file6), "realityrp/bizzes/%d.ini", b);
    BizzInfo[b][benx] = dini_Float(file6, "benx");
    BizzInfo[b][beny] = dini_Float(file6, "beny");
    BizzInfo[b][benz] = dini_Float(file6, "benz");
    if(PlayerInfo[playerid][pJob] == pJob_8)
    {
        if(vjob[GetPlayerVehicleID(playerid)] == 8)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15.0,  BizzInfo[b][benx],BizzInfo[b][beny], BizzInfo[b][benz]))
            {
                new ammount;
                 if(!sscanf(params, "i", ammount))
                 {
                    new price;
                    price = ammount * 8;
                    if(PlayerInfo[playerid][Prods] >= ammount)
                    {
                        if(ammount + BizzInfo[b][bprods] <= 300)
                        {
                            new string[128];
                            GivePlayerCash(playerid, price);
                            BizzInfo[b][bprods] = BizzInfo[b][bprods] + ammount;
                            PlayerInfo[playerid][Prods] = PlayerInfo[playerid][Prods] - ammount;
                            format(string, sizeof(string), "You just sold %d products for $%d!", ammount, price);
                            SendClientMessage(playerid, COLOR_ORANGE, string);
                        }
                        else return SendClientMessage(playerid, COLOR_GREY, "Business can not have more then 300 products!");
                    }
                    else return SendClientMessage(playerid, COLOR_GREY, "You do not have enough products for that!");
                }
                else return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sellprods [ammount]");
            }
            else return SendClientMessage(playerid, COLOR_GREY, "You are not near a business!");
        }
        else return SendClientMessage(playerid, COLOR_GREY, "You must be in a delivery truck!");
    }
    else return SendClientMessage(playerid, COLOR_GREY, "You must be a trucker to do this!");
    }
    return 1;
}
Anyone has any idea?
Reply
#2

Bump
Reply
#3

pawn Код:
CMD:sellprods(playerid, params[])
{
    new ammount;
    new price;
    new string[128];
    for(new b= 0; b < sizeof(BizzInfo); b++)
    {
        format(file6, sizeof(file6), "realityrp/bizzes/%d.ini", b);
        BizzInfo[b][benx] = dini_Float(file6, "benx");
        BizzInfo[b][beny] = dini_Float(file6, "beny");
        BizzInfo[b][benz] = dini_Float(file6, "benz");
        if(sscanf(params, "i", ammount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sellprods [ammount]");
        if(PlayerInfo[playerid][pJob] != pJob_8) return SendClientMessage(playerid, COLOR_GREY, "You must be a trucker to do this!");
        if(vjob[GetPlayerVehicleID(playerid)] != 8) return SendClientMessage(playerid, COLOR_GREY, "You must be in a delivery truck!");
        if(!IsPlayerInRangeOfPoint(playerid, 15.0,  BizzInfo[b][benx],BizzInfo[b][beny], BizzInfo[b][benz])) return SendClientMessage(playerid, COLOR_GREY, "You are not near a business!");
        if(PlayerInfo[playerid][Prods] <= ammount) return SendClientMessage(playerid, COLOR_GREY, "You do not have enough products for that!");
        if(ammount + BizzInfo[b][bprods] >= 300) return SendClientMessage(playerid, COLOR_GREY, "Business can not have more then 300 products!");
        price = ammount * 8;
        GivePlayerCash(playerid, price);
        BizzInfo[b][bprods] = BizzInfo[b][bprods] + ammount;
        PlayerInfo[playerid][Prods] = PlayerInfo[playerid][Prods] - ammount;
        format(string, sizeof(string), "You just sold %d products for $%d!", ammount, price);
        SendClientMessage(playerid, COLOR_ORANGE, string);
    }
    return 1;
}
Reply
#4

Are you sure it saved the pos in file when create bizz? Maybe it only set the BizzInfo, so, you need a restart to save the pos in the file, or just make it save the pos in /createbizz code.

It is reading from file, if file doesn't contain the coordenates, it will fail. The same happened to me and it was it, that's why i am telling.

Like this:
I only had it setting the FarmInfo to a value, and on game mode exit, it saved into files.
pawn Код:
FarmBInfo[Money] = FarmBInfo[Money]+50;
Than i just made it also save.
pawn Код:
FarmBInfo[Money] = FarmBInfo[Money]+50;
    format(file,sizeof(file),"Farm/Farm.ini");
    if(dini_Exists(file))
    {
        dini_IntSet(file,"Money",FarmBInfo[Money]);
        return 1;
    }
Reply
#5

Ypur wrong ricardo
Reply
#6

Fixed it, thanks anyway for the effort. Problem was a dumb dumb dumb fault where i forgot a capital
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)