Only 1 game mode in fretta, where do i put this code?

I have this code that will supposedly skip the game mode voting and just show maps when the users are voting
[lua]function GM:StartFrettaVote() if GAMEMODE.m_bVotingStarted or GAMEMODE:InGamemodeVote() then return end
– manually set what would be the result of a GM vote otherwise
GAMEMODE.WinningGamemode = “Gamemode name (i know what to put here)”

  GAMEMODE.m_bVotingStarted = true

  GAMEMODE:ClearPlayerWants()
   
  GAMEMODE:StartMapVote()

end[/lua]

how do i implement this?

Thanks

Did you put that in there? It’s not in pseudo, so I was curious.

yes, i do…

the game mode name.

the folder name of the gamemode

If you’re asking how to get the gamemode name, check the GAMEMODE table? GAMEMODE.Name might be what you’re looking for?

no… i am asking where do i put that code for fretta?

[editline]20th October 2011[/editline]

anyone??!?

instead of forcing a gamemode choice despite the real outcome of the vote why not remove the vote all together?
fretta_voting 0 will stop gamemode votes

that will also stop map voting too

i don’t believe so, let me test it but from my experience i think that only stops the gamemode voting, 1 sec let me launch my dev server and see if it works or not

well the code i pasted was from TTT voting

and they only vote for maps

can anyone help

Have you tried asking whoever gave it to you?

i found it off of a forum post on FP… didn’t want to bump it so i made a new one

here i was looking into it for a deathrun im working on… i started working on it when i remembered this, here you go… its the fretta_must_de.lua take it and redo it for your deathrun. you also need the vgui/continuevote.lua

heres the code of both


 -- This is a set of overrides and hook/concommand removals of things Fretta
-- installs that are for whatever reason not wanted in TTT.

-- Bring on the pain...
DeriveGamemode( "fretta" )

AddCSLuaFile("cl_fretta_must_die.lua")
AddCSLuaFile("vgui/continuevote.lua")

-- Kill Fretta's class Thinks and end of game checks (doing our own)
function GM:Think()
end

-- Do not freeze players and stuff
function GM:OnEndOfGame()
end
-- FIXME: will we be using Fretta's GM:EndOfGame? if not, above not needed

-- Any dmg limitations are handled in our EntityTakeDamage hook
function GM:PlayerShouldTakeDamage(victim, attacker)
   return true
end

-- Don't see this called anywhere, nor does base gm have it, but hey
function GM:PostPlayerDeath(ply)
end

-- Fretta has a timeleft command, but it's not very meaningful here, oh well
function GM:GetGameTimeLeft()
   return math.max(0, (GetConVar("deathrun_time_limit_minutes"):GetInt() * 60) - CurTime())
end


-- The thing with Fretta's round handling is that it's all very nice and all
-- but I already have something more appropriate in place. So I have to turn
-- it all off with some ugly hacks.

function GM:CheckPlayerDeathRoundEnd()
end

-- Not really necessary to remove these
--hook.Remove("PlayerDisconnected", "RoundCheck_PlayerDisconnect")
--hook.Remove("PostPlayerDeath", "RoundCheck_PostPlayerDeath")

-- None of the other timer and round stuff should ever be started up because
-- we override GM:Initialize


-- And some spectator stuff we already have
concommand.Remove("spec_mode")
concommand.Remove("spec_next")
concommand.Remove("spec_prev")

-- We don't need all the CallClassFunction stuff Fretta does.

function GM:Move(ply, mv)
end

function GM:KeyPress(ply, key)
end

function GM:KeyRelease(ply, key)
end


---- End of round continue/change voting

--- Copies some of the gamemode/mapvote structure because that works pretty
--- well.

local ttt_grace = CreateConVar("ttt_fretta_votegracerounds", "0", 0, "Number of rounds that must be played before players can vote to change map/gamemode.")

local function RoundsPlayed()
   return GetConVarNumber("ttt_round_limit") - GetGlobalInt("ttt_rounds_left", 0)
end

-- The continue vote is basically a VoteForChange vote with a different hat
function GM:StartContinueVote()
   if fretta_voting:GetBool() then
      if CurTime() < GetConVarNumber("fretta_votegraceperiod") then return end
      if RoundsPlayed() <= ttt_grace:GetInt() then return end

      BroadcastLua("GAMEMODE:ShowContinueChooser()")
      SetGlobalBool("InContinueVote", true)
   end
end

-- Start gamemode vote if necessary, else do nothing
function GM:FinishContinueVote()
   if not fretta_voting:GetBool() then return end

   SetGlobalBool("InContinueVote", false)

   BroadcastLua("GAMEMODE:HideContinueChooser()")

   if CurTime() < GetConVarNumber("fretta_votegraceperiod") then return end
   if RoundsPlayed() <= ttt_grace:GetInt() then return end

   local frac = GAMEMODE:GetFractionOfPlayersThatWantChange() -- jesus h.
   if frac > fretta_votesneeded:GetFloat() then
      GAMEMODE:StartFrettaVote()
   end
end

local function VoteForChangeSilent(ply, cmd, args)
   if not fretta_voting:GetBool() then return end
   if not IsValid(ply) then return end
   if not #args == 1 then return end
   if GAMEMODE:InGamemodeVote() then return end
   
   local want = tonumber(args[1])

   if want == 0 then
      ply:SetNWBool("WantsVote", false)
   elseif want == 1 then
      ply:SetNWBool("WantsVote", true)
   end 
end
concommand.Add("votecontinue", VoteForChangeSilent)

---- Direct map voting, skipping gamemode vote

local ttt_mapvoting = CreateConVar("ttt_fretta_mapvoting", "0")

-- Start either a gamemode or a map vote
function GM:StartFrettaVote()
   if GAMEMODE.m_bVotingStarted or GAMEMODE:InGamemodeVote() then return end

   if ttt_mapvoting:GetBool() then
      -- manually set what would be the result of a GM vote otherwise
      GAMEMODE.WinningGamemode = "terrortown"

      SetGlobalBool("InGamemodeVote", true)
      GAMEMODE.m_bVotingStarted = true

      GAMEMODE:ClearPlayerWants()
      
      GAMEMODE:StartMapVote()
   else
      -- switching gamemodes, so remove ttt-specific tags
      GAMEMODE:UpdateServerTags(true)

      GAMEMODE.BaseClass.StartGamemodeVote(GAMEMODE)
   end
end

-- Override GM.StartGamemodeVote with StartFrettaVote so that standard fretta
-- stuff like VoteForChange mechanics will transparently start the correct type
-- of vote.
GM.StartGamemodeVote = GM.StartFrettaVote


-- When someone votes for change, the chat message says "voted to change
-- gamemode". This is hardcoded, so we are forced to override and duplicate
-- GM.VoteForChange just to change it.

function GM:VoteForChange( ply )
   if GetConVarNumber( "fretta_voting" ) == 0 then return end
   if ply:GetNWBool( "WantsVote" ) then return end
   if GAMEMODE:InGamemodeVote() then return end   

   ply:SetNWBool( "WantsVote", true )
   
   local VotesNeeded = GAMEMODE:GetVotesNeededForChange()
   local NeedTxt = ""
   if VotesNeeded > 0 and CurTime() < GetConVarNumber("fretta_votegraceperiod") then
      NeedTxt = " (need "..VotesNeeded.." more)"
   end

   local votetype = ttt_mapvoting:GetBool() and "map" or "gamemode"

   PrintMessage(HUD_PRINTTALK, Format("(VOTE)	%s voted to change the %s", ply:Nick(), votetype) .. NeedTxt)
   
   MsgN( ply:Nick() .. " voted to change the " .. votetype )
   
   timer.Simple( 5, function() GAMEMODE:CountVotesForChange() end )

end



clientside fretta_must_die





DeriveGamemode( "fretta" )

include("vgui/continuevote.lua")

---- Continue vote at end of round
local cont_chooser = nil
local function GetContinueChooser()
   if IsValid(cont_chooser) then return cont_chooser end
   cont_chooser = vgui.Create("ContinueVote")
   return cont_chooser
end

function GM:ShowContinueChooser()
   GetContinueChooser():Show()
end

function GM:HideContinueChooser()
   GetContinueChooser():Hide()
end

function GM:ContinueVoted(want)
   if GetGlobalBool("InContinueVote", false) then
      RunConsoleCommand("votecontinue", want and 1 or 0)
   end
end

---- Fretta overrides/fixes

util.SafeRemoveHook("InitPostEntity", "CreateDeathNotify")

function GM:DrawPlayerRing(ply)
end
util.SafeRemoveHook("PrePlayerDraw", "DrawPlayerRing")

function GM:InputMouseApply(cmd, x, y, angle)
end

function GM:Move(ply, mv)
end

function GM:KeyPress(ply, key)
end

function GM:KeyRelease(ply, key)
end


local logo = surface.GetTextureID("VGUI/ttt/score_logo")
local lw, lh = 215 / 2, 220 / 2
local helptxt = {text="", font="Trebuchet22", xalign=TEXT_ALIGN_CENTER, color=COLOR_WHITE}
local bgcolor = Color(200, 0, 0, 40)
function GM:PaintSplashScreen(w, h)
   draw.RoundedBox(16, w/2 - 230, h/2 - 128, 460, 256, bgcolor)

   surface.SetTexture( logo )
   surface.SetDrawColor( 255, 255, 255, 255 )
   surface.DrawTexturedRect( w / 2 - lw, h / 2 - lh, 256, 256 )

   helptxt.text = LANG.GetTranslation("intro_help")

   helptxt.pos = {w / 2, h / 2 + 80}
   draw.TextShadow(helptxt, 2, 255)
end




and the vgui



-- It's like VoteScreen but different!
local PANEL = {}

PANEL.Votes = {
   {
      txt = "contvote_continue",
      keytxt = "[NUMPAD 1]",
      want = false
   },

   {
      txt = "contvote_change",
      keytxt = "[NUMPAD 2]",
      want = true
   }     
};

function PANEL:Init()
   self:SetSkin( GAMEMODE.HudSkin )
   self:ParentToHUD()
   
   self.ControlCanvas = vgui.Create( "Panel", self )
   self.ControlCanvas:SetPaintBackgroundEnabled(false)
   self.ControlCanvas:SetKeyboardInputEnabled( false )
   self.ControlCanvas:SetMouseInputEnabled( false )

   self.ctrlList = vgui.Create( "DPanelList", self.ControlCanvas )
   self.ctrlList:SetDrawBackground( false )
   self.ctrlList:SetSpacing( 2 )
   self.ctrlList:SetPadding( 2 )
   self.ctrlList:EnableHorizontal( true )

   for _, data in ipairs(self.Votes) do
      local lbl = vgui.Create("DButton", self.ctrlList)
      Derma_Hook( lbl, "Paint", "Paint",	"GamemodeButton" )
      Derma_Hook( lbl, "ApplySchemeSettings", "Scheme", "GamemodeButton" )
      Derma_Hook( lbl, "PerformLayout", "Layout", "GamemodeButton" )

      lbl:SetText(data.keytxt .. "  " .. LANG.GetTranslation(data.txt))

      lbl:SetTall( 24 )
      lbl:SetWide( 300 )
      lbl:SetZPos(10)

      lbl.keytxt = data.keytxt
      lbl.txt = data.txt
      lbl.want = data.want
      lbl.numvotes = 0

      self.ctrlList:AddItem(lbl)
   end

   self.Peeps = {}
   
   for i =1, MaxPlayers() do
      self.Peeps* = vgui.Create( "DImage", self.ctrlList:GetCanvas() )
      self.Peeps*:SetSize( 16, 16 )
      --self.Peeps*:SetZPos( 1000 )
      self.Peeps*:SetVisible( false )
      self.Peeps*:SetImage( "gui/silkicons/emoticon_smile" )
      self.Peeps*:SetImageColor(Color(255,255,255, 100))
   end

   self:SetVisible(false)
end

function PANEL:PerformLayout()
   self:SetPos( 0, 0 )
   self:SetSize( 310, 60 )

   self:CenterHorizontal()
   
   self.ControlCanvas:StretchToParent( 0, 0, 0, 0 )
   self.ControlCanvas:SetZPos( 0 )
   
   self.ctrlList:StretchToParent( 2, 4, 2, 4 )
end

function PANEL:ResetPeeps()
   for i=1, MaxPlayers() do
      self.Peeps*:SetPos( math.random( 0, 600 ), -16 )
      self.Peeps*:SetVisible( false )
      self.Peeps*.want = nil
   end
end

function PANEL:FindWantBar(want)
   for k, v in pairs( self.ctrlList:GetItems() ) do
      if v.want == want then return v end
   end
end

function PANEL:PeepThink( peep, ent )
   if not IsValid(ent) then 
      peep:SetVisible( false )
      return
   end

   if peep.want == nil then
      peep:SetVisible( true )
      peep:SetPos( math.random( 0, 600 ), -16 )
      peep.CurPos = nil

      if ent == LocalPlayer() then
         peep:SetImage( "gui/silkicons/star" )
      end
   end

   peep.want = ent:GetNWString( "WantsVote", false )

   local bar = self:FindWantBar( peep.want ) 
   if IsValid(bar) then
      bar.numvotes = bar.numvotes + 1

      local vNewPos = Vector( (bar.x + bar:GetWide()) - 15 * bar.numvotes - 4, bar.y + ( bar:GetTall() * 0.5 - 8 ), 0 )
      
      if ( !peep.CurPos || peep.CurPos != vNewPos ) then
         peep:MoveTo( vNewPos.x, vNewPos.y, 0.2 )
         peep.CurPos = vNewPos
      end

      local a = 150 * math.max(0, vNewPos.x) / bar:GetWide()
      peep:SetImageColor(Color(255,255,255, a))
   end
end

function PANEL:Think()
   for k, v in pairs( self.ctrlList:GetItems() ) do
      v.numvotes = 0
   end

   for i=1, MaxPlayers() do
      self:PeepThink( self.Peeps*, Entity(i) )
   end
end

local bgcolor = Color(0, 0, 10, 200)
function PANEL:Paint()
   draw.RoundedBox(4, 0, 0, self:GetWide(), self:GetTall(), bgcolor)
end

function PANEL:Show()
   self:ResetPeeps()

   for _, pnl in pairs(self.ctrlList:GetItems()) do
      pnl:SetText(pnl.keytxt .. "  " .. LANG.GetTranslation(pnl.txt))
   end

   self:SetVisible(true)
end

function PANEL:Hide()
   self:SetVisible(false)
end

derma.DefineControl("ContinueVote", "", PANEL, "DPanel")



thank you
i will tell you the results

[editline]23rd October 2011[/editline]

I actually want to hire you :smiley: Add me on steam

But i am quite confused on your instructions

So here are my “edits” i had to the gamemodes
http://cl.ly/0J0M3c3j2Y121T361A3s (I just copied fretta and changed the sv_gmchanger.lua from selectable=1 to =2)
http://cl.ly/0I2L1L430x3P312J3s2i (this is the deathrun i used, again, i changed the info.txt from selectable=1 to =2)

I sent you a friend request but need it accepted, I am [HZ] BGEN Bob Who?