Person8880 / Shine

An administration mod for Natural Selection 2.
53 stars 23 forks source link

Is tournament mode enabled? #177

Closed lancehilliard closed 11 years ago

lancehilliard commented 11 years ago

How can I use Shine's API (or NS2's stock API, if that applies) to determine if tournament mode is enabled on the server?

GhoulofGSG9 commented 11 years ago

As far as i know shine and vanilla have no "tournament mode". Only NS2Stats has a tournament mode atm. To get if NS2Stats TM is enabled use RBPS.RBPSconfig.tournamentMode

GhoulofGSG9 commented 11 years ago

BTW im writting a "tournament mode" plugin for shine atm,so why exactly do you need to check this?

lancehilliard commented 11 years ago

We play scrims/pickups on the public TGNS server, and we use tournament mode to play them. We call them "captains games", wherein one person on each team picks the rest of the team. We turn tournament mode on and off depending on whether or not we're playing "captains games". I guess DAK is what's made tournament mode possible for us so far (we don't run NS2Stats). I thought that was stock NS the whole time. I'm surprised.

More pointedly to your question: I guess the only feature of tournament mode that we really need is the ability to not start the game until both teams type ready. More precisely: until the captain on each team types ready (my mod could manage who's captain and make sure only /they/ had rights to the command.

lancehilliard commented 11 years ago

Come to think of it, setting tournament mode aside...

Is there a way in Shine that I can prevent the start of the game until I manually (programmatically, triggered by logic) start it? I don't mind writing code to make that happen. I'm just not sure what I'd manipulate to pull that off.

lancehilliard commented 11 years ago

One idea: no one can enter the chair in "captains games" pre-game until the captain(s) allow it. Therefore, the game can't start until the captains "ready up".

Person8880 commented 11 years ago

Look at my pregame extension (though it's quite messy), it essentially blocks the CheckGameStart event and the UpdatePregame event until its conditions for starting are met.

Basically,

function Plugin:CheckGameStart( Gamerules )
    --Do all your game start checking here...

    return false
end

function Plugin:UpdatePregame( Gamerules )
    --If the game state is kGameState.PreGame, you should return false here too.
end

--Call this to start the game, passing in Gamerules.
function Plugin:StartGame( Gamerules )
    Gamerules:ResetGame()
    Gamerules:SetGameState( kGameState.Countdown )
    Gamerules.countdownTime = kCountDownLength
    Gamerules.lastCountdownPlayed = nil

    for _, Player in ientitylist( Shared.GetEntitiesWithClassname( "Player" ) ) do
        if Player.ResetScores then
            Player:ResetScores()
        end
    end
end

It's a bit silly that the NS2 Gamerules class doesn't provide a way to start the game by itself.

lancehilliard commented 11 years ago

Delicious. Thank you. On Aug 18, 2013 8:14 AM, "Person8880" notifications@github.com wrote:

Look at my pregame extension, it essentially blocks the CheckGameStartevent and the UpdatePregame event until its conditions for starting are met.

Basically,

function Plugin:CheckGameStart( Gamerules ) --Do all your game start checking here...

return falseend

function Plugin:UpdatePregame( Gamerules ) --If the game state is kGameState.PreGame, you should return false here too.end --Call this to start the game, passing in Gamerules.function Plugin:StartGame( Gamerules ) Gamerules:ResetGame() Gamerules:SetGameState( kGameState.Countdown ) Gamerules.countdownTime = kCountDownLength Gamerules.lastCountdownPlayed = nil

for _, Player in ientitylist( Shared.GetEntitiesWithClassname( "Player" ) ) do
    if Player.ResetScores then
        Player:ResetScores()
    end
endend

— Reply to this email directly or view it on GitHubhttps://github.com/Person8880/Shine/issues/177#issuecomment-22830261 .

GhoulofGSG9 commented 11 years ago

For denying ppl access to commchair Plugin:CommLoginPlayer(Building, Player) should do that job.

GhoulofGSG9 commented 11 years ago

BTW here is my current state of work on the tournament mode: https://github.com/BrightPaul/Shine/blob/tornamentmode/lua/shine/extensions/tournamentmode.lua