Dinkleberg's GMod
Change to Forceswap command - Printable Version

+- Dinkleberg's GMod (https://www.dinklebergsgmod.com/site)
+-- Forum: Prop Hunt (https://www.dinklebergsgmod.com/site/forumdisplay.php?fid=4)
+--- Forum: PH Suggestions & Help (https://www.dinklebergsgmod.com/site/forumdisplay.php?fid=11)
+--- Thread: Change to Forceswap command (/showthread.php?tid=12853)



Change to Forceswap command - RussEfarmer - 10-20-2020

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.


RE: Change to Forceswap command - Deer-ly - 10-20-2020

+1


RE: Change to Forceswap command - lacer - 10-21-2020

I miss Yeezy, he was cool