1
votes

I am getting this error when i run my code: error CS1525: Unexpected symbol `void', expecting `,', `;', or `='

Here is my code: (Error is in the code!)

private void ManageScores(BasePlayer player)
{
    var bPoints = points.BlueTeamPoints;
    var rPoints = points.RedTeamPoints;

    bool BlueWinning()
    {
        if (bPoints == 100 && bPoints > rPoints)
        {
            return true;
        }
        return false;
    }
    bool RedWinning()
    {
        if (rPoints == 100 && rPoints > bPoints)
        {
            return true;
        }
        return false;
    }

    if (BlueWinning() == true)
    {
        EndKoth(player);
        return;
    }
    else if (RedWinning() == true)
    {
        EndKoth(player);
        return;
    }
}

private void EndKoth(BasePlayer player)
{
    Server.Broadcast("Ending the KOTH game!"); // KOTH.cs(260,15): error CS1525: Unexpected symbol `void', expecting `,', `;', or `='
    if (TeamExists(bteamID))
    {
        var bteam = RelationshipManager.ServerInstance.FindTeam(bteamID);
        bteam.Disband();
    }
    if (TeamExists(rteamID))
    {
        var rteam = RelationshipManager.ServerInstance.FindTeam(rteamID);
        rteam.Disband();
    }
    else return;
    Puts("Game Ending!");
    foreach (var p in BasePlayer.activePlayerList)
    {
        p.Teleport(Spawn);
        Server.Broadcast("KOTH Ended!");
        p.Team.RemovePlayer(p.userID);
        foreach (var i in p.inventory.AllItems())
        {
            i.Remove();
        }
        timer.Once(100f, () =>
        {
            startKoth(player);
            showLeaderboard(player);
        });
        gameRunning = false;
    }
}
There are 2 "void"s in your code. Which one does the error occur on.phuzi
@YongShun: You can nest methods in some versions of C#... it's not clear to me which version of C# the poster is using though.Jon Skeet
tell us please on what line the error occurs ( the code should also be underlined red)speyck