28.12.2017, 07:27
Hello people.
I have created a race system, works fine without any bugs except for one thing. For example, when race starts, there are, lets say, 20 checkpoints loaded, dynamic race checkpoints (incognitos streamer). The problem is, you don't have to enter all checkpoints, you just go to the last checkpoint and you win the race without picking up others. Here is the code:
I don't know if I forgot to add something or maybe the way I scripted this won't work?
I have created a race system, works fine without any bugs except for one thing. For example, when race starts, there are, lets say, 20 checkpoints loaded, dynamic race checkpoints (incognitos streamer). The problem is, you don't have to enter all checkpoints, you just go to the last checkpoint and you win the race without picking up others. Here is the code:
pawn Код:
public StartRace()
{
KillTimer(StartRaceTmr);
Race = random(10);
RaceActive = true;
PutPlayerInRaceTmr = SetTimer("PutPlayerInRace", 20000, false);
EndRaceTmr = SetTimer("EndRace", 140000, false);
if(Race == 0 )
{
SendClientMessageToAll(-1, "Race 'Need4Speed' starts in 20 seconds, type /race to join.");
CreateRace0CP[0] = CreateDynamicRaceCP(0, -2484.602783, -2417.871582, 32.702911, -2417.383544, -2578.697509, 54.198608, 10.0, 14, -1, -1, 300.0);
CreateRace0CP[1] = CreateDynamicRaceCP(0, -2417.383544, -2578.697509, 54.198608, -2093.344970, -2684.317871, 53.607620, 10.0, 14, -1, -1, 300.0);
...
pawn Код:
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
if( Race == 0 )
{
if(checkpointid == CreateRace0CP[0] && PlayerJoined[playerid] == true)
{
TogglePlayerDynamicRaceCP(playerid, CreateRace0CP[0], 0);
TogglePlayerDynamicRaceCP(playerid, CreateRace0CP[1], 1);
}
if(checkpointid == CreateRace0CP[1] && PlayerJoined[playerid] == true)
{
TogglePlayerDynamicRaceCP(playerid, CreateRace0CP[1], 0);
TogglePlayerDynamicRaceCP(playerid, CreateRace0CP[2], 1);
}
...