Page 1 of 1

Few questions

Posted: Sat Apr 05, 2014 10:27 am
by SkinN
Hey guys, :)

I got a few things I'd like to know:

1- How can we change players teams?

2- Does it kill the player?

3- Does it save the players score?

Thanks in advance,

SkinN!

Posted: Sun Apr 06, 2014 2:53 am
by satoon101

Syntax: Select all

# all three of these are exactly the same thing
# they kill the player
<PlayerEntity>.set_team(<value>)
<PlayerEntity>.team = <value>
<PlayerInfo>.change_team(<value>)


# These are also the same thing, but different from the first set
<PlayerEntity>.SetTeam(<value>)
<PlayerEntity>.InputSetTeam(<value>)
All of the above will kill the player if they are alive and also cause a suicide which is -1 on their score/kills. If the player is already dead, the score remains the same.


You can also set the offset directly:

Syntax: Select all

<PlayerEntity>.m_iTeamNum = <value>
But this has side effects that include crashing the server. You should only use this if you intend to almost immediately return them back to their original team.

If you want, you can find the signature for CCSPlayer::SwitchTeam, which does not kill the player and has no side effects other than a message is printed to chat about the team switch. You can also probably hook the usermessage and make sure that specific one is never printed.

Posted: Sun Apr 06, 2014 10:56 am
by SkinN
Are you guys thinking in the future making a function which doesn't kill the player and keeps the players score as it is?

Posted: Sun Apr 06, 2014 1:44 pm
by satoon101
You already can with what I last mentioned in my last post:
satoon101 wrote:If you want, you can find the signature for CCSPlayer::SwitchTeam, which does not kill the player and has no side effects other than a message is printed to chat about the team switch. You can also probably hook the usermessage and make sure that specific one is never printed.
We already have the CBasePlayer::ChangeTeam signature for CSGO, so that is already possible with that game. Though, there are planned changes within the memory and entities packages as to how we handle these. Once those changes are made, we will look to adding that same dynamic function for more games/engines. We will leave the "hook the usermessage" part up to individual scripts, though, as that is not something the plugin should handle on its own.

Posted: Mon Apr 07, 2014 1:42 am
by satoon101
I just pushed the changes I was mentioning to the entities/memory packages. I also tested CBasePlayer::ChangeTeam for CSGO, and it seems if you set the second boolean argument to True, the message is not sent to chat. If the second boolean argument is False, the message will be printed.

Syntax: Select all

from conversions_c import index_from_userid
from events import Event
from players.entity import PlayerEntity

@Event
def player_say(game_event):
player = PlayerEntity(index_from_userid(game_event.get_int('userid')))
text = game_event.get_string('text')
if text == 'one':
player.switch_team(5 - player.team, True, True)
if text == 'two':
player.switch_team(5 - player.team, True, False)
if text == 'three':
player.switch_team(5 - player.team, False, True)
if text == 'four':
player.switch_team(5 - player.team, False, False)

two and four both showed messages, while one and three did not.

I will test this out on CS:S and other OrangeBox games when I get that signature for them, as well.