SA-MP Forums Archive
random vehicle 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: random vehicle spawn (/showthread.php?tid=615786)



random vehicle spawn - MerryDeer - 27.08.2016

Hi,

I make random vehicle spawns but all vehicles size is different height and some of them is in air.. How to right put any vehicle on ground?


Re: random vehicle spawn - IFilip - 27.08.2016

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
Hi,

I make random vehicle spawns but all vehicles size is different height and some of them is in air.. How to right put any vehicle on ground?
Please show code, and i'll try to help you..


Re: random vehicle spawn - MerryDeer - 27.08.2016

What code? i take a read here:

https://sampwiki.blast.hk/wiki/SetVehiclePos

Код:
An empty vehicle will not fall after being teleported into the air.
So i need how to calculate right z to put on ground vehicle?


Re: random vehicle spawn - IFilip - 27.08.2016

You can do a simple command to teleport vehicle to player.. like this:
Код:
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
SetVehiclePos(vehicleid, x, y, z);



Re: random vehicle spawn - MerryDeer - 27.08.2016

No you don't understand.. I write /save with one vehicle to get coordinates where i want to teleport. Then i teleport random vehicles to that coordinates, but some of them is in air, and some of them in ground.. That because if there is no driver this function where teleport there vehicle and stands.. I need something that could correct z coordinate on ground using X,Y


Re: random vehicle spawn - DeeadPool - 27.08.2016

Here you go :-
PHP код:
new Float:VehSpawn[][] =
{
    {
x,y,z}, //add your coordinates
    
{x,y,z},//add your coordinates
    
{x,y,z}//add your coordinates
}; 
PHP код:
//Under your command.
new rand random(sizeof(VehSpawn));
SetVehiclePos(vehicleidVehSpawn[rand][0], VehSpawn[rand][1], VehSpawn[rand][2]); 



Re: random vehicle spawn - MerryDeer - 27.08.2016

I'am already doing that, but some vehicles are in air, i repeating i need function that give my right Z, for any vehicle for x,y


Re: random vehicle spawn - Stinged - 27.08.2016

You want vehicles to teleport to those locations or spawn at them?
Because CreateVehicle works, if you want a vehicle spawn


Re: random vehicle spawn - MerryDeer - 27.08.2016

I teleport them using setvehiclepos in game, but some of them is in air.. I need smth that i can correct that vehicle reach ground