I need some small help -
Shockey HD - 22.08.2011
At the very top of my script i have
pawn Code:
new VehicleNames[212][] = {
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","ZR3 50","Walton","Regina",
"Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood",
"Jetmax","Hotring","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","Cropdust","Stunt","Tanker","RoadTrain",
"Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","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 A","Emperor",
"Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","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"
};
Im using this for my command to spawn cars.
pawn Code:
CMD:car(playerid,params[])
{
if (PlayerInfo[playerid][pAdmin] == 0)
{
SendClientMessage(playerid,COLOR_RED,"You Must Be VIP To Use This Command!");
return 1;
}
else if (PlayerInfo[playerid][pAdmin] >= 2)
{
new vehicle,color1,color2,string[128];
if(sscanf(params,"sdd",vehicle,color1,color2)) SendClientMessage(playerid,COLOR_RED,"Usage: /car [Vehicle Name] [Color 1][Color 2]");
else
{
vehicle = VehicleNames;
new Float:x, Float:y, Float:z,angle;
GetPlayerPos(playerid,x,y,z);
new id = CreateVehicle(vehicle, x+3,y,z, angle, -1,-1,-1);
new vehicleid = GetPlayerVehicleID(playerid);
PutPlayerInVehicle(playerid, vehicleid, 0 );
ChangeVehicleColor(id, color1, color2);
}
}
return 1;
}
My issue is that,
dosnt grab the list from the top, how do i do that?
Re: I need some small help -
iggy1 - 22.08.2011
VehicleNames is an array of strings, so you can't put an array inside a standard int var. "CreateVehicle" needs to be passed a modelid not a string.
PS, Look for "GetVehicleIdFromName" function its in the usefull functions section.
Re: I need some small help -
Shockey HD - 22.08.2011
So i cant do it like this? Having a little trouble understanding
Re: I need some small help -
iggy1 - 22.08.2011
EDIT: Sorry i think you want something like "GetVehicleModelidFromName".
It might be better if you create some kind of menu for spawning vehicles because your relying on the player correctly spelling a vehicle model.
If you haven't found a solution by the time i finish work ill write a command for you, but i still think its better with a menu.
Re: I need some small help -
iggy1 - 22.08.2011
pawn Code:
new VehicleNames[212][] =
{
{"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"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 1"},{"Previon"},
{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"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"},{"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"},{"Cropdust"},{"Stunt"},
{"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
{"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
{"Firetruck LA"},{"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 Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
{"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"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"}
};
CMD:car(playerid,params[])
{
if (PlayerInfo[playerid][pAdmin] == 0)
{
SendClientMessage(playerid,COLOR_RED,"You Must Be VIP To Use This Command!");
return 1;
}
else if (PlayerInfo[playerid][pAdmin] >= 2)
{
new
vehicle,
string[128],
color1, color2;
if(sscanf(params,"sdd",vehicle,color1,color2)) SendClientMessage(playerid,COLOR_RED,"Usage: /car [Vehicle Name] [Color 1][Color 2]");//if your using the plugin you should be declaring the size of the string.
else
{
vehicle = GetVehicleModelIDFromName(vehicle);
if(vehicle != INVALID_VEHICLE_ID)
{
new
id,
Float:x, Float:y, Float:z,angle;
GetPlayerPos(playerid,x,y,z);
id = CreateVehicle(vehicle, x,y,z+0.5, angle, -1,-1,-1);//i changed this so it spawns above the player and not by the side (maybe half inside a building)
PutPlayerInVehicle(playerid, id, 0 );
ChangeVehicleColor(id, color1, color2);
}
else
SendClientMessage(playerid, 0xFF0000AA, "ERROR: That is not a valid vehicle name.");
}
}
return 1;
}
GetVehicleModelIDFromName(szVehicleName[])
{
for(new i = 0; i < 211; i++)
if(strfind(VehicleNames[i], szVehicleName, true) != -1 )
return i + 400;
return INVALID_VEHICLE_ID;
}
EDIT: If you want to do an exact match on the vehicle name just change the "strfind" to an "strcmp".