OnVehicleDeath - Place car on random position -
Faith - 06.04.2010
Hello.
I have been trying to figure this out, but it all got worse and worse.
I need a solution to place a car at a random position when the car gets destroyed.
I have some positions in an area that the car shall spawn at - but randomly.
Something like
OnVehicleDeath - Spawn car at one of these coordinates.
Everything i've tried has failed on way or another.
I would appreciate if there is one here, that could help me out.
Thanks.
Re: OnVehicleDeath - Place car on random position -
huyguy - 06.04.2010
Try this:
Код:
#define MAX_RANDOM_POSITIONS 2
new Float:rPos[MAX_RANDOM_POSITIONS][3]={
{123.456,123.456,12.45},
{456.789,456.789,45.67}};
public OnVehicleDeath(vehicleid, killerid)
{
SetVehicleToRespawn(vehicleid);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
new r = random(MAX_RANDOM_POSITIONS-1);
SetVehiclePos(vehicleid, rPos[r][0], rPos[r][1], rPos[r][2]);
return 1;
}
Re: OnVehicleDeath - Place car on random position -
Faith - 06.04.2010
I appreciate your quick reply.
However, this makes it spawn at a specific position.
But i have several coords for it to spawn at (randomly).
Any ideas how such code could be?
Thanks.
Re: OnVehicleDeath - Place car on random position -
campkz - 06.04.2010
No, you got it wrong. He said the right thing.
he said this bit
Quote:
new Float:rpos[MAX_RANDOM_POSITIONS][3]={
{123.456,123.456,12.45},
{456.789,456.789,45.67}}
|
which are two random pos's.
So he was correct
Re: OnVehicleDeath - Place car on random position -
huyguy - 06.04.2010
Ye, i edited it.
Re: OnVehicleDeath - Place car on random position -
campkz - 06.04.2010
I believe you could do
Код:
{123.456,123.456,12.45},
{456.789,456.789,45.67},{another Pos},{AnotherPos}}
Re: OnVehicleDeath - Place car on random position -
huyguy - 06.04.2010
Quote:
|
Originally Posted by campkz
I believe you could do
Код:
{123.456,123.456,12.45},
{456.789,456.789,45.67},{another Pos},{AnotherPos}}
|
Yes, but don't forget to change the MAX_RANDOM_POSITIONS.
Re: OnVehicleDeath - Place car on random position -
Faith - 06.04.2010
Thanks guys!
Re: OnVehicleDeath - Place car on random position -
Faith - 06.04.2010
I tried this out, but apparantly the OnVehicleSpawn(vehicleid)
makes all the vehicles on server to spawn at these locations that i have when the server starts up.
Is it possible to change that?
Re: OnVehicleDeath - Place car on random position -
huyguy - 06.04.2010
Quote:
|
Originally Posted by Faith
I tried this out, but apparantly the OnVehicleSpawn(vehicleid)
makes all the vehicles on server to spawn at these locations that i have when the server starts up.
Is it possible to change that?
|
Isn't it supposed to do that ?
This code spawns the vehicleid's 1,2 and 5-55 to the random positions. All others aren't touched.
Код:
public OnVehicleSpawn(vehicleid)
{
switch(vehicleid)
{
case 1,2,5..55:
{
new r = random(MAX_RANDOM_POSITIONS-1);
SetVehiclePos(vehicleid, rPos[r][0], rPos[r][1], rPos[r][2]);
}
}
return 1;
}