*DELETED*

Please post any questions about developing your plugin here. Please use the search function before posting!
Sam
Senior Member
Posts: 100
Joined: Tue Jul 03, 2018 3:00 pm
Location: *DELETED*
Contact:

[H] IClientEntity -> CBaseEntity (CBasePlayer)

Postby Sam » Tue Apr 28, 2020 10:15 pm

[syntax=py]from plugins.info import PluginInfo
from cvars import ConVar
from listeners import OnConVarChanged
from cvars.flags import ConVarFlags
from entities.hooks import EntityPreHook, EntityCondition
from entities.helpers import baseentity_from_pointer
from memory import find_binary, Convention, DataType, make_object
from players.entity import Player
from entities.constants import MoveType
from players.constants import PlayerStates, PlayerButtons
from mathlib import Vector, QAngle
from players import UserCmd
from random import randint
from engines.server import queue_command_string
from core import console_message
from filters.recipients import RecipientFilter

CreateInterface_engine = find_binary('engine')['CreateInterface'].make_function(
Convention.CDECL, # __cdecl
[
DataType.STRING, # const char *
DataType.POINTER, # int *
],
DataType.POINTER # void *
)

CreateInterface_client = find_binary('client')['CreateInterface'].make_function(
Convention.CDECL, # __cdecl
[
DataType.STRING, # const char *
DataType.POINTER, # int *
],
DataType.POINTER # void *
)

p_gEngineClient = CreateInterface_engine('VEngineClient013', None)
p_gClientEntityList = CreateInterface_client('VClientEntityList003', None)

# int IVEngineClient013::GetLocalPlayer(void);
GetLocalPlayer = p_gEngineClient.make_virtual_function(
12, # int GetLocalPlayer();
Convention.THISCALL, # __thiscall
[
DataType.POINTER, # IVEngineClient013*
],
DataType.INT # int
)

# void IClientEntityList::GetClientEntity(int entnum);
GetClientEntity = p_gClientEntityList.make_virtual_function(
3, # void GetClientEntity();
Convention.THISCALL, # __thiscall
[
DataType.POINTER, # p_gClientEntityList*
DataType.INT, # int
],
DataType.POINTER # void
)

index = GetLocalPlayer(p_gEngineClient) # = 1

IClientEntity = GetClientEntity(p_gClientEntityList, index)[/syntax]

How can I convert or get `CBaseEntity` from` IClientEntity`?
Last edited by Sam on Tue Apr 28, 2020 11:24 pm, edited 1 time in total.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [H] IClientEntity -> CBaseEntity (CBasePlayer)

Postby Ayuto » Wed Apr 29, 2020 11:02 am

Can't help you right now, but wanted to leave one hint. You don't need to grab the CreateInterface functions yourself from the libraries. Instead you could simply do the following:

Syntax: Select all

import core

p_gEngineClient = core.get_interface('engine', 'VEngineClient013')
p_gClientEntityList = core.get_interface('client', 'VClientEntityList003')
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [H] IClientEntity -> CBaseEntity (CBasePlayer)

Postby L'In20Cible » Wed Apr 29, 2020 12:49 pm

IClientEntity inherits from IClientUnknown which inherits from IHandleEntity so assuming the client was built with RTTI the following should work:

Syntax: Select all

from entities import HandleEntity
from entities.helpers import baseentity_from_basehandle
from memory import make_object

base_entity = baseentity_from_basehandle(
make_object(HandleEntity, IClientEntity).basehandle
)

Otherwise have a look at IServerTools::GetIServerEntity and grab it from IServerEntity::GetBaseEntity. That said, not sure how I feel helping knowing you have to use an hacked client to run that code.
Sam
Senior Member
Posts: 100
Joined: Tue Jul 03, 2018 3:00 pm
Location: *DELETED*
Contact:

Re: [H] IClientEntity -> CBaseEntity (CBasePlayer)

Postby Sam » Wed Apr 29, 2020 1:19 pm

L'In20Cible wrote:IClientEntity inherits from IClientUnknown which inherits from IHandleEntity so assuming the client was built with RTTI the following should work:

Syntax: Select all

from entities import HandleEntity
from entities.helpers import baseentity_from_basehandle
from memory import make_object

base_entity = baseentity_from_basehandle(
make_object(HandleEntity, IClientEntity).basehandle
)

Otherwise have a look at IServerTools::GetIServerEntity and grab it from IServerEntity::GetBaseEntity. That said, not sure how I feel helping knowing you have to use an hacked client to run that code.

] sp plugin reload AdvancedBunnyHop
[SP] Unloading plugin 'AdvancedBunnyHop'...
[SP] Unable to unload plugin 'AdvancedBunnyHop' as it is not currently loaded.
[SP] Loading plugin 'AdvancedBunnyHop'...

[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\plugins\command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "..\addons\source-python\packages\source-python\plugins\manager.py", line 194, in load
plugin._load()
File "..\addons\source-python\packages\source-python\plugins\instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "..\addons\source-python\plugins\AdvancedBunnyHop\AdvancedBunnyHop.py", line 71, in <module>
make_object(HandleEntity, IClientEntity).basehandle

ValueError: Conversion from "BaseHandle" (<_entities.BaseEntityHandle object at 0x2F7D0278>) to "BaseEntity" failed.


I tried to try with `IServerEntity::GetBaseEntity`, but nothing worked either.
I think it would be better to use offsets rather than trying to get the `CBaseEntity` of another player.

`That said, not sure how I feel helping knowing you have to use an hacked client to run that code.[/quote]` - Patch (I'm not doing this for bad intentions xP [In addition to the latest nightly builds xDD])
Last edited by Sam on Wed Apr 29, 2020 1:19 pm, edited 1 time in total.
Reason: Original post version
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [H] IClientEntity -> CBaseEntity (CBasePlayer)

Postby L'In20Cible » Wed Apr 29, 2020 1:41 pm

Sam wrote:ValueError: Conversion from "BaseHandle" (<_entities.BaseEntityHandle object at 0x2F7D0278>) to "BaseEntity" failed.

Does this return a valid index?

Syntax: Select all

basehandle.entry_index

If so, then perhaps its serial number just can't be validated from-to the server.

Sam wrote:`That said, not sure how I feel helping knowing you have to use an hacked client to run that code.` - Patch (I'm not doing this for bad intentions xP [In addition to the latest nightly builds xDD])
I'm not saying you are, but the fact you label it as "undetected" is quite amusing to be honest. Hard-coded binary patches is the basic an anti-cheat would look for. :tongue:

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 51 guests