19.11.2012, 13:18
HiHo, could anyone tell me how to make a vehicle spawn randomly in one of the given coordinates?
//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);
you can do it like this
pawn Код:
|
error 012: invalid function call, not a valid address error 008: must be a constant expression; assumed zero
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;
}
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