Meva Posted September 22, 2014 Share Posted September 22, 2014 (edited) Hi, guys I have balance.lua script and it work yes, but I wanted to add sounds "player move to axis/allies". modname = "balance"version = "0.1" function et_InitGame(levelTime,randomSeed,restart)et.RegisterModname(modname .. " " .. version)end unevenDiff = 2max_unevenTime = 15max_unevenDiff = 4 axisPlayers = {}alliedPlayers = {}unevenTime = 15 function et_RunFrame( levelTime ) local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if numAlliedPlayers >= numAxisPlayers + max_unevenDiff then local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) elseif numAxisPlayers >= numAlliedPlayers + max_unevenDiff then local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" )et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) elseif numAlliedPlayers >= numAxisPlayers + unevenDiff then if unevenTime > 0 then if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" )et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" )et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) end else unevenTime = tonumber( levelTime ) end elseif numAxisPlayers >= numAlliedPlayers + unevenDiff then if unevenTime > 0 then if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" )et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" )et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) end else unevenTime = tonumber( levelTime ) end else unevenTime = -1 endend function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth ) if teamChange ~= 0 then local team = tonumber( et.gentity_get( clientNum, "sess.sessionTeam" ) ) -- these were the teamnumbers prior to the move local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if team == 1 then for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) break end end -- this should not happen but still check for it to avoid doubles for i, num in ipairs( axisPlayers ) do if num == clientNum then return end end -- make sure a player who (got) moved when teams were uneven doesn't get moved right back if numAlliedPlayers >= numAxisPlayers + unevenDiff then table.insert( axisPlayers, 1, clientNum ) else table.insert( axisPlayers, clientNum ) end elseif team == 2 then for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) break end end for i, num in ipairs( alliedPlayers ) do if num == clientNum then return end end if numAxisPlayers >= numAlliedPlayers + unevenDiff then table.insert( alliedPlayers, 1, clientNum ) else table.insert( alliedPlayers, clientNum ) end else for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end end end endend function et_ClientDisconnect( clientNum ) for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end endendAnd doesn't work :< I'm put on other team but can not hear sound... please help me :< Edited September 22, 2014 by Meva Quote Link to comment Share on other sites More sharing options...
Dragonji Posted September 22, 2014 Share Posted September 22, 2014 (edited) Use this instead: http://mygamingtalk.com/wiki/index.php/Silent_Lua#G_globalSound et.G_globalSound("playermove.wav") Edited September 22, 2014 by Dragonji Meva 1 Quote Link to comment Share on other sites More sharing options...
Meva Posted September 22, 2014 Author Share Posted September 22, 2014 ok it work! thank you! Quote Link to comment Share on other sites More sharing options...
Sentrosii Posted October 9, 2014 Share Posted October 9, 2014 Hello,I know that this is topic about sound in ballance cfg, but i have question about cfg balance so i think that this subject is correct. Is it possible to balance team only to 12 lvl? I mean, i want to balance all players without admins over 12 lvl. Quote Link to comment Share on other sites More sharing options...
Purple Posted October 9, 2014 Share Posted October 9, 2014 (edited) Hello,I know that this is topic about sound in ballance cfg, but i have question about cfg balance so i think that this subject is correct. Is it possible to balance team only to 12 lvl? I mean, i want to balance all players without admins over 12 lvl.Yes it is, right before you move the player, check to see if their level is 12 or higher, if its 12 or higher then return to reload the script and check again. if et.G_shrubbot_level(_clientNum) >= 12 then return end Edited October 9, 2014 by Purple Quote Link to comment Share on other sites More sharing options...
Sentrosii Posted October 10, 2014 Share Posted October 10, 2014 Thanks it really help me out.One more think. When i need to put this cmd? Because there is few places where is putteam. Quote Link to comment Share on other sites More sharing options...
Purple Posted October 11, 2014 Share Posted October 11, 2014 Thanks it really help me out.One more think. When i need to put this cmd? Because there is few places where is putteam. modname = "balance" version = "0.1" function et_InitGame(levelTime,randomSeed,restart) et.RegisterModname(modname .. " " .. version) end unevenDiff = 2 max_unevenTime = 15 max_unevenDiff = 4 axisPlayers = {} alliedPlayers = {} unevenTime = 15 function et_RunFrame( levelTime ) local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if numAlliedPlayers >= numAxisPlayers + max_unevenDiff then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) elseif numAxisPlayers >= numAlliedPlayers + max_unevenDiff then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) elseif numAlliedPlayers >= numAxisPlayers + unevenDiff then if unevenTime > 0 then if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) end else unevenTime = tonumber( levelTime ) end elseif numAxisPlayers >= numAlliedPlayers + unevenDiff then if unevenTime > 0 then if et.G_shrubbot_level(clientNum) >= 12 then return end if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) end else unevenTime = tonumber( levelTime ) end else unevenTime = -1 end end function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth ) if teamChange ~= 0 then local team = tonumber( et.gentity_get( clientNum, "sess.sessionTeam" ) ) -- these were the teamnumbers prior to the move local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if team == 1 then for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) break end end -- this should not happen but still check for it to avoid doubles for i, num in ipairs( axisPlayers ) do if num == clientNum then return end end -- make sure a player who (got) moved when teams were uneven doesn't get moved right back if numAlliedPlayers >= numAxisPlayers + unevenDiff then table.insert( axisPlayers, 1, clientNum ) else table.insert( axisPlayers, clientNum ) end elseif team == 2 then for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) break end end for i, num in ipairs( alliedPlayers ) do if num == clientNum then return end end if numAxisPlayers >= numAlliedPlayers + unevenDiff then table.insert( alliedPlayers, 1, clientNum ) else table.insert( alliedPlayers, clientNum ) end else for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end end end end end function et_ClientDisconnect( clientNum ) for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end end end hellreturn 1 Quote Link to comment Share on other sites More sharing options...
Sentrosii Posted October 18, 2014 Share Posted October 18, 2014 (edited) Hm it didnt work.I dont know, maybe this end endendis not nessesary? Could someone give me an answer of that problem?Thanks a lot. Edited October 18, 2014 by Sentrosii Quote Link to comment Share on other sites More sharing options...
Meva Posted October 22, 2014 Author Share Posted October 22, 2014 maybe now it work: modname = "balance"version = "0.1"function et_InitGame(levelTime,randomSeed,restart) et.RegisterModname(modname .. " " .. version)endunevenDiff = 2max_unevenTime = 15max_unevenDiff = 4axisPlayers = {}alliedPlayers = {}unevenTime = 15function et_RunFrame( levelTime ) local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if numAlliedPlayers >= numAxisPlayers + max_unevenDiff then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) elseif numAxisPlayers >= numAlliedPlayers + max_unevenDiff then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) elseif numAlliedPlayers >= numAxisPlayers + unevenDiff then if unevenTime > 0 then if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then if et.G_shrubbot_level(clientNum) >= 12 then return end local clientNum = alliedPlayers[ numAlliedPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " r" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1AXIS\"" ) end else unevenTime = tonumber( levelTime ) end elseif numAxisPlayers >= numAlliedPlayers + unevenDiff then if unevenTime > 0 then if et.G_shrubbot_level(clientNum) >= 12 then return end if tonumber( levelTime ) - unevenTime >= max_unevenTime * 1000 then local clientNum = axisPlayers[ numAxisPlayers ] et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. " b" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^4ALLIES\"" ) end else unevenTime = tonumber( levelTime ) end else unevenTime = -1endendfunction et_ClientSpawn( clientNum, revived, teamChange, restoreHealth )if teamChange ~= 0 thenlocal team = tonumber( et.gentity_get( clientNum, "sess.sessionTeam" ) )-- these were the teamnumbers prior to the movelocal numAlliedPlayers = table.getn( alliedPlayers )local numAxisPlayers = table.getn( axisPlayers )if team == 1 thenfor i, num in ipairs( alliedPlayers ) doif num == clientNum thentable.remove( alliedPlayers, i )breakendend-- this should not happen but still check for it to avoid doublesfor i, num in ipairs( axisPlayers ) doif num == clientNum thenreturnendend-- make sure a player who (got) moved when teams were uneven doesn't get moved right backif numAlliedPlayers >= numAxisPlayers + unevenDiff thentable.insert( axisPlayers, 1, clientNum )elsetable.insert( axisPlayers, clientNum )endelseif team == 2 thenfor i, num in ipairs( axisPlayers ) doif num == clientNum thentable.remove( axisPlayers, i )breakendendfor i, num in ipairs( alliedPlayers ) doif num == clientNum thenreturnendendif numAxisPlayers >= numAlliedPlayers + unevenDiff thentable.insert( alliedPlayers, 1, clientNum )elsetable.insert( alliedPlayers, clientNum )endelsefor i, num in ipairs( alliedPlayers ) doif num == clientNum thentable.remove( alliedPlayers, i )returnendendfor i, num in ipairs( axisPlayers ) doif num == clientNum thentable.remove( axisPlayers, i )returnendendendendendfunction et_ClientDisconnect( clientNum )for i, num in ipairs( alliedPlayers ) doif num == clientNum thentable.remove( alliedPlayers, i )returnendendfor i, num in ipairs( axisPlayers ) doif num == clientNum thentable.remove( axisPlayers, i )returnendendend Quote Link to comment Share on other sites More sharing options...
Sentrosii Posted November 12, 2014 Share Posted November 12, 2014 Eh no, it's still not working. I'll try this all and nothing.Could you correct this somehow? Maybe you could figure it out what could be wrong in this cmd. Thanks a lof for this all replays:) Quote Link to comment Share on other sites More sharing options...
Purple Posted November 14, 2014 Share Posted November 14, 2014 Eh no, it's still not working. I'll try this all and nothing.Could you correct this somehow? Maybe you could figure it out what could be wrong in this cmd. Thanks a lof for this all replays:)Do me a favor. fill this out and let me know. Mod:version:Did you include the file in your server config?(lua_modules "name.lua":What is your problem?: clan DIABOLIK 1 Quote Link to comment Share on other sites More sharing options...
Pixelowy Posted November 25, 2014 Share Posted November 25, 2014 (edited) Our(Mine and Sentrosii) mod is silent 0.8.3 We would like to have autobalance option in our server. Our problem is in adminlevel. We would like to have a script which move all players without adminlvl >= 12. We would be very grateful if someone would help us write it. Sorry for my English Edited November 25, 2014 by Pixelowy Quote Link to comment Share on other sites More sharing options...
Petbark Posted November 25, 2014 Share Posted November 25, 2014 Our(Mine and Sentrosii) mod is silent 0.8.3 We would like to have autobalance option in our server. Our problem is in adminlevel. We would like to have a script which move all players without adminlvl >= 12. We would be very grateful if someone would help us write it. Sorry for my English Interesting I did not know that 8.3 was around. I am only aware of 8.2. Quote Link to comment Share on other sites More sharing options...
Pixelowy Posted November 25, 2014 Share Posted November 25, 2014 ohh it's my mistake. I mean 0.8.2 Quote Link to comment Share on other sites More sharing options...
Purple Posted November 28, 2014 Share Posted November 28, 2014 We have posted the script multiple times, yet you haven't managed to give us a probable cause to why its not working. I'm not sure what you want us to do here. Quote Link to comment Share on other sites More sharing options...
Pixelowy Posted December 6, 2014 Share Posted December 6, 2014 It is not working because it does not move player with admin level <12 to the other team. Quote Link to comment Share on other sites More sharing options...
Management TheSilencerPL Posted December 9, 2014 Management Share Posted December 9, 2014 Fixed version. I've fixed it for Pixelowy on his request, but I will share it here, so that everyone can have some use of it. modname = "balance" version = "0.2" function et_InitGame(levelTime,randomSeed,restart) et.RegisterModname(modname .. " " .. version) end unevenDiff = 2 max_unevenTime = 15 max_unevenDiff = 4 axisPlayers = {} alliedPlayers = {} unevenTime = 15 immuneLvl = 12 function putTeam(clientNum, team) if clientNum == -1 then return end local teamStr if ( team == "AXIS" ) then teamStr = " r" else teamStr = " b" end et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam " .. clientNum .. teamStr ) et.trap_SendConsoleCommand( et.EXEC_APPEND, "playsound playermove.wav\n" ) et.trap_SendServerCommand(-1, "chat \"balancing teams... " .. et.gentity_get( clientNum, "pers.netname" ) .. "^7 moved to ^1" .. team .. "\"" ) end function longEnough(levelTime) return (tonumber(levelTime) - unevenTime >= max_unevenTime * 1000) end -- check if the level can be moved function goodLevel(clientNum) return ( et.G_shrubbot_level(clientNum) < immuneLvl) end -- pick player from the team specified by the parameter -- pick only players with lower than immuneLvl level -- return -1 if not found function pickPlayer(team) if team == "AXIS" then for clientNum = #axisPlayers,1,-1 do if goodLevel(axisPlayers[clientNum]) then return axisPlayers[clientNum] end end else for clientNum = #alliedPlayers,1,-1 do if goodLevel(alliedPlayers[clientNum]) then return alliedPlayers[clientNum] end end end -- not found -- all higher admins? return -1 end function pickFromAndMove(from, to) local clientNum = pickPlayer(from) putTeam(clientNum, to) end function et_RunFrame( levelTime ) local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if numAlliedPlayers >= numAxisPlayers + max_unevenDiff then pickFromAndMove("ALLIES", "AXIS") elseif numAxisPlayers >= numAlliedPlayers + max_unevenDiff then pickFromAndMove("AXIS", "ALLIES") elseif numAlliedPlayers >= numAxisPlayers + unevenDiff then if unevenTime > 0 then if longEnough(levelTime) then pickFromAndMove("ALLIES", "AXIS") end else unevenTime = tonumber( levelTime ) end elseif numAxisPlayers >= numAlliedPlayers + unevenDiff then if unevenTime > 0 then if longEnough(levelTime) then pickFromAndMove("AXIS", "ALLIES") end else unevenTime = tonumber( levelTime ) end else unevenTime = -1 end end function et_ClientSpawn( clientNum, revived, teamChange, restoreHealth ) if teamChange ~= 0 then local team = tonumber( et.gentity_get( clientNum, "sess.sessionTeam" ) ) -- these were the teamnumbers prior to the move local numAlliedPlayers = table.getn( alliedPlayers ) local numAxisPlayers = table.getn( axisPlayers ) if team == 1 then for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) break end end -- this should not happen but still check for it to avoid doubles for i, num in ipairs( axisPlayers ) do if num == clientNum then return end end -- make sure a player who (got) moved when teams were uneven doesn't get moved right back if numAlliedPlayers >= numAxisPlayers + unevenDiff then table.insert( axisPlayers, 1, clientNum ) else table.insert( axisPlayers, clientNum ) end elseif team == 2 then for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) break end end for i, num in ipairs( alliedPlayers ) do if num == clientNum then return end end if numAxisPlayers >= numAlliedPlayers + unevenDiff then table.insert( alliedPlayers, 1, clientNum ) else table.insert( alliedPlayers, clientNum ) end else for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end end end end end function et_ClientDisconnect( clientNum ) for i, num in ipairs( alliedPlayers ) do if num == clientNum then table.remove( alliedPlayers, i ) return end end for i, num in ipairs( axisPlayers ) do if num == clientNum then table.remove( axisPlayers, i ) return end end end hellreturn 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.