[GodFather RP Fix] /buyprods /sellprods
#1

Heres a fix for the trucking job.... since I seen ALOT of people trying to fix it... if this is the wrong section, my apologizes..

Credit: FeaR // Original Creator of GodFather RP script
https://sampforum.blast.hk/showthread.php?tid=7797

pawn Code:
if(strcmp(cmd, "/load", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new tmpcar = GetPlayerVehicleID(playerid);
            if(!IsATruck(tmpcar))
            {
                GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
                return 1;
            }
            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
        }
        return 1;
    }
   
    if(strcmp(cmd, "/buyprods", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new tmpcar = GetPlayerVehicleID(playerid);
            if(PlayerToPoint(70.0, playerid, 2468.4919,-2092.9902,13.5469))
            {
                if(IsATruck(tmpcar))
                {
                    if(PlayerInfo[playerid][pTruckLoad] < 200)
                    {
                        tmp = strtok(cmdtext, idx);
                        if(!strlen(tmp))
                        {
                            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /buyprods [1-200]");
                            return 1;
                        }
                        new amount = strval(tmp);
                        if(amount < 1 || amount > 200) { SendClientMessage(playerid, COLOR_GREY, "   Can't buy less then 1 Product or more then 200 !"); return 1; }
                        new cost = amount*50;
                        if(GetPlayerMoney(playerid) > cost)
                        {
                            PlayerInfo[playerid][pTruckLoad] += amount;
                            format(string, sizeof(string), "You bought %d Products for $%d.", amount,cost);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            SafeGivePlayerMoney(playerid,-cost);
                            return 1;
                        }
                        else
                        {
                            format(string, sizeof(string), "You cant afford %d Products at $%d !", amount,cost);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, "You cannot carry more then 200 products at a time");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, TEAM_GROVE_COLOR, "This Vehicle does not deliver Products.");
                    return 1;
                }
            }
        }
        return 1;
    }
   
    if(strcmp(cmd, "/sellprods", true) == 0)
    {
        new cashmade;
        new tmpcar;
        if(IsPlayerConnected(playerid))
        {
            tmpcar = GetPlayerVehicleID(playerid);
            if(!IsATruck(tmpcar))
            {
                GameTextForPlayer(playerid, "~r~You are not in a delivery truck", 5000, 1);
                return 1;
            }
            if(PlayerInfo[playerid][pTruckLoad] == 0)
            {
                GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                return 1;
            }
            for(new i = 0; i < sizeof(BizzInfo); i++)
            {
                if (IsPlayerInRangeOfPoint(playerid, 10,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
                {
                    //printf("Found House :%d",i);
                    for(new l = PlayerInfo[playerid][pTruckLoad]; l > 0; l--)
                    {
                        if(BizzInfo[i][bProducts] == BizzInfo[i][bMaxProducts])
                        {
                            GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                        if(BizzInfo[i][bPriceProd] > BizzInfo[i][bTill])
                        {
                            GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                        PlayerInfo[playerid][pTruckLoad]--;
                        BizzInfo[i][bProducts]++;
                        cashmade = cashmade+BizzInfo[i][bPriceProd];
                        //ConsumingMoney[playerid] = 1;
                        SafeGivePlayerMoney(playerid,BizzInfo[i][bPriceProd]);
                        BizzInfo[i][bTill] -= BizzInfo[i][bPriceProd];
                        if(PlayerInfo[playerid][pTruckLoad] == 0)
                        {
                            GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                            format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                            SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            return 1;
                        }
                    }
                    OnPropUpdate(3,i);
                    return 1;
                }
            }
        }
        for(new i = 0; i < sizeof(SBizzInfo); i++)
        {
            if (IsPlayerInRangeOfPoint(playerid, 10,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
            {
                //printf("Found House :%d",i);
                for(new l = PlayerInfo[playerid][pTruckLoad]; l > 0; l--)
                {
                    if(SBizzInfo[i][sbProducts] == SBizzInfo[i][sbMaxProducts])
                    {
                        GameTextForPlayer(playerid, "~r~Our stores are full", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                    if(SBizzInfo[i][sbPriceProd] > SBizzInfo[i][sbTill])
                    {
                        GameTextForPlayer(playerid, "~r~We Cant Afford The Deal", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                    PlayerInfo[playerid][pTruckLoad]--;
                    SBizzInfo[i][sbProducts]++;
                    cashmade = cashmade+SBizzInfo[i][sbPriceProd];
                    //ConsumingMoney[playerid] = 1;
                    SafeGivePlayerMoney(playerid,SBizzInfo[i][sbPriceProd]);
                    SBizzInfo[i][sbTill] -= SBizzInfo[i][sbPriceProd];
                    if(PlayerInfo[playerid][pTruckLoad] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Truck is empty, return to the stock house", 5000, 1);
                        format(string, sizeof(string), "Cash Earned $%d.", cashmade);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        format(string, sizeof(string), "Products: %d.", PlayerInfo[playerid][pTruckLoad]);
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
                        return 1;
                    }
                }
                OnPropUpdate(3,i);
                return 1;
            }
        }
        GameTextForPlayer(playerid, "~r~To Far From A Business", 5000, 1);
        return 1;
    }
search for pInfo, should be a list add
pawn Code:
pTruckLoad,// if your adding to the end don't include the , and add the , to the prior.
search for OnPlayerConnect add with the other inisets...
pawn Code:
PlayerInfo[playerid][pTruckLoad] = 0;
search for onplayerregister add this line with other inisets
pawn Code:
dini_IntSet(string3, "TruckLoad",PlayerInfo[playerid][pTruckLoad]);
search for onplayerlogin add this with other inisets
pawn Code:
PlayerInfo[playerid][pTruckLoad] = dini_Int(string2,"TruckLoad");
this is a junky fix but it works... the down side of doing it this way you can't have more then one truckload number unless you make some if statements for the model # of the cars... and it doesn't save for the car that you buy the prods, it stays with the player.

Please say thanks if you like though
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)