Raised This Month: $51 Target: $400
 12% 

Switch team without dying


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cgirerd
Junior Member
Join Date: Jul 2021
Old 07-23-2021 , 06:12   Switch team without dying
Reply With Quote #1

Hello everyone,
I wrote a team balancer for CSDM that works well. The only issue is that I use user_silentkill on the player that needs to be balanced, in order to respawn him and force the team change. The issue is that the items bought in the custom shop are lost, HPs are reset etc..., so I wanted to find a way to transfer the player alive, without having to kill him.
In order to do that, I tried to:
- set the new team for the player using cs_set_user_team(Player, newTeam)
- reset its skin using cs_reset_user_model(Player)
- teleport the user to respawn location using set_pev(Player, pev_origin, SpawnLoc)
The problem with this is that the player / bot still behaves as if he was part of the original team, and not the new one, until he dies. It looks like him dying triggers something on the server that makes it work but... I don't want to kill him. Does anybody know if there is a solution to this problem?
Best,
cgirerd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-23-2021 , 19:06   Re: Switch team without dying
Reply With Quote #2

This could probably be fixed by adding a few saving/loading moments. Save all stats before transfer, Load all stats after transfer. Player ID changes when he transfers to another team.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
cgirerd
Junior Member
Join Date: Jul 2021
Old 07-25-2021 , 04:24   Re: Switch team without dying
Reply With Quote #3

mmmh yes you're right, there are probably two ways: trying to switch team without killing the user by trying to set his new team, skin, teleporting him to new respawn point (but I have issues with that), or saving his "attributes", killing him and resettings his "attributes". I think that there are known functions to get his hp, armor, weapons etc... However, we have a custom shop on the server with things such as double damage, invisibility etc... and I am not sure how to access these information in order to restore them after respawning the player... Do you know any functions that would enable the access of such information?
cgirerd is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-25-2021 , 15:38   Re: Switch team without dying
Reply With Quote #4

You would have to edit the plugins. It's not possible to create a new plugin for that.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-26-2021 , 04:56   Re: Switch team without dying
Reply With Quote #5

http://www.amxmodx.org/api/cstrike/cs_set_user_team
PHP Code:
Sets the client's team without killing the player, and sets the client model. 
What's wrong with cs_set_user_team() ?
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-26-2021 , 05:22   Re: Switch team without dying
Reply With Quote #6

PHP Code:
ExecuteHamB(Ham_CS_RoundRespawnid); 
Try this, You can respawn without killing.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
cgirerd
Junior Member
Join Date: Jul 2021
Old 07-27-2021 , 02:14   Re: Switch team without dying
Reply With Quote #7

Quote:
Originally Posted by Shadows Adi View Post
http://www.amxmodx.org/api/cstrike/cs_set_user_team
PHP Code:
Sets the client's team without killing the player, and sets the client model. 
What's wrong with cs_set_user_team() ?
When using this option on a bot, he still behaves as if he was part of the original team, and not the new one, till he is killed. For a real player, he will think that he is in the new team, but won't be able to do damages to his opponents, only to his teammates. He needs to die for things to work as expected.

Quote:
Originally Posted by +ARUKARI- View Post
PHP Code:
ExecuteHamB(Ham_CS_RoundRespawnid); 
Try this, You can respawn without killing.
This works well, it does respawns a player without killing him, which is great. So thank you for that . However, some items bought in custom shop like double damage etc... seem to be lost during transfer. Not sure how to restore his complete profile...
cgirerd is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-27-2021 , 03:56   Re: Switch team without dying
Reply With Quote #8

There may be a process in Ham_Spawn or Ham_RoundSpawn that resets your custom shop purchases.
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- is offline
cgirerd
Junior Member
Join Date: Jul 2021
Old 08-15-2021 , 20:41   Re: Switch team without dying
Reply With Quote #9

Thanks a lot for all the feedback and ideas! I am contacting the developer of the custom shop directly for hints as this sounds quite challenging for me...
cgirerd is offline
Reply



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 08:58.


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