Get Vehicle Name From Model Id
#1

I need a function that gets the vehicles name from the model Id.

Im using this function for names.

pawn Code:
new vehNames[212][] =
{
    {"Landstalker"},
    {"Bravura"},
    {"Buffalo"},
    {"Linerunner"},
    {"Perrenial"},
    {"Sentinel"},
    {"Dumper"},
    {"Firetruck"},
    {"Trashmaster"},
    {"Stretch"},
    {"Manana"},
    {"Infernus"},
    {"Voodoo"},
    {"Pony"},
    {"Mule"},
    {"Cheetah"},
    {"Ambulance"},
    {"Leviathan"},
    {"Moonbeam"},
    {"Esperanto"},
    {"Taxi"},
    {"Washington"},
    {"Bobcat"},
    {"MrWhoopee"},
    {"BFInjection"},
    {"Hunter"},
    {"Premier"},
    {"Enforcer"},
    {"Securicar"},
    {"Banshee"},
    {"Predator"},
    {"Bus"},
    {"Rhino"},
    {"Barracks"},
    {"Hotknife"},
    {"Trailer1"},
    {"Previon"},
    {"Coach"},
    {"Cabbie"},
    {"Stallion"},
    {"Rumpo"},
    {"RCBandit"},
    {"Romero"},
    {"Packer"},
    {"Monster"},
    {"Admiral"},
    {"Squalo"},
    {"Seasparrow"},
    {"Pizzaboy"},
    {"Tram"},
    {"Trailer2"},
    {"Turismo"},
    {"Speeder"},
    {"Reefer"},
    {"Tropic"},
    {"Flatbed"},
    {"Yankee"},
    {"Caddy"},
    {"Solair"},
    {"BerkleyRCVan"},
    {"Skimmer"},
    {"PCJ-600"},
    {"Faggio"},
    {"Freeway"},
    {"RCBaron"},
    {"RCRaider"},
    {"Glendale"},
    {"Oceanic"},
    {"Sanchez"},
    {"Sparrow"},
    {"Patriot"},
    {"Quad"},
    {"Coastguard"},
    {"Dinghy"},
    {"Hermes"},
    {"Sabre"},
    {"Rustler"},
    {"ZR-350"},
    {"Walton"},
    {"Regina"},
    {"Comet"},
    {"BMX"},
    {"Burrito"},
    {"Camper"},
    {"Marquis"},
    {"Baggage"},
    {"Dozer"},
    {"Maverick"},
    {"NewsChopper"},
    {"Rancher"},
    {"FBIRancher"},
    {"Virgo"},
    {"Greenwood"},
    {"Jetmax"},
    {"Hotring"},
    {"Sandking"},
    {"Blista Compact"},
    {"Police Maverick"},
    {"Boxville"},
    {"Benson"},
    {"Mesa"},
    {"RCGoblin"},
    {"HotringRacer A"},
    {"HotringRacer B"},
    {"BloodringBanger"},
    {"Rancher"},
    {"SuperGT"},
    {"Elegant"},
    {"Journey"},
    {"Bike"},
    {"MountainBike"},
    {"Beagle"},
    {"Cropdust"},
    {"Stunt"},
    {"Tanker"},
    {"Roadtrain"},
    {"Nebula"},
    {"Majestic"},
    {"Buccaneer"},
    {"Shamal"},
    {"Hydra"},
    {"FCR-900"},
    {"NRG-500"},
    {"HPV1000"},
    {"CementTruck"},
    {"TowTruck"},
    {"Fortune"},
    {"Cadrona"},
    {"FBITruck"},
    {"Willard"},
    {"Forklift"},
    {"Tractor"},
    {"Combine"},
    {"Feltzer"},
    {"Remington"},
    {"Slamvan"},
    {"Blade"},
    {"Freight"},
    {"Streak"},
    {"Vortex"},
    {"Vincent"},
    {"Bullet"},
    {"Clover"},
    {"Sadler"},
    {"FiretruckLA"},
    {"Hustler"},
    {"Intruder"},
    {"Primo"},
    {"Cargobob"},
    {"Tampa"},
    {"Sunrise"},
    {"Merit"},
    {"Utility"},
    {"Nevada"},
    {"Yosemite"},
    {"Windsor"},
    {"MonsterA"},
    {"MonsterB"},
    {"Uranus"},
    {"Jester"},
    {"Sultan"},
    {"Stratum"},
    {"Elegy"},
    {"Raindance"},
    {"RC Tiger"},
    {"Flash"},
    {"Tahoma"},
    {"Savanna"},
    {"Bandito"},
    {"FreightFlat"},
    {"StreakCarriage"},
    {"Kart"},
    {"Mower"},
    {"Duneride"},
    {"Sweeper"},
    {"Broadway"},
    {"Tornado"},
    {"AT-400"},
    {"DFT-30"},
    {"Huntley"},
    {"Stafford"},
    {"BF-400"},
    {"Newsvan"},
    {"Tug"},
    {"Trailer 3"},
    {"Emperor"},
    {"Wayfarer"},
    {"Euros"},
    {"Hotdog"},
    {"Club"},
    {"FreightCarriage"},
    {"Trailer3"},
    {"Andromada"},
    {"Dodo"},
    {"RCCam"},
    {"Launch"},
    {"PoliceCar(LSPD)"},
    {"PoliceCar(SFPD)"},
    {"PoliceCar(LVPD)"},
    {"PoliceRanger"},
    {"Picador"},
    {"S.W.A.T.Van"},
    {"Alpha"},
    {"Phoenix"},
    {"Glendale"},
    {"Sadler"},
    {"LuggageTrailerA"},
    {"LuggageTrailerB"},
    {"StairTrailer"},
    {"Boxville"},
    {"FarmPlow"},
    {"UtilityTrailer"}
};
Reply
#2

I was thinking something like.....
pawn Code:
stock VehGetNameFromModel(playerid)
{
    new modelname[128], vehicleid = GetPlayerVehicleID(playerid);
    switch(GetVehicleModel(vehicleid))
    {
        case 400: format(modelname, sizeof(modelname), "LandStalker");
        case 401: format(modelname, sizeof(modelname), "Bravura");
        case 402: format(modelname, sizeof(modelname), "Buffalo");
        case 403: format(modelname, sizeof(modelname), "Linerunner");
        case 404: format(modelname, sizeof(modelname), "Perenniel");
        case 405: format(modelname, sizeof(modelname), "Sentinel");
        case 406: format(modelname, sizeof(modelname), "Dumper");
        case 407: format(modelname, sizeof(modelname), "Firetruck");
        case 408: format(modelname, sizeof(modelname), "Trash Master");
        case 409: format(modelname, sizeof(modelname), "Stretch");
        case 410: format(modelname, sizeof(modelname), "Manana");
        case 411: format(modelname, sizeof(modelname), "Infernus");
        case 412: format(modelname, sizeof(modelname), "Stretch");
    }
    return modelname;
}
Not sure how that would work out though
Reply
#3

Thaw would take way to much scripting time. I know theres a function because ive used it before, but i dont have it anymore.
Reply
#4

pawn Code:
new VehicleNames[][] =
{
    "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
    "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
    "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
    "Esperanto", "Taxi", "Washington", "Bobcat", "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", "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", "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", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
    "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
    "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
    "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
    "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
    "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
    "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
    "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
    "Tiller", "Utility Trailer"
};

stock GetVehicleName(vehicleid)
{
    format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    format(String,sizeof(String),"You are entering a(n) %s.",GetVehicleName(vehicleid));
    SendClientMessage(playerid,-1,String);
    return 1;
}
That's just an example.
Reply
#5

I repeat: Subtract 400 from the vehicle ID. ID 0 in the array will be vehicle 400, ID 1 will be vehicle 401, etc.
Reply
#6

That's what the function does but he want's to get the Vehicle's name.
Reply
#7

No, subtracting 400 from the array will return the vehicle's name. The function is irrelevant.
Reply
#8

That's what it was. I made the function to make it easier for him. It could just be done like this:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    format(String,sizeof(String),"You are entering a(n) %s.",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    SendClientMessage(playerid,-1,String);
    return 1;
}
Reply
#9

Yeah, im sorry so much of a pain, but im just getting back to samp after a few months and forgot about 80% of my coding knowledge.

Tee, do you have an msn or skype by chance?
Reply
#10

Yes I do have MSN. I'll PM you the ID.
Reply
#11

Quote:
Originally Posted by Tee
View Post
That's what it was. I made the function to make it easier for him. It could just be done like this:

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    format(String,sizeof(String),"You are entering a(n) %s.",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    SendClientMessage(playerid,-1,String);
    return 1;
}
I know, but it's not really easier is it. A define would have been easier, but the function is just a waste of memory.
Reply
#12

PHP Code:
new VehicleNames[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","Sandking",
   
"Blista Compact""Police Maverick""Boxville""Benson","Mesa","RC Goblin",
   
"Hotring Racer""Hotring Racer""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 Truck",  "Nevada""Yosemite""Windsor",  "Monster",
   
"Monster","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RCTiger",
   
"Flash","Tahoma","Savanna""Bandito""Freight""Trailer""Kart""Mower",
   
"Dune""Sweeper""Broadway""Tornado""AT-400",  "DFT-30""Huntley",
   
"Stafford""BF-400""Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros",
   
"Hotdog""Club""Trailer""Trailer","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","Luggage Trailer","Stair Trailer""Boxville""Farm Plow",
   
"Utility Trailer"
}; 
PHP Code:
GetVehicleModelIDFromName(vname[])
{
    for(new 
0211i++)
    {
        if(
strfind(VehicleNames[i], vnametrue) != -1)
        return 
400;
    }
    return 
0;

That's what I would script if I'd need to send a message with the vehicle's name;

PHP Code:
format(strsizeof(str),"[VEHICLE]: "COL_WHITE"You spawned %s.",VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessage(playerid,COLOR_YELLOW,str); 
Hope I've helped you.
Reply
#13

Quote:
Originally Posted by xRandomGuy
View Post
PHP Code:
new VehicleNames[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","Sandking",
   
"Blista Compact""Police Maverick""Boxville""Benson","Mesa","RC Goblin",
   
"Hotring Racer""Hotring Racer""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 Truck",  "Nevada""Yosemite""Windsor",  "Monster",
   
"Monster","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RCTiger",
   
"Flash","Tahoma","Savanna""Bandito""Freight""Trailer""Kart""Mower",
   
"Dune""Sweeper""Broadway""Tornado""AT-400",  "DFT-30""Huntley",
   
"Stafford""BF-400""Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros",
   
"Hotdog""Club""Trailer""Trailer","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","Luggage Trailer","Stair Trailer""Boxville""Farm Plow",
   
"Utility Trailer"
}; 
PHP Code:
GetVehicleModelIDFromName(vname[])
{
    for(new 
0211i++)
    {
        if(
strfind(VehicleNames[i], vnametrue) != -1)
        return 
400;
    }
    return 
0;

That's what I would script if I'd need to send a message with the vehicle's name;

PHP Code:
format(strsizeof(str),"[VEHICLE]: "COL_WHITE"You spawned %s.",VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessage(playerid,COLOR_YELLOW,str); 
Hope I've helped you.
He has already solved the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)