Random items twice
#1

Hmm, i'm really bad with arrays, when it creates a dropoff it picks a random Itemname once again.
I want it to use the itemname given on CreateTruckPickup, how would I do that?
pawn Код:
new PickupLoc[][TruckArray] =
{
    {"Deceased donkeys",    "Rusty Ring Donut1",        "Market",       1041.4270, -1336.3523, 13.5504},
    {"Illegal Retards",     "Offtrack Betting1",        "Temple",       1628.3125,-1169.7318,24.0781},
    {"Rubber Dolls",        "Jefferson Motel1",         "Jefferson",    2229.2886,-1155.0635,25.8359}
};

new DropLoc[][TruckArray2] =
{
    {5000, 10000, "Rusty Ring Donut2",      "Market",       1041.4270, -1336.3523, 13.5504},
    {5000, 10000, "Offtrack Betting2",      "Temple",       1628.3125,-1169.7318,24.0781},
    {5000, 10000, "Jefferson Motel2",       "Jefferson",                    2229.2886,-1155.0635,25.8359}
};

stock CreateTruckPickup(playerid)
{
    TruckMission[playerid] = 1;
    new random1 = random(sizeof(PickupLoc)),
        string[126];
    PickupCP[playerid] = CreateDynamicCP(PickupLoc[random1][pX], PickupLoc[random1][pY], PickupLoc[random1][pZ], 3, -1, -1, playerid, 300.0);           // Creates a new checkpoint from array

    format(string, sizeof(string), "{FFFF00}[TRUCK DELIVERY] {FFFFFF}Pickup %s from %s in %s", PickupLoc[random1][ITEM], PickupLoc[random1][NAME], PickupLoc[random1][ZONE]);   // New location, fetching data from array.
    SendClientMessage(playerid, -1, string); // Updates textdraw string
    return 1;
}
stock CreateTruckDropoff(playerid)
{
    new random1 = random(sizeof(DropLoc)),
        string[126];
    DropoffCP[playerid] = CreateDynamicCP(DropLoc[random1][pX], DropLoc[random1][pY], DropLoc[random1][pZ], 3, -1, -1, playerid, 300.0);            // Creates a new checkpoint from array

    format(string, sizeof(string), "{FFFF00}[TRUCK DELIVERY] {FFFFFF}Deliver %s to %s in %s", PickupLoc[random1][ITEM], DropLoc[random1][NAME], DropLoc[random1][ZONE]);    // New location, fetching data from array.
    SendClientMessage(playerid, -1, string); // Updates textdraw string
    return 1;
}
Reply
#2

bump
Reply
#3

bump
Reply
#4

You could create a global variable for every player which stores the random number and read it when creating the dropoff location:

pawn Код:
// Top of script:
new CurrentLoad[MAX_PLAYERS];

// @CreateTruckPickup:
CurrentLoad[playerid] = random1;

// @CreateTruckDropoff:
// In the format function, change 'PickupLoc[random1][ITEM]' to:
PickupLoc[CurrentLoad[playerid]][ITEM]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)