Page 1 of 1
Kill a player
Posted: Thu Mar 17, 2016 9:26 am
by Jerome69
Hello,
I would like to be able to kill a human player, but the command doesn't work. Can you help me please?
This is the code I'm using :
Syntax: Select all
from engines.server import engine_server
[...]player_list = PagedMenu(title='Liste des joueurs', select_callback=joueurselect)
for player in PlayerIter('human'):
player_list.append(PagedOption(player.name, player.name))
main_menu.close()
player_list.send(index)
def joueurselect(menu, player_index, option):
engine.server.server_command('kill ' + option.value)
And this is the message :
The attachment Command.jpg is no longer available
Is it a bad using of "kill" command?
Thanks for your help
Posted: Thu Mar 17, 2016 10:29 am
by Ayuto
The problem is this line:
Syntax: Select all
engine.server.server_command('kill ' + option.value)
It should look like this:
Syntax: Select all
engine_server.server_command('kill ' + option.value)
However, since I'm not sure if there is a "kill" server command, I would simply use the built-in functionality.
Syntax: Select all
from players.entity import Player
player_list = PagedMenu(title='Liste des joueurs', select_callback=joueurselect)
for player in PlayerIter('human'):
player_list.append(PagedOption(player.name, player.index))
player_list.send(index)
def joueurselect(menu, player_index, option):
selected_player = Player(option.value)
selected_player.slay()
Posted: Thu Mar 17, 2016 12:05 pm
by Jerome69
I added the code but I have this error :
The attachment Sans titre.jpg is no longer available
[EDIT] I didn't see all the change you have done, so i didn't do them. I'll tell you when it will be done

Posted: Thu Mar 17, 2016 12:48 pm
by Ayuto
I guess you are still passing player.name to PagedOption as the second parameter. That's why option.value contains a string.
Posted: Mon Mar 21, 2016 12:07 pm
by Jerome69
Ok it works fine.
But I see when I kill a player, he has "-1" to his result. Is it possible to don't give him -1 to his result?
Thanks
Posted: Mon Mar 21, 2016 2:08 pm
by iPlayer
Well, I guess you can make it up by
Posted: Mon Mar 21, 2016 2:13 pm
by satoon101
Posted: Mon Mar 21, 2016 2:24 pm
by iPlayer
Yep, but I looked the code up and thought that calling increment_frag_count would be better in this case. Because otherwise I don't see a reason to call it ever at all, and using .kills shortcut still calls this function but also requires m_iFrags property.
Posted: Mon Mar 21, 2016 2:31 pm
by satoon101
It only calls it for CS:GO. And, the only reason for that is
this issue. Also, if Valve ever updates the signature of increment_frag_count, that functionality will be broken until we update our data. Whereas, we get the m_iFrags value directly from the DataMap, so it will never be broken. And, currently increment_frag_count only is implemented for the OrangeBox and CS:GO engines, so making a plugin cross-engine/game compatible would be limited.
*Edit: and, to me, using <Player>.kills += <value> just looks a whole lot better.
Posted: Mon Mar 21, 2016 2:35 pm
by iPlayer
I get it. I remember that issue but didn't look up the commit which closed it. Plus I missed that it was GO-only implementation.
Edit: Especially <Player>.kills -= <value>
Posted: Tue Mar 22, 2016 10:49 am
by Jerome69
It works fine, thanks
