• Я зарабатываю 100 000 RUB / месяц на этом сайте!

    А знаешь как? Я всего-лишь публикую (создаю темы), а админ мне платит. Трачу деньги на мороженое, робуксы и сервера в Minecraft. А ещё на паль из Китая. 

    Хочешь так же? Пиши и узнавай условия: https://t.me/alex_redact
    Реклама: https://t.me/yougame_official

Вопрос Спектатор лист на python работает неправильно

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
13 Окт 2022
Сообщения
30
Реакции
0
Код:
Expand Collapse Copy
import requests
import pymem
import pymem.process
offsets = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json').json()
client_dll_data = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/client_dll.json').json()
dwEntityList = offsets["client.dll"]["dwEntityList"]
dwLocalPlayerPawn = offsets['client.dll']['dwLocalPlayerPawn']
m_iTeamNum = client_dll_data['client.dll']['classes']['C_BaseEntity']['fields']['m_iTeamNum']
m_hPlayerPawn = 0x80C
m_iszPlayerName = 0x660
m_lifeState = 0x348
m_hObserverTarget = 0x44
def get_spectators():
    pm = pymem.Pymem("cs2.exe")
    client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
    spectators = []
    entity_list = pm.read_longlong(client + dwEntityList)
    entity_ptr = pm.read_longlong(entity_list + 0x10)
    localplayer = pm.read_longlong(client + dwLocalPlayerPawn)
   
    for i in range(1, 64):
        try:
            entity_controller = pm.read_longlong(entity_ptr + 0x78 * (i & 0x1FF))
            if not entity_controller:
                continue
           
            entity_controller_pawn = pm.read_longlong(entity_controller + m_hPlayerPawn)
            if not entity_controller_pawn:
                continue
           
            entity_list_pawn = pm.read_longlong(entity_list + 0x8 * ((entity_controller_pawn & 0x7FFF) >> 0x9) + 0x10)
            if not entity_list_pawn:
                continue
           
            entity_pawn_addr = pm.read_longlong(entity_list_pawn + 0x78 * (entity_controller_pawn & 0x1FF))
            if not entity_pawn_addr:
                continue
           
            entity_alive = pm.read_int(entity_pawn_addr + m_lifeState)
           
           
            observer_target_entity = pm.read_longlong(entity_pawn_addr + m_hObserverTarget)
            observer_target = pm.read_longlong(localplayer + m_hObserverTarget)
            print(observer_target_entity, observer_target)
           
            if observer_target == observer_target_entity and entity_alive != 256:
                name = pm.read_string(entity_controller + m_iszPlayerName, 32)
                spectators.append(name)
               
        except Exception as e:
            print(f"ошибка {e}")
            continue
           
    return spectators
spectators = get_spectators()
print(f"Спектаторы: {spectators}")
Код показывает просто всех мертвых на карте. Я так понял проблема с получением

observer_target_entity, но вроде все правильно, не знаю как пофиксить :(
 
Python:
Expand Collapse Copy
import requests
import pymem
import pymem.process
offsets = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json').json()
client_dll_data = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/client_dll.json').json()
dwEntityList = offsets["client.dll"]["dwEntityList"]
dwLocalPlayerPawn = offsets['client.dll']['dwLocalPlayerPawn']
m_iTeamNum = client_dll_data['client.dll']['classes']['C_BaseEntity']['fields']['m_iTeamNum']
m_hPlayerPawn = 0x80C
m_iszPlayerName = 0x660
m_lifeState = 0x348
m_hObserverTarget = 0x44

def get_local_handle(pm, client):
    localplayer = pm.read_longlong(client + dwLocalPlayerPawn)
    entity_list = pm.read_longlong(client + dwEntityList)
    for i in range(1, 64):
        try:
            entity_controller = pm.read_longlong(entity_list + 0x78 * (i & 0x1FF))
            if not entity_controller:
                continue
            entity_controller_pawn = pm.read_longlong(entity_controller + m_hPlayerPawn)
            if entity_controller_pawn == localplayer:
                return entity_controller_pawn
        except Exception:
            continue
    return None

def get_spectators():
    pm = pymem.Pymem("cs2.exe")
    client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
    local_handle = get_local_handle(pm, client)
    spectators = []
    entity_list = pm.read_longlong(client + dwEntityList)
    for i in range(1, 64):
        try:
            entity_controller = pm.read_longlong(entity_list + 0x78 * (i & 0x1FF))
            if not entity_controller:
                continue
            entity_controller_pawn = pm.read_longlong(entity_controller + m_hPlayerPawn)
            if not entity_controller_pawn:
                continue
            entity_list_pawn = pm.read_longlong(entity_list + 0x8 * ((entity_controller_pawn & 0x7FFF) >> 0x9) + 0x10)
            if not entity_list_pawn:
                continue
            entity_pawn_addr = pm.read_longlong(entity_list_pawn + 0x78 * (entity_controller_pawn & 0x1FF))
            if not entity_pawn_addr:
                continue
            entity_alive = pm.read_int(entity_pawn_addr + m_lifeState)
            observer_target_entity = pm.read_longlong(entity_pawn_addr + m_hObserverTarget)
            if observer_target_entity == local_handle and entity_alive != 256:
                name = pm.read_string(entity_controller + m_iszPlayerName, 32)
                spectators.append(name)
        except Exception:
            continue
    return spectators

spectators = get_spectators()
print(f"Спектаторы: {spectators}")
 
Python:
Expand Collapse Copy
import requests
import pymem
import pymem.process
offsets = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json').json()
client_dll_data = requests.get('https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/client_dll.json').json()
dwEntityList = offsets["client.dll"]["dwEntityList"]
dwLocalPlayerPawn = offsets['client.dll']['dwLocalPlayerPawn']
m_iTeamNum = client_dll_data['client.dll']['classes']['C_BaseEntity']['fields']['m_iTeamNum']
m_hPlayerPawn = 0x80C
m_iszPlayerName = 0x660
m_lifeState = 0x348
m_hObserverTarget = 0x44

def get_local_handle(pm, client):
    localplayer = pm.read_longlong(client + dwLocalPlayerPawn)
    entity_list = pm.read_longlong(client + dwEntityList)
    for i in range(1, 64):
        try:
            entity_controller = pm.read_longlong(entity_list + 0x78 * (i & 0x1FF))
            if not entity_controller:
                continue
            entity_controller_pawn = pm.read_longlong(entity_controller + m_hPlayerPawn)
            if entity_controller_pawn == localplayer:
                return entity_controller_pawn
        except Exception:
            continue
    return None

def get_spectators():
    pm = pymem.Pymem("cs2.exe")
    client = pymem.process.module_from_name(pm.process_handle, "client.dll").lpBaseOfDll
    local_handle = get_local_handle(pm, client)
    spectators = []
    entity_list = pm.read_longlong(client + dwEntityList)
    for i in range(1, 64):
        try:
            entity_controller = pm.read_longlong(entity_list + 0x78 * (i & 0x1FF))
            if not entity_controller:
                continue
            entity_controller_pawn = pm.read_longlong(entity_controller + m_hPlayerPawn)
            if not entity_controller_pawn:
                continue
            entity_list_pawn = pm.read_longlong(entity_list + 0x8 * ((entity_controller_pawn & 0x7FFF) >> 0x9) + 0x10)
            if not entity_list_pawn:
                continue
            entity_pawn_addr = pm.read_longlong(entity_list_pawn + 0x78 * (entity_controller_pawn & 0x1FF))
            if not entity_pawn_addr:
                continue
            entity_alive = pm.read_int(entity_pawn_addr + m_lifeState)
            observer_target_entity = pm.read_longlong(entity_pawn_addr + m_hObserverTarget)
            if observer_target_entity == local_handle and entity_alive != 256:
                name = pm.read_string(entity_controller + m_iszPlayerName, 32)
                spectators.append(name)
        except Exception:
            continue
    return spectators

spectators = get_spectators()
print(f"Спектаторы: {spectators}")
У меня он не выводит даже мертвых,
1741451493670.png
 
Назад
Сверху Снизу