Raised This Month: $64 Target: $400

[ANY] How to properly switch team

Post New Thread Reply   
Thread Tools Display Modes
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 04-02-2019 , 12:14   Re: [ANY] How to properly switch team
Reply With Quote #11

Originally Posted by Whai View Post
For switch to spectator team, you can just use that :
Again, your snippet, while it might work for this particular use case, just remains a workaround the many hidden rules one game might have when using
PHP Code:
PHP Code:
Here you miss the point that my snippet is all about switching a player's team, without changing their current state or calling any game functions.

Originally Posted by Whai View Post
because with your method, we have to check offsets every updates
PHP Code:
hasn't changed in years by Valve, the vtable offsets used today are likely to be still valid in 20 years from now.

Originally Posted by Whai View Post
If you want to change team but not in spectator, just use this
I'm already aware of this method, I've been using it myself for as long as I can remember

Again this misses the point of this snippet, here it's provide something that will work "universally" across all source games. (hence the tag [ANY])
You're not safe from a game where the dev decided that they don't care if the player is alive or not, and will make the player respawn anyway regardless of their state/team upon calling sourcemod's
PHP Code:

While on the other hand the snippet I provided will work, regardless of the set of "hidden" rules behind the function
PHP Code:

Last edited by Benoist3012; 04-02-2019 at 12:16.
Benoist3012 is offline
Veteran Member
Join Date: Jan 2012
Location: Dublin
Old 04-03-2019 , 09:22   Re: [ANY] How to properly switch team
Reply With Quote #12

void ToolsSetClientTeam(int clientIndex, int iValue)
// Validate team
if(GetClientTeam(clientIndex) <= TEAM_SPECTATOR)
// Sets team of the client
ChangeClientTeam(clientIndex, iValue);
// Switch team of the client
CS_SwitchTeam(clientIndex, iValue);
gubka is offline
Send a message via ICQ to gubka Send a message via Skype™ to gubka

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 09:18.

Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode