Here's an array with vehicle names, it's in order so you can use it to get the vehicles model from the name. You can use it to spawn vehicles by typing their name, instead of the model ID etc. You can find the array at the bottom of the post, simply put it near the top of your gamemode, among other defines and variables.
The array:
Example command: !vehicle
Description: Type !vehicle <name> to spawn the vehicle.
Additional function: vModelFromName
Description: Gets the vehicle model ID from the name, using the array.
Pastebin link of array: http://pastebin.com/f3afd52cf
Pastebin link of vModelFromName: http://pastebin.com/f5851c541
Pastebin link of example command: http://pastebin.com/f30444fc6
The array:
Code Select
new vArray[107][] =
{
{"Landstalker"},
{"Idaho"},
{"Stinger"},
{"Linerunner"},
{"Perennial"},
{"Sentinel"},
{"Rio"},
{"Firetruck"},
{"Trashmaster"},
{"Stretch"},
{"Manana"},
{"Infernus"},
{"Voodoo"},
{"Pony"},
{"Mule"},
{"Cheetah"},
{"Ambulance"},
{"FBI Washington"},
{"Moonbeam"},
{"Esperanto"},
{"Taxi"},
{"Washington"},
{"Bobcat"},
{"Mr Whoopee"},
{"BF Injection"},
{"Hunter"},
{"Police"},
{"Enforcer"},
{"Securicar"},
{"Banshee"},
{"Predator"},
{"Bus"},
{"Rhino"},
{"Barracks"},
{"Cuban Hermes"},
{"Helicopter"}, // WARNING: Crashes the client if exited
{"Angel"},
{"Coach"},
{"Cabbie"},
{"Stallion"},
{"Rumpo"},
{"RC Bandit"},
{"Romero's Hearse"},
{"Packer"},
{"Sentinel XS"},
{"Admiral"},
{"Squalo"},
{"Sea Sparrow"},
{"Pizza Boy"},
{"Gang Burrito"},
{" "}, // UNKNOWN ID
{" "}, // UNKNOWN ID
{"Speeder"},
{"Reefer"},
{"Tropic"},
{"Flatbed"},
{"Yankee"},
{"Caddy"},
{"Zebra Cab"},
{"Top Fun"},
{"Skimmer"},
{"PCJ 600"},
{"Faggio"},
{"Freeway"},
{"RC Baron"}, // WARNING: Crashes the client if exited
{"RC Raider"}, // WARNING: Crashes the client if exited
{"Glendale"},
{"Oceanic"},
{"Sanchez"},
{"Sparrow"},
{"Patriot"},
{"Love Fist"},
{"Coast Guard"},
{"Dinghy"},
{"Hermes"},
{"Sabre"},
{"Sabre Turbo"},
{"Phoenix"},
{"Walton"},
{"Regina"},
{"Comet"},
{"Deluxo"},
{"Burrito"},
{"Spand Express"},
{"Marquis"},
{"Baggage Handler"},
{"Kaufman Cab"},
{"Maverick"},
{"VCN Maverick"},
{"Rancher"},
{"FBI Rancher"},
{"Virgo"},
{"Greenwood"},
{"Cuban Jetmax"},
{"Hotring Racer 1"},
{"Sandking"},
{"Blista Compact"},
{"Police Maverick"},
{"Benson"},
{"Boxville"},
{"Mesa Grande"},
{"RC Goblin"},
{"Hotring Racer 2"},
{"Hotring Racer 3"},
{"Bloodring Banger 1"},
{"Bloodring Bander 2"},
{"FBI Cheetah"}
};
Example command: !vehicle
Description: Type !vehicle <name> to spawn the vehicle.
Code Select
/*
new cmd[256],
string[128],
idx,
cmd = strtok(cmdtext, idx);
*/
// Add to OnPlayerText callback and make sure you have the variables shown above present already.
if(strcmp(cmd,"!vehicle",true) == 0)
{
new Float:x,
Float:y,
Float:z,
Float:angle,
vDat,
pveh[MAX_PLAYERS] = 0;
vDat = vModelFromName(cmdtext[9]);
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,angle);
if(vDat < 130 || vDat > 236)
{
SendClientMessage(playerid,COLOR_GREY,"Invalid model ID or name!");
return 0;
}
pveh[playerid] = CreateVehicle(vDat,x,y,z,angle,-1,-1,100);
PutPlayerInVehicle(playerid,pveh[playerid]);
format(string,sizeof(string),"Spawned a %s",vArray[vDat - 130]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 0;
}
Additional function: vModelFromName
Description: Gets the vehicle model ID from the name, using the array.
Code Select
vModelFromName(vName[])
{
for(new i = 0; i < 109; i++)
if(strfind(vArray[i],vName,true) != -1 )
return i+130;
return -1;
}
Pastebin link of array: http://pastebin.com/f3afd52cf
Pastebin link of vModelFromName: http://pastebin.com/f5851c541
Pastebin link of example command: http://pastebin.com/f30444fc6