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


Messages In This Thread
Melee votes - by Drunken F00l - Jan 18, 2008, 12:31 AM
Melee votes - by OmegaZero_Alpha - Jan 18, 2008, 01:48 AM
Melee votes - by Biggs - Jan 18, 2008, 02:40 PM
Melee votes - by Drunken F00l - Jan 18, 2008, 05:05 PM
Melee votes - by OmegaZero_Alpha - Jan 19, 2008, 12:31 AM
Melee votes - by Biggs - Jan 19, 2008, 12:45 AM
Melee votes - by Drunken F00l - Jan 19, 2008, 12:52 AM
Melee votes - by OmegaZero_Alpha - Jan 19, 2008, 01:40 AM
Melee votes - by Dynamo - Jan 26, 2008, 03:45 AM
Melee votes - by Drunken F00l - Jan 26, 2008, 05:08 PM
Melee votes - by Kaylee - Jan 27, 2008, 05:06 AM
Melee votes - by Drunken F00l - Jan 27, 2008, 06:03 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)