Enum help displaying on ClientMessage
#1

I'm trying to display it in ClientMessage everytime four of the array.

this is the enum

pawn Код:
enum DEALERSHIP_VEHICLES
{
    dCarModel,
    dCarPrice
}
new CarsPrices[][DEALERSHIP_VEHICLES] = {
{462, 11999},
{525, 19500},
{543, 21000},
{473, 26000},
{463, 30500},
{440, 31000},
{532, 35500},
{600, 35999},
{491, 35999},
{410, 35999},
{516, 35999},
{418, 36000},
{586, 36000},
{467, 36500},
{547, 39500},
{401, 41500},
{549, 41999},
{436, 41999},
{420, 45500},
{517, 45999},
{589, 45999},
{518, 45999},
{527, 45999},
{551, 45999},
{439, 45999},
{445, 46000},
{478, 46000},
{492, 48999},
{422, 51000},
{529, 51500},
{405, 52500},
{466, 52999},
{546, 53999},
{540, 55500},
{474, 55999},
{526, 55999},
{500, 56000},
{483, 56000},
{545, 56000},
{419, 56781},
{561, 56999},
{459, 61000},
{421, 61500},
{458, 61500},
{550, 61999},
{576, 62500},
{412, 64500},
{438, 65500},
{533, 65999},
{534, 65999},
{585, 65999},
{507, 65999},
{554, 66000},
{567, 66500},
{536, 66500},
{599, 66500},
{575, 66999},
{479, 71400},
{489, 71750},
{431, 76000},
{523, 76000},
{575, 76500},
{542, 76500},
{413, 80000},
{496, 80299},
{535, 80999},
{508, 81800},
{426, 86500},
{404, 86500},
{562, 92999},
{580, 95999},
{482, 96500},
{566, 100500},
{587, 101000},
{423, 101500},
{588, 101500},
{559, 105999},
{579, 106500},
{400, 109999},
{453, 121000},
{402, 126000},
{558, 126000},
{480, 126500},
{408, 126500},
{602, 15100},
{565, 155999},
{555, 186000},
{484, 232200},
{430, 246000},
{409, 251000},
{560, 276000},
{454, 300999},
{603, 345000},
{415, 456999},
{446, 501000},
{563, 1001000},
{417, 1001000},
{487, 2551000},
{593, 3501000},
{509, 12000},
{481, 12000},
{477, 425000},
{468, 55000},
{521, 100000},
{541, 555999},
{429, 560000}
};
And my stock:
it displays all, but in the end something wrong..
pawn Код:
stock ShowBuyableVehicles(playerid)
{
    new str[128];
    for(new i = 0; i < sizeof(CarsPrices)-3; i+=3)
    {
        format(str, sizeof(str), "[ %s: %d , $%d ] [ %s: %d , $%d ] [ %s: %d , $%d ] [ %s: %d , $%d ]",
        VehicleNames[CarsPrices[i][dCarModel]-400], CarsPrices[i][dCarModel], CarsPrices[i][dCarPrice],
        VehicleNames[CarsPrices[i+1][dCarModel]-400], CarsPrices[i+1][dCarModel], CarsPrices[i+1][dCarPrice],
        VehicleNames[CarsPrices[i+2][dCarModel]-400], CarsPrices[i+2][dCarModel], CarsPrices[i+2][dCarPrice],
        VehicleNames[CarsPrices[i+3][dCarModel]-400], CarsPrices[i+3][dCarModel], CarsPrices[i+3][dCarPrice]
        );
        SCM(playerid, COLOR_WHITE, str);
    }
}
Reply
#2

pawn Код:
for(new i = 0; i != sizeof(CarsPrices) - 3; i += 4)
#e: Some explanation.

You are accessing i, .. i +3. With your current incrementation on second iteration you will have i+3, ... i+6 - your last and first elements are overlapping. Last iteration: sizeof(CarsPrices) - 4, ... sizeof(CarsPrices) - 1
Reply
#3

it doesn't display the last 2 ones.
Reply
#4

for(new i = 0; i != sizeof(CarsPrices) - 3; i += 6)

Experiment with last nummber 6 ++
Reply
#5

pawn Код:
stock ShowBuyableVehicles(playerid)
{
    new str[128];
    for(new i = 0; i != sizeof(CarsPrices); i+=3)
    {
        for(new j = 0; j != 4 && i + j < sizeof(CarsPrices); ++j) {
            format(str, sizeof(str), "%s[ %s: %d , $%d ] ", str, VehicleNames[CarsPrices[i+j][dCarModel]-400], CarsPrices[i][dCarModel], CarsPrices[i][dCarPrice]);
        }
        SCM(playerid, COLOR_WHITE, str);
    }
}
#e2: In fact, why not just

pawn Код:
stock ShowBuyableVehicles(playerid)
{
    new str[128];
    for(new i = 0; i != sizeof(CarsPrices); ++i)
    {
        if(0 == i % 4 && i != 0) {
            SCM(playerid, COLOR_WHITE, str);
            str[0] = EOS;
        }
        format(str, sizeof(str), "%s[ %s: %d , $%d ] ", VehicleNames[CarsPrices[i+j][dCarModel]-400], CarsPrices[i][dCarModel], CarsPrices[i][dCarPrice]);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)