Welcome to Open Carnage

A resource for Halo 1 modding and tech, with unique means of rewarding individual content creation and support. Have a wander to see why we're worth the time! EST. 2012

Sign in to follow this  
Followers 0
Kavawuvi

Team Shuffler

35 posts in this topic

Well, I haven't a clue why this isn't working. Even with a lot of players there's still no change - same teams every time.

 

I have this running on 2 servers and it's not working on either - weird. Am I missing something ?

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

Do you have the lua_load command in the correct init?

 

Yes.. in the sapp init

lua 1
lua_load shuffler

Here is the lua script I'm using:

-- Team Shuffler by 002 v1.0.2-- Configuration


-- How many games between shuffles? Set to 0 for every game. Set to -1 to disable automatic shuffling.
SHUFFLE_INTERVAL = 0


-- Seconds to wait on the game start until the teams are shuffled.
TIME_UNTIL_SHUFFLE = 8


-- Warning given to players when teams will be shuffled (shown upon joining).
-- Variables: $SECONDS = seconds remaining
SHUFFLE_WARNING = "Teams will be shuffled in $SECONDS seconds."


-- The notice when teams have been shuffled.
SHUFFLED = "Teams have been shuffled."


-- End of configuration


games_since_last_shuffle = 0
api_version = "1.6.0.0"
time = nil


function OnScriptLoad()
    if(SHUFFLE_INTERVAL >= 0) then register_callback(cb['EVENT_GAME_START'],"OnGameStart") end
    register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
end
function OnScriptUnload()


end
function OnGameStart()
    if(get_var(1,"$ffa") == "0") then
        games_since_last_shuffle = games_since_last_shuffle + 1
    end
    if(games_since_last_shuffle == SHUFFLE_INTERVAL) then
        timer(TIME_UNTIL_SHUFFLE * 1000,"ShuffleTeams")
        time = os.clock()
    end
end
function OnPlayerJoin(PlayerIndex)
    if(time ~= nil) then say(PlayerIndex,string.gsub(SHUFFLE_WARNING,"$SECONDS",math.ceil(time + TIME_UNTIL_SHUFFLE - os.clock()))) end
end
function ShuffleTeams()
    if(get_var(1,"$ffa") == "1") then return end
    say_all(SHUFFLED)
    local players = {}
    for i=1,16 do
        if(player_present(i)) then
            local player = get_player(i)
            local old_value = read_word(player + 0xD4)
            if(player_alive(i) == true) then 
                write_word(player + 0xD4, 0xFFFF)
                kill(i)
                write_word(player + 0xD4, old_value)
                write_word(player + 0xAE, read_word(player + 0xAE) - 1)
            end
            players[table.getn(players) + 1] = i
            write_dword(player + 0x2C, 0)
            execute_command("st " .. i .. " red")
        end
    end
    local players_count = table.getn(players)
    while true do
        local red = tonumber(get_var(1,"$reds"))
        local blue = tonumber(get_var(1,"$blues"))
        if(red > blue + 1) then
            while true do
                local i = players[rand(1,players_count+1)]
                local player = get_player(i)
                if(read_word(player + 0x20) == 0) then
                    execute_command("st " .. i .. " blue")
                    break
                end
            end
        else
            break
        end
    end
    time = nil
    games_since_last_shuffle = 0
end

PS. I know that lua scripts work ok, as I also have the grenade_capacity script running ok on one of my servers - on that particular server I also have the shuffler lua script, but for some reason it's not working which is weird.

Share this post


Link to post
Share on other sites

I used the very same version of the script on my server for weeks and didn't have to worry. Is SAPP up to date?

 

 

 

9.5.3.1

Share this post


Link to post
Share on other sites

My next thought would be to download the script from here again and start over or could there be a conflict if you have auto team balance running also.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.