Change teams without respawning?

Hey,
Is it possible to change teams without respawning. like a player will hit F2, change teams, and will not repsawn, but will get new loadout and such at that players locaton. Is this possible, if so… how?

Well you could make so that when the player changes team, the server saves his/her position and then respawn the player and directly after spawning places the player at the location the player was at before changing teams.

Okay, Is there a wiki tutorial on it, or pretty much all need to know is how to get the players position. Thanks btw.

Go find it out yourself.

What?

PLAYER:SetTeam( # ) …

But won’t make the player get the new loadout huh?

gamemode.Call(“PlayerLoadout”, PLAYER)

or

GAMEMODE:PlayerLoadout(PLAYER)

I already have,
Ply:SetTeam set up, and the spawn. If i didnt have the spawn, people would not spawn for the first time…

[lua]
function toDoChangeTeam(ply)
ply:SetTeam(TEAM_WHATEVER)
gamemode.Call(“PlayerLoadout”, ply)
end
[/lua]

That

so do i replace this:



 -------------------------------------------------------------------------
 function team_1( ply ) 
 
     ply:SetTeam( 1 ) //Make the player join team 1
	 ply:StripWeapons( )
	 ply:Spawn ()

 end 


with this:



function toDoChangeTeam(ply)
	ply:SetTeam(TEAM_WHATEVER)
	gamemode.Call("PlayerLoadout", ply)
end


or do i just add that in to the init? thanks

[lua]
meta = GetMetaTable(“Player”)
function meta:ChangeTeam(teamint)
self:SetTeam(teamint)
gamemode.Call(“PlayerLoadout”, self)
return “” …self:Nick()… " " …teamint… “”
end
[/lua]

I originally forgot that SetTeam doesn’t take a string :S woops.

edit:
If you’re just using this once you don’t really need the return line. That’s so you can do something like:
[lua]
if !ply:ChangeTeam(10) then ply:ChangeTeam(2) end
[/lua]

Which is sort of useful, I don’t know. I do that kind of thing oftenish, so it’s useful sometimes. Assuming that the SetTeam function errors when you give it a non-existant team ofc.

I think you still need to strip the player’s weapons.

Can be done in Loadout.

Could also use GAMEMODE:PlayerLoadout(ply) in lieu of gamemode.Call()

Also, this is what I use:
[lua]
local meta = FindMetaTable(“Player”)
function meta:ChangeTeam(teamID)
if teamID and type(teamID) == “number” and self:Team() != teamID and team.GetName(teamID) then --GetName is used to determine is the team exists.
self:SetTeam(teamID)
self:PrintMessage(HUD_PRINTTALK, "You have joined " … team.GetName(teamID))
end
self:Spawn()
end[/lua]

Thanks you guys, got it working,