Getvehiclenamefromid help
#1

ok, refresh my memory how to add getvehiclenameformid to this command, had a car wreck and forgot some shit.


PHP код:
CMD:v(playeridparams[])
{
    new 
v1color1,color2idx;
    
idx GetVehicleModelIDFromName(v1);
    if (
sscanf(params,"iii",v1color1,color2))
    {
    return 
SendClientMessage(playerid, -1"Syntax: /v <vehicle ID>, color1, color2");
    }
    if ( 
getveh[playerid] > )
    {
    
DestroyVehicle(getveh[playerid]);
    
getveh[playerid] = 0;
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
getveh[playerid] = CreateVehicle(v1xyz90color1color2false);
    
PutPlayerInVehicle(playeridgetveh[playerid], 0);
    }else{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
getveh[playerid] = CreateVehicle(v1xyz90color1color2false);
    
PutPlayerInVehicle(playeridgetveh[playerid], 0);
    }
    return 
1;

Reply
#2

Ouch, no replys? its been over night so bump?
Reply
#3

Is this what you mean?

pawn Код:
//At the top
new VehicleNames[212][] =
{
    "400 - Landstalker",        "401 - Bravura",            "402 - Buffalo",    "403 - Linerunner",         "404 - Pereniel",       "405 - Sentinel",       "406 - Dumper",             "407 - Firetruck",      "408 - Trashmaster",    "409 - Stretch",
    "410 - Manana",             "411 - Infernus",           "412 - Voodoo",     "413 - Pony",               "414 - Mule",           "415 - Cheetah",        "416 - Ambulance",          "417 - Leviathan",      "418 - Moonbeam",       "419 - Esperanto",          "420 - Taxi",
    "421 - Washington",         "422 - Bobcat",             "423 - Mr Whoopee", "424 - BF Injection",       "425 - Hunter",         "426 - Premier",        "427 - Enforcer",           "428 - Securicar",      "429 - Banshee",        "430 - Predator",
    "431 - Bus",                "432 - Rhino",              "433 - Barracks",   "434 - Hotknife",           "435 - Trailer",        "436 - Previon",        "437 - Coach",              "438 - Cabbie",         "439 - Stallion",       "440 - Rumpo",              "441 - RC Bandit",      "442 - Romero",
    "443 - Packer",             "444 - Monster",            "445 - Admiral",    "446 - Squalo",             "447 - Seasparrow",     "448 - Pizzaboy",       "449 - Tram",               "450 - Trailer",        "451 - Turismo",        "452 - Speeder",            "453 - Reefer",         "454 - Tropic",         "455 - Flatbed",
    "456 - Yankee",             "457 - Caddy",              "458 - Solair",     "459 - Berkley's RC Van",   "460 - Skimmer",        "461 - PCJ-600",        "462 - Faggio",             "463 - Freeway",        "464 - RC Baron",       "465 - RC Raider",
    "466 - Glendale",           "467 - Oceanic",            "468 - Sanchez",    "469 - Sparrow",            "470 - Patriot",        "471 - Quad",           "472 - Coastguard",         "473 - Dinghy",         "474 - Hermes",         "475 - Sabre",              "476 - Rustler",
    "477 - ZR350",              "478 - Walton",             "479 - Regina",     "480 - Comet",              "481 - BMX",            "482 - Burrito",        "483 - Camper",             "484 - Marquis",        "485 - Baggage",        "486 - Dozer",              "487 - Maverick",       "488 - News Chopper",
    "489 - Rancher",            "490 - FBI Rancher",        "491 - Virgo",      "492 - Greenwood",          "493 - Jetmax",         "494 - Hotring",        "495 - Sandking",           "496 - Blista Compact", "497 - Police Maverick",
    "498 - Boxville",           "499 - Benson",             "500 - Mesa",       "501 - RC Goblin",          "502 - Hotring Racer""503 - Hotring Racer""504 - Bloodring Banger",   "505 - Rancher",        "506 - Super GT",
    "507 - Elegant",            "508 - Journey",            "509 - Bike",       "510 - Mountain Bike",      "511 - Beagle",         "512 - Cropdust",       "513 - Stunt",              "514 - Tanker",         "515 - RoadTrain",      "516 - Nebula",             "517 - Majestic",
    "518 - Buccaneer",          "519 - Shamal",             "520 - Hydra",      "521 - FCR-900",            "522 - NRG-500",        "523 - HPV1000",        "524 - Cement Truck",       "525 - Tow Truck",      "526 - Fortune",        "527 - Cadrona",            "528 - FBI Truck",
    "529 - Willard",            "530 - Forklift",           "531 - Tractor",    "532 - Combine",            "533 - Feltzer",        "534 - Remington",      "535 - Slamvan",            "536 - Blade",          "537 - Freight",        "538 - Streak",             "539 - Vortex",         "540 - Vincent",
    "541 - Bullet",             "542 - Clover",             "543 - Sadler",     "544 - Firetruck",          "545 - Hustler",        "546 - Intruder",       "547 - Primo",              "548 - Cargobob",       "549 - Tampa",          "550 - Sunrise",            "551 - Merit",          "552 - Utility",
    "553 - Nevada",             "554 - Yosemite",           "555 - Windsor",    "556 - Monster",            "557 - Monster",        "558 - Uranus",         "559 - Jester",             "560 - Sultan",         "561 - Stratum",        "562 - Elegy",              "563 - Raindance",      "564 - RC Tiger",
    "565 - Flash",              "566 - Tahoma",             "567 - Savanna",    "568 - Bandito",            "569 - Freight",        "570 - Trailer",        "571 - Kart",               "572 - Mower",          "573 - Duneride",       "574 - Sweeper",            "575 - Broadway",
    "576 - Tornado",            "577 - AT-400",             "578 - DFT-30",     "579 - Huntley",            "580 - Stafford",       "581 - BF-400",         "582 - Newsvan",            "583 - Tug",            "584 - Trailer",        "585 - Emperor",            "586 - Wayfarer",
    "587 - Euros",              "588 - Hotdog",             "589 - Club",       "590 - Trailer",            "591 - Trailer",        "592 - Andromada",      "593 - Dodo",               "594 - RC Cam",         "595 - Launch",         "596 - Police Car (LSPD)",   "597 - Police Car (SFPD)",
    "598 - Police Car (LVPD)",   "599 - Police Ranger",     "600 - Picador",    "601 - S.W.A.T. Van",       "602 - Alpha",          "603 - Phoenix",        "604 - Glendale",           "605 - Sadler",         "606 - Luggage Trailer A",
    "607 - Luggage Trailer B",   "608 - Stair Trailer",     "609 - Boxville",   "610 - Farm Plow",          "611 - Utility Trailer"
};


//Under your command

new CarName, Float:X, Float:Y, Float:Z;
CarName = GetVehicleModelIDFromName(params);
GetPlayerPos(playerid,X, Y, Z);
CreateVehicle(CarName, X, Y, Z+1, 180, -1, -1, -1);

//Somewhere
GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if (strfind(VehicleNames[i], vname, true) != -1)
        return i + 400;
    }
    return -1;
}
Untested.
Reply
#4

Well, heres my command with it in.

PHP код:
CMD:v(playeridparams[])
{
    new 
color1,color2;
    new 
CarName;
    new 
string[50];
    
CarName GetVehicleModelIDFromName(params);
    if (
sscanf(params,"i",CarName))
    {
    return 
SendClientMessage(playerid, -1"Syntax: /v <vehicle ID>, color1, color2");
    }
    if ( 
getveh[playerid] > )
    {
    
DestroyVehicle(getveh[playerid]);
    
getveh[playerid] = 0;
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
getveh[playerid] = CreateVehicle(CarNamexyz90color1color2false);
    
PutPlayerInVehicle(playeridgetveh[playerid], 0);
    }else{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
getveh[playerid] = CreateVehicle(CarNamexyz90color1color2false);
    
PutPlayerInVehicle(playeridgetveh[playerid], 0);
    }
    return 
1;
}
 
doesnt workD
Reply
#5

Try this

pawn Код:
CMD:v(playerid, params[])
{
    new color1,color2;
    new CarName, getveh[128];
    if(sscanf(params,"sii",params, color1, color2)) return SendClientMessage(playerid, -1, "Syntax: /v <vehicle ID>, color1, color2");
    new vehicle = GetVehicleModelIDFromName(params);
    if(IsNumeric(params)) vehicle = strval(params);
    else vehicle = GetVehicleModelIDFromName(params);
    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, 0xAA3333AA, "Invalid vehicle ID/name");
    else
    if ( getveh[playerid] > 0 )
    {
        DestroyVehicle(getveh[playerid]);
        getveh[playerid] = 0;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        getveh[playerid] = CreateVehicle(CarName, x, y, z, 90, color1, color2, false);
        PutPlayerInVehicle(playerid, getveh[playerid], 0);
    }
    return 1;
}
Reply
#6

It keeps repearting the sscanf message, The syntax.
Reply
#7

Something wrong with color1, color2. Try delete it from the sscanf line and the variables
Reply
#8

I did, didnt work.
Reply
#9

Omg
pawn Код:
CMD:v(playerid, params[])
{
    new getveh[24],color1,color2;
    if(sscanf(params,"s[24]dd",getveh, color1, color2)) return SendClientMessage(playerid, -1, "Syntax: /v <vehicle [Name / ID]>, color1, color2");
    new vehicleID = GetVehicleModelIDFromName(getveh);
    if(vehicleID == (-1)) vehicleID = strval(getveh);
    if(!(400 <= vehicleID <= 611)) SendClientMessage(playerid, 0xAA3333AA, "Invalid vehicle ID/name");
    else{
        if( getveh[playerid] > 0 ) DestroyVehicle(getveh[playerid]);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        getveh[playerid] = CreateVehicle(vehicleID, x, y, z, 90, color1, color2, 60000);
        PutPlayerInVehicle(playerid, getveh[playerid], 0);
    }
    return 1;
}
// Edit better version xD
Reply
#10

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Omg
pawn Код:
CMD:v(playerid, params[])
{
    new getveh[24],color1,color2;
    if(sscanf(params,"s[24]dd",getveh, color1, color2)) return SendClientMessage(playerid, -1, "Syntax: /v <vehicle [Name / ID]>, color1, color2");
    new vehicleID = GetVehicleModelIDFromName(getveh);
    if(vehicleID == (-1)) vehicleID = strval(getveh);
    if(!(400 <= vehicleID <= 611)) SendClientMessage(playerid, 0xAA3333AA, "Invalid vehicle ID/name");
    else{
        if( getveh[playerid] > 0 ) DestroyVehicle(getveh[playerid]);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        getveh[playerid] = CreateVehicle(vehicleID, x, y, z, 90, color1, color2, 60000);
        PutPlayerInVehicle(playerid, getveh[playerid], 0);
    }
    return 1;
}
// Edit better version xD
Ok thanks jeff, it works great, but now it doesnt destroy the old vehicle.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)