How to put NPC to passenger in a vehicle - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to put NPC to passenger in a vehicle (
/showthread.php?tid=655723)
How to put NPC to passenger in a vehicle -
ATomas - 28.06.2018
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
Re: How to put NPC to passenger in a vehicle -
GTLS - 28.06.2018
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.
Re: How to put NPC to passenger in a vehicle -
ATomas - 29.06.2018
Quote:
Originally Posted by GTLS
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.
Re: How to put NPC to passenger in a vehicle -
Sasino97 - 29.06.2018
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(playerid, npcSpecialVehicle, 0);
// ...
}
Re: How to put NPC to passenger in a vehicle -
RoboN1X - 01.07.2018
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.