Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------------------------------------------------------------*-
- - Includes
- -*----------------------------------------------------------------------------*/
- #include <a_samp>
- /*----------------------------------------------------------------------------*-
- - Setup defines
- -*----------------------------------------------------------------------------*/
- #define DIALOG_VEHICLE_LIST 7747 // ID of the purchase menu.
- #define MAX_VEHICLE_MENUS 20 // Maximum buy menus that can be added.
- #define MAX_MENU_VEHICLES 15 // Maximum vehicles that can be added to a vehicle shop.
- #define PICKUP_MODEL 1275 // Pickup model.
- #define PICKUP_WORLD 0 // Pickup world. Change this if you do not use the default world.
- /*----------------------------------------------------------------------------*-
- - Defines
- -*----------------------------------------------------------------------------*/
- #define MIN_VEHICLE_MODEL 400 // Minimum vehicle model ID.
- #define MAX_VEHICLE_MODEL 611 // Maximum vehicle model ID.
- /*----------------------------------------------------------------------------*-
- - Enumerations
- -*----------------------------------------------------------------------------*/
- enum E_MENU_DATA {
- bool:CREATED,
- PICKUP_ID,
- Float:POS_X,
- Float:POS_Y,
- Float:POS_Z,
- Float:SPAWN_X,
- Float:SPAWN_Y,
- Float:SPAWN_Z,
- Float:SPAWN_A,
- }
- enum E_VEHICLE_DATA {
- bool:CREATED,
- MODEL,
- PRICE,
- }
- /*----------------------------------------------------------------------------*-
- - Variables
- -*----------------------------------------------------------------------------*/
- stock
- MenuData[MAX_VEHICLE_MENUS][E_MENU_DATA],
- VehicleData[MAX_VEHICLE_MENUS][MAX_MENU_VEHICLES][E_VEHICLE_DATA];
- stock const vehicleName [ 212 ][ 18 ] = {
- /* vehicleName array taken from a Gamemode made By Slice
- */
- { "Landstalker" }, { "Bravura" }, { "Buffalo" }, { "Linerunner" }, // 400, 401, 402, 403
- { "Perrenial" }, { "Sentinel" }, { "Dumper" }, { "Firetruck" }, // 404, 405, 406, 407
- { "Trashmaster" }, { "Stretch" }, { "Manana" }, { "Infernus" }, // 408, 409, 410, 411
- { "Voodoo" }, { "Pony" }, { "Mule" }, { "Cheetah" }, // 412, 413, 414, 415
- { "Ambulance" }, { "Leviathan" }, { "Moonbeam" }, { "Esperanto" }, // 416, 417, 418, 419
- { "Taxi" }, { "Washington" }, { "Bobcat" }, { "Mr Whoopee" }, // 420, 421, 422, 423
- { "BF Injection" }, { "Hunter" }, { "Premier" }, { "Enforcer" }, // 424, 425, 426, 427
- { "Securicar" }, { "Banshee" }, { "Predator" }, { "Bus" }, // 428, 429, 430, 431
- { "Rhino" }, { "Barracks" }, { "Hotknife" }, { "Trailer 1" }, // 432, 433, 434, 435
- { "Previon" }, { "Coach" }, { "Cabbie" }, { "Stallion" }, // 436, 437, 438, 439
- { "Rumpo" }, { "RC Bandit" }, { "Romero" }, { "Packer" }, // 440, 441, 442, 443
- { "Monster" }, { "Admiral" }, { "Squalo" }, { "Seasparrow" }, // 444, 445, 446, 447
- { "Pizzaboy" }, { "Tram" }, { "Trailer 2" }, { "Turismo" }, // 448, 449, 450, 451
- { "Speeder" }, { "Reefer" }, { "Tropic" }, { "Flatbed" }, // 452, 453, 454, 455
- { "Yankee" }, { "Caddy" }, { "Solair" }, { "RC Van" }, // 456, 457, 458, 459
- { "Skimmer" }, { "PCJ-600" }, { "Faggio" }, { "Freeway" }, // 460, 461, 462, 463
- { "RC Baron" }, { "RC Raider" }, { "Glendale" }, { "Oceanic" }, // 464, 465, 466, 467
- { "Sanchez" }, { "Sparrow" }, { "Patriot" }, { "Quad" }, // 468, 469, 470, 471
- { "Coastguard" }, { "Dinghy" }, { "Hermes" }, { "Sabre" }, // 472, 473, 474, 475
- { "Rustler" }, { "ZR-350" }, { "Walton" }, { "Regina" }, // 476, 477, 478, 479
- { "Comet" }, { "BMX" }, { "Burrito" }, { "Camper" }, // 480, 481, 482, 483
- { "Marquis" }, { "Baggage" }, { "Dozer" }, { "Maverick" }, // 484, 485, 486, 487
- { "News Chopper" }, { "Rancher" }, { "FBI Rancher" }, { "Virgo" }, // 488, 489, 490, 491
- { "Greenwood" }, { "Jetmax" }, { "Hotring" }, { "Sandking" }, // 492, 493, 494, 495
- { "Blista" }, { "Police Maverick" }, { "Boxville" }, { "Benson" }, // 496, 497, 498, 499
- { "Mesa" }, { "RC Goblin" }, { "Hotring A" }, { "Hotring B" }, // 500, 501, 502, 503
- { "Bloodring Banger" }, { "Rancher" }, { "Super GT" }, { "Elegant" }, // 504, 505, 506, 507
- { "Journey" }, { "Bike" }, { "Mountain Bike" }, { "Beagle" }, // 508, 509, 510, 511
- { "Cropdust" }, { "Stuntplane" }, { "Tanker" }, { "Roadtrain" }, // 512, 513, 514, 515
- { "Nebula" }, { "Majestic" }, { "Buccaneer" }, { "Shamal" }, // 516, 517, 518, 519
- { "Hydra" }, { "FCR-900" }, { "NRG-500" }, { "HPV1000" }, // 520, 521, 522, 523
- { "Cement Truck" }, { "Tow Truck" }, { "Fortune" }, { "Cadrona" }, // 524, 525, 526, 527
- { "FBI Truck" }, { "Willard" }, { "Forklift" }, { "Tractor" }, // 528, 529, 530, 531
- { "Combine" }, { "Feltzer" }, { "Remington" }, { "Slamvan" }, // 532, 533, 534, 535
- { "Blade" }, { "Freight" }, { "Streak" }, { "Vortex" }, // 536, 537, 538, 539
- { "Vincent" }, { "Bullet" }, { "Clover" }, { "Sadler" }, // 540, 541, 542, 543
- { "Firetruck LA" }, { "Hustler" }, { "Intruder" }, { "Primo" }, // 544, 545, 546, 547
- { "Cargobob" }, { "Tampa" }, { "Sunrise" }, { "Merit" }, // 548, 549, 550, 551
- { "Utility" }, { "Nevada" }, { "Yosemite" }, { "Windsor" }, // 552, 553, 554, 555
- { "Monster" }, { "Monster" }, { "Uranus" }, { "Jester" }, // 556, 557, 558, 559
- { "Sultan" }, { "Stratum" }, { "Elegy" }, { "Raindance" }, // 560, 561, 562, 563
- { "RC Tiger" }, { "Flash" }, { "Tahoma" }, { "Savanna" }, // 564, 565, 566, 567
- { "Bandito" }, { "Freight Flat" }, { "Streak Carriage" }, { "Kart" }, // 568, 569, 570, 571
- { "Mower" }, { "Duneride" }, { "Sweeper" }, { "Broadway" }, // 572, 573, 574, 575
- { "Tornado" }, { "AT-400" }, { "DFT-30" }, { "Huntley" }, // 576, 577, 578, 579
- { "Stafford" }, { "BF-400" }, { "Newsvan" }, { "Tug" }, // 580, 581, 582, 583
- { "Trailer 3" }, { "Emperor" }, { "Wayfarer" }, { "Euros" }, // 584, 585, 586, 587
- { "Hotdog" }, { "Club" }, { "Freight Carriage" }, { "Trailer 3" }, // 588, 589, 590, 591
- { "Andromada" }, { "Dodo" }, { "RC Cam" }, { "Launch" }, // 592, 593, 594, 595
- { "Police LS" }, { "Police SF" }, { "Police LV" }, { "Police Ranger" }, // 596, 597, 598, 599
- { "Picador" }, { "S.W.A.T. Van" }, { "Alpha" }, { "Phoenix" }, // 600, 601, 602, 603
- { "Glendale" }, { "Sadler" }, { "Luggage Trailer A" }, { "Luggage Trailer B" }, // 604, 605, 606, 607
- { "Stair Trailer" }, { "Boxville" }, { "Farm Plow" }, { "Utility Trailer" } // 608, 609, 610, 611
- };
- /*----------------------------------------------------------------------------*/
- stock GetFreeSlot() {
- /* GetFreeSlot()
- Search through MenuData to find and return a free slot.
- Returns a free slot, -1 if no free slots are available.
- */
- for (new i; i != MAX_VEHICLE_MENUS; i++)
- if (!MenuData[i][CREATED])
- return i;
- return -1;
- }
- stock GetFreeVehicleSlot(shop_id) {
- /* GetFreeVehicleSlot()
- Search through VehicleData to find and return a free slot.
- Returns a free slot, -1 if no free slots are available.
- */
- for (new i; i != MAX_MENU_VEHICLES; i++)
- if (!VehicleData[shop_id][i][CREATED])
- return i;
- return -1;
- }
- stock AddVehicleShop(Float:pos_x, Float:pos_y, Float:pos_z, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:spawn_a) {
- /* AddVehicleShop(Float:pos_x, Float:pos_y, Float:pos_z, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:spawn_a)
- Add a vehicle shop to the map.
- Returns the ID of the shop that was added, -1 otherwise.
- */
- new slot = GetFreeSlot();
- if (slot == -1) {
- print("Could not create vehicle shop. No slot available.");
- return 0;
- }
- MenuData[slot][CREATED] = true;
- MenuData[slot][POS_X] = pos_x;
- MenuData[slot][POS_Y] = pos_y;
- MenuData[slot][POS_Z] = pos_z;
- MenuData[slot][SPAWN_X] = spawn_x;
- MenuData[slot][SPAWN_Y] = spawn_y;
- MenuData[slot][SPAWN_Z] = spawn_z;
- MenuData[slot][SPAWN_A] = spawn_a;
- MenuData[slot][PICKUP_ID] = CreatePickup(PICKUP_MODEL, 1, spawn_x, spawn_y, spawn_z, PICKUP_WORLD);
- return slot;
- }
- stock AddVehicleShopVehicle(shop_id, vehicle_model, vehicle_price) {
- /* AddVehicleShopVehicle(shop_id, vehicle_model, vehicle_price)
- Add a buyable vehicle to a shop menu.
- returns 1 on success, 0 otherwise.
- */
- if (shop_id < 0 || shop_id >= MAX_VEHICLE_MENUS) {
- print("Could not add vehicle. Invalid slot.");
- return 0;
- }
- if (!MenuData[shop_id][CREATED]) {
- printf("Could not add vehicle. shop_id %d is not created.", shop_id);
- return 0;
- }
- if (vehicle_price < 0)
- vehicle_price = 0;
- if (vehicle_model < MIN_VEHICLE_MODEL || vehicle_model > MAX_VEHICLE_MODEL) {
- print("Could not add vehicle. Invalid vehicle model.");
- return 0;
- }
- new slot = GetFreeVehicleSlot(shop_id);
- if (slot == -1) {
- print("Could not add shop vehicle. No slot available.");
- return 0;
- }
- VehicleData[shop_id][slot][CREATED] = true;
- VehicleData[shop_id][slot][MODEL] = vehicle_model;
- VehicleData[shop_id][slot][PRICE] = vehicle_price;
- return 1;
- }
- stock ShowVehicleMenu(playerid, menu_id) {
- if (menu_id < 0 || menu_id >= MAX_VEHICLE_MENUS) {
- print("Could not show menu. Invalid menu_id.");
- return 0;
- }
- if (!MenuData[menu_id][CREATED]) {
- printf("Could not show menu. menu_id %d is not created.", menu_id);
- return 0;
- }
- new string[1024], count;
- while (count < MAX_MENU_VEHICLES) {
- if (VehicleData[menu_id][count][CREATED]) {
- format(string, sizeof(string), "%s%s\t\t%d\n", string, vehicleName[ VehicleData[menu_id][count][MODEL] - 400 ], VehicleData[menu_id][count][PRICE]);
- }
- count++;
- }
- print(string);
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- main()
- {
- OnFilterScriptInit();
- quit();
- }
- public OnFilterScriptInit() {
- /* OnFilterScriptInit()
- Called when this filterscript is loaded.
- */
- new shopid;
- shopid = AddVehicleShop(0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- AddVehicleShopVehicle(shopid, 522, 5000);
- ShowVehicleMenu(0, shopid);
- return 1;
- }
Add Comment
Please, Sign In to add comment