need working script that acutally switches player for csgo

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Oct 07, 2014 1:00 pm

Well, this can easilly be done with something like that, I guess.[PYTHON]from events import Event
from players.entity import PlayerEntity

silent_players = set()

def switch_team(player, team_index, silent=False):
if silent:
silent_players.add(player.userid)
player.switch_team(team_index)
silent_players.discard(player.userid)

@Event
def player_team(game_event):
if game_event.get_int('userid') not in silent_players:
return
game_event.set_bool('silent', True)[/PYTHON]This will only work on CS:GO, tho since OrangeBox games are not supporting the "silent" variable. Also, the symbol for CBasePlayer::ChangeTeam in the cstrike.ini file is wrong. The right one is "_ZN11CBasePlayer10ChangeTeamEi" since it only accepts the teamid as parameter.
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Oct 07, 2014 1:09 pm

Actually, there are 2 CBasePlayer::ChangeTeam functions. One that only takes an integer and one that takes an integer and 2 boolean values. I added it instead of the simpler one to see if I could get the same to happen in CS:S, which unfortunately did not happen.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Oct 07, 2014 1:33 pm

Now you got me curious since there is only one into the SDK! I guess I will have to launch IDA, hehe. :)
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Fri Oct 31, 2014 4:01 pm

hello its me again what number do I use to switch player to spectator?? i tried 0,1,4,5 already but doesn't work

Code: Select all

CCSPlayer::SwitchTeam( 4 ) - invalid team index.
User avatar
Ayuto
Project Leader
Posts: 2209
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Oct 31, 2014 4:16 pm

The spectator index is 1.
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Fri Oct 31, 2014 4:50 pm

Ayuto wrote:The spectator index is 1.


tried 1 already!
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Oct 31, 2014 5:42 pm

If you are changing to spectator, don't use CCSPlayer::SwitchTeam. Just use the normal Change Team functionality.

*Edit: also, 4 and 5 are certainly not team indexes. I have only known 1 game that even used 4 (pvkii), and that is because there are 3 different teams.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 173 guests