Raised This Month: $64 Target: $400
 16% 

[ANY] How to properly switch team


Post New Thread Reply   
 
Thread Tools Display Modes
Benoist3012
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

Quote:
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:
TF2_ChangeClientTeam 
or
PHP Code:
TF2_RespawnPlayer 
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.


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

Quote:
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
https://github.com/Kenzzer/Slender-F...stocks.sp#L600

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:
ChangeClientTeam 


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

Last edited by Benoist3012; 04-02-2019 at 12:16.
Benoist3012 is offline
gubka
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

FOR CS:GO
Quote:
void ToolsSetClientTeam(int clientIndex, int iValue)
{
// Validate team
if(GetClientTeam(clientIndex) <= TEAM_SPECTATOR)
{
// Sets team of the client
ChangeClientTeam(clientIndex, iValue);
}
else
{
// 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
Reply


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