Frage zu Admincarsystem

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
  • Guten Abend Brotfische,


    Ich habe mal eine Frage, ich würde gerne ein Befehl einbauen zum Beispiel "/veh [ID | Name] " Also man könnte entweder die ID oder z.B. die ersten 3 Buchstaben des Fahrzeuges.
    Meines Wissens ist sowas möglich, man muss das bestimmt die Name definen.. aber wie mache ich das mit dem definenen und den Befehl?


    Ich hoffe ihr könnt mir helfen :)


    MfG German_ScripterHD


    Mit freundlichen Grüßen
    German_ScripterHD

  • Ich hab mich einfach mal hier bedient und den Fehler ausgebessert: http://forum.sa-mp.com/showthread.php?t=291633&page=3


    Den Rest habe ich gelassen, da ich denke, du passt das ohnehin an deine Bedürfnisse an, aber so hast du alles was du brauchst.


    Spoiler anzeigen
    #include <a_samp>

    Spoiler anzeigen
    #define l_red 0xFF0000AA
    #define l_green 0x33FF33AA

    Spoiler anzeigen
    new aVehicleNames[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"}
    };

    Spoiler anzeigen
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new cmd[20], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/veh", true) == 0)
    {
    new String[200];
    new tmp[20];
    new Float:x, Float:y, Float:z;

    Spoiler anzeigen
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, l_red, "You didn't give a vehicle name");
    new vehicle;

    Spoiler anzeigen
    if(!IsNumeric(tmp)) vehicle = GetVehicleModelIDFromName(tmp);
    else vehicle = strval(tmp);

    Spoiler anzeigen
    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, l_red, "That vehicle name was not found");

    Spoiler anzeigen
    new Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);

    Spoiler anzeigen
    if(IsPlayerInAnyVehicle(playerid) == 1)
    {
    GetXYInFrontOfPlayer(playerid, x, y, 8);
    }
    else
    {
    GetXYInFrontOfPlayer(playerid, x, y, 5);
    }

    Spoiler anzeigen
    new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
    LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));

    Spoiler anzeigen
    format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
    SendClientMessage(playerid, l_green, String);
    return 1;
    }
    return 0;
    }

    Spoiler anzeigen
    stock strtok(const string[], &index) //©Jeffry
    {
    new result[20], length = strlen(string), i = index;
    while ((i < length) && (string[i] == ' ')) i++;
    strmid(result,string,i,((index = strfind(string, " ", false, i)) == -1) ? (index = length) : (index) , 20);
    index++;
    return result;
    }

    Spoiler anzeigen
    stock IsNumeric(str[]) //©Jeffry
    {
    if(!strlen(str)) return 0;
    for (new i = 0, j = strlen(str); i < j; i++) if(str[i] > '9' || str[i] < '0') return 0;
    return 1;
    }

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

    Spoiler anzeigen
    stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
    {
    new Float:a;

    Spoiler anzeigen
    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);

    Spoiler anzeigen
    if(GetPlayerVehicleID(playerid))
    {
    GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    Spoiler anzeigen
    x2 += (distance * floatsin(-a, degrees));
    y2 += (distance * floatcos(-a, degrees));
    }

  • new VehicleNames[212][] = //Weiter oben
    {
    "400 - Landstalker", "401 - Bravura", "402 - Buffalo", "403 - Linerunner", "404 - Pereniel", "405 - Sentinel", "406 - Dumper", "407 - Firetruck", "408 - Trashmaster", "409 - Limosine",
    "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"
    };


    ocmd:veh(playerid, params[])
    {
    new vehicle[30], color1, color2;
    if(sscanf(params, "s[30]ii", vehicle, color1, color2))return SendClientMessage(playerid, Weiß, "Befehl: /veh [Model/Name] [Farbe1] [Farbe2]"),
    new idx = GetVehicleModelIDFromName(vehicle);
    if(idx == -1)
    {
    if(idx < 400 || idx > 611 || !strcmp(idx, "-", true))return SendClientMessage(playerid, Rot, "Error: Falsche/r Model ID/Name!");
    }
    new Float:vPos[4];
    GetPlayerPos(playerid, vPos[0], vPos[1], vPos[2]), GetPlayerFacingAngle(playerid, vPos[3]),
    CreateVehicle(idx, vPos[0], vPos[1], vPos[2], vPos[3], color1, color2, -1);
    return 1;
    }


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


    Man kann somit entweder die ID oder den Vehiclenamen schreiben.


    EDIT (Post von Jeffry): Habe das ganze jetzt mal verändern, denke so hast du das gemeint oder ?


    mfg :thumbup:

    Einmal editiert, zuletzt von Kasakow ()

  • @xMichael:
    Das ist bis dahin die interessanteste Methode, die ich gesehen habe, so einen Befehl zu machen. Die IDs in das Array zu schreiben. Ist zwar nicht ganz so performant wie es mit IsNumeric zu prüfen, aber es hat was.


    Allerdings müsstest du noch abfragen, ob man nur ein Minus eingegeben hat ("-"), macht man das nämlich, bekommt man einen Lankstalker.


    Und:
    for(new i = 0; i < 211; i++)
    zu:
    for(new i = 0; i < 212; i++)




    EDIT: (Post unten)
    @xMichael: Haha ok! Wäre trotzdem gut, wenn du die Änderungen machst, falls sich das mal jemand raus kopiert. ;)

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen