Forcing random players to swap teams JAILBREAK

Just need to make a custom command that swaps random players to a team for jailbreak the command could be anything i will edit that



local randomPlayer = table.Random(team.GetPlayers( TEAM_WHATEVER ) )
randomPlayer:SetTeam( TEAM_OTHERTEAM )


will this only get one player? and change their team

[editline]21st September 2014[/editline]

and where would i put that Anon?

Yes one player.
Anywhere server side but you would want to put that in a function or a timer or whatever you are using it for.
I hope you also know you need to change the team enumeration to the proper team
[sp] I don’t think you are certified to code. Let me guess, it’s your brothers account? Just like that other guy said. [/sp]

How would i get it to change one whole team so TEAM_GUARD i want them to be out of the team and a bunch of random players from TEAM_PRISONERS to go on the other team

[editline]21st September 2014[/editline]

btw im only certified in java script not lua but no one asked

Errr



function SwapTeams( guardAmount )
    local oldPrisoners = team.GetPlayers( TEAM_PRISONERS )
    for k,v in pairs( team.GetPlayers( TEAM_GUARD ) ) do
        v:SetTeam( TEAM_PRISONERS )
    end
    if #oldPrisoners > guardAmount then guardAmount = #oldPrisoners end
    for i=1, guardAmount do
        local rand = math.Random( 1, #oldPrisoners )
        oldPrisoners[rand]:SetTeam( TEAM_GUARD )
        table.remove( oldPrisoners, rand )
    end
end


?
Do I please you now?

k and put it in lua/autorun/server k!

[editline]21st September 2014[/editline]

and i want it to be a command i think i can do the command



concommand.Add("SpoonFeedMeMore", function ( ply, cmd, args  )
    if not ply:IsAdmin() then return end
    local guardAmount = args[1]
    local oldPrisoners = team.GetPlayers( TEAM_PRISONERS )
    for k,v in pairs( team.GetPlayers( TEAM_GUARD ) ) do
        v:SetTeam( TEAM_PRISONERS )
    end
    if #oldPrisoners < guardAmount then guardAmount = #oldPrisoners end
    for i=1, guardAmount do
        local rand = math.Random( 1, #oldPrisoners )
        oldPrisoners[rand]:SetTeam( TEAM_GUARD )
        table.remove( oldPrisoners, rand )
    end
end


Would you like fries with that?

yes please

[editline]21st September 2014[/editline]

and anon with the fries can u make it a chat command please?

[editline]21st September 2014[/editline]

CHAT COMMAND lol



hook.Add("PlayerSay", "SpoonFedMyWholeLife", function( ply, txt )
    if string.lower(txt) == "/guardswitch" then
        if not ply:IsAdmin() then return end
        local guardAmount = tonumber(string.Explode(" ", txt)[2]) or 2
        local oldPrisoners = team.GetPlayers( TEAM_PRISONERS )
        for k,v in pairs( team.GetPlayers( TEAM_GUARD ) ) do
            v:SetTeam( TEAM_PRISONERS )
        end
        if #oldPrisoners < guardAmount then guardAmount = #oldPrisoners end
        for i=1, guardAmount do
            local rand = math.Random( 1, #oldPrisoners )
            oldPrisoners[rand]:SetTeam( TEAM_GUARD )
            table.remove( oldPrisoners, rand )
        end
    end
end)


ye im satisfied can i have a drink too?

[editline]21st September 2014[/editline]

It does not work? i put it in lua/autorun/server

I THINK u put too much chicken salt on the fries

I missed a ‘)’ at the end because I’m on my phone.
I doubt you know any code. Anyone who knew a bit of code would be able to fix that and read errors.
Next time if there are more errors post the error.
I updated my last post

THNX and FOR UR INFO I DO KNOW LUA I Just couldnt be bothered… lol

I was actually more effort to post asking for help than to fix the error, but nice try.

NOW GUYS lets sing songs to each other… lel

[editline]21st September 2014[/editline]

Still does not work Anon… No errors or anything

[editline]21st September 2014[/editline]

Bumpy bummp ummp

Well, you said you do know lua, just can’t be bothered

Guess it’s time to start reading and putting your own effort in