Resolve file using sourcepython

All other Source.Python topics and issues.
Tetragromaton
Junior Member
Posts: 20
Joined: Tue Mar 03, 2020 6:39 am

Resolve file using sourcepython

Postby Tetragromaton » Tue Mar 31, 2020 2:38 pm

There is an extension that lets you resolve client side file here it is.
So is there anyway to request file from client using sourcepython plugin ?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Resolve file using sourcepython

Postby Ayuto » Thu Apr 02, 2020 8:18 am

Currently, you can only send files, but not request them. And you can listen to file "events" using hooks. But since we have exposed the function info, you can easily create the hooks to listen to those events.
https://github.com/Source-Python-Dev-Te ... p#L73-L106

In a few days I can provide an example or even update SP to do that stuff easily.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Resolve file using sourcepython

Postby Ayuto » Thu Apr 09, 2020 7:53 pm

Here is the promised example:

Syntax: Select all

from players.entity import Player
from entities.hooks import EntityPreHook
from entities.hooks import EntityCondition
from memory import get_virtual_function

def netchannel_hook(func):
def init_hook(base_entity):
player = Player(base_entity.index)
return get_virtual_function(player.client.net_channel.msg_handler, func)

return init_hook

@EntityPreHook(
EntityCondition.is_human_player,
netchannel_hook('FileRequested'))
def pre_file_requested(args):
print('FileRequested', tuple(args))

@EntityPreHook(
EntityCondition.is_human_player,
netchannel_hook('FileReceived'))
def pre_file_rceived(args):
print('FileReceived', tuple(args))

@EntityPreHook(
EntityCondition.is_human_player,
netchannel_hook('FileDenied'))
def pre_file_denied(args):
print('FileDenied', tuple(args))

@EntityPreHook(
EntityCondition.is_human_player,
netchannel_hook('FileSent'))
def pre_file_sent(args):
print('FileSent', tuple(args))

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 22 guests