Dinkleberg's GMod

Full Version: Change to Forceswap command
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This simple change to the ULX Forceswap command allows it to swap people out of unassigned onto a team. I'm not sure why you'd need to do this, but Travis said it would be cool, so I made it.

Download

Code:
function ulx.forceswap( calling_ply, target_ply )
    if target_ply:Team() == TEAM_PROPS then
        target_ply:Kill()
        target_ply:SetTeam(TEAM_HUNTERS)
    elseif target_ply:Team() == TEAM_HUNTERS then
        target_ply:Kill()
        target_ply:SetTeam(TEAM_PROPS)
    elseif target_ply:Team() ~= TEAM_PROPS or TEAM_HUNTERS then
        if team.NumPlayers(TEAM_PROPS) <= team.NumPlayers(TEAM_HUNTERS) then
            target_ply:Kill()
            target_ply:SetTeam(TEAM_PROPS)
        else
            target_ply:Kill()
            target_ply:SetTeam(TEAM_HUNTERS)
        end
    end
    ulx.fancyLogAdmin( calling_ply, "#A has forced #T to switch teams.", target_ply )
end

local forceswap = ulx.command( CATEGORY_NAME, "ulx forceswap", ulx.forceswap, "!forceswap" )
forceswap:defaultAccess( ULib.ACCESS_ADMIN )
forceswap:addParam{ type=ULib.cmds.PlayerArg }
forceswap:help( "Swaps a players team" )

For the record, the original was made by Yeezy Jeezy. I am not a programmer, I stole most of what I added from the gmod wiki and the lua manual.

If wanted, I can change this command to offset the negative kill and death added to the scoreboard.
+1
I miss Yeezy, he was cool