PDA

View Full Version : Random Position


silverms
21/04/2017, 04:54 PM
hey I have this SetPlayerRaceCheckpoint(playerid, 1, -1643.4783, -2686.9014, 48.2021, 0, 0, 0, 5.0);
but I want it to be set in a random location so how can I do it like I define 2 locations and set the race to one of them randomly how?

coool
21/04/2017, 05:02 PM
new cps[][] = //An array for holding the pos of our cps
{
{x, y, z}, //for first
{x, y, z} //for second
};

new rand = Random(sizeof(cps)); //random the size of cps, in this case 2. And put it in variable rand
SetPlayerRaceCheckpoint(playerid, 1, cps[rand][0], cps[rand][1], cps[rand][2], 0, 0, 0, 5.0);

silverms
21/04/2017, 05:32 PM
now new tfl[][] =
{
{-1643.4783, -2686.9014, 48.2021},
{-71.0421, -1159.6626, 1.3745},
{2482.3040, -2089.8215, 13.1609}
};
on every one of {blabla} I get 3 warnings tag mismatch

Toroi
21/04/2017, 06:19 PM
Add the float tag to the array


new Float:tfl[][] =

oktokt1
21/04/2017, 08:39 PM
Note:

add 1 more float for Angle.
it will be like

new Float:tfl[][][][] =
{
{-1643.4783, -2686.9014, 48.2021,Angle},
{-71.0421, -1159.6626, 1.3745,Angle},
{2482.3040, -2089.8215, 13.1609,Angle}
};

new rand = Random(sizeof(tfl)); //random the size of tfl, in this case 2. And put it in variable rand
SetPlayerRaceCheckpoint(playerid, 1, tfl[rand][0], tfl[rand][1], tfl[rand][2], 0, 0, 0, 5.0);
SetFacingAngle(playerid,tfl[rand][4]);