Heads up

All other Source.Python topics and issues.
SkinN
Junior Member
Posts: 25
Joined: Fri Jul 19, 2013 7:29 am

Heads up

Postby SkinN » Wed Mar 26, 2014 6:55 am

Hi,

Point #1
----------
For sometime that I have been wanting to explore SourcePython, I haven't really got the time lately, but now I'm trying to get a bit more into it. I can see, and it's pretty obvious that you guys still have a hard work to do, and I believe that there is still lots of things to be done, and improvements to make, so don't take the following questions as of "pressure" but "heads up" on how development is going, and kinda of an exchange of ideas for what I would like to see. And I also must say that I will be bringing a lot of ES comparison questions because I've been coding on ES for the last 2 years and as far as I can see SP is way more advance when it comes to code, I've seen a lot of things that I'm not familiar with. But don't worry I'm going to ask all at once, because I know most of these things take time and practice to learn them all. I guess I'm too comfortable to how simple is to code in ES, and I believe with SP it's the time to go more advanced.

Point #2
----------
The thing I want to do the most is to bringing my script (SAM) from CS:S to GO to with SP, and perhaps to CS:S aswell, for now I've been thinking on what is worth doing in GO since GO more complete than Source is.
And in ES there's some details that I would like to know if you guys are going to "fix" or do like:

1 #
Are you guys thinking on thinking on functions to mute people?
EXP: player.mute(0 or 1) | player.gag(0 or 1) - Like you could do with playerlib on ES, with noclip or godmode, and so on.

2 #
I don't know if this sounds worth enough for you, but I always thought of a server-side sayfilter, so we could prevent messages from the server, or modify them on our will.

3 #
I am not really familiar to SQL, but what about a lib that could work like keyvalues in ES?
EXP functions:
db = sql.connect(database)
db = sql.createtable(<tablename>)
db = sql.commit(database)
db = cursor()
and functions to get/set data easily to the DB.

Point #3
----------
I'm sorry if most of this is pointless, and if I seem like some nab that does not know what he is talking about, because I am, and here I am trying to learn something. :)
Again I do not have much of experience, but I do look forward for SP and I really want to start working in something, I just wanted to know how things going to be in the future of SP.

PS: Sorry for the large "poem".

SkinN!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Mar 26, 2014 12:39 pm

1: I think muting is definitely something I would like to look into adding at some point. I would say it will most likely be implemented at some point, but I don't know when.

2: That is already "possible" with the dynamic function hooking we have in place (same with SPE), though I would say Ayuto and L'In20Cible are the 2 that would be best at asking how to do that.

3: That is certainly possible. I actually tried to see if I could find a good sqlite3 dictionary-type package to handle our user settings database, since I had no prior experience with SQL. Luckily I was able to work with ashbash, who has a good amount of experience with it, and get that sorted out. I am not sure we plan on creating a package to do this ourselves, but if anyone did, it would certainly get considered for inclusion in the plugin. In case you want to look at the user settings code we use:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/settings/storage.py
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Mar 26, 2014 6:04 pm

SkinN wrote:I don't know if this sounds worth enough for you, but I always thought of a server-side sayfilter, so we could prevent messages from the server, or modify them on our will.
I didn't test but, something like this should works:

Syntax: Select all

from messages import SayText2
from commands.server import ServerCommand

@ServerCommand('say')
def server_say_callback(command):

# Get the message...
message = command.get_arg_string()

# Is the server trying to say 'lol'?
if message.lower() == 'lol':

# We don't want the server to laugh...
return

# Here we can send the message...
SayText2(message='(CONSOLE) %s' % message).send()
SkinN
Junior Member
Posts: 25
Joined: Fri Jul 19, 2013 7:29 am

Postby SkinN » Wed Mar 26, 2014 6:17 pm

L'In20Cible wrote:I didn't test but, something like this should works:

Syntax: Select all

from messages import SayText2
from commands.server import ServerCommand

@ServerCommand('say')
def server_say_callback(command):

# Get the message...
message = command.get_arg_string()

# Is the server trying to say 'lol'?
if message.lower() == 'lol':

# We don't want the server to laugh...
return

# Here we can send the message...
SayText2(message='(CONSOLE) %s' % message).send()


That is a good example, but not really what I tried to mention, I meant any messages, for example in CS:S was pretty annoying doing our own connected/disconnected messages when the server would still have its own right next to ours, and I believe without SPE it was not possible to remove them. With some kind of console filter/listener, if we could remove messages would be pretty cool.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Wed Mar 26, 2014 6:48 pm

Something like this should block the connect/disconnect messages:

Syntax: Select all

from memory import get_object_pointer
from memory import make_object
from memory import Convention, Argument, Return
from events import GameEvent
from events.manager import GameEventManager
from memory.hooks import PreHook
from core import PLATFORM

FIRE_EVENT_FUNC = get_object_pointer(GameEventManager).make_virtual_function(
7 if PLATFORM == 'windows' else 8,
Convention.THISCALL,
(Argument.POINTER, Argument.POINTER, Argument.BOOL),
Return.VOID
)

@PreHook(FIRE_EVENT_FUNC)
def pre_fire_event(arguments):
game_event = make_object(GameEvent, arguments[1])
if game_event.get_name() in ('player_team', 'player_connect', 'player_disconnect'):
arguments[2] = True
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Sun Mar 30, 2014 3:05 pm

PreHook is not documented atm, right? (Nothing from "memory" is?)

I couldn't find it on the wiki. (As I've been searching for it for a while, hehe.)
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sun Mar 30, 2014 3:50 pm

Yep, it's not documented and the memory_c docs are a little bit out-dated. I will update them when I get the chance. For now take a look at the source code. :P
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Sun Mar 30, 2014 6:05 pm

Ayuto wrote:Yep, it's not documented and the memory_c docs are a little bit out-dated. I will update them when I get the chance. For now take a look at the source code. :P


Okay, wonderful!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Mar 31, 2014 2:13 am

The jist of the PreHook and PostHook decorators is that they automatically register and unregister the hook for you. So, you can use a Function instance's hook/unhook methods directly:

Syntax: Select all

from memory import HookType

def load():
<myFunction>.add_hook(HookType.PRE, pre_function)

# or
<myFunction>.add_post_hook(post_function)

def unload():
<myFunction>.remove_hook(HookType.POST, post_function)

# as well as
<myFunction>.remove_pre_hook(pre_function)

def pre_function(arguments):
pass

def post_function(arguments):
pass

Or, you can just use the decorators:

Syntax: Select all

from memory.hooks import PreHook
from memory.hooks import PostHook

@PreHook(<myFunction>)
def pre_function(arguments):
pass

@PostHook(<myFunction>)
def post_function(arguments):
pass


Note that "Function" is a type of object you can get when you have a Pointer instance, and use its make_function or make_virtual_function method. Those are not on the wiki, currently, either, but we'll work on that when we can.
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Tue Apr 01, 2014 8:48 pm

Okay, I can see the similarities between your and L'In20Cible's examples and SPE, however I noticed that there are signature files included (for CSGO) in the data files. Does this mean that this'll also be provided for hooks, or is it something which is meant for internal SP use? I haven't seen any examples on this. (My bad if I missed them.)

Also, Posthook!? What does this entail, you surely can't alter something after it has happened, does this mean that it'll function more like an event? (Which would be cool, since I've run into occasions where that would have been handy in SPE.)

Also, since I haven't done this, thanks for your time, helpfulness and for this project in general (aimed towards all developers!), it really does look powerful and a better designed system overall when compared to ES, it'll just take some time getting used to! I'm really exited!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Apr 01, 2014 8:57 pm

PostHooks can be used for a few things. One specific example I intend to use it for is moving players back to their original team in Free-For-All, since not doing so will cause crashing. With ES/SPE, we just used a gamethread delay for this. Another is that you can change the value the function returns. Even though the function has already been executed, at the time the PostHook is called, it has not returned to its caller.

The data files will be changed a bit here shortly. The current ones work (with the exception of Remove), and can even be used by BaseEntity/PlayerEntity. To see the linked attributes for these, go to your ../data/source-python/entities/functions/ folder. All dynamic functions are Function instances, and therefor can be used with Pre/PostHooks.

Sorry for the lack of examples. Again, we are going to be having some major changes website-wise here soon, so after that we intend on really getting some examples out and the wiki updated. Bare with us, we'll get there.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Apr 01, 2014 9:06 pm

satoon101 wrote:The current ones work (with the exception of Remove)

Syntax: Select all

from tools_c import ServerTools

# A super usefull script that remove the world and crash the server when loaded. It is a must for every servers!
ServerTools.remove_entity(0)

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 73 guests