Hooked 'end_touch' function crashes server when weapon is picked up
Posted: Thu Jul 05, 2018 8:32 pm
Hello,
There is an example of plugin for debugging 'end_touch' hooks.
When plugin is loaded and I try to pick up a weapon server "crashes" .
Source.Python info:
Plugin code:
Console output:
I've tried to fix it with filtering,
but it only suppresses console output and server still crashes.
Reproducing crash:
1. Start server/game (with -condebug launch option for generating console.log)
2. Load this plugin
3. Drop weapon, then try to pick it up
4. Server/game "crashes" (writing to console output still works so exit server/game to avoid big console.log file)
Is there a way to fix this?
Thanks for help.
There is an example of plugin for debugging 'end_touch' hooks.
When plugin is loaded and I try to pick up a weapon server "crashes" .
Source.Python info:
Code: Select all
--------------------------------------------------------
Checksum : d2a4f6977f9edad7c5e6ebf1c7b44b6a
Date : 2018-07-05 17:53:13.616464
OS : Windows-7-6.1.7601-SP1
Game : css
SP version : 654
Github commit : 972547be070e74a3f785284cefef53d98fab83c8
Server plugins:
00: Source.Python, (C) 2012-2018, Source.Python Team.
SP plugins:
00: test
--------------------------------------------------------
Plugin code:
Syntax: Select all
# ../test/test.py
from entities.hooks import EntityPostHook
from entities.hooks import EntityPreHook
from entities.hooks import EntityCondition
from entities.helpers import index_from_pointer
from messages.base import SayText2
@EntityPreHook(EntityCondition.is_player, 'end_touch')
def pre_ent_end_touch(args):
index1 = index_from_pointer(args[0])
index2 = index_from_pointer(args[1])
print(f"Pre End Touched: {index1} Touching: {index2}")
# SayText2(f"Pre End Touched: {index1} Touching: {index2}").send()
@EntityPostHook(EntityCondition.is_player, 'end_touch')
def post_ent_end_touch(args, ret):
index1 = index_from_pointer(args[0])
index2 = index_from_pointer(args[1])
print(f"Post End Touched: {index1} Touching: {index2}")
# SayText2(f"Post End Touched: {index1} Touching: {index2}").send()
Console output:
Code: Select all
[...]
Counter-Strike: Source
Map: de_dust2
Players: 1 / 16
Build: 4017558
Server Number: 1
[...]
Pre End Touched: 0 Touching: 1
Post End Touched: 0 Touching: 1
Pre End Touched: 1 Touching: 0
Post End Touched: 1 Touching: 0
Pre End Touched: 45 Touching: 1
Post End Touched: 45 Touching: 1
Pre End Touched: 0 Touching: 1
Post End Touched: 0 Touching: 1
Pre End Touched: 1 Touching: 0
Post End Touched: 1 Touching: 0
Pre End Touched: 45 Touching: 1
Pre End Touched: 1 Touching: 1 # moment when weapon is picked up
Post End Touched: 1 Touching: 1
Post End Touched: 1 Touching: 1
Post End Touched: 1 Touching: 1
Post End Touched: 1 Touching: 1
# Rest of console output is endless stream of "Post End Touched: 1 Touching: 1", ends when server is closed
I've tried to fix it with filtering,
Syntax: Select all
if index1 == index2:
return
but it only suppresses console output and server still crashes.
Reproducing crash:
1. Start server/game (with -condebug launch option for generating console.log)
2. Load this plugin
3. Drop weapon, then try to pick it up
4. Server/game "crashes" (writing to console output still works so exit server/game to avoid big console.log file)
Is there a way to fix this?
Thanks for help.