[Cs:s] PreEvent player_hurt crash

Please post any questions about developing your plugin here. Please use the search function before posting!
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

[Cs:s] PreEvent player_hurt crash

Postby cssbestrpg » Sat Aug 28, 2021 9:27 pm

Hi, why my linux server crashes when i use PreEvent code for making player die.

here is the code crashes:

Syntax: Select all

from players.entity import Player
from events.hooks import PreEvent

@PreEvent('player_hurt')
def player_hurt(args):
if args.get_int('attacker') > 1:
hurter = Player.from_userid(args['attacker'])
victim = Player.from_userid(args['userid'])
if hurter.is_bot():
victim.client_command('kill', True)


Here is the sp info

Code: Select all

[2021-08-29 00:26:37]: --------------------------------------------------------
[2021-08-29 00:26:37]: Checksum : 59e4e4e4182f6803350b42eac3be0519
[2021-08-29 00:26:37]: Date : 2021-08-28 21:26:37.302930
[2021-08-29 00:26:37]: OS : Linux-4.15.0-129-generic-x86_64-with-debian-10.10
[2021-08-29 00:26:37]: Game : css[2021-08-29 00:26:37]: SP version : 705
[2021-08-29 00:26:37]: Github commit : 38e4fe48579f9445b878624a9439ce10e28aa7e6
[2021-08-29 00:26:37]: Server plugins:
[2021-08-29 00:26:37]: 00: Metamod:Source 1.11.0-dev+1144
[2021-08-29 00:26:37]: 01: Source.Python, (C) 2012-2020, Source.Python Team.
[2021-08-29 00:26:37]: SP plugins:
[2021-08-29 00:26:37]: 00: rpg
[2021-08-29 00:26:37]: 01: items
[2021-08-29 00:26:37]: 02: chat
[2021-08-29 00:26:37]: 03: rpgmarket, 1.0.0, https://cssbestrpg.online
[2021-08-29 00:26:37]: 04: zr, 1.6.0, https://forums.sourcepython.com/viewtopic.php?f=7&t=2506
[2021-08-29 00:26:37]: --------------------------------------------------------
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [Cs:s] PreEvent player_hurt crash

Postby L'In20Cible » Sat Aug 28, 2021 10:22 pm

Because you cannot kill a player before it gets hurt. Delay the kill on the next frame:

Syntax: Select all

victim.delay(0, victim.client_command, ('kill', True))

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 21 guests