Hilfe bei /car befehl

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 mans machen das Man auch Über den Namen das Auto Spawnen kann?
    Also z.B. " /car Sultan 0 0"


    Hier der Code



    ocmd:car(playerid,params[])
    {
    if(!isPlayerAnAdmin(playerid, 4)) return ErrorMessages(playerid, 4);
    {
    if(CarTrue[playerid] == 0)
    {
    new car;
    new string[128];
    new colour1, colour2;
    if(sscanf(params,"iii",car, colour1, colour2))return SendClientMessage(playerid,ORANGE,"Benutzung: /car [Model/ID] [Farbe1] [Farbe2]");
    if(car < 400 || car > 611) return SendClientMessage(playerid, ROT, "ERROR: Ungültige Vehicle Model ID!");
    new LVehicleID;
    new Float:X,Float:Y,Float:Z;
    new Float:Angle,int1;
    GetPlayerPos(playerid, X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    int1 = GetPlayerInterior(playerid);
    DestroyVehicle(LVehicleID);
    LVehicleID = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, -1);
    LinkVehicleToInterior(LVehicleID,int1);
    format(string, sizeof(string), "|- Du hast einen "%s" gespawned (Model: %d) with Colours: %d,%d -|", VehicleNames[car-400], car, colour1, colour2);
    CarTrue[playerid] = 1;
    return SendClientMessage(playerid,HELLBLAU, string);
    }
    else
    {
    SendClientMessage(playerid, ROT, "Du hast bereits ein Fahrzeug!");
    return 1;
    }

    }
    }

  • Hab dir mal ein Filterscript dafür gemacht du kannst Autos mit der ID oder dem Namen Spawnen also /v nrg 1 1 oder /v 522 1 1


    // This is a comment
    // uncomment the line below if you want to write a filterscript
    //#define FILTERSCRIPT


    #include <a_samp>
    #include <ocmd>


    //Farben
    #define COLOR_GREY 0x808080FF
    #define COLOR_WHITE 0xFFFFFFFF
    #define COLOR_YELLOW 0xFFFF00FF
    #define COLOR_GREEN 0x088A08FF


    //Foorwards
    forward GetVehicleModelIDFromName(vname[]);


    //PlayerInfo
    enum pInfo
    {


    bool:pCanSpawnVehicle,
    pSpawnVehicle,
    }


    //Client Variabelen
    new PlayerInfo[MAX_PLAYERS][pInfo];
    //Server Variabelen
    new Float:pX,
    Float:pY, Float:pZ, Float:pAngle;


    //Auto Namen
    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"}};


    ////////////////////////////////////////////////////////


    #if defined FILTERSCRIPT


    public OnFilterScriptInit()
    {
    print("\n--------------------------------------");
    print(" Car Spawen by JAGHAX");
    print("--------------------------------------\n");
    return 1;
    }


    public OnFilterScriptExit()
    {
    return 1;
    }


    #else


    main()
    {
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
    }


    #endif


    public GetVehicleModelIDFromName(vname[])
    {
    for(new i = 0; i < 211; i++)
    {
    if ( strfind(VehicleNames[i], vname, true) != -1 )
    return i + 400;
    }
    return -1;
    }


    ocmd:v(playerid, params[])
    {
    new Vehicle[32], VehicleID, Farbe1, Farbe2;
    PlayerInfo[playerid][pCanSpawnVehicle] = true;
    if(sscanf(params, "s[32]D(1)D(1)", Vehicle, Farbe1, Farbe2))
    {
    PlayerInfo[playerid][pCanSpawnVehicle] = true;
    SendClientMessage(playerid, COLOR_GREY, "[Benutze]: /v[CarID/CarName] [Farbe 1] [Farbe 2]");
    SendClientMessage(playerid, COLOR_GREY, "[Benutze]: /v Nrg 1 1 /v 522 1 1");
    return 1;
    }


    if(PlayerInfo[playerid][pCanSpawnVehicle])
    {
    VehicleID = GetVehicleModelIDFromName(Vehicle);
    if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 &&
    VehicleID != 430 && VehicleID != 417 && VehicleID != 435 &&
    VehicleID != 446 && VehicleID != 449 && VehicleID != 450 &&
    VehicleID != 452 && VehicleID != 453 && VehicleID != 454 &&
    VehicleID != 460 && VehicleID != 464 && VehicleID != 465 &&
    VehicleID != 469 && VehicleID != 472 && VehicleID != 473 &&
    VehicleID != 476 && VehicleID != 484 && VehicleID != 487 &&
    VehicleID != 488 && VehicleID != 493 && VehicleID != 497 &&
    VehicleID != 501 && VehicleID != 511 && VehicleID != 512 &&
    VehicleID != 513 && VehicleID != 519 && VehicleID != 520 &&
    VehicleID != 537 && VehicleID != 538 && VehicleID != 548 &&
    VehicleID != 553 && VehicleID != 563 && VehicleID != 564 &&
    VehicleID != 569 && VehicleID != 570 && VehicleID != 577 &&
    VehicleID != 584 && VehicleID != 590 && VehicleID != 591 &&
    VehicleID != 592 && VehicleID != 593 && VehicleID != 594 &&
    VehicleID != 595 && VehicleID != 606 && VehicleID != 607 &&
    VehicleID != 608 && VehicleID != 610 && VehicleID != 611) {
    if(VehicleID == -1 )
    {
    VehicleID = strval(Vehicle);


    if(VehicleID < 400 || VehicleID > 611 )
    {
    return SendClientMessage(playerid, COLOR_GREY, "Falsche CarID/CarName");
    }
    }


    GetPlayerPos(playerid, pX, pY, pZ);
    GetPlayerFacingAngle(playerid, pAngle);


    DestroyVehicle(PlayerInfo[playerid][pSpawnVehicle]);
    PlayerInfo[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, Farbe1, Farbe2, -1);
    LinkVehicleToInterior(PlayerInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][pSpawnVehicle], 0);
    SendClientMessage(playerid, COLOR_GREY, "Auto erstellt!");
    } else {
    SendClientMessage(playerid, COLOR_GREY, "Du darfst dieses Auto nicht Spawnen!!");
    }
    } else {
    SendClientMessage(playerid, COLOR_GREY, "Du kannst kein Car hier Spawnen!");
    }
    return 1;
    }



    stock sscanf(string[], format[], {Float,_}:...)
    {
    #if defined isnull
    if (isnull(string))
    #else
    if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
    #endif
    {
    return format[0];
    }
    #pragma tabsize 4
    new
    formatPos = 0,
    stringPos = 0,
    paramPos = 2,
    paramCount = numargs(),
    delim = ' ';
    while (string[stringPos] && string[stringPos] <= ' ')
    {
    stringPos++;
    }
    while (paramPos < paramCount && string[stringPos])
    {
    switch (format[formatPos++])
    {
    case '\0':
    {
    return 0;
    }
    case 'i', 'd':
    {
    new
    neg = 1,
    num = 0,
    ch = string[stringPos];
    if (ch == '-')
    {
    neg = -1;
    ch = string[++stringPos];
    }
    do
    {
    stringPos++;
    if ('0' <= ch <= '9')
    {
    num = (num * 10) + (ch - '0');
    }
    else
    {
    return -1;
    }
    }
    while ((ch = string[stringPos]) > ' ' && ch != delim);
    setarg(paramPos, 0, num * neg);
    }
    case 'h', 'x':
    {
    new
    num = 0,
    ch = string[stringPos];
    do
    {
    stringPos++;
    switch (ch)
    {
    case 'x', 'X':
    {
    num = 0;
    continue;
    }
    case '0' .. '9':
    {
    num = (num << 4) | (ch - '0');
    }
    case 'a' .. 'f':
    {
    num = (num << 4) | (ch - ('a' - 10));
    }
    case 'A' .. 'F':
    {
    num = (num << 4) | (ch - ('A' - 10));
    }
    default:
    {
    return -1;
    }
    }
    }
    while ((ch = string[stringPos]) > ' ' && ch != delim);
    setarg(paramPos, 0, num);
    }
    case 'c':
    {
    setarg(paramPos, 0, string[stringPos++]);
    }
    case 'f':
    {


    new changestr[16], changepos = 0, strpos = stringPos;
    while(changepos < 16 && string[strpos] && string[strpos] != delim)
    {
    changestr[changepos++] = string[strpos++];
    }
    changestr[changepos] = '\0';
    setarg(paramPos,0,_:floatstr(changestr));
    }
    case 'p':
    {
    delim = format[formatPos++];
    continue;
    }
    case '\'':
    {
    new
    end = formatPos - 1,
    ch;
    while ((ch = format[++end]) && ch != '\'') {}
    if (!ch)
    {
    return -1;
    }
    format[end] = '\0';
    if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
    {
    if (format[end + 1])
    {
    return -1;
    }
    return 0;
    }
    format[end] = '\'';
    stringPos = ch + (end - formatPos);
    formatPos = end + 1;
    }
    case 'u':
    {
    new
    end = stringPos - 1,
    id = 0,
    bool:num = true,
    ch;
    while ((ch = string[++end]) && ch != delim)
    {
    if (num)
    {
    if ('0' <= ch <= '9')
    {
    id = (id * 10) + (ch - '0');
    }
    else
    {
    num = false;
    }
    }
    }
    if (num && IsPlayerConnected(id))
    {
    setarg(paramPos, 0, id);
    }
    else
    {
    #if !defined foreach
    #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
    #define __SSCANF_FOREACH__
    #endif
    string[end] = '\0';
    num = false;
    new
    name[MAX_PLAYER_NAME];
    id = end - stringPos;
    foreach (Player, playerid)
    {
    GetPlayerName(playerid, name, sizeof (name));
    if (!strcmp(name, string[stringPos], true, id))
    {
    setarg(paramPos, 0, playerid);
    num = true;
    break;
    }
    }
    if (!num)
    {
    setarg(paramPos, 0, INVALID_PLAYER_ID);
    }
    string[end] = ch;
    #if defined __SSCANF_FOREACH__
    #undef foreach
    #undef __SSCANF_FOREACH__
    #endif
    }
    stringPos = end;
    }
    case 's', 'z':
    {
    new
    i = 0,
    ch;
    if (format[formatPos])
    {
    while ((ch = string[stringPos++]) && ch != delim)
    {
    setarg(paramPos, i++, ch);
    }
    if (!i)
    {
    return -1;
    }
    }
    else
    {
    while ((ch = string[stringPos++]))
    {
    setarg(paramPos, i++, ch);
    }
    }
    stringPos--;
    setarg(paramPos, i, '\0');
    }
    default:
    {
    continue;
    }
    }
    while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
    {
    stringPos++;
    }
    while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
    {
    stringPos++;
    }
    paramPos++;
    }
    do
    {
    if ((delim = format[formatPos++]) > ' ')
    {
    if (delim == '\'')
    {
    while ((delim = format[formatPos++]) && delim != '\'') {}
    }
    else if (delim != 'z')
    {
    return delim;
    }
    }
    }
    while (delim > ' ');
    return 0;
    }


    Ich hoffe ich konnte dir weiterhelfen

  • ocmd:car(playerid,params[]){
    if(CarTrue[playerid] != 0)return SendClientMessage(playerid, ROT, "Du hast bereits ein Fahrzeug!");
    if(!isPlayerAnAdmin(playerid, 4)) return ErrorMessages(playerid, 4);
    new carData[3],Float:Pos[4],;
    if(sscanf(params,"k<vehicle>ii",carData[0],carData[1],carData[2])return SendClientMessage(playerid,ORANGE,"Benutzung: /car [Model/ID] [Farbe1] [Farbe2]");
    if(carData[0] == -1)return SendClientMessage(playerid, ROT, "ERROR: Ungültige Vehicle Model ID!");
    GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
    GetPlayerFacingAngle(playerid,Pos[3]);
    DestroyVehicle(CarTrue[playerid]);
    CarTrue[playerid] = CreateVehicle(carData[0], Pos[0]+3,Pos[1],Pos[2], Pos[3],carData[1],carData[2], -1);
    LinkVehicleToInterior(CarTrue[playerid],GetPlayerInterior(playerid));
    format(string, sizeof(string), "|- Du hast einen "%s" gespawned (Model: %d) with Colours: %d,%d -|", VehicleNames[carData[0]-400], carData[0], carData[1],carData[2]);
    return SendClientMessage(playerid,HELLBLAU, string);
    }


    Warum so umständlich wozu gibt es die Pluginversion dort kannst du auch deine eigene specifer erstellen vehicle ist schon vordefiniert siehe sscanf include
    SSCANF:vehicle(string[]) ...