Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Melee votes
#1

I've implemented a melee vote system using SourceOP's Lua system. It's quite simple really. First I coded a generic Vote class which uses my Menu class to display voting options. Then, from that, I made an "AbstainableVote" class where players can choose to abstain. After that, coding the melee vote wasn't very difficult.

Code:
function meleevoteover( vote )
  local yesvotes    = vote.picks[1]
  local novotes     = vote.picks[2]
  local abstentions = vote.picks[3]

  if(yesvotes >= novotes) then
    wintext = "Yes wins:  "
    game.ConsoleCommand("DF_tf2_meleeonly 1")
  else
    wintext = "No wins:  "
    game.ConsoleCommand("DF_tf2_meleeonly 0")
  end

  wintext = wintext .. "Yes: " .. yesvotes .. ", No: " .. novotes .. ", Abstain: " .. abstentions .. "\n"
  sourceop.SayTextAll(wintext)
end

function meleevote( pPlayer, command, arguments )
  if(!pPlayer || pPlayer:IsAdmin(8, "admin_meleevote")) then
    AbstainableVote("Enable melee only mode?",
                    {"Yes", "No", "Abstain"}, 3, 30,
                    "Abstain is the default choice.\nAbstentions go to the majority.",
                    meleevoteover)
  end
end

if(sourceop.FeatureStatus(FEAT_ADMINCOMMANDS)) then
  concommand.Add("admin_meleevote", meleevote)
end

The code will probably change as I finalize some things. 30 is the number of seconds the vote stays up. 3 just tells AbstainableVote which choice is the Abstain one (3rd one).

The vote can only be started by admins and isn't automatic or on a schedule (unless people want it like that?).

I just thought I'd share some recent development.

Oh, and here is what it looks like in game:
http://www.sourceop.com/screenshots/meleevote.jpg
Reply
#2

I think it should be able to be initiated by the winning team, or the point leader.

/sarcasm
Reply
#3

Seems like a pretty good setup.


Just a suggestion, but it'd be cool if it did a vote right before sudden death to make SD melee only.

I know another server I've played on automatically switches everyone to the same class (it's random which class it is) on sudden death and makes it melee only. It's pretty fun and makes SD go a lot faster, but it would be much better if it were setup on a vote system so that the players decide whether to do it or not.
Reply
#4

I don't want to annoy players with a vote every 15 minutes though.
Reply
#5

you could make it one per map.

/sarcasm
Reply
#6

Drunken_F00l Wrote:I don't want to annoy players with a vote every 15 minutes though.
Yea, didn't think about that. Votes can be quite distracting sometimes too.
Reply
#7

OmegaZero_Alpha Wrote:you could make it one per map.

Even once per map would get annoying.
Reply
#8

I wouldn't mind one vote per map. (especially when the deadlocks on 2fort last for hours.)

Than again, people could abuse the system in strategic situations.

I would keep it as an administrator-only feature unless you re-implement the credit system.

/sarcasm
Reply
#9

Personally I think the vote should just come up at the beginning of 2fort.
Reply
#10

Ya, that's because you loved it so much when I did it last night (or really early this morning I guess).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)