Guest User

Untitled

a guest
Jun 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.98 KB | None | 0 0
  1. /*----------------------------------------------------------------------------*-
  2. - Includes
  3. -*----------------------------------------------------------------------------*/
  4.  
  5. #include <a_samp>
  6.  
  7. /*----------------------------------------------------------------------------*-
  8. - Setup defines
  9. -*----------------------------------------------------------------------------*/
  10.  
  11. #define DIALOG_VEHICLE_LIST                                                 7747 // ID of the purchase menu.
  12. #define MAX_VEHICLE_MENUS                                                     20 // Maximum buy menus that can be added.
  13. #define MAX_MENU_VEHICLES                                                     15 // Maximum vehicles that can be added to a vehicle shop.
  14. #define PICKUP_MODEL                                                        1275 // Pickup model.
  15. #define PICKUP_WORLD                                                           0 // Pickup world. Change this if you do not use the default world.
  16.  
  17. /*----------------------------------------------------------------------------*-
  18. - Defines
  19. -*----------------------------------------------------------------------------*/
  20.  
  21. #define MIN_VEHICLE_MODEL                                                    400 // Minimum vehicle model ID.
  22. #define MAX_VEHICLE_MODEL                                                    611 // Maximum vehicle model ID.
  23.  
  24. /*----------------------------------------------------------------------------*-
  25. - Enumerations
  26. -*----------------------------------------------------------------------------*/
  27.  
  28. enum E_MENU_DATA {
  29.     bool:CREATED,
  30.     PICKUP_ID,
  31.     Float:POS_X,
  32.     Float:POS_Y,
  33.     Float:POS_Z,
  34.     Float:SPAWN_X,
  35.     Float:SPAWN_Y,
  36.     Float:SPAWN_Z,
  37.     Float:SPAWN_A,
  38. }
  39.  
  40. enum E_VEHICLE_DATA {
  41.     bool:CREATED,
  42.     MODEL,
  43.     PRICE,
  44. }
  45.  
  46. /*----------------------------------------------------------------------------*-
  47. - Variables
  48. -*----------------------------------------------------------------------------*/
  49.  
  50. stock
  51.     MenuData[MAX_VEHICLE_MENUS][E_MENU_DATA],
  52.     VehicleData[MAX_VEHICLE_MENUS][MAX_MENU_VEHICLES][E_VEHICLE_DATA];
  53.    
  54. stock const vehicleName   [ 212 ][ 18 ] = {
  55. /*  vehicleName array taken from a Gamemode made By Slice
  56. */
  57.     { "Landstalker"       }, { "Bravura"           }, { "Buffalo"           }, { "Linerunner"        }, // 400, 401, 402, 403
  58.     { "Perrenial"         }, { "Sentinel"          }, { "Dumper"            }, { "Firetruck"         }, // 404, 405, 406, 407
  59.     { "Trashmaster"       }, { "Stretch"           }, { "Manana"            }, { "Infernus"          }, // 408, 409, 410, 411
  60.     { "Voodoo"            }, { "Pony"              }, { "Mule"              }, { "Cheetah"           }, // 412, 413, 414, 415
  61.     { "Ambulance"         }, { "Leviathan"         }, { "Moonbeam"          }, { "Esperanto"         }, // 416, 417, 418, 419
  62.     { "Taxi"              }, { "Washington"        }, { "Bobcat"            }, { "Mr Whoopee"        }, // 420, 421, 422, 423
  63.     { "BF Injection"      }, { "Hunter"            }, { "Premier"           }, { "Enforcer"          }, // 424, 425, 426, 427
  64.     { "Securicar"         }, { "Banshee"           }, { "Predator"          }, { "Bus"               }, // 428, 429, 430, 431
  65.     { "Rhino"             }, { "Barracks"          }, { "Hotknife"          }, { "Trailer 1"         }, // 432, 433, 434, 435
  66.     { "Previon"           }, { "Coach"             }, { "Cabbie"            }, { "Stallion"          }, // 436, 437, 438, 439
  67.     { "Rumpo"             }, { "RC Bandit"         }, { "Romero"            }, { "Packer"            }, // 440, 441, 442, 443
  68.     { "Monster"           }, { "Admiral"           }, { "Squalo"            }, { "Seasparrow"        }, // 444, 445, 446, 447
  69.     { "Pizzaboy"          }, { "Tram"              }, { "Trailer 2"         }, { "Turismo"           }, // 448, 449, 450, 451
  70.     { "Speeder"           }, { "Reefer"            }, { "Tropic"            }, { "Flatbed"           }, // 452, 453, 454, 455
  71.     { "Yankee"            }, { "Caddy"             }, { "Solair"            }, { "RC Van"            }, // 456, 457, 458, 459
  72.     { "Skimmer"           }, { "PCJ-600"           }, { "Faggio"            }, { "Freeway"           }, // 460, 461, 462, 463
  73.     { "RC Baron"          }, { "RC Raider"         }, { "Glendale"          }, { "Oceanic"           }, // 464, 465, 466, 467
  74.     { "Sanchez"           }, { "Sparrow"           }, { "Patriot"           }, { "Quad"              }, // 468, 469, 470, 471
  75.     { "Coastguard"        }, { "Dinghy"            }, { "Hermes"            }, { "Sabre"             }, // 472, 473, 474, 475
  76.     { "Rustler"           }, { "ZR-350"            }, { "Walton"            }, { "Regina"            }, // 476, 477, 478, 479
  77.     { "Comet"             }, { "BMX"               }, { "Burrito"           }, { "Camper"            }, // 480, 481, 482, 483
  78.     { "Marquis"           }, { "Baggage"           }, { "Dozer"             }, { "Maverick"          }, // 484, 485, 486, 487
  79.     { "News Chopper"      }, { "Rancher"           }, { "FBI Rancher"       }, { "Virgo"             }, // 488, 489, 490, 491
  80.     { "Greenwood"         }, { "Jetmax"            }, { "Hotring"           }, { "Sandking"          }, // 492, 493, 494, 495
  81.     { "Blista"            }, { "Police Maverick"   }, { "Boxville"          }, { "Benson"            }, // 496, 497, 498, 499
  82.     { "Mesa"              }, { "RC Goblin"         }, { "Hotring A"         }, { "Hotring B"         }, // 500, 501, 502, 503
  83.     { "Bloodring Banger"  }, { "Rancher"           }, { "Super GT"          }, { "Elegant"           }, // 504, 505, 506, 507
  84.     { "Journey"           }, { "Bike"              }, { "Mountain Bike"     }, { "Beagle"            }, // 508, 509, 510, 511
  85.     { "Cropdust"          }, { "Stuntplane"        }, { "Tanker"            }, { "Roadtrain"         }, // 512, 513, 514, 515
  86.     { "Nebula"            }, { "Majestic"          }, { "Buccaneer"         }, { "Shamal"            }, // 516, 517, 518, 519
  87.     { "Hydra"             }, { "FCR-900"           }, { "NRG-500"           }, { "HPV1000"           }, // 520, 521, 522, 523
  88.     { "Cement Truck"      }, { "Tow Truck"         }, { "Fortune"           }, { "Cadrona"           }, // 524, 525, 526, 527
  89.     { "FBI Truck"         }, { "Willard"           }, { "Forklift"          }, { "Tractor"           }, // 528, 529, 530, 531
  90.     { "Combine"           }, { "Feltzer"           }, { "Remington"         }, { "Slamvan"           }, // 532, 533, 534, 535
  91.     { "Blade"             }, { "Freight"           }, { "Streak"            }, { "Vortex"            }, // 536, 537, 538, 539
  92.     { "Vincent"           }, { "Bullet"            }, { "Clover"            }, { "Sadler"            }, // 540, 541, 542, 543
  93.     { "Firetruck LA"      }, { "Hustler"           }, { "Intruder"          }, { "Primo"             }, // 544, 545, 546, 547
  94.     { "Cargobob"          }, { "Tampa"             }, { "Sunrise"           }, { "Merit"             }, // 548, 549, 550, 551
  95.     { "Utility"           }, { "Nevada"            }, { "Yosemite"          }, { "Windsor"           }, // 552, 553, 554, 555
  96.     { "Monster"           }, { "Monster"           }, { "Uranus"            }, { "Jester"            }, // 556, 557, 558, 559
  97.     { "Sultan"            }, { "Stratum"           }, { "Elegy"             }, { "Raindance"         }, // 560, 561, 562, 563
  98.     { "RC Tiger"          }, { "Flash"             }, { "Tahoma"            }, { "Savanna"           }, // 564, 565, 566, 567
  99.     { "Bandito"           }, { "Freight Flat"      }, { "Streak Carriage"   }, { "Kart"              }, // 568, 569, 570, 571
  100.     { "Mower"             }, { "Duneride"          }, { "Sweeper"           }, { "Broadway"          }, // 572, 573, 574, 575
  101.     { "Tornado"           }, { "AT-400"            }, { "DFT-30"            }, { "Huntley"           }, // 576, 577, 578, 579
  102.     { "Stafford"          }, { "BF-400"            }, { "Newsvan"           }, { "Tug"               }, // 580, 581, 582, 583
  103.     { "Trailer 3"         }, { "Emperor"           }, { "Wayfarer"          }, { "Euros"             }, // 584, 585, 586, 587
  104.     { "Hotdog"            }, { "Club"              }, { "Freight Carriage"  }, { "Trailer 3"         }, // 588, 589, 590, 591
  105.     { "Andromada"         }, { "Dodo"              }, { "RC Cam"            }, { "Launch"            }, // 592, 593, 594, 595
  106.     { "Police LS"         }, { "Police SF"         }, { "Police LV"         }, { "Police Ranger"     }, // 596, 597, 598, 599
  107.     { "Picador"           }, { "S.W.A.T. Van"      }, { "Alpha"             }, { "Phoenix"           }, // 600, 601, 602, 603
  108.     { "Glendale"          }, { "Sadler"            }, { "Luggage Trailer A" }, { "Luggage Trailer B" }, // 604, 605, 606, 607
  109.     { "Stair Trailer"     }, { "Boxville"          }, { "Farm Plow"         }, { "Utility Trailer"   }  // 608, 609, 610, 611
  110. }
  111.  
  112. /*----------------------------------------------------------------------------*/
  113.  
  114. stock GetFreeSlot() {
  115. /*  GetFreeSlot()
  116.  
  117.     Search through MenuData to find and return a free slot.
  118.     Returns a free slot, -1 if no free slots are available.
  119. */
  120.     for (new i; i != MAX_VEHICLE_MENUS; i++)
  121.         if (!MenuData[i][CREATED])
  122.             return i;
  123.            
  124.     return -1;
  125. }
  126.  
  127. stock GetFreeVehicleSlot(shop_id) {
  128. /*  GetFreeVehicleSlot()
  129.  
  130.     Search through VehicleData to find and return a free slot.
  131.     Returns a free slot, -1 if no free slots are available.
  132. */
  133.     for (new i; i != MAX_MENU_VEHICLES; i++)
  134.         if (!VehicleData[shop_id][i][CREATED])
  135.             return i;
  136.            
  137.     return -1;
  138. }
  139.  
  140. stock AddVehicleShop(Float:pos_x, Float:pos_y, Float:pos_z, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:spawn_a) {
  141. /*  AddVehicleShop(Float:pos_x, Float:pos_y, Float:pos_z, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:spawn_a)
  142.  
  143.     Add a vehicle shop to the map.
  144.     Returns the ID of the shop that was added, -1 otherwise.
  145. */
  146.     new slot = GetFreeSlot();
  147.    
  148.     if (slot == -1) {
  149.         print("Could not create vehicle shop. No slot available.");
  150.         return 0;
  151.     }
  152.    
  153.     MenuData[slot][CREATED] = true;
  154.     MenuData[slot][POS_X] = pos_x;
  155.     MenuData[slot][POS_Y] = pos_y;
  156.     MenuData[slot][POS_Z] = pos_z;
  157.     MenuData[slot][SPAWN_X] = spawn_x;
  158.     MenuData[slot][SPAWN_Y] = spawn_y;
  159.     MenuData[slot][SPAWN_Z] = spawn_z;
  160.     MenuData[slot][SPAWN_A] = spawn_a;
  161.     MenuData[slot][PICKUP_ID] = CreatePickup(PICKUP_MODEL, 1, spawn_x, spawn_y, spawn_z, PICKUP_WORLD);
  162.    
  163.     return slot;
  164. }
  165.  
  166. stock AddVehicleShopVehicle(shop_id, vehicle_model, vehicle_price) {
  167. /*  AddVehicleShopVehicle(shop_id, vehicle_model, vehicle_price)
  168.  
  169.     Add a buyable vehicle to a shop menu.
  170.     returns 1 on success, 0 otherwise.
  171. */
  172.     if (shop_id < 0 || shop_id >= MAX_VEHICLE_MENUS) {
  173.         print("Could not add vehicle. Invalid slot.");
  174.         return 0;
  175.     }
  176.    
  177.     if (!MenuData[shop_id][CREATED]) {
  178.         printf("Could not add vehicle. shop_id %d is not created.", shop_id);
  179.         return 0;
  180.     }
  181.    
  182.     if (vehicle_price < 0)
  183.         vehicle_price = 0;
  184.        
  185.     if (vehicle_model < MIN_VEHICLE_MODEL || vehicle_model > MAX_VEHICLE_MODEL) {
  186.         print("Could not add vehicle. Invalid vehicle model.");
  187.         return 0;
  188.     }
  189.    
  190.     new slot = GetFreeVehicleSlot(shop_id);
  191.    
  192.     if (slot == -1) {
  193.         print("Could not add shop vehicle. No slot available.");
  194.         return 0;
  195.     }
  196.    
  197.     VehicleData[shop_id][slot][CREATED] = true;
  198.     VehicleData[shop_id][slot][MODEL] = vehicle_model;
  199.     VehicleData[shop_id][slot][PRICE] = vehicle_price;
  200.    
  201.     return 1;
  202. }
  203.  
  204. stock ShowVehicleMenu(playerid, menu_id) {
  205.  
  206.     if (menu_id < 0 || menu_id >= MAX_VEHICLE_MENUS) {
  207.         print("Could not show menu. Invalid menu_id.");
  208.         return 0;
  209.     }
  210.    
  211.     if (!MenuData[menu_id][CREATED]) {
  212.         printf("Could not show menu. menu_id %d is not created.", menu_id);
  213.         return 0;
  214.     }  
  215.    
  216.     new string[1024], count;
  217.    
  218.     while (count < MAX_MENU_VEHICLES) {
  219.         if (VehicleData[menu_id][count][CREATED]) {
  220.             format(string, sizeof(string), "%s%s\t\t%d\n", string, vehicleName[ VehicleData[menu_id][count][MODEL] - 400 ], VehicleData[menu_id][count][PRICE]);
  221.         }
  222.         count++;
  223.     }
  224.    
  225.     print(string);
  226.    
  227.     return 1;
  228. }
  229. /*----------------------------------------------------------------------------*/
  230. main()
  231. {
  232.     OnFilterScriptInit();
  233.     quit();
  234. }
  235. public OnFilterScriptInit() {
  236. /*  OnFilterScriptInit()
  237.  
  238.     Called when this filterscript is loaded.
  239. */
  240.     new shopid;
  241.    
  242.     shopid = AddVehicleShop(0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6);
  243.     AddVehicleShopVehicle(shopid, 522, 5000);
  244.     AddVehicleShopVehicle(shopid, 522, 5000);
  245.     AddVehicleShopVehicle(shopid, 522, 5000);
  246.     AddVehicleShopVehicle(shopid, 522, 5000);
  247.     AddVehicleShopVehicle(shopid, 522, 5000);
  248.     AddVehicleShopVehicle(shopid, 522, 5000);
  249.     AddVehicleShopVehicle(shopid, 522, 5000);
  250.     AddVehicleShopVehicle(shopid, 522, 5000);
  251.     AddVehicleShopVehicle(shopid, 522, 5000);
  252.     AddVehicleShopVehicle(shopid, 522, 5000);
  253.     AddVehicleShopVehicle(shopid, 522, 5000);
  254.     AddVehicleShopVehicle(shopid, 522, 5000);
  255.     AddVehicleShopVehicle(shopid, 522, 5000);
  256.     AddVehicleShopVehicle(shopid, 522, 5000);
  257.     AddVehicleShopVehicle(shopid, 522, 5000);
  258.     AddVehicleShopVehicle(shopid, 522, 5000);
  259.     AddVehicleShopVehicle(shopid, 522, 5000);
  260.     AddVehicleShopVehicle(shopid, 522, 5000);
  261.     AddVehicleShopVehicle(shopid, 522, 5000);
  262.     AddVehicleShopVehicle(shopid, 522, 5000);
  263.     AddVehicleShopVehicle(shopid, 522, 5000);
  264.     AddVehicleShopVehicle(shopid, 522, 5000);
  265.     ShowVehicleMenu(0, shopid);
  266.     return 1;
  267. }
Add Comment
Please, Sign In to add comment