NPC Bot

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
  • Hallo.


    Ich wollte geradeeben auf meinem Server paar NPCs einfügen. Habe dies auch gemacht, aber leider diesconnecten die sofort:



    Hier ist mal der ausschnitt aus der server.log


    Mein Script sieht wiefolgt aus:


    #include <a_samp>
    #include <a_npc>


    new Coach1;
    new Coach2;
    new Barracks;
    new LSPDcar;
    new Ambulance;
    new Ambulanceheli;
    new Firetruck;
    new Hunter;
    new PDbike;
    new Train;
    new Infernus;
    new Sultan;
    new AT400;


    public OnGameModeInit()
    {
    ConnectNPC("Mike","busbot");
    ConnectNPC("Tom","busbot2");
    ConnectNPC("Andrew","barracksbot");
    ConnectNPC("Johnson","copcarbot");
    ConnectNPC("Anderson","ertbot");
    ConnectNPC("Mathew","erthelicopterbot");
    ConnectNPC("Davidson","firetruckbot");
    ConnectNPC("Moralles","hunterbot");
    ConnectNPC("Yards","policebikebot");
    ConnectNPC("Kelroy","trainbot");
    ConnectNPC("Sarah","infbot");
    ConnectNPC("Michael","sultanbot1");
    ConnectNPC("Roy","at400bot");

    Coach1 = AddStaticVehicle(437, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    Coach2 = AddStaticVehicle(437, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    Barracks = AddStaticVehicle(433, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    LSPDcar = AddStaticVehicle(596, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    Ambulance = AddStaticVehicle(416, 2109.1763, 1503.0453, 32.2887, 82.2873, 3, 6);
    Ambulanceheli = AddStaticVehicle(563, 2109.1763, 1503.0453, 32.2887, 82.2873, 3, 6);
    Firetruck = AddStaticVehicle(407, 2109.1763, 1503.0453, 32.2887, 82.2873, 6, 3);
    Hunter = AddStaticVehicle(425, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 0);
    PDbike = AddStaticVehicle(523, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    Train = AddStaticVehicle(538, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    Infernus = AddStaticVehicle(411, 2109.1763, 1503.0453, 32.2887, 82.2873, 3, 3);
    Sultan = AddStaticVehicle(560, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 0);
    AT400 = AddStaticVehicle(577, 2109.1763, 1503.0453, 32.2887, 82.2873, 1, 3);


    }


    public OnPlayerSpawn(playerid)
    {
    if(!IsPlayerNPC(playerid)) return 0;


    new playername[64];
    GetPlayerName(playerid,playername,64);


    if(!strcmp(playername,"Mike",true)) {
    PutPlayerInVehicle(playerid, Coach1, 0);
    }
    else if(!strcmp(playername,"Tom",true)) {
    PutPlayerInVehicle(playerid, Coach2, 0);
    }
    else if(!strcmp(playername,"Andrew",true)) {
    PutPlayerInVehicle(playerid, Barracks, 0);
    }
    else if(!strcmp(playername,"Johnson",true)) {
    PutPlayerInVehicle(playerid, LSPDcar, 0);
    }
    else if(!strcmp(playername,"Anderson",true)) {
    PutPlayerInVehicle(playerid, Ambulance, 0);
    }
    else if(!strcmp(playername,"Mathew",true)) {
    PutPlayerInVehicle(playerid, Ambulanceheli, 0);
    }
    else if(!strcmp(playername,"Davidson",true)) {
    PutPlayerInVehicle(playerid, Firetruck, 0);
    }
    else if(!strcmp(playername,"Moralles",true)) {
    PutPlayerInVehicle(playerid, Hunter, 0);
    }
    else if(!strcmp(playername,"Yards",true)) {
    PutPlayerInVehicle(playerid, PDbike, 0);
    }
    else if(!strcmp(playername,"Kelroy",true)) {
    PutPlayerInVehicle(playerid, Train, 0);
    }
    else if(!strcmp(playername,"Sarah",true)) {
    PutPlayerInVehicle(playerid, Infernus, 0);
    }
    else if(!strcmp(playername,"Michael",true)) {
    PutPlayerInVehicle(playerid, Sultan, 0);
    }
    else if(!strcmp(playername,"Roy",true)) {
    PutPlayerInVehicle(playerid, AT400, 0);
    }
    return 1;
    }


    Weis einer woran das liegen kann mit dem sofortigen disconnect?


    Gruß Tim

  • Diese schaut so aus:


  • versuch mal anstatt else if nur if zu nehmen


    das bei OnPlayerConnect rein


    if(IsPlayerNPC(playerid))
    {
    SpawnPlayer(playerid);
    TogglePlayerControllable(playerid, 1);
    return 1;
    }


    und wenn dein system iswie nicht will hier noch mal nen Muster


    if(IsPlayerNPC(playerid))
    {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof name);
    SetPlayerSkin(playerid, 253); //lisa_simpson


    //Linie 2
    if(!strcmp(name,"hans_peter", true, 15))
    {
    SpielerInfo[playerid][pLkw] = 1;
    PutPlayerInVehicle(playerid,hans_peter,0);
    SetPlayerColor(playerid, cBlue);
    SetVehicleNumberPlate(hans_peter,"hans_peter");
    return 1;
    }

    if(!strcmp(name,"lisa_simpson", true, 15))
    {
    SpielerInfo[playerid][pLkw] = 1;
    PutPlayerInVehicle(playerid,lisa_simpson,0);
    SetPlayerColor(playerid, cBlue);
    SetVehicleNumberPlate(lisa_simpson,"lisa_simpson");
    return 1;
    }
    return 1;
    }

  • mach es so wie ich es dir da gepostet habe


    so klappt es auf jeden fall