[REP+]npc/bot not going in his vehicle...
#1

hey guys,

since short im busy with a new gamemode for my server, but now i have a problem with my npc, it doesnt gets in his vehicle, i dont know how but it just doesnt, i already checked it with printf but in console it doesnt says that the npc goes into the car... and the car aint driving when pressing the selected item in my menu:

anyways here is my codes:
pawn Код:
case 1: // hit the road
            {
                    if(IsPlayerNPC(playerid))
                    {
                        new npcname[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, npcname, sizeof(npcname)); //De naam aanvragen
                        if(!strcmp(npcname, "NPCone", true)) //Kijken of de naam klopt
                        {
                            PutPlayerInVehicle(playerid, garagetostopcar, 0);
                            printf("NPC in vehicle");
                        }
                    }
                    if(HasCar[playerid] == 1)
                    {
                        SetPlayerCameraPos(playerid,2518.2378,-1535.4877,24.0190);
                        SetPlayerCameraLookAtEx(playerid, 2520.8469,-1537.4227,24.0190);
                        MovePlayerCamera(playerid,2508.6433,-1547.5991,24.9592, 5.0,2513.9517,-1532.4204,24.0190);
                        SetPlayerVirtualWorld(playerid, 0);
                        SetPlayerInterior(playerid, 0);
                        HasCar[playerid] = 0;
                        //SetTimer("StartDriving", 10000, 0);
                    }
                    else if(HasCar[playerid] != 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: you should first get a car");
                    return 1;
            }
pawn Код:
stock pName(playerid)
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  return name;
}
stock IsNumeric(string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if ( strfind(VehicleNames[i], vname, true) != -1 )
            return i + 400;
    }
    return -1;
}
CMD:car(playerid,params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 20.0, 2521.1641,-1538.3766,23.9995))
    {
        new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index);
        if(isnull(tmp)) return SendClientMessage(playerid, red, "USAGE: /car [Modelid/Name] [colour1] [colour2]");
        new colour1, colour2, string[128];
        if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
        if(isnull(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
        new Float:X,Float:Y,Float:Z, Float:Angle,int1;  GetPlayerPos(playerid, X,Y,Z);  GetPlayerFacingAngle(playerid,Angle);   int1 = GetPlayerInterior(playerid);
        LVehicleID = CreateVehicle(car, 2521.1641,-1538.3766,23.9995,88.9031, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
        format(string, sizeof(string), "%s spawned a \"%s\" (Model:%d) colour (%d, %d), at %0.2f, %0.2f, %0.2f", pName(playerid), VehicleNames[car-400], car, colour1, colour2, X, Y, Z);
        format(string, sizeof(string), "You have spawned a \"%s\" (Model:%d) colour (%d, %d)", VehicleNames[car-400], car, colour1, colour2);
        HasCar[playerid] = 1;
        return SendClientMessage(playerid,lightblue, string);
    }
    else if(!IsPlayerInRangeOfPoint(playerid, 20.0,2521.1641,-1538.3766,23.9995)) return SendClientMessage(playerid, COLOR_RED, "ERROR: you arent at your garage!");
    else if(IsPlayerNPC(playerid))
    {
        HasCar[playerid] = 1;
        return 1;
    }
    return 1;
}
pawn Код:
new LVehicleID;
new car;
new HasCar[MAX_PLAYERS];
new VehicleNames[212][] = {
    "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","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","ZR3 50","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","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","Trailer",
    "Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor",
    "Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","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"
};
new Menu:garagemenu, Menu:tunemenu, Menu:carshopmenu, Menu:mycarsmenu, Menu:buycarmenu, Menu:startmenu;
new PlayerCars[PLAYERS_MAX][4];
new garagetostopcar;
pawn Код:
public OnGameModeInit()
{

    // the text that will be shown at the MODE in samp.exe
    SetGameModeText("Tokyo Drift by Niels44");
    // the skin the player gets
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(1, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(2, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    //ConnectNPC("StartNPC","garagetoroadscript");
    ConnectNPC("NPCone", "garagetostopscript");
    garagetostopcar = CreateVehicle(car, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
// there is more code here
pawn Код:
public OnPlayerSpawn(playerid)
{
    /*if(IsPlayerNPC(playerid)) //Kijken of de gespawnde speler een NPC is
    {
        else if(!strcmp(npcname, "MySecondNPC", true))
        {
            PutPlayerInVehicle(playerid, AnotherVehicleID, 0);
        }
        return 1;
    }*/

    SetPlayerCameraPos(playerid,2518.2378,-1535.4877,24.0190);
    SetPlayerCameraLookAtEx(playerid, 2520.8469,-1537.4227,24.0190);
    ShowMenuForPlayer(startmenu,playerid);
    TogglePlayerControllable(playerid, 0);
    SetPlayerPos(playerid, 2518.2378,-1535.4877,24.0190);
    HasCar[playerid] = 0;
    return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname)); //De naam aanvragen
        if(!strcmp(npcname, "NPCone", true)) //Kijken of de naam klopt
        {
            SetSpawnInfo(playerid,0,0,2520.8469,-1537.4227,24.0190,180.0,0,0,0,0,0,0);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
            return 1;
        }
        return 1;
    }
    else if(!IsPlayerNPC(playerid))
    {
        SetSpawnInfo(playerid,0,0,2664.1328,-1995.8257,13.5547,180.0,0,0,0,0,0,0);
        SpawnPlayer(playerid);
        return 1;
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new ip_addr_npc[64+1];
        new ip_addr_server[64+1];
        new playername[64];
        GetPlayerName(playerid,playername,64);
        GetServerVarAsString("bind",ip_addr_server,64);
        GetPlayerIp(playerid,ip_addr_npc,64);

        if(!strlen(ip_addr_server))
        {
            ip_addr_server = "127.0.0.1";
        }

        if(!strcmp(playername,"Test_Test",true))
        {
        SetSpawnInfo(playerid,0,240,539.2943,-1291.9962,17.2422,0.0,0,0,0,0,0,0);
        }

        if(strcmp(ip_addr_npc,ip_addr_server,true) != 0)
        {
            // this bot is remote connecting
            printf("NPC: Got a remote NPC connecting from %s and I'm kicking it.",ip_addr_npc);
            Kick(playerid);
            return 0;
        }
        printf("NPC: Connection from %s is allowed.",ip_addr_npc);
    }
    else if(!IsPlayerNPC(playerid)) return 1;
    return 1;
}
so what im trying to say is that my NPC isnt getting in his car... so at the first code, and then you see, isplayernpc(playerid)), and then you see it should supposed to go into the car... but it aint it aint getting in the car

anyone knows how to fix this?
greets niels
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)