I've been trying to get my server perfect for the last two days. I've contacted Support numerous times. They were very helpful. I had a question that they could not answer, so hopefully you can answer this. I added Fretta Deathrun to the server and after every game (15 Rounds) it ask's you to choose the next Gamemode... (I want to remove this)
This might be the problem? Please answer me.
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 = "whateveryourdeathrungamemodeis"
GAMEMODE.m_bVotingStarted = true
GAMEMODE:ClearPlayerWants()
GAMEMODE:StartMapVote()
end
Gamemode Switching? {PLEASE HELP}
-
- New to forums
- Posts: 9
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Tue May 01, 2012 6:03 am
Re: Gamemode Switching? {PLEASE HELP}
I downloaded the mod and I did not see any config files to set certain variables for it. That code you found does look like it controls the voting. If you wish you can comment it out and see if it stops the vote from occurring.
@Kraze^NFo> Juski has a very valid point
@Juski> Got my new signature, thanks!
@Kraze^NFo> Out of context!
@Juski> Doesn't matter!
@Juski> You said I had a valid point! You can't take it back now! It's out there!
@Juski> Got my new signature, thanks!
@Kraze^NFo> Out of context!
@Juski> Doesn't matter!
@Juski> You said I had a valid point! You can't take it back now! It's out there!
Re: Gamemode Switching? {PLEASE HELP}
Well, it seems as if the Fretta Gamemode is doing this, not the Deathrun...
What would i put in my fretta_must_die.lua to stop the Gamemode Voting?
What would i put in my fretta_must_die.lua to stop the Gamemode Voting?
Re: Gamemode Switching? {PLEASE HELP}
I only need to shut down the Gamemode Voting, not the Map voting...
I've tried fretta_voting 0 (rcon, but it just freezes the game, so no luck)
Please explain to me thoroughly on how to do this...
Keep in mind, the Fretta Gamemode is doing this, not the deathrun.
I've tried fretta_voting 0 (rcon, but it just freezes the game, so no luck)
Please explain to me thoroughly on how to do this...
Keep in mind, the Fretta Gamemode is doing this, not the deathrun.
-
- A regular
- Posts: 48
- Joined: Mon Apr 02, 2012 1:10 pm
- Location: Canada, British Columbia
- Contact:
Re: Gamemode Switching? {PLEASE HELP}
May I suggest making a thread in http://facepunch.com/forums/337
They know a lot more about coding for garrysmod etc.
They know a lot more about coding for garrysmod etc.
Re: Gamemode Switching? {PLEASE HELP}
Kropp,
Thank you, but they're not very helpful... Maybe John would know?
Thank you, but they're not very helpful... Maybe John would know?
Re: Gamemode Switching? {PLEASE HELP}
If you commented out everything in that function (leaving just the declaration and "end" bits), I would expect for it to longer do any voting. But, I am not very familiar with this particular topic.
Re: Gamemode Switching? {PLEASE HELP}
Ok, it's in the Fretta Gamemode folder. The function is in the cl_gmchanger.lua
This came with your server. What would i do to make the cl_gmchanger not activate and be skipped over to the maps voting.
Here's the script for the gamemode voter.
This came with your server. What would i do to make the cl_gmchanger not activate and be skipped over to the maps voting.
Here's the script for the gamemode voter.
Code: Select all
require( "datastream" ) -- Have you tried Datastream (by DecoDaMan and Janorkie)?
include( "vgui/vgui_vote.lua" )
g_PlayableGamemodes = {}
g_bGotGamemodesTable = false
function RcvPlayableGamemodes( handler, id, rawdata, procdata )
g_PlayableGamemodes = procdata
g_bGotGamemodesTable = true
end
datastream.Hook( "PlayableGamemodes", RcvPlayableGamemodes );
local GMChooser = nil
local function GetVoteScreen()
if ( IsValid( GMChooser ) ) then return GMChooser end
GMChooser = vgui.Create( "VoteScreen" )
return GMChooser
end
function GM:ShowGamemodeChooser()
local votescreen = GetVoteScreen()
votescreen:ChooseGamemode()
end
function GM:GamemodeWon( mode )
local votescreen = GetVoteScreen()
votescreen:FlashItem( mode )
end
function GM:ChangingGamemode( mode, map )
local votescreen = GetVoteScreen()
votescreen:FlashItem( map )
end
function GM:ShowMapChooserForGamemode( gmname )
local votescreen = GetVoteScreen()
votescreen:ChooseMap( gmname )
end
local ClassChooser = nil
cl_classsuicide = CreateConVar( "cl_classsuicide", "0", { FCVAR_ARCHIVE } )
function GM:ShowClassChooser( TEAMID )
if ( !GAMEMODE.SelectClass ) then return end
if ( ClassChooser ) then ClassChooser:Remove() end
ClassChooser = vgui.CreateFromTable( vgui_Splash )
ClassChooser:SetHeaderText( "Choose Class" )
ClassChooser:SetHoverText( "What class do you want to be?" );
Classes = team.GetClass( TEAMID )
for k, v in SortedPairs( Classes ) do
local displayname = v
local Class = player_class.Get( v )
if ( Class && Class.DisplayName ) then
displayname = Class.DisplayName
end
local description = "Click to spawn as " .. displayname
if( Class and Class.Description ) then
description = Class.Description
end
local func = function() if( cl_classsuicide:GetBool() ) then RunConsoleCommand( "kill" ) end RunConsoleCommand( "changeclass", k ) end
local btn = ClassChooser:AddSelectButton( displayname, func, description )
btn.m_colBackground = team.GetColor( TEAMID )
end
ClassChooser:AddCancelButton()
ClassChooser:MakePopup()
ClassChooser:NoFadeIn()
end
Re: Gamemode Switching? {PLEASE HELP}
I didn't realize until now that there are 2 lua files with GM voting scripts...
The above was the cl_gmchanger
This is the sv_gmchanger
The above was the cl_gmchanger
This is the sv_gmchanger
Code: Select all
/*
sv_gmchanger.lua - Gamemode Changer (server side)
-----------------------------------------------------
Most of the internal stuff for the votes is here and contains stuff you really don't
want to override.
*/
require( "datastream" )
local g_PlayableGamemodes = {}
fretta_votesneeded = CreateConVar( "fretta_votesneeded", "0.7", { FCVAR_ARCHIVE } )
fretta_votetime = CreateConVar( "fretta_votetime", "20", { FCVAR_ARCHIVE } )
fretta_votegraceperiod = CreateConVar( "fretta_votegraceperiod", "30", { FCVAR_ARCHIVE } )
local function SendAvailableGamemodes( ply )
datastream.StreamToClients( ply, "PlayableGamemodes", g_PlayableGamemodes );
end
function GetRandomGamemodeName()
local num = math.random( 1, table.Count( g_PlayableGamemodes ) )
return table.Random( g_PlayableGamemodes ).name
end
function GetRandomGamemodeMap( gm )
return table.Random( g_PlayableGamemodes[ gm ].maps )
end
function GetNumberOfGamemodeMaps( gm )
return table.Count( g_PlayableGamemodes[ gm ].maps )
end
hook.Add( "PlayerInitialSpawn", "SendAvailableGamemodes", SendAvailableGamemodes )
local AllMaps = file.Find( "maps/*.bsp", true )
for key, map in pairs( AllMaps ) do
AllMaps[ key ] = string.gsub( map, ".bsp", "" )
end
local GameModes = GetGamemodes()
for _, gm in pairs( GetGamemodes() ) do
local info = file.Read( "gamemodes/"..gm.Name.."/info.txt", true )
if ( info ) then
local info = KeyValuesToTable( info )
if ( info.selectable == 1 ) then
g_PlayableGamemodes[ gm.Name ] = {}
g_PlayableGamemodes[ gm.Name ].name = gm.Name
g_PlayableGamemodes[ gm.Name ].label = info.name
g_PlayableGamemodes[ gm.Name ].description = info.description
g_PlayableGamemodes[ gm.Name ].author = info.author_name
g_PlayableGamemodes[ gm.Name ].authorurl = info.author_url
g_PlayableGamemodes[ gm.Name ].maps = {}
if ( info.fretta_maps ) then
for _, mapname in pairs( AllMaps ) do
for _, p in pairs( info.fretta_maps ) do
if ( string.find( mapname, p ) ) then
table.insert( g_PlayableGamemodes[ gm.Name ].maps, mapname )
end
end
end
else
g_PlayableGamemodes[ gm.Name ].maps = AllMaps
end
if ( info.fretta_maps_disallow ) then
for key, mapname in pairs( g_PlayableGamemodes[ gm.Name ].maps ) do
for _, p in pairs( info.fretta_maps_disallow ) do
if ( string.find( mapname, p ) ) then
g_PlayableGamemodes[ gm.Name ].maps[ key ] = nil
end
end
end
end
end
end
end
GameModes = nil
function GM:IsValidGamemode( gamemode, map )
if ( g_PlayableGamemodes[ gamemode ] == nil ) then return false end
if ( map == nil ) then return true end
for _, mapname in pairs( g_PlayableGamemodes[ gamemode ].maps ) do
if ( mapname == map ) then return true end
end
return false
end
local gVotes = {}
function GM:VotePlayGamemode( ply, gamemode )
if ( !gamemode ) then return end
if ( GAMEMODE.WinningGamemode ) then return end
if ( !GAMEMODE:InGamemodeVote() ) then return end
if ( !GAMEMODE:IsValidGamemode( gamemode ) ) then return end
ply:SetNWString( "Wants", gamemode )
end
concommand.Add( "votegamemode", function( pl, cmd, args ) GAMEMODE:VotePlayGamemode( pl, args[1] ) end )
function GM:VotePlayMap( ply, map )
if ( !map ) then return end
if ( !GAMEMODE.WinningGamemode ) then return end
if ( !GAMEMODE:InGamemodeVote() ) then return end
if ( !GAMEMODE:IsValidGamemode( GAMEMODE.WinningGamemode, map ) ) then return end
ply:SetNWString( "Wants", map )
end
concommand.Add( "votemap", function( pl, cmd, args ) GAMEMODE:VotePlayMap( pl, args[1] ) end )
function GM:GetFractionOfPlayersThatWantChange()
local Humans = player.GetHumans()
local NumHumans = #Humans
local WantsChange = 0
for k, player in pairs( Humans ) do
if ( player:GetNWBool( "WantsVote" ) ) then
WantsChange = WantsChange + 1
end
// Don't count players that aren't connected yet
if ( !player:IsConnected() ) then
NumHumans = NumHumans - 1
end
end
local fraction = WantsChange / NumHumans
return fraction, NumHumans, WantsChange
end
function GM:GetVotesNeededForChange()
local Fraction, NumHumans, WantsChange = GAMEMODE:GetFractionOfPlayersThatWantChange()
local FractionNeeded = fretta_votesneeded:GetFloat()
local VotesNeeded = math.ceil( FractionNeeded * NumHumans )
return VotesNeeded - WantsChange
end
function GM:CountVotesForChange()
if ( CurTime() >= GetConVarNumber( "fretta_votegraceperiod" ) ) then // can't vote too early on
if ( GAMEMODE:InGamemodeVote() ) then return end
fraction = GAMEMODE:GetFractionOfPlayersThatWantChange()
if ( fraction > fretta_votesneeded:GetFloat() ) then
GAMEMODE:StartGamemodeVote()
return false
end
end
return true
end
function GM:VoteForChange( ply )
if ( GetConVarNumber( "fretta_voting" ) == 0 ) then return end
if ( ply:GetNWBool( "WantsVote" ) ) then return end
ply:SetNWBool( "WantsVote", true )
local VotesNeeded = GAMEMODE:GetVotesNeededForChange()
local NeedTxt = ""
if ( VotesNeeded > 0 ) then NeedTxt = ", Color( 80, 255, 50 ), [[ (need "..VotesNeeded.." more) ]] " end
if ( CurTime() < GetConVarNumber( "fretta_votegraceperiod" ) ) then // can't vote too early on
local timediff = math.Round( GetConVarNumber( "fretta_votegraceperiod" ) - CurTime() );
BroadcastLua( "chat.AddText( Entity("..ply:EntIndex().."), Color( 255, 255, 255 ), [[ voted to change the gamemode]] )" )
else
BroadcastLua( "chat.AddText( Entity("..ply:EntIndex().."), Color( 255, 255, 255 ), [[ voted to change the gamemode]] "..NeedTxt.." )" )
end
Msg( ply:Nick() .. " voted to change the gamemode\n" )
timer.Simple( 5, function() GAMEMODE:CountVotesForChange() end )
end
concommand.Add( "VoteForChange", function( pl, cmd, args ) GAMEMODE:VoteForChange( pl ) end )
timer.Create( "VoteForChangeThink", 10, 0, function() if ( GAMEMODE ) then GAMEMODE.CountVotesForChange( GAMEMODE ) end end )
function GM:ClearPlayerWants()
for k, ply in pairs( player.GetAll() ) do
ply:SetNWString( "Wants", "" )
end
end
function GM:StartGamemodeVote()
if( !GAMEMODE.m_bVotingStarted ) then
if ( fretta_voting:GetBool() ) then
GAMEMODE:ClearPlayerWants()
BroadcastLua( "GAMEMODE:ShowGamemodeChooser()" );
SetGlobalBool( "InGamemodeVote", true )
else
GAMEMODE.WinningGamemode = GAMEMODE.FolderName
return GAMEMODE:StartMapVote()
end
timer.Simple( fretta_votetime:GetFloat(), function() GAMEMODE:FinishGamemodeVote( true ) end )
SetGlobalFloat( "VoteEndTime", CurTime() + fretta_votetime:GetFloat() )
GAMEMODE.m_bVotingStarted = true;
end
end
function GM:StartMapVote()
// If there's only one map, let the 'random map' thing choose it
if ( GetNumberOfGamemodeMaps( GAMEMODE.WinningGamemode ) == 1 ) then
return GAMEMODE:FinishMapVote( true )
end
BroadcastLua( "GAMEMODE:ShowMapChooserForGamemode( \""..GAMEMODE.WinningGamemode.."\" )" );
timer.Simple( fretta_votetime:GetFloat(), function() GAMEMODE:FinishMapVote() end )
SetGlobalFloat( "VoteEndTime", CurTime() + fretta_votetime:GetFloat() )
end
function GM:GetWinningWant()
local Votes = {}
for k, ply in pairs( player.GetAll() ) do
local want = ply:GetNWString( "Wants", nil )
if ( want && want != "" ) then
Votes[ want ] = Votes[ want ] or 0
Votes[ want ] = Votes[ want ] + 1
end
end
return table.GetWinningKey( Votes )
end
function GM:WorkOutWinningGamemode()
if ( GAMEMODE.WinningGamemode ) then return GAMEMODE.WinningGamemode end
// Gamemode Voting disabled, return current gamemode
if ( !fretta_voting:GetBool() ) then
return GAMEMODE.FolderName
end
local winner = GAMEMODE:GetWinningWant()
if ( !winner ) then return GetRandomGamemodeName() end
return winner
end
function GM:GetWinningMap( WinningGamemode )
if ( GAMEMODE.WinningMap ) then return GAMEMODE.WinningMap end
local winner = GAMEMODE:GetWinningWant()
if ( !winner ) then return GetRandomGamemodeMap( GAMEMODE.WinningGamemode ) end
return winner
end
function GM:FinishGamemodeVote()
GAMEMODE.WinningGamemode = GAMEMODE:WorkOutWinningGamemode()
GAMEMODE:ClearPlayerWants()
// Send bink bink notification
BroadcastLua( "GAMEMODE:GamemodeWon( '"..GAMEMODE.WinningGamemode.."' )" );
// Start map vote..
timer.Simple( 2, function() GAMEMODE:StartMapVote() end )
end
function GM:FinishMapVote()
GAMEMODE.WinningMap = GAMEMODE:GetWinningMap()
GAMEMODE:ClearPlayerWants()
// Send bink bink notification
BroadcastLua( "GAMEMODE:ChangingGamemode( '"..GAMEMODE.WinningGamemode.."', '"..GAMEMODE.WinningMap.."' )" );
// Start map vote?
timer.Simple( 3, function() GAMEMODE:ChangeGamemode() end )
end
function GM:ChangeGamemode()
local gm = GAMEMODE:WorkOutWinningGamemode()
local mp = GAMEMODE:GetWinningMap()
RunConsoleCommand( "changegamemode", mp, gm )
end