Browse through pre-setted vehicles
#1

Im creating a vehicle shop and i want to be able to browse through the vehicles i have selected for the shop.
I was thinking to browse through the vehicles with dialog_style_msgbox with keys, 'next' and 'close'. So when i press next, the vehicle shown for player is destroyed and it will create the next one in the line.

problem is, i have no idea how to do it. all i got so far is a list of the vehicles that is for the shop.

pawn Код:
#define MAX_BUYABLE_MODELS 111

new BuyableVehicle[MAX_BUYABLE_MODELS] =
{
    400, 402, 403, 404, 405, 409, 411, 412, 413, 414,
    415, 419, 420, 421, 422, 423, 424, 426, 428, 429,
    431, 434, 437, 438, 439, 440, 442, 444, 445, 451,
    457, 458, 461, 462, 463, 466, 467, 468, 470, 471,
    474, 475, 477, 478, 479, 480, 481, 482, 483, 485,
    489, 491, 492, 494, 495, 496, 500, 502, 503, 504,
    505, 506, 507, 508, 509, 510, 514, 515, 516, 518,
    521, 522, 523, 525, 526, 530, 533, 534, 535, 536,
    539, 541, 542, 545, 549, 554, 555, 556, 557, 558,
    559, 560, 561, 562, 565, 567, 568, 571, 572, 574,
    575, 578, 579, 580, 581, 586, 587, 588, 589, 602,
    603
};
When we are at shop, and select browse through vehicles, it will start browsing from ID 400, and then go to 402 when i press next button. hope you understood what i meant and are able to help a little with my problem.
Reply
#2

How will you see the vehicles if there's a dialog in the middle of the screen? I'd personally use a textdraw with < > arrow keys using OnPlayerUpdate and GetPlayerKeys.
Reply
#3

Thanks for the tip, MP2. But how to browse through my IDs while pressing arrow keys?
Reply
#4

I will make a tutorial tonight. P
Reply
#5

Ok, thanks. But noone else knows this? I want the vehicle browser to be like Skin selection. When i press Right it moves from veh ID 400 to 402, etc..
Reply
#6

Give me two hours. I am on the bus on the way home. It will help more people if I write a tutorial than if I just told you in a reply.
Reply
#7

Sorry I don't have time to do this.
Reply
#8

How to do what exactly, hearing you already have the right ideas
Reply
#9

Something like this might give you an idea;
pawn Код:
enum vStat { CurrentIndex = 0, CurrentVehicleId };
new gVehicleShopStat[MAX_PLAYERS][vStat]; // If only 1 person can browse at a time, remove the max players

// When creating the first vehicle
gVehicleShopStat[playerid][CurrentIndex] = 0;
gVehicleShopStat[playerid][CurrentVehicleId] = CreateVehicle(gVehicleShopStat[playerid][CurrentIndex], x, y, z, ...);

// When going to the next vehicle
DestroyVehicle(gVehicleStopStat[playerid][CurrentVehicleId]);
gVehicleShopStat[playerid][CurrentVehicleId] = CreateVehicle(++gVehicleShopStat[playerid][CurrentIndex], x, y, z, ...);
Still very rough though, and you will also need some checks to prevent Out Of Bounds errors.
Reply
#10

I have changed the BuyableVehicles to include vehicleid and price now. And the vehicle selection is created, but problem is that it dosent switch to a valid vehicle model when i press < L or R >. Im using sscanf to check if its valid vehicle model. Here is the vehicle enum, i tried to make a loop to change to next vehiclemodel, but it failed ig.
pawn Код:
#define MAX_BUYABLE_MODELS 111


enum _VehSale
{
    ovModel,
    ovPrice,
};

new BuyableVehicle[MAX_BUYABLE_MODELS][_VehSale] =
{
    {400, 500000}, {402, 750000}, {403, 1000000}, {404, 95000}, {405, 350000}, {409, 1000000}, {411, 2500000}, {412, 450000}, {413, 300000}, {414, 300000},
    {415, 1700000}, {419, 340000}, {420, 555000}, {421, 430000}, {422, 260000}, {423, 600000}, {424, 900000}, {426, 250000}, {428, 960000},{429, 2000000},
    {431, 3000000}, {434, 2600000}, {437, 3000000}, {438, 650000}, {439, 456000}, {440, 405000}, {442, 650000}, {444, 5000000}, {445, 600000}, {451, 2200000},
    {457, 250000}, {458, 450000}, {461, 605000}, {462, 150000}, {463, 460000}, {466, 350000}, {467, 250000}, {468, 350000}, {470, 1500000}, {471, 290000},
    {474, 350000}, {475, 350000}, {477, 1300000}, {478, 350000}, {479, 350000}, {480, 2000000}, {481, 99000}, {482, 450000}, {483, 350000}, {485, 195000},
    {489, 650000}, {491, 200000}, {492, 249000}, {494, 3000000}, {495, 3000000}, {496, 650000}, {500, 850000}, {502, 3000000}, {503, 3000000}, {504, 3000000},
    {505, 750000}, {506, 1450000}, {507, 350000}, {508, 350000}, {509, 99000}, {510, 99000}, {514, 3000000}, {515, 3000000}, {516, 350000}, {518, 350000},
    {521, 990000}, {522, 3000000}, {523, 750000}, {525, 450000}, {526, 350000}, {530, 150000}, {533, 250000}, {534, 350000}, {535, 650000},  {536, 655000},
    {539, 2350000}, {541, 2400000}, {542, 190000}, {545, 1800000}, {549, 150000}, {554, 300000}, {555, 1200000}, {556, 5000000}, {557, 5000000}, {558, 650000},
    {559, 650000}, {560, 990000}, {561, 290000}, {562, 650000}, {565, 650000}, {567, 350000}, {568, 1300000}, {571, 200000}, {572, 90000}, {574, 120000},
    {575, 330000}, {578, 550000}, {579, 800000}, {580, 489000}, {581, 600000}, {586, 250000}, {587, 700000}, {588, 690000}, {589, 390000}, {602, 1600000},
    {603, 1500000}
};
Edit: This is solved. I added owID to the enum which i used to browse through the vehicles.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)