SA-MP Forums Archive
Player in vehicle after spawn - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player in vehicle after spawn (/showthread.php?tid=256646)



Player in vehicle after spawn - Srdjan - 21.05.2011

Hello. I am totally new to scripting, but I'm improving my skills really fast.
I came upon the problem. So this is the drill. I want to make player get in a car after spawning it with /cars.
/cars give out the dialog box and you choose which car you want. Then after clicking "spawn", I want the player to get in a car immediately after spawning it.
This is how my code on dialog box looks like:

Quote:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new Float: x, Float: y, Float: z, Float: a;

GetPlayerPos (playerid, x, y, z);
GetPlayerFacingAngle (playerid, a);

if (dialogid == 1 && response == 1)
{
if (IsPlayerInAnyVehicle (playerid)) return SendClientMessage (playerid, 0xafafafAA, "Step out of the vehicle first.");

else
{
switch (listitem)
{
case 0:
{
CreateVehicle (598, x, y, z, a, 16, 1, 50000);
}
case 1:
{
CreateVehicle (497, x, y, z, a, 16, 1, 50000);
}
case 2:
{
CreateVehicle (415, x, y, z, a, -1, -1, 50000);
}
case 3:
{
CreateVehicle (541, x, y, z, a, -1, -1, 50000);
}
case 4:
{
CreateVehicle (560, x, y, z, a, -1, -1, 50000);
}
case 5:
{
CreateVehicle (523, x, y, z, a, 16, 1, 50000);
}
case 6:
{
CreateVehicle (599, x, y, z, a, 16, 1, 50000);
}
case 7:
{
CreateVehicle (579, x, y, z, a, -1, -1, 50000);
}
case 8:
{
CreateVehicle (562, x, y, z, a, -1, -1, 50000);
}
case 9:
{
CreateVehicle (402, x, y, z, a, -1, -1, 50000);
}
case 10:
{
CreateVehicle (492, x, y, z, a, -1, -1, 50000);
}
case 11:
{
CreateVehicle (422, x, y, z, a, -1, -1, 50000);
}
case 12:
{
CreateVehicle (554, x, y, z, a, -1, -1, 50000);
}
case 13:
{
CreateVehicle (426, x, y, z, a, -1, -1, 50000);
}
case 14:
{
CreateVehicle (521, x, y, z, a, -1, -1, 50000);
}
case 15:
{
CreateVehicle (480, x, y, z, a, -1, -1, 50000);
}
case 16:
{
CreateVehicle (412, x, y, z, a, -1, -1, 50000);
}
}
}
}
return 1;
}




Re: Player in vehicle after spawn - xalith - 21.05.2011

you need something like veh=createvehicle(......
then setplayerinvehicle(playerid,veh);


Re: Player in vehicle after spawn - Srdjan - 21.05.2011

Quote:
Originally Posted by xalith
Посмотреть сообщение
you need something like veh=createvehicle(......
then setplayerinvehicle(playerid,veh);
Awesome. This worked!
Thanks a lot!