08.03.2015, 20:45
(
Последний раз редактировалось Nicker; 09.03.2015 в 14:28.
)
My race system works fine when only 1 player is in the race, but whenever a race starts with more than 1 racer, the checkpoints bug out and the players can't trigger them. Sometimes it only bugs out for one person (usually the racer who joined last), but sometimes it bugs out for all racers.
Here's my code: (sorry it's so long and the indentation has been messed up by the forum)
Also, I have some code on OnPlayerUpdate for triggering the checkpoint while the player is already in it when the race starts, as it wasn't getting triggered at first unless the player drove out and then into the checkpoint again:
If you're bugged, no matter how many times you enter the checkpoint, you cannot trigger it. Does anyone have any ideas of what could be causing this, or has anyone else experienced this? Is it because two players enter the checkpoint together in such a short timespan so the script can't process it properly?
I also have a Goldpot system that uses normal dynamic checkpoints, but I've tried to disable these in case they were conflicting but to no avail.
EDIT: It also seems my /leave command is interfering with other players; when a player /leaves a race, it removes checkpoints for all players in the race.
Here's my code: (sorry it's so long and the indentation has been messed up by the forum)
Код:
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid) { if(checkpointid == PlayerRaceCP[playerid]) //If player enters their race checkpoint { if(RaceBegun == 1 && InRace[playerid] == 1) //Check if the race has started and the player is in the race { DestroyDynamic3DTextLabel(RacePickupLabels[playerid]); //Destroy a label which informs of vehicle-spawning checkpoints if(RaceCheckpointsType[PlayerCheckpoint[playerid]] == 0) //If the checkpoint type is 0 (on-foot trigger) { DestroyVehicle(GetPlayerVehicleID(playerid)); //Destroy player's vehicle SendClientMessage(playerid, -1, C_RACE"Continue on-foot!"); //Tell them to continue on-foot } else if(RaceCheckpointsType[PlayerCheckpoint[playerid]] > 1) //If type is higher than 1 (a vehicle ID) (vehicle spawner) { format(strang, sizeof(strang), "%d", RaceCheckpointsType[PlayerCheckpoint[playerid]]); cmd_vrace(playerid, strang); //spawn the type's vehicle } if(RaceCheckpointsType[PlayerCheckpoint[playerid]+1] == 0) //if the next checkpoint's type is 0, add a textlabel saying so { RacePickupLabels[playerid] = CreateDynamic3DTextLabel("On-foot!", 0xFFFFFFFF, RaceCheckpoints[PlayerCheckpoint[playerid]+1][0], RaceCheckpoints[PlayerCheckpoint[playerid]+1][1], RaceCheckpoints[PlayerCheckpoint[playerid]+1][2], 500.0); } else if(RaceCheckpointsType[PlayerCheckpoint[playerid]+1] > 1) //and the same for vehicle spawning checkpoints { format(strang, sizeof(strang), "%s!", aVehicleNames[RaceCheckpointsType[PlayerCheckpoint[playerid]+1] - 400]); RacePickupLabels[playerid] = CreateDynamic3DTextLabel(strang, 0xFFFFFFFF, RaceCheckpoints[PlayerCheckpoint[playerid]+1][0], RaceCheckpoints[PlayerCheckpoint[playerid]+1][1], RaceCheckpoints[PlayerCheckpoint[playerid]+1][2], 500.0); } PlayerPlaySound(playerid, 1056, 0, 0, 0); //play the checkpoint sound PlayerCheckpoint[playerid] ++; //add one to the player's checkpoint progress DestroyDynamicRaceCP(PlayerRaceCP[playerid]); //Destroy the CP they just went through if(PlayerCheckpoint[playerid] == checkpointamount+1) //If the checkpoint is the finish { SetPlayerVirtualWorld(playerid, 0); //Send them back to the real world SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), 0); //along with their vehicle InRace[playerid] = 0; //Set the player out of the race Racers --; //Take racers down by one //REMOVED UNRELATED CODE } else { if(PlayerCheckpoint[playerid] == checkpointamount) //If player's checkpoint is second from last { PlayerRaceCP[playerid] = CreatePlayerRaceCP(playerid, 1); //create FINISH LINE checkpoint } else { PlayerRaceCP[playerid] = CreatePlayerRaceCP(playerid); //otherwise create a normal checkpoint } } } } return 1; }
pawn Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInDynamicRaceCP(playerid, PlayerRaceCP[playerid]) && InRace[playerid] == 1 && RaceBegun == 1)
{ //If player is in their race CP and they're in the race and the race has started
if(PlayerRaceCP[playerid] == 1) //If the player's Race checkpoint is the first one
{
PlayerPlaySound(playerid, 4202, 0, 0, 0); //play sound
PlayerCheckpoint[playerid] ++; //Add to progress
DestroyDynamicRaceCP(PlayerRaceCP[playerid]); //Destroy checkpoint they just went through
PlayerRaceCP[playerid] = CreatePlayerRaceCP(playerid); //Create next checkpoint
}
}
return 1;
}
If you're bugged, no matter how many times you enter the checkpoint, you cannot trigger it. Does anyone have any ideas of what could be causing this, or has anyone else experienced this? Is it because two players enter the checkpoint together in such a short timespan so the script can't process it properly?
I also have a Goldpot system that uses normal dynamic checkpoints, but I've tried to disable these in case they were conflicting but to no avail.
EDIT: It also seems my /leave command is interfering with other players; when a player /leaves a race, it removes checkpoints for all players in the race.