Race: spawning in line
#1

Hello, I need some help about my racing mod, about spawns especially.

So I've done something like this:

pawn Код:
else if(playerid > 0 && playerid < 10) {
        if(started == 1){
            Veh[2] = CreateVehicle(487, FirstSpawn[0][0],FirstSpawn[0][1]+10,FirstSpawn[0][2], FirstSpawn[0][3], 3, 3, 60);
            SetPlayerVirtualWorld(playerid, 0);
            GameTextForPlayer(playerid, "~r~Race already started", 5000, 4);
            PutPlayerInVehicle(playerid, Veh[2], 0);
            TogglePlayerControllable(playerid, 1);
        }
        else {
            Veh[2] = CreateVehicle(487, FirstSpawn[0][0],FirstSpawn[0][1]+10,FirstSpawn[0][2], FirstSpawn[0][3], 3, 3, 60);
            PutPlayerInVehicle(playerid, Veh[2], 0);
            TogglePlayerControllable(playerid, 0);
        }
    }
Of course this doesn't work as I would like it to do.
My idea was to make something like giving the coordinates for playerid 0 and then setting the spawn pos of the others with these coordinates + some distance to make each car spawning by the previous. Like in this pic (don't criticize please ^^):



So playerid 0 has 1, playerid 1 has 2 .... Then playerid 10 (for example) would be placed on line '4' and we have cars on 2;4 3;4 3;5 and 2;5. I know the way to do it player by player 1 spawns here, 2 spawns here ect... But I was expecting another way to only write the first pos and then set the others to spawn next to it farer every time.

Hope to be clear, thanks for reading.
Reply
#2

1) Do you mean global player IDs, or just when the player joined the race (first participant gets id 0, second 1, ...)

2) You need to figure out how many columns you want to have
Reply
#3

I was planning to use one pos for one ID so ID 0 always gets first, ID 1 second ...
And It would depend of the place I have for the spawns, more than 40pos.

Thank you.
Reply
#4

Okay, this is the basic idea:

pawn Код:
new Float:X, Float:Y; //Coordinates the car will spawn on
new columns = 5; //This is the number of columns. If you set it to 5, a new row will start every 5 cars
new i;
while(idx >= columns*(i+1)) i++;
idx -= columns*i;
X = floatadd(FirstSpawn[0][0], floatmul(10.0, idx)); //Column
Y = floatsub(FirstSpawn[0][1], floatmul(10.0, i)); //Row
This is intended for cars facing north, if you want it differently tell me ^^

Replace idx with playerid! As an alternative, you can set idx to be the number of racers who already joined
Reply
#5

Wow thank you, that's nice I'm going to look but can it takes Z position and angle, not always north but my Firstspawn[x][3] which is facing direction?
Reply
#6

Z position is the same on all cars (assuming the ground is flat), if you want this system to work with all possible Z angles, it gets a lot more complicated. But I guess it's doable with cos and sin. I'll see what I can do
Reply
#7

Thank you that's enough I got only one race which is not flat, I will change the area there's no problem, thank you very much for your help, I've added rep.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)