NPC Attach trailer to vehicle?
#1

Hey, I have a NPC truck driver, and no matter what I do, the trailer won't attach? I've tried allsorts.. Searched for previous topics, and the answers haven't given me the outcome I was hoping for.

pawn Code:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new NPC[MAX_PLAYER_NAME];
        GetPlayerName(playerid,NPC,sizeof(NPC));
        if(!strcmp(NPC,"TruckDriver",true))
        {
            PutPlayerInVehicle(playerid,Tanker,0);
            AttachTrailerToVehicle(Trailer,GetPlayerVehicleID(playerid));
        }
        return 1;
    }
    //other code
    return 1;
}
pawn Code:
new Tanker;
    new Trailer;
    Tanker = AddStaticVehicle(514,-1138.3733,-2271.3184,36.0016,340.9931,25,1);
    Trailer = AddStaticVehicle(584,-1138.3733,-2271.3184,40.0016,340.9931,25,1);
pawn Code:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(IsPlayerNPC(playerid))
    {
        new NPC[MAX_PLAYER_NAME];
        GetPlayerName(playerid,NPC,sizeof(NPC));
        if(!strcmp(NPC,"TruckDriver",true))
        {
            if(newstate==PLAYER_STATE_DRIVER) AttachTrailerToVehicle(Trailer,Tanker);
        }
    }
    return 1;
}
I've tried pretty much everything.. Here's some of the things I have tried. There must be something I'm missing?
Reply
#2

where is he spawned?
both truck and trailer needs to be streamed in
make sure you spawn him near the truck before you attach.
Reply
#3

I have.. And yeah I have tried that too
Reply
#4

thing is on my server if i save the truck and trailer pos when they are attached
and make that their spawn pos, when i enter one they are already attached.
Not sure if this is something with the NPC or not.

try attaching before you place the npc inside.

good luck.
Reply
#5

Quote:
Originally Posted by Jonny5
View Post
thing is on my server if i save the truck and trailer pos when they are attached
and make that their spawn pos, when i enter one they are already attached.
Not sure if this is something with the NPC or not.


good luck.
Ahhh, I shall try that. Thanks

EDIT: Still isn't working.. :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)