Page 1 of 1

[CS:GO] Accept Input Error

Posted: Mon Dec 10, 2018 3:31 pm
by velocity
I'm getting error UnicodeDecodeError with this code:

Syntax: Select all

@EntityPreHook(EntityCondition.is_player, "accept_input")
def pre_accept_input(stack_data):

SayText2("Hello").send()
input_name = stack_data[1]



Syntax: Select all

File "../addons/source-python/plugins/trikzcafe/no_shake_jump.py", line 43, in pre_accept_input

input_name = stack_data[1]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 0: invalid continuation byte


Syntax: Select all

# _ZN11CBaseEntity11AcceptInputEPKcPS_S2_9variant_ti
[[accept_input]]
offset_linux = 42
offset_windows = 41
arguments_linux = STRING, POINTER, POINTER, POINTER, INT
arguments_windows = STRING, POINTER, POINTER, POINTER, POINTER, POINTER, POINTER, POINTER, INT
return_type = BOOL

Re: [CS:GO] Accept Input Error

Posted: Tue Dec 11, 2018 4:57 am
by L'In20Cible
Are you sure your data is up-to-date?

That being said, I'm not even sure why you are hooking this method instead of hooking the inputs your are looking for directly. Basically, an input is only a member method of an entity class. The AcceptInput method is an helper that read the datamap of the entity to retrieve the pointer of the input and then call it. When you are hooking that helper, you will not get called when someone is calling the input directly. For example, your hook will never gets called when a Source.Python plugin is calling an input because we are not passing by that extra layer and we call the input method directly. Anyways, hooking a specific input is quite easy since you can simply use Entity.get_input that returns a Function instance. Here is a basic example:

Syntax: Select all

from entities.constants import WORLD_ENTITY_INDEX
from entities.entity import Entity
from memory.hooks import PreHook

world_entity = Entity(WORLD_ENTITY_INDEX)

@PreHook(world_entity.get_input('Kill'))
def pre_input_kill(stack_data):
if stack_data[0] != world_entity.pointer:
return
print('Don\'t kill the world unless you want to crash... dumbass.')
return False

world_entity.remove()


Alternatively, you could also use EntityPreHook and benefit from the fact you don't have to get an instance first:

Syntax: Select all

from entities.constants import WORLD_ENTITY_INDEX
from entities.entity import Entity
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook

@EntityPreHook(EntityCondition.equals_entity_classname('worldspawn'),
lambda entity: entity.get_input('Kill'))
def pre_input_kill(stack_data):
if stack_data[0] != Entity(WORLD_ENTITY_INDEX).pointer:
return
print('Don\'t kill the world unless you want to crash... dumbass.')
return False

Entity(WORLD_ENTITY_INDEX).remove()

Re: [CS:GO] Accept Input Error

Posted: Tue Dec 11, 2018 10:13 pm
by velocity
Thanks for that, but I still want to know why I get an error

Re: [CS:GO] Accept Input Error

Posted: Wed Dec 12, 2018 3:49 am
by L'In20Cible
velocity wrote:Thanks for that, but I still want to know why I get an error

You are getting an error because whatever is stored into stack_data[1], it cannot be decoded as a string. This can be caused by outdated offset, prototype or even convention; hence why I asked if you are sure your data is up-to-date.