Random Position
#1

hey I have this
PHP код:
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?
Reply
#2

PHP код:
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); 
Reply
#3

now
PHP код:
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
Reply
#4

Add the float tag to the array

PHP код:
new Float:tfl[][] = 
Reply
#5

Note:

add 1 more float for Angle.
it will be like
PHP код:
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]); 
Reply


Forum Jump:


Users browsing this thread: