#include <zcmd>
// Description: Including the best command processor out there - zcmd by Zeex.
// Note: Add this to the top of the script.
#define DIALOG_VEHICLES 123321
// Description: Defining the dialog for later use.
static const VehicleName[212][] = {
"Landstalker","Bravura","Buffalo","Linerunner","Perennial","Sentinel","Dumper","Firetruck","Trashmaster","Stretch",
"Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi",
"Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee","Predator",
"Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo","RC Bandit", "Romero",
"Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder","Reefer","Tropic","Flatbed",
"Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider",
"Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler",
"ZR-350","Walton","Regina","Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper",
"Rancher","FBI Rancher","Virgo","Greenwood","Jetmax","Hotring Racer","Sandking","Blista Compact","Police Maverick",
"Boxville","Benson","Mesa","RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT",
"Elegant","Journey","Bike","Mountain Bike","Beagle","Cropduster","Stuntplane","Tanker","Road Train","Nebula","Majestic",
"Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV-1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck",
"Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent",
"Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility",
"Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger",
"Flash","Tahoma","Savanna","Bandito","Freight","Trailer","Kart","Mower","Duneride","Sweeper","Broadway",
"Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer","Emperor","Wayfarer",
"Euros","Hotdog","Club","Trailer","Trailer","Andromada","Dodo","RCCam","Launch","Police Car (LSPD)","Police Car (SFPD)",
"Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A",
"Luggage Trailer B","Stair Trailer","Boxville","Farm Plow","Utility Trailer"
};
// Description: A static constant including vehicle names, very useful for getting them.
#define GetVehicleName(%0) VehicleName[GetVehicleModel(%0)-400]
// Description: Get any vehicle's name from the vehicle's ID.
#define GetVehicleModelName(%0) VehicleName[%0-400]
// Description: Get any vehicle's name from the vehicle's model ID.
stock randomEx(minnum = cellmin, maxnum = cellmax)
{
return random(maxnum - minnum + 1) + minnum;
}
// Description: Get a randomized number between the minimum and the maximum number.
// Usage: randomEx(2, 10);
// Will return: A randomized value between 2 and 10.
stock SpawnVehicleInFrontOfPlayer(playerid, vehiclemodel, color1, color2)
{
new Float:x,Float:y,Float:z;
new Float:facing;
new Float:distance;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, facing);
new Float:size_x,Float:size_y,Float:size_z;
GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
distance = size_x + 0.5;
x += (distance * floatsin(-facing, degrees));
y += (distance * floatcos(-facing, degrees));
facing += 90.0;
if(facing > 360.0) facing -= 360.0;
return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
}
// Description: Spawning a vehicle in front of the player. VERY useful.
CMD:vspawner(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
new dstring[2048];
new string[64];
format(dstring,sizeof(dstring),"{FFFFFF}");
for(new i=400; i < 612; i++)
{
format(string,sizeof(string),"%s\n",GetVehicleModelName(i));
strcat(dstring, string);
}
ShowPlayerDialogEx(playerid, DIALOG_VEHICLES, DIALOG_STYLE_LIST, "{FFFFFF}Vehicles",dstring,"Spawn","Cancel");
}
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 2)
if(IsPlayerAdmin(playerid))
new dstring[2048];
new string[64];
format(dstring,sizeof(dstring),"{FFFFFF}");
for(new i=400; i < 612; i++)
format(string,sizeof(string),"%s\n",GetVehicleModelName(i));
strcat(dstring, string);
ShowPlayerDialog(playerid, DIALOG_VEHICLES, DIALOG_STYLE_LIST, "{FFFFFF}Vehicles",dstring,"Spawn","Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_VEHICLES: // If the dialog ID is DIALOG_VEHICLES (defined earlier as 123321)
{
if(response) // If the player clicked "Spawn" or the enter key on the keyboard
{
SpawnVehicleInFrontOfPlayer(playerid, listitem+400, randomEx(0,255), randomEx(0,255));
// Spawn a vehicle in front of the player.
// listitem+400 you ask. This is used because the list items are actually 0, 1, 2 etc., so it will add 400 to it, because that's the lowest vehicle model ID.
// randomEx(0,255) - Randomizing the vehicle's color 1 and color 2.
}
}
}
return 1;
}
Have you tested this tutorial?
Because dialogs only show up to 50 lines, all 212 vehiclemodels won't be listed, even when they fit inside your huge string. |