I know the automapcycle has a configured amount of people for it. I currently have it at zero. Does that mean it only auto mapcycles if zero people are on the server and if the time limit happens to hit and there is one or more people on the server it does nothing??? If not, do you think making it behave in such a manner would be better?
It would be kind of a bummer if there was a long heated match and then the map changes just because the automapcycle limit is reached.
<!--quoteo(post=2060499:date=Jan 14 2013, 06:41 PM:name=xDragon)--><div class='quotetop'>QUOTE (xDragon @ Jan 14 2013, 06:41 PM) <a href="index.php?act=findpost&pid=2060499"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Some of that gets complicated, having multiple mods interact to perform the same basic functions make it difficult to insure exactly what logic is applied when. - the Public mode for my tournament mode does not require players to ready - instead once the minimum player counts are reached, the game will start.<!--QuoteEnd--></div><!--QuoteEEnd-->
I see where you're coming from. It just seems like the tournamentmode plugin isn't very compatible with pub play, unless I just have it configured wrong. Even with pub mode true it lets people join teams with no restriction, i.e. everyone can join the same team if they all walk through the same door (or type j1). For pub play it is obviously better if the difference between team sizes is restricted, ideally to 1 as in vanilla NS2.
It seems to me like it would work better if the pub mode variables were just moved to the mapvote plugin and have tournamentmode be solely for competitive matches. That's my 2 cents.
The automapcycle players value sets the maximum amount of people that can be on the server and the mapcycle will still trigger - if set to 0, there cannot be anyone on there server for the automatic mapcycle to trigger.
For the tournamentmode public setting, that is a bug that the public mode allowed players to join any team - I will correct that for the next version.
I published an update last night that should correct the tournamentmode issue, and some other issues that I discovered during testing. I have also updated the readme and added a changelog, along with changes to versions of plugins/DAK.
Nice, though at least in my browser the readme now appears as one continuous string of text, no line breaks like if you open it in wordpad, makes it hard to read for people who cba to download and open it in another program.
I was wondering, have you considered adding a VoteKick plugin?
I'm having issues with the Vote Random command. When the vote random command is entered, the "unstuck" command is run. The vote counts, but when the vote passes, nothing seems to happen.
DAKConfig.json <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->"VoteRandom": { "kVoteRandomInstantly": true, "kVoteRandomConnectAlert": "Random teams are enabled, you are being randomed to a team.", "kVoteRandomMinimumPercentage": 60, "kVoteRandomDuration": 30, "kVoteRandomVoteCountAlert": "%s voted for random teams. (%s votes, needed %s).", "kVoteRandomEnabledDuration": "Random teams have been enabled for the next %s Minutes", "kVoteRandomChatCommands": [ "voterandom", "random" ], "kVoteRandomEnabled": "Random teams have been enabled, the round will restart." },<!--QuoteEnd--></div><!--QuoteEEnd-->
kDAKRevisions["VoteRandom"] = 1.8 local function SetupDefaultConfig(Save) if kDAKConfig.VoteRandom == nil then kDAKConfig.VoteRandom = { } end kDAKConfig.VoteRandom.kVoteRandomInstantly = false kDAKConfig.VoteRandom.kVoteRandomDuration = 30 kDAKConfig.VoteRandom.kVoteRandomMinimumPercentage = 60 kDAKConfig.VoteRandom.kVoteRandomEnabled = "Random teams have been enabled, the round will restart." kDAKConfig.VoteRandom.kVoteRandomEnabledDuration = "Random teams have been enabled for the next %s Minutes" kDAKConfig.VoteRandom.kVoteRandomConnectAlert = "Random teams are enabled, you are being randomed to a team." kDAKConfig.VoteRandom.kVoteRandomVoteCountAlert = "%s voted for random teams. (%s votes, needed %s)." kDAKConfig.VoteRandom.kVoteRandomChatCommands = { "voterandom", "random" } if Save then SaveDAKConfig() end end
table.insert(kDAKPluginDefaultConfigs, {PluginName = "VoteRandom", DefaultConfig = function(Save) SetupDefaultConfig(Save) end })<!--QuoteEnd--></div><!--QuoteEEnd-->
plugin_voterandom.json
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->//NS2 Vote Random Teams
if kDAKConfig and kDAKConfig.VoteRandom then
local kVoteRandomTeamsEnabled = false local RandomNewRoundDelay = 15 local RandomVotes = { } local RandomDuration = 0 local RandomRoundRecentlyEnded = nil
local function LoadVoteRandom()
if kDAKSettings.RandomEnabledTill ~= nil then if kDAKSettings.RandomEnabledTill > Shared.GetSystemTime() then kVoteRandomTeamsEnabled = not kDAKConfig.VoteRandom.kVoteRandomInstantly Shared.Message(string.format("RandomTeams set to %s", ToString(kVoteRandomTeamsEnabled))) EnhancedLog(string.format("RandomTeams set to %s", ToString(kVoteRandomTeamsEnabled))) else kVoteRandomTeamsEnabled = false end else kDAKSettings.RandomEnabledTill = 0 end end
LoadVoteRandom()
local function ShuffleTeams(ShuffleAllPlayers) local playerList = ShufflePlayerList()
for i = 1, (#playerList) do if ShuffleAllPlayers or playerList[i]:GetTeamNumber() == 0 then local teamnum = math.fmod(i,2) + 1 local client = Server.GetOwner(playerList[i]) if client ~= nil then //Trying just making team decision based on position in array.. two randoms seems to somehow result in similar teams.. local gamerules = GetGamerules() if gamerules and not DAKGetClientCanRunCommand(client, "sv_dontrandom") then gamerules:JoinTeam(playerList[i], teamnum) end end end end end
local function UpdateRandomVotes(silent, playername)
local playerRecords = Shared.GetEntitiesWithClassname("Player") local totalvotes = 0
for i = #RandomVotes, 1, -1 do local clientid = RandomVotes[i] local stillplaying = false
for _, player in ientitylist(playerRecords) do if player ~= nil then local client = Server.GetOwner(player) if client ~= nil then if clientid == client:GetUserId() then stillplaying = true totalvotes = totalvotes + 1 break end end end end
if not stillplaying then table.remove(RandomVotes, i) end
end
if totalvotes >= math.ceil((playerRecords:GetSize() * (kDAKConfig.VoteRandom.kVoteRandomMinimumPercentage / 100))) then
RandomVotes = { }
if kDAKConfig.VoteRandom.kVoteRandomInstantly then chatMessage = string.sub(string.format("Random teams have been enabled, the round will restart."), 1, kMaxChatLength) Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) if Server then Shared.ConsoleCommand("sv_rrall") Shared.ConsoleCommand("sv_reset") ShuffleTeams(true) end else chatMessage = string.sub(string.format("Random teams have been enabled for the next %s Minutes", kDAKConfig.VoteRandom.kVoteRandomDuration), 1, kMaxChatLength) Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) kDAKSettings.RandomEnabledTill = Shared.GetSystemTime() + (kDAKConfig.VoteRandom.kVoteRandomDuration * 60) SaveDAKSettings() kVoteRandomTeamsEnabled = true end
if client ~= nil then local player = client:GetControllingPlayer()
if player ~= nil and kVoteRandomTeamsEnabled then chatMessage = string.sub(string.format("Random teams are enabled, you are being randomed to a team."), 1, kMaxChatLength) Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) JoinRandomTeam(player) end return true end return false end
local function VoteRandomJoinTeam(player, newTeamNumber, force) if RandomRoundRecentlyEnded ~= nil and RandomRoundRecentlyEnded + RandomNewRoundDelay > Shared.GetTime() and (newTeamNumber == 1 or newTeamNumber == 2) then chatMessage = string.sub(string.format("Random teams are enabled, you will be randomed to a team shortly."), 1, kMaxChatLength) Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) return false end return true end
if kDAKSettings.RandomEnabledTill > Shared.GetSystemTime() then kVoteRandomTeamsEnabled = not kDAKConfig.VoteRandom.kVoteRandomInstantly else kVoteRandomTeamsEnabled = false end if RandomRoundRecentlyEnded ~= nil and RandomRoundRecentlyEnded + RandomNewRoundDelay < Shared.GetTime() then ShuffleTeams(false) RandomRoundRecentlyEnded = nil end
local player = client:GetControllingPlayer() if player ~= nil then if kVoteRandomTeamsEnabled then chatMessage = string.sub(string.format("Random teams already enabled."), 1, kMaxChatLength) Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) return end if RandomVotes[client:GetUserId()] ~= nil then chatMessage = string.sub(string.format("You already voted for random teams."), 1, kMaxChatLength) Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) else local playerRecords = Shared.GetEntitiesWithClassname("Player") table.insert(RandomVotes,client:GetUserId()) RandomVotes[client:GetUserId()] = true Shared.Message(string.format("%s voted for random teams.", client:GetUserId())) EnhancedLog(string.format("%s voted for random teams.", client:GetUserId())) UpdateRandomVotes(false, player:GetName()) end end
local function OnVoteRandomChatMessage(message, playerName, steamId, teamNumber, teamOnly, client)
if client and steamId and steamId ~= 0 then for c = 1, #kDAKConfig.VoteRandom.kVoteRandomChatCommands do local chatcommand = kDAKConfig.VoteRandom.kVoteRandomChatCommands[c] if message == chatcommand then OnCommandVoteRandom(client) end end end
kVoteRandomTeamsEnabled = false kDAKSettings.RandomEnabledTill = 0 SaveDAKSettings() chatMessage = string.sub(string.format("Random teams have been disabled."), 1, kMaxChatLength) Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) if client ~= nil then local player = client:GetControllingPlayer() if player ~= nil then PrintToAllAdmins("sv_randomoff", client) end end end
end
DAKCreateServerAdminCommand("Console_sv_randomoff", VoteRandomOff, "Turns off any currently active random teams vote.")
local function VoteRandomOn(client)
if kVoteRandomTeamsEnabled == false then
if kDAKConfig.VoteRandom.kVoteRandomInstantly then chatMessage = string.sub(string.format("Random teams have been enabled, the round will restart."), 1, kMaxChatLength) Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) if Server then Shared.ConsoleCommand("sv_rrall") Shared.ConsoleCommand("sv_reset") ShuffleTeams(true) end else chatMessage = string.sub(string.format("Random teams have been enabled for the next %s Minutes", kDAKConfig.VoteRandom.kVoteRandomDuration), 1, kMaxChatLength) Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true) kDAKSettings.RandomEnabledTill = Shared.GetSystemTime() + (kDAKConfig.VoteRandom.kVoteRandomDuration * 60) SaveDAKSettings() kVoteRandomTeamsEnabled = true end if client ~= nil then local player = client:GetControllingPlayer() if player ~= nil then PrintToAllAdmins("sv_randomon", client) end end end
end
DAKCreateServerAdminCommand("Console_sv_randomon", VoteRandomOn, "Will enable random teams.")
Hey Dragon, I have a few questions/comments for you:
1) On my server a map vote is getting triggered at the end of rounds and then again at the start of the round, which is obviously annoying. Is this something to do with b236 or is it just me?
2) In the DAKConfig file if I set a percentage for a vote, does it get rounded up or rounded down? E.g. for a team of 10 does 51% mean 5 people or 6 people have to vote?
3) With the AutoConcede plugin is there a way to have the message about the round ending be repeated? Currently it just says "round will end in 30 seconds..." and then no more messages before the round ends.
4) I am running TournamentMode with pub mode, "kTournamentModePubMinPlayersPerTeam" = 3. When people start joining teams, the scoreboard shows everyone is still in the readyroom until there are 3 people on each team, then the scoreboard shows everyone on the right team. Think this may be a bug, but not a big deal really.
5) With VoteSurrender plugin I have had reports on my server that a team voted to surrender and then it said that team had won and the team that was winning had lost.
-I think i found the issue causing the map votes to trigger twice, that should be fixed hopefully soon -Pretty much all percentages are rounded up for comparisions - the map vote definately is. -I dont see anything with the VoteSurrender that could cause the incorrect team to lose - all the surrender vote does is move all the players on the team to the readyroom. I did correct an issue that could have caused the first player to get missed when the aliens voted to surrender. -I will look into the scoreboard issue with the tournamentmode plugin - I have been making a couple large changes to this plugin so it might take me a little before I can update this. -I will add a periodic message to the autoconcede plugin.
Thank you so very much for keeping this mod up to date!
The more I poke at this, the more I think UWE just needs to hire you to get this stuff into NS2 main already.
I hope the new version with the fixes show up on the Steam Workshop soon!
In any case, I was wondering if there were any plans to make the commands accepted for stuff like vote, random, surrender, etc. case insensitive? Is this even possible? Currently, to get around this, I have my voting plugin set up as: <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> "kVoteChatCommands": [ "vote", "Vote", "VOTE" ],<!--c2--></div><!--ec2--> This is to help make it easier for users to vote no matter how they are capitalizing the word vote.
If there aren't any plans for making these case-insensitive, is there any sort of maximum limit on the amount of variations for each command that I can specify?
I tried to set a bunch of variations today, which seemed to kind of work, but then I ran into that issue where trying to random the teams triggered the unstuck plugin instead, and I thought I broke it, lol. Turns out it's a bug, going by posts in this thread.
Still, making it case-insensitive would make things a lot easier, as I only have to add variations with a slash or something.
My only other observation is that the votemap plugin seems to insert its own string of ******'s after certain lines of text, even though I've deleted them in the DAKConfig file.
In the current github version all the massages have to be edited in EN.json (or whatever language you choose) in the lua/lang folder, but I don't know if that is in the current workshop version.
Its not because i need to test somethings to make sure its compt. with workshop. The votemap plugin used to stick those * on the end, that is changed in the new version (its just not out on workshop yet). Im hoping to update the workshop build this weekend.
If there are new features and changes, does the DAKConfig file need to be rewritten?
By this, I mean, are there new commands and stuff that we should/can add to it? I ask because I believe the mod doesn't want to overwrite the config file, even if there are new settings we can use; in this case, it would be helpful to know if we need to delete/re-generate the config file to get the new settings.
I tried reading the readme on the github, but it's currently an unformatted mess.. haha.
Thanks for all the information, though. I haven't yet tried using the github version, because I'm not sure what would happen with dropping in those files into our server currently modding the "official" way, from the workshop.
I was looking at hiding the mods to unflag our server, but from what I can tell, I can only hide DAK - not ns2stats nor the badge mod, which makes the whole effort kind of pointless.
Yea that readme has done nothing but mock me, i cannot seem to get it formatted at all the way I want on github. It opens fine in notepad++ however.
The way DAK loads the config files and your server specific config files insures that if new config options are added, that they will get automatically updated in your config.
Depending on the changes made to the config - you can reload the config mid game by typing sv_reloadconfig. Many things will update automatically, however not everything will. If you loaded a new plugin - you can type sv_reloadplugins to reload those, but thats not always ideal. At worst you just need to change the map for everything to be reloaded.
<!--quoteo(post=2062754:date=Jan 19 2013, 02:42 AM:name=xDragon)--><div class='quotetop'>QUOTE (xDragon @ Jan 19 2013, 02:42 AM) <a href="index.php?act=findpost&pid=2062754"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Yea that readme has done nothing but mock me, i cannot seem to get it formatted at all the way I want on github. It opens fine in notepad++ however.<!--QuoteEnd--></div><!--QuoteEEnd-->
I flavored your readme with markdown on GitHub and sent a pull request :)
Ah and one more thing, it seems that when I perform a "random" command via chat (console works fine), both unstuck and random will execute. Does this happen to anyone else?
Can't seem to get player badges working. Does it work in build 237? I've got my user assigned to admin_group in serveradmin.json. The admin commands are working for the player. I can see badges listed via sv_listplugins. Any ideas?
I don't think badges have anything to do with the DAK.. But FWIW, Huze's Player Badges mod works fine on my server, alongside DAK and NS2Stats.
Anyway, many thanks for the quick updates, and getting it out to the Steam Workshop! The random-triggering-unstuck bug is gone, although now the message that random teams have been enabled is appearing twice.
I am looking over everything now and have noticed that you introduced a new language thing, and split off all the messages away from the config file. It will take me a bit to edit everything properly and split it up, but this might be the reason those messages appear twice.. I think?
In any case, one question I have now is that the DAK includes both Default.json and EN.json in the language folder - Which one does this use currently? If a new player enters our server and does not specify or override the language, does it display strings from Default or EN? Is Default only used as a fallback in case EN is corrupted, doesn't exist, or if sv_resetsettings or sv_defaultconfig are used?
<!--quoteo(post=2063108:date=Jan 19 2013, 12:03 PM:name=A[L]C)--><div class='quotetop'>QUOTE (A[L]C @ Jan 19 2013, 12:03 PM) <a href="index.php?act=findpost&pid=2063108"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--> Can't seem to get player badges working. Does it work in build 237? I've got my user assigned to admin_group in serveradmin.json. The admin commands are working for the player. I can see badges listed via sv_listplugins. Any ideas?<!--QuoteEnd--></div><!--QuoteEEnd--> I think it requires ns2stats for it to work.
Well, I think I solved all the issues on my end. I went through and redid my whole config to conform with the new format, and the message doesn't appear twice anymore.
I also added to the DAKConfig "kDefaultLanguage": "EN", And this seems to force the use of the EN.json language file by default. Curiously, the server loads without the quotes around EN, but doesn't allow anyone to join due to "Invalid data." This would be good to note down in the readme, I think.
The badges plugin was only designed to make an already installed badges mod (from huze) recognize admins that are pulled from web queries in DAK, if you just use the ServerAdmin.json file to configure all your admins then you wouldnt need the badges plugin.
For the languages, Default.json is intended to be the fallback in case the users configured language doesnt have the required strings - And also should be used to create any custom langauges, and will be the only language file that I update so that and new language strings dont override your already configured file.
I also published a quick update to correct some issues with missing tournament mode settings.
Comments
I know the automapcycle has a configured amount of people for it. I currently have it at zero. Does that mean it only auto mapcycles if zero people are on the server and if the time limit happens to hit and there is one or more people on the server it does nothing??? If not, do you think making it behave in such a manner would be better?
It would be kind of a bummer if there was a long heated match and then the map changes just because the automapcycle limit is reached.
I see where you're coming from. It just seems like the tournamentmode plugin isn't very compatible with pub play, unless I just have it configured wrong. Even with pub mode true it lets people join teams with no restriction, i.e. everyone can join the same team if they all walk through the same door (or type j1). For pub play it is obviously better if the difference between team sizes is restricted, ideally to 1 as in vanilla NS2.
It seems to me like it would work better if the pub mode variables were just moved to the mapvote plugin and have tournamentmode be solely for competitive matches. That's my 2 cents.
For the tournamentmode public setting, that is a bug that the public mode allowed players to join any team - I will correct that for the next version.
I was wondering, have you considered adding a VoteKick plugin?
DAKConfig.json
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->"VoteRandom": {
"kVoteRandomInstantly": true,
"kVoteRandomConnectAlert": "Random teams are enabled, you are being randomed to a team.",
"kVoteRandomMinimumPercentage": 60,
"kVoteRandomDuration": 30,
"kVoteRandomVoteCountAlert": "%s voted for random teams. (%s votes, needed %s).",
"kVoteRandomEnabledDuration": "Random teams have been enabled for the next %s Minutes",
"kVoteRandomChatCommands": [ "voterandom", "random" ],
"kVoteRandomEnabled": "Random teams have been enabled, the round will restart."
},<!--QuoteEnd--></div><!--QuoteEEnd-->
config_voterandom.json
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->//reservedslots config
kDAKRevisions["VoteRandom"] = 1.8
local function SetupDefaultConfig(Save)
if kDAKConfig.VoteRandom == nil then
kDAKConfig.VoteRandom = { }
end
kDAKConfig.VoteRandom.kVoteRandomInstantly = false
kDAKConfig.VoteRandom.kVoteRandomDuration = 30
kDAKConfig.VoteRandom.kVoteRandomMinimumPercentage = 60
kDAKConfig.VoteRandom.kVoteRandomEnabled = "Random teams have been enabled, the round will restart."
kDAKConfig.VoteRandom.kVoteRandomEnabledDuration = "Random teams have been enabled for the next %s Minutes"
kDAKConfig.VoteRandom.kVoteRandomConnectAlert = "Random teams are enabled, you are being randomed to a team."
kDAKConfig.VoteRandom.kVoteRandomVoteCountAlert = "%s voted for random teams. (%s votes, needed %s)."
kDAKConfig.VoteRandom.kVoteRandomChatCommands = { "voterandom", "random" }
if Save then
SaveDAKConfig()
end
end
table.insert(kDAKPluginDefaultConfigs, {PluginName = "VoteRandom", DefaultConfig = function(Save) SetupDefaultConfig(Save) end })<!--QuoteEnd--></div><!--QuoteEEnd-->
plugin_voterandom.json
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->//NS2 Vote Random Teams
if kDAKConfig and kDAKConfig.VoteRandom then
local kVoteRandomTeamsEnabled = false
local RandomNewRoundDelay = 15
local RandomVotes = { }
local RandomDuration = 0
local RandomRoundRecentlyEnded = nil
local function LoadVoteRandom()
if kDAKSettings.RandomEnabledTill ~= nil then
if kDAKSettings.RandomEnabledTill > Shared.GetSystemTime() then
kVoteRandomTeamsEnabled = not kDAKConfig.VoteRandom.kVoteRandomInstantly
Shared.Message(string.format("RandomTeams set to %s", ToString(kVoteRandomTeamsEnabled)))
EnhancedLog(string.format("RandomTeams set to %s", ToString(kVoteRandomTeamsEnabled)))
else
kVoteRandomTeamsEnabled = false
end
else
kDAKSettings.RandomEnabledTill = 0
end
end
LoadVoteRandom()
local function ShuffleTeams(ShuffleAllPlayers)
local playerList = ShufflePlayerList()
for i = 1, (#playerList) do
if ShuffleAllPlayers or playerList[i]:GetTeamNumber() == 0 then
local teamnum = math.fmod(i,2) + 1
local client = Server.GetOwner(playerList[i])
if client ~= nil then
//Trying just making team decision based on position in array.. two randoms seems to somehow result in similar teams..
local gamerules = GetGamerules()
if gamerules and not DAKGetClientCanRunCommand(client, "sv_dontrandom") then
gamerules:JoinTeam(playerList[i], teamnum)
end
end
end
end
end
local function UpdateRandomVotes(silent, playername)
local playerRecords = Shared.GetEntitiesWithClassname("Player")
local totalvotes = 0
for i = #RandomVotes, 1, -1 do
local clientid = RandomVotes[i]
local stillplaying = false
for _, player in ientitylist(playerRecords) do
if player ~= nil then
local client = Server.GetOwner(player)
if client ~= nil then
if clientid == client:GetUserId() then
stillplaying = true
totalvotes = totalvotes + 1
break
end
end
end
end
if not stillplaying then
table.remove(RandomVotes, i)
end
end
if totalvotes >= math.ceil((playerRecords:GetSize() * (kDAKConfig.VoteRandom.kVoteRandomMinimumPercentage / 100))) then
RandomVotes = { }
if kDAKConfig.VoteRandom.kVoteRandomInstantly then
chatMessage = string.sub(string.format("Random teams have been enabled, the round will restart."), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
if Server then
Shared.ConsoleCommand("sv_rrall")
Shared.ConsoleCommand("sv_reset")
ShuffleTeams(true)
end
else
chatMessage = string.sub(string.format("Random teams have been enabled for the next %s Minutes", kDAKConfig.VoteRandom.kVoteRandomDuration), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
kDAKSettings.RandomEnabledTill = Shared.GetSystemTime() + (kDAKConfig.VoteRandom.kVoteRandomDuration * 60)
SaveDAKSettings()
kVoteRandomTeamsEnabled = true
end
elseif not silent then
chatMessage = string.sub(string.format("%s voted for random teams. (%s votes, needed %s).", playername, totalvotes, math.ceil((playerRecords:GetSize() * (kDAKConfig.VoteRandom.kVoteRandomMinimumPercentage / 100)))), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
end
return true
end
table.insert(kDAKOnClientDisconnect, function(client) return UpdateRandomVotes(true, "") end)
local function VoteRandomClientConnect(client)
if client ~= nil then
local player = client:GetControllingPlayer()
if player ~= nil and kVoteRandomTeamsEnabled then
chatMessage = string.sub(string.format("Random teams are enabled, you are being randomed to a team."), 1, kMaxChatLength)
Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
JoinRandomTeam(player)
end
return true
end
return false
end
table.insert(kDAKOnClientDelayedConnect, function(client) return VoteRandomClientConnect(client) end)
local function VoteRandomJoinTeam(player, newTeamNumber, force)
if RandomRoundRecentlyEnded ~= nil and RandomRoundRecentlyEnded + RandomNewRoundDelay > Shared.GetTime() and (newTeamNumber == 1 or newTeamNumber == 2) then
chatMessage = string.sub(string.format("Random teams are enabled, you will be randomed to a team shortly."), 1, kMaxChatLength)
Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
return false
end
return true
end
table.insert(kDAKOnTeamJoin, function(player, newTeamNumber, force) return VoteRandomJoinTeam(player, newTeamNumber, force) end)
local function VoteRandomEndGame(winningTeam)
if kVoteRandomTeamsEnabled then
RandomRoundRecentlyEnded = Shared.GetTime()
end
end
table.insert(kDAKOnGameEnd, function(winningTeam) return VoteRandomEndGame(winningTeam) end)
local function RandomTeams()
PROFILE("VoteRandom:RandomTeams")
if kVoteRandomTeamsEnabled then
if kDAKSettings.RandomEnabledTill > Shared.GetSystemTime() then
kVoteRandomTeamsEnabled = not kDAKConfig.VoteRandom.kVoteRandomInstantly
else
kVoteRandomTeamsEnabled = false
end
if RandomRoundRecentlyEnded ~= nil and RandomRoundRecentlyEnded + RandomNewRoundDelay < Shared.GetTime() then
ShuffleTeams(false)
RandomRoundRecentlyEnded = nil
end
end
return true
end
DAKRegisterEventHook(kDAKOnServerUpdate, function(deltatime) return RandomTeams() end, 5)
local function OnCommandVoteRandom(client)
if client ~= nil then
local player = client:GetControllingPlayer()
if player ~= nil then
if kVoteRandomTeamsEnabled then
chatMessage = string.sub(string.format("Random teams already enabled."), 1, kMaxChatLength)
Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
return
end
if RandomVotes[client:GetUserId()] ~= nil then
chatMessage = string.sub(string.format("You already voted for random teams."), 1, kMaxChatLength)
Server.SendNetworkMessage(player, "Chat", BuildChatMessage(false, "PM - " .. kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
else
local playerRecords = Shared.GetEntitiesWithClassname("Player")
table.insert(RandomVotes,client:GetUserId())
RandomVotes[client:GetUserId()] = true
Shared.Message(string.format("%s voted for random teams.", client:GetUserId()))
EnhancedLog(string.format("%s voted for random teams.", client:GetUserId()))
UpdateRandomVotes(false, player:GetName())
end
end
end
end
Event.Hook("Console_voterandom", OnCommandVoteRandom)
Event.Hook("Console_random", OnCommandVoteRandom)
local function OnVoteRandomChatMessage(message, playerName, steamId, teamNumber, teamOnly, client)
if client and steamId and steamId ~= 0 then
for c = 1, #kDAKConfig.VoteRandom.kVoteRandomChatCommands do
local chatcommand = kDAKConfig.VoteRandom.kVoteRandomChatCommands[c]
if message == chatcommand then
OnCommandVoteRandom(client)
end
end
end
end
table.insert(kDAKOnClientChatMessage, function(message, playerName, steamId, teamNumber, teamOnly, client) return OnVoteRandomChatMessage(message, playerName, steamId, teamNumber, teamOnly, client) end)
local function VoteRandomOff(client)
if kVoteRandomTeamsEnabled then
kVoteRandomTeamsEnabled = false
kDAKSettings.RandomEnabledTill = 0
SaveDAKSettings()
chatMessage = string.sub(string.format("Random teams have been disabled."), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
if client ~= nil then
local player = client:GetControllingPlayer()
if player ~= nil then
PrintToAllAdmins("sv_randomoff", client)
end
end
end
end
DAKCreateServerAdminCommand("Console_sv_randomoff", VoteRandomOff, "Turns off any currently active random teams vote.")
local function VoteRandomOn(client)
if kVoteRandomTeamsEnabled == false then
if kDAKConfig.VoteRandom.kVoteRandomInstantly then
chatMessage = string.sub(string.format("Random teams have been enabled, the round will restart."), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
if Server then
Shared.ConsoleCommand("sv_rrall")
Shared.ConsoleCommand("sv_reset")
ShuffleTeams(true)
end
else
chatMessage = string.sub(string.format("Random teams have been enabled for the next %s Minutes", kDAKConfig.VoteRandom.kVoteRandomDuration), 1, kMaxChatLength)
Server.SendNetworkMessage("Chat", BuildChatMessage(false, kDAKConfig.DAKLoader.MessageSender, -1, kTeamReadyRoom, kNeutralTeamType, chatMessage), true)
kDAKSettings.RandomEnabledTill = Shared.GetSystemTime() + (kDAKConfig.VoteRandom.kVoteRandomDuration * 60)
SaveDAKSettings()
kVoteRandomTeamsEnabled = true
end
if client ~= nil then
local player = client:GetControllingPlayer()
if player ~= nil then
PrintToAllAdmins("sv_randomon", client)
end
end
end
end
DAKCreateServerAdminCommand("Console_sv_randomon", VoteRandomOn, "Will enable random teams.")
end
Shared.Message("VoteRandom Loading Complete")<!--QuoteEnd--></div><!--QuoteEEnd-->
1) On my server a map vote is getting triggered at the end of rounds and then again at the start of the round, which is obviously annoying. Is this something to do with b236 or is it just me?
2) In the DAKConfig file if I set a percentage for a vote, does it get rounded up or rounded down? E.g. for a team of 10 does 51% mean 5 people or 6 people have to vote?
3) With the AutoConcede plugin is there a way to have the message about the round ending be repeated? Currently it just says "round will end in 30 seconds..." and then no more messages before the round ends.
4) I am running TournamentMode with pub mode, "kTournamentModePubMinPlayersPerTeam" = 3. When people start joining teams, the scoreboard shows everyone is still in the readyroom until there are 3 people on each team, then the scoreboard shows everyone on the right team. Think this may be a bug, but not a big deal really.
5) With VoteSurrender plugin I have had reports on my server that a team voted to surrender and then it said that team had won and the team that was winning had lost.
Thanks!
-Pretty much all percentages are rounded up for comparisions - the map vote definately is.
-I dont see anything with the VoteSurrender that could cause the incorrect team to lose - all the surrender vote does is move all the players on the team to the readyroom. I did correct an issue that could have caused the first player to get missed when the aliens voted to surrender.
-I will look into the scoreboard issue with the tournamentmode plugin - I have been making a couple large changes to this plugin so it might take me a little before I can update this.
-I will add a periodic message to the autoconcede plugin.
I think the map vote being triggered twice may have had something to do with the tournamentmode reset, seems to stop when i disable tournamentmode.
The more I poke at this, the more I think UWE just needs to hire you to get this stuff into NS2 main already.
I hope the new version with the fixes show up on the Steam Workshop soon!
In any case, I was wondering if there were any plans to make the commands accepted for stuff like vote, random, surrender, etc. case insensitive? Is this even possible?
Currently, to get around this, I have my voting plugin set up as:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> "kVoteChatCommands": [ "vote", "Vote", "VOTE" ],<!--c2--></div><!--ec2-->
This is to help make it easier for users to vote no matter how they are capitalizing the word vote.
If there aren't any plans for making these case-insensitive, is there any sort of maximum limit on the amount of variations for each command that I can specify?
Thanks!
Thank you for the speedy reply. :D
I tried to set a bunch of variations today, which seemed to kind of work, but then I ran into that issue where trying to random the teams triggered the unstuck plugin instead, and I thought I broke it, lol.
Turns out it's a bug, going by posts in this thread.
Still, making it case-insensitive would make things a lot easier, as I only have to add variations with a slash or something.
My only other observation is that the votemap plugin seems to insert its own string of ******'s after certain lines of text, even though I've deleted them in the DAKConfig file.
Thanks again!
By this, I mean, are there new commands and stuff that we should/can add to it?
I ask because I believe the mod doesn't want to overwrite the config file, even if there are new settings we can use; in this case, it would be helpful to know if we need to delete/re-generate the config file to get the new settings.
I tried reading the readme on the github, but it's currently an unformatted mess.. haha.
Thanks for all the information, though. I haven't yet tried using the github version, because I'm not sure what would happen with dropping in those files into our server currently modding the "official" way, from the workshop.
I was looking at hiding the mods to unflag our server, but from what I can tell, I can only hide DAK - not ns2stats nor the badge mod, which makes the whole effort kind of pointless.
Thanks
The way DAK loads the config files and your server specific config files insures that if new config options are added, that they will get automatically updated in your config.
Depending on the changes made to the config - you can reload the config mid game by typing sv_reloadconfig. Many things will update automatically, however not everything will. If you loaded a new plugin - you can type sv_reloadplugins to reload those, but thats not always ideal. At worst you just need to change the map for everything to be reloaded.
I flavored your readme with markdown on GitHub and sent a pull request :)
Ah and one more thing, it seems that when I perform a "random" command via chat (console works fine), both unstuck and random will execute. Does this happen to anyone else?
Edit - That version is now up on GitHub and on steam workshop.
But FWIW, Huze's Player Badges mod works fine on my server, alongside DAK and NS2Stats.
Anyway, many thanks for the quick updates, and getting it out to the Steam Workshop!
The random-triggering-unstuck bug is gone, although now the message that random teams have been enabled is appearing twice.
I am looking over everything now and have noticed that you introduced a new language thing, and split off all the messages away from the config file.
It will take me a bit to edit everything properly and split it up, but this might be the reason those messages appear twice.. I think?
In any case, one question I have now is that the DAK includes both Default.json and EN.json in the language folder - Which one does this use currently?
If a new player enters our server and does not specify or override the language, does it display strings from Default or EN?
Is Default only used as a fallback in case EN is corrupted, doesn't exist, or if sv_resetsettings or sv_defaultconfig are used?
Thanks!
Can't seem to get player badges working. Does it work in build 237? I've got my user assigned to admin_group in serveradmin.json. The admin commands are working for the player. I can see badges listed via sv_listplugins. Any ideas?<!--QuoteEnd--></div><!--QuoteEEnd-->
I think it requires ns2stats for it to work.
I went through and redid my whole config to conform with the new format, and the message doesn't appear twice anymore.
I also added to the DAKConfig
"kDefaultLanguage": "EN",
And this seems to force the use of the EN.json language file by default.
Curiously, the server loads without the quotes around EN, but doesn't allow anyone to join due to "Invalid data."
This would be good to note down in the readme, I think.
For the languages, Default.json is intended to be the fallback in case the users configured language doesnt have the required strings - And also should be used to create any custom langauges, and will be the only language file that I update so that and new language strings dont override your already configured file.
I also published a quick update to correct some issues with missing tournament mode settings.