respawn help -
TwoTone - 23.02.2018
Hello
what trying to do is when the race is finnished everyone that be in the race will respawn back (out of race)
so I set a timer for the last checkpoint in the race for 30 seconds
when any player reaches that checkpoint it will start the count
and after 30 seconds it will need to respawn all players (only the players that be in the race)
how will it be possible ?
becouse I don't want it to be respawning players that are not in race
and worst I don't want it to respawn only the player that finnished the race
I want it to respawn everyone in race
here is what I did
Код:
SetTimerEx("StopRace", 30000, false, "i");// Start a 30 second timer to finnish the race
public StopRace(playerid)
{
if(InRace[playerid] == 1)
{
SpawnPlayer(playerid);
InRace[playerid] = 0;
}
appreciate any help
Re: respawn help -
TwoTone - 23.02.2018
if I add this loop will it work ?
Quote:
for(new i = 0; i < MAX_PLAYERS; i++)
|
Re: respawn help -
RogueDrifter - 23.02.2018
what seems to be the problem exactly? where do you place 'stoprace' and when is InRace[playerid] variable checked as 1?
Re: respawn help -
TwoTone - 23.02.2018
not a problem I'm just kinda confused by this
I place the stoprace in a SetTimerEx and add it to the last checkpoint in the race so when any player that is playing the race reaches that last checkpoint the timer will start to count for the 30 seconds and that will make other players rather they finnish the race or not exit it and respawn back
but I kinda think the way I did it will make only the player that finnish the race exit and respawn back
and other players will continue the race untill they finnish it
InRace[playerid] will be 1 at the time when players type the command to join the race
Re: respawn help -
AstroPoid - 23.02.2018
Try the normal timer , SetTimer(function, time, repeative);
This timer is running for all server , you can do a loop on all players to check if they are in race or not , and if yes , make them exit and finish & respawn them, with the values you gave them when they entered the race
Re: respawn help -
AstroPoid - 23.02.2018
Example:
Код:
Racestarted = 1;
if(Racestarted == 1)
{
SetTimer("racestop", 30000, false);
}
forward racestop();
public racestop()
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(InRace[i] == 1)
{
SpawnPlayer(i);
InRace[i] = 0;
RaceStarted = 0;
// you can add more things depends on the values you changed for players whom are in race
}
}
return 1;
}
Re: respawn help -
TwoTone - 23.02.2018
yeah man thanks that's what basically I did tho
Код:
public StopRace(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(InRace[i] == 1)
{
InRace[i] = 0;
SpawnPlayer(i);
}
return 1;
}
and it does work as I wanted it to
but will it also get the other players that still not reach the last checkpoint out of the race too ?
Re: respawn help -
AstroPoid - 23.02.2018
You can put new variable at OnPlayerEnterRaceCheckpoint , for example
Код:
new pickedcheckpoint[MAX_PLAYERS];
}
And OnPlayerEnterRaceCheckpoint, if(InRace[playerid] == 1) pickedcheckpoint[playerid] = 1;
//
for(new i=0; i < MAX_PLAYERS; i++)
{
if(InRace[i] == 1 && pickedcheckpoint[playerid] != 1) // changable
{
InRace[i] = 0;
SpawnPlayer(i);
}
Re: respawn help -
TwoTone - 23.02.2018
in what will it help me ?
Re: respawn help -
AstroPoid - 23.02.2018
You want to respawn players who pickedup checkpoint before the 30 second , am i correct ? , if yes that would help you