How to put NPC to passenger in a vehicle
#1

Hello,
i try put NPC to passenger in a vehicle.

Code:
ConnectNPC("Text","nonscript");
Code:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) PutPlayerInVehicle(playerid,958,1);
return 1;
}
And NPC is not in a vehicle

http://www.img.tpx.cz/uploads/sa-mp-...aaaaaaaaaa.png

Thanks for any help
Reply
#2

https://sampwiki.blast.hk/wiki/PutPlayerInVehicle - Second Parameter is Vehicle ID means ID which was assigned by server to that car. You can use /dl to see the car id. Also, what you can do is, create the vehicle onGameModeInit and store its return value into a variable and use that variable instead of vehicleid in the function.
Reply
#3

Quote:
Originally Posted by GTLS
View Post
https://sampwiki.blast.hk/wiki/PutPlayerInVehicle - Second Parameter is Vehicle ID means ID which was assigned by server to that car. You can use /dl to see the car id. Also, what you can do is, create the vehicle onGameModeInit and store its return value into a variable and use that variable instead of vehicleid in the function.
Yes i know. 958 is ID of the vehicle as you can see in screenshot.
Reply
#4

Don't hardcode the id of the vehicle, unless you want to deal with bugs later. You can retrieve it during its creation.

PHP Code:
// Global
new npcSpecialVehicle;
// Creation
public OnGameModeInit()
{
    
// ...
    
npcSpecialVehicle CreateVehicle(...);
    
// ...
}
// Assigning it to the NPC
public OnPlayerConnect(playerid)
{
    if(
IsPlayerNPC(playerid))
        
PutPlayerInVehicle(playeridnpcSpecialVehicle0);
       
    
// ...

Reply
#5

Normally it's not possible, i already tried something like this months ago.

NPC vehicle recording can only occupy driver seat and NPC onfoot recording can't be in a vehicle seat.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)