SA-MP Forums Archive
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)
+--- Thread: Spawn (/showthread.php?tid=607072)



Spawn - Micko123 - 14.05.2016

So guys i want player on command /derby to spawn on random coords and i want him to be in vehicle on spawn
Here is what i did. It spawns player where i want but wont put him in vehicle
Код:
CMD:derby(playerid, params[])
{
	PlayerJoinedDerby[playerid] = 1;
	new randomcoords = random(sizeof(DBSpawn));
	SPP(playerid, DBSpawn[randomcoords][0], DBSpawn[randomcoords][1], DBSpawn[randomcoords][2]);
        PutPlayerInVehicle(playerid, 411, 0);
	LoadObjectsForPlayer(playerid);
	return 1;
}
What to do?


Re: Spawn - Sawalha - 14.05.2016

Код:
PutPlayerInVehicle(playerid, 411, 0);
you here put player in a vehicle which its id is 411, not it's model.
function's structure:
Код:
PuPlayerInVehicle(playerid, vehicleid, seatid)
i guess you here meant 411 as a vehicle model id, but it's the vehicle id where to put the player, defined by AddStaticVehicle or CreateVehicle, so you need to create the vehicle, and assign a variable for the function's return value, and use that variable that holds the vehicleid in PutPlayerInVehicle, like this
Код:
new veh;
veh = CreateVehicle(411, // the rest of params); 
PutPlayerInVehicle(playerid, veh, 0);



Re: Spawn - iggy1 - 14.05.2016

Correct. Also you don't need to use the 'veh' var if you only need to use it once. But really, you should be storing the vehicle id globally so it can be destroyed.

Код:
PutPlayerInVehicle(playerid, CreateVehicle(411, // the rest of params), 0);



Re: Spawn - Micko123 - 14.05.2016

Thank you guys a lot