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.
PLAYER:SetTeam( # ) …
But won’t make the player get the new loadout huh?
I already have,
Ply:SetTeam set up, and the spawn. If i didnt have the spawn, people would not spawn for the first time…
so do i replace this:
------------------------------------------------------------------------- function team_1( ply ) ply:SetTeam( 1 ) //Make the player join team 1 ply:StripWeapons( ) ply:Spawn () end
function toDoChangeTeam(ply) ply:SetTeam(TEAM_WHATEVER) gamemode.Call("PlayerLoadout", ply) end
or do i just add that in to the init? thanks
meta = GetMetaTable(“Player”)
return “” …self:Nick()… " " …teamint… “”
I originally forgot that SetTeam doesn’t take a string :S woops.
If you’re just using this once you don’t really need the return line. That’s so you can do something like:
if !ply:ChangeTeam(10) then ply:ChangeTeam(2) end
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:
local meta = FindMetaTable(“Player”)
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:PrintMessage(HUD_PRINTTALK, "You have joined " … team.GetName(teamID))
Thanks you guys, got it working,