Few questions

Please post any questions about developing your plugin here. Please use the search function before posting!
SkinN
Junior Member
Posts: 25
Joined: Fri Jul 19, 2013 7:29 am

Few questions

Postby SkinN » Sat Apr 05, 2014 10:27 am

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!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Apr 06, 2014 2:53 am

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.
SkinN
Junior Member
Posts: 25
Joined: Fri Jul 19, 2013 7:29 am

Postby SkinN » Sun Apr 06, 2014 10:56 am

Are you guys thinking in the future making a function which doesn't kill the player and keeps the players score as it is?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Apr 06, 2014 1:44 pm

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.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Apr 07, 2014 1:42 am

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 19 guests