/v [VehicleName]

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hey,


    wie kann ich die ModelID eines Autos durch den Namen herrausfinden?
    Momentan sieht mein Code so aus::


    ocmd:v(playerid,params[])
    {
    new vName[64];
    if(sscanf(params,"s",vName)) {
    formatEx(playerid,Grau,"{FEFEFE}[Benutze]: /v {FDD700}[Autoname] {FEFEFE}(Beispiel: /v {FDD700}Elegy{FEFEFE})",0);
    return 1;
    }
    for(new i=0; i<611; i++) {
    if(strcmp(vName,VehicleName[i],true)) {
    // ?
    }
    }
    return 1;
    }


  • new VehNames[][] =
    {
    "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", "Boxvillde", "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", "Stratum",
    "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", "CopCarLS",
    "CopCarSF", "CopCarLV", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
    "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
    "Tiller", "Utility Trailer"
    };



    GetVehicleIDByName(EnteredName[])
    {
    for(new v = 0; v < sizeof(VehNames); v++)
    {
    if(strfind(VehNames[v],EnteredName,true) != -1)
    {
    return v+400;
    }
    }
    if(strval(EnteredName) > 0) return strval(EnteredName);
    return -1;
    }


    //Cmd (der geht so)
    if (strcmp("/veh", cmdtext, true,4) == 0)
    {
    new vehicleID,car,Float:x, Float:y, Float:z;
    if(GetVehicleIDByName(cmdtext[5]) == -1)
    {
    return 1;
    }
    vehicleID = GetVehicleIDByName(cmdtext[5]);
    GetPlayerPos(playerid, x, y, z);
    car = CreateVehicle(vehicleID,x,y,z+1.0,0.0,1,1,-1);
    PutPlayerInVehicle(playerid, car, 0);
    return 1;
    }
    //Edit Verbesserte CMD version:
    if (strcmp("/veh", cmdtext, true,4) == 0)
    {
    new Float:x, Float:y, Float:z;
    new vehicleID = GetVehicleIDByName(cmdtext[5]);
    if(vehicleID == -1) return 1;
    GetPlayerPos(playerid, x, y, z);
    PutPlayerInVehicle(playerid, CreateVehicle(vehicleID,x,y,z+1.0,0.0,1,1,-1), 0);
    return 1;
    }


    Büdde, kannst den Cmd ja umschreiben wenn du willst, er geht aber auch so.

  • Und wieso kackt der PAWNO bei diesem Befehl ab?


    if (strcmp("/veh", cmdtext, true,4) == 0)
    {
    new Float:x, Float:y, Float:z;
    new vehicleID = GetVehicleIDByName(cmdtext[5]);
    if(vehicleID == -1) return 1;
    GetPlayerPos(playerid, x, y, z);
    PutPlayerInVehicle(playerid, CreateVehicle(vehicleID,x,y,z+1.0,0.0,1,1,-1), 0);
    return 1;
    }

  • kA, aber ich mache es mit ocmd, und es funktioniert gut ;)


    ocmd:v(playerid,params[])
    {
    new vName[64];
    new vehicleID,car,Float:x, Float:y, Float:z, Float:a;
    if(sscanf(params,"s",vName)) {
    formatEx(playerid,Grau,"{FEFEFE}[Benutze]: /v {FDD700}[Autoname] {FEFEFE}(Beispiel: /v {FDD700}Elegy{FEFEFE})",0);
    return 1;
    }
    if(GetVehicleIDByName(vName) == -1)
    {
    return 1;
    }
    vehicleID = GetVehicleIDByName(vName);
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    car = CreateVehicle(vehicleID,x,y,z+0.5,a,1,1,-1);
    PutPlayerInVehicle(playerid, car, 0);
    return 1;
    }