How to spawn a vehicle in a random position? -
Moron - 19.11.2012
HiHo, could anyone tell me how to make a vehicle spawn randomly in one of the given coordinates?
Re: How to spawn a vehicle in a random position? -
[HK]Ryder[AN] - 19.11.2012
you can do it like this
pawn Код:
//some random positions..u can keep adding more
new Float:RandomSpawn[][4] =
{
// Positions, (X, Y, Z and Facing Angle)
{-2796.9854, 1224.8180, 20.5429, 192.0335},
{-2454.2170, 503.8759, 30.0790, 267.2932},
{-2669.7322, -6.0874, 6.1328, 89.8853}
};
//now under ongamemodeinit
new rand = Random(sizeof(RandomSpawn));
CreateVehicle(510/*i m adding a hydra, change it*/, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2], RandomSpawn[rand][3], 0, 1, 60);
AW: How to spawn a vehicle in a random position? -
Blackazur - 19.11.2012
Spawn a Car in Game use then /save goto your GTA San Andreas User Files Folder, and copy the X, Y and Z coordinate, and paste it in the script with "AddStaticVehicle". Maybe i understand that false, so make that what
[HK]Ryder[AN] says.
Re: AW: How to spawn a vehicle in a random position? -
[HK]Ryder[AN] - 19.11.2012
Quote:
Originally Posted by Blackazur
Spawn a Car in Game use then /save goto your GTA San Andreas User Files Folder, and copy the X, Y and Z coordinate, and paste it in the script with "AddStaticVehicle".
|
he wants to make it at a
RANDOM location..learn to read
EDIT - Just saw your edit..
Re: How to spawn a vehicle in a random position? -
Moron - 19.11.2012
Quote:
Originally Posted by [HK]Ryder[AN]
you can do it like this
pawn Код:
//some random positions..u can keep adding more new Float:RandomSpawn[][4] = { // Positions, (X, Y, Z and Facing Angle) {-2796.9854, 1224.8180, 20.5429, 192.0335}, {-2454.2170, 503.8759, 30.0790, 267.2932}, {-2669.7322, -6.0874, 6.1328, 89.8853} }; //now under ongamemodeinit new rand = Random(sizeof(RandomSpawn)); CreateVehicle(510/*i m adding a hydra, change it*/, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2], RandomSpawn[rand][3], 0, 1, 60);
|
I place the new rand... on the top of my gamemode.
I create a vehicle by using your line in one of the GUI dialogs and I get these errors for new rand...
Код:
error 012: invalid function call, not a valid address
error 008: must be a constant expression; assumed zero
Re: How to spawn a vehicle in a random position? -
Moron - 20.11.2012
Bumpsy
Re: How to spawn a vehicle in a random position? -
dr.lozer - 20.11.2012
Who said you to make on top of the GamemodeInit ?? Do like this
pawn Код:
new Float:RandomSpawn[][4] =
{
// Positions, (X, Y, Z and Facing Angle)
{-2796.9854, 1224.8180, 20.5429, 192.0335},
{-2454.2170, 503.8759, 30.0790, 267.2932},
{-2669.7322, -6.0874, 6.1328, 89.8853}
};
public OnGameModeInit()
{
new rand = Random(sizeof(RandomSpawn));
CreateVehicle(510, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2], RandomSpawn[rand][3], 0, 1,1000);
return 1;
}
Re: How to spawn a vehicle in a random position? -
Moron - 20.11.2012
I get this when I place new rand = random(sizeof(RandomSpawn)); under OnDialogResponse (I place it there, because that's where my car shop is).
Код:
error 012: invalid function call, not a valid address
error 001: expected token: ";", but found "sizeof"
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
fatal error 107: too many error messages on one line
Re: How to spawn a vehicle in a random position? -
Luis- - 20.11.2012
Might be the 'random' it shouldn't have a capital.
Re: How to spawn a vehicle in a random position? -
Moron - 20.11.2012
Quote:
Originally Posted by -Luis
Might be the 'random' it shouldn't have a capital.
|
It works now, lol