My thoughts, questions and wishes

Discuss API design here.
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 8:08 am

  1. I wish see PlayerIter which can yields custom Player entity from cache.
  2. Can we put get_button_combination_status and ButtonStatus to other place?
  3. Can wee wrap NetChannelInfo like SourceMod did it to Player class to get latency packets info and other stuff without any problems.
  4. Can we add player's object variable which shows current max walk speed. It is depending on weapon wearing by player.
  5. How to determine if player's variable like origin or eye_angle is read-only. Should I copy it or just create sort of reference to it?
  6. How to tweek ListRadioMenu better? For example I can't add new lines to it and can't change appearance of Next and Back buttons.
  7. What's wrong with get_interface from core module on Linux?
  8. Noticed get_public_ip function.in core module which do callls to external site to retrieve the IP. Maybe will be better to get the IP from game memory directly because I think it is there, because server did queries to Steam to verify a player and if you type status on server's console it shows the public IP.
  9. Can we include geoiplite2 module to standard library of site-packsges?
  10. Can we add threaded sqlite/mysql/other db system like did it SourceMod by default?
  11. Do you really recommend SQLAlchemy instead native toolkits?
  12. What about adding primitive functions to get players netprops from index for example in players.helpers module?
  13. How to print a message to player's console directly?
  14. Does it mean that I can't hook virtual function only, because like I understand virtual function offset serves only for searching main function ? For PreHook PostHook and EntityPostHook EntityPreHook. It is already awesome to have global hooks by default but with native virtual functions it will be more awesome.
  15. Can we improve mathlib externally, for example adding normalize_angle like helper or rotation on some degree Vector or rectangle, box?
  16. Wish to see on_auomatically_removed function in Player class if it has internal caching .
  17. Do you know that Colors module doesn't work properly in CS:GO because there is other color system, not RGB like orangebox games.
  18. Can I disable logging and translating text at all?
  19. Also I not satisfied with default settings module, because as.I remember I couldnt store integer in 0 to 3 values only and the settings module registers a menu that I couldn't stop.
  20. Is it really to replace standard Player class to class inhtrenatjeed from it in your API in various listeners?
Sorry for the examination.
Last edited by Ayuto on Fri Dec 27, 2019 11:18 am, edited 1 time in total.
Reason: Utilize [list=1] to be able to reference specific points in a discussion
User avatar
satoon101
Project Leader
Posts: 2609
Joined: Sat Jul 07, 2012 1:59 am

Re: My thoughts, questions and wishes

Postby satoon101 » Fri Dec 27, 2019 1:34 pm

For many of these items, you are more than welcome to create a Pull Request for each individually. Even though I haven't been very involved in SP for a while now, I'll try to respond to a few of these.

1. You can already do that fairly easily by creating your own iteration class:

Syntax: Select all

from entities.helpers import index_from_edict
from filters.players import PlayerIter
from players import PlayerGenerator
from players.entity import Player

class MyPlayer(Player):
pass

class MyPlayerIter(PlayerIter):
@staticmethod
def iterator():
for edict in PlayerGenerator():
yield MyPlayer(index_from_edict(edict))

However, I do realize that it might be nice to have the ability to set your yield class and instead make it something more like:

Syntax: Select all

from filters.players import PlayerIter
from players.entity import Player

class MyPlayer(Player):
pass

class MyPlayerIter(PlayerIter):
yield_class = MyPlayer

# Or even
for player in PlayerIter('human', yield_class=MyPlayer):
pass


6. The default menus are just that, defaults. If you wish to be able to make changes, again, feel free to inherit from them and make your changes. The defaults are what most people prefer to use and allow us to standardize the look that users experience. There are ways to change certain aspects of them, as well. For instance, not that this is exactly what you're looking for, but in GunGame I added a couple other ways to display things in the menus:
https://github.com/GunGame-Dev-Team/Gun ... options.py

13. That's easy enough:

Syntax: Select all

from messages import HudDestination, TextMsg

TextMsg(message, HudDestination.CONSOLE).send(*users, **tokens)


17. Yes, there isn't much we can do, we are limited by the game itself, since it does not allow for the same color system as other games. I'm not sure what you want us to do about it..

18. I would highly recommend against disabling all logging, but you can set it to 'critical only' by setting "level" to 0 under the LOG_SETTINGS in your server's ../cfg/source-python/core_settings.ini. I'm not sure why you would want to disable translations, that honestly doesn't make any sense to me.

19. I'm not entirely sure what you're saying there. For integers, you can set min/max values, which will only be restricted in the menu, I believe. I never did completely finish the ideas I had in the settings module, but I also don't remember what was left to do.
Image
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 2:13 pm

satoon101 wrote:For many of these items, you are more than welcome to create a Pull Request for each individually.

I don't know maybe API better to write only in C++, and my knowledge with it, is only reading source-sdk.
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 4:07 pm

I can create a pull request with some features related to INetChannelnfo in Player class using only Python if you give me the go ahead so that I don't suffer for nothing.
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:15 pm

3.

Code: Select all

from engines.server import engine_server
pl_inf = engine_server.get_player_net_info( 1 ) # ARGS: Player Index
print(f"Channel name = {pl_inf.name}")
print(f"Net address of the player = {pl_inf.address}")
print(f"Current net time = {pl_inf.time}")
print(f"Amount of time the player has been connected = {pl_inf.time_connected}")
print(f"Packet history size = {pl_inf.buffer_size}")
print(f"Send data rate in bytes/second = {pl_inf.data_rate}")
print(f"Is loopback = {pl_inf.is_loopback()}")
print(f"Channel is timing out = {pl_inf.is_timing_out()}")
print(f"Is demo playback = {pl_inf.is_playback()}")
print(f"Current latency (RTT) = {pl_inf.get_latency()}")
print(f"Average latency in seconds = {pl_inf.get_avg_latency()}")
print(f"Average packet loss = {pl_inf.get_avg_loss()}")
print(f"Average packet choke = {pl_inf.get_avg_choke()}")
print(f"Average data flow in bytes/second = {pl_inf.get_avg_data()}")
print(f"Average packets/second = {pl_inf.get_avg_packets()}")
print(f"Total flow in/out in bytes = {pl_inf.get_total_data()}")
print(f"Last sent sequence number = {pl_inf.get_sequence_number()}")
print(f"True if the packet was not lost, dropped, choked or flushed = {pl_inf.is_valid_packet()}")
print(f"Time when the packet was sent = {pl_inf.get_packet_time()}")
print(f"Group size of this packet = {pl_inf.get_packet_bytes()}")
print(f"TCP progress if transmitting = {pl_inf.get_stream_progress()}")
print(f"Time since the last received packet in seconds = {pl_inf.time_since_last_received}")
It's a trap!
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:25 pm

8.
Not bad but not always working.
It's a trap!
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 4:27 pm

Sam wrote:3.

Code: Select all

from engines.server import engine_server
pl_inf = engine_server.get_player_net_info( 1 ) # ARGS: Player Index
print(f"Channel name = {pl_inf.name}")
print(f"Net address of the player = {pl_inf.address}")
print(f"Current net time = {pl_inf.time}")
print(f"Amount of time the player has been connected = {pl_inf.time_connected}")
print(f"Packet history size = {pl_inf.buffer_size}")
print(f"Send data rate in bytes/second = {pl_inf.data_rate}")
print(f"Is loopback = {pl_inf.is_loopback()}")
print(f"Channel is timing out = {pl_inf.is_timing_out()}")
print(f"Is demo playback = {pl_inf.is_playback()}")
print(f"Current latency (RTT) = {pl_inf.get_latency()}")
print(f"Average latency in seconds = {pl_inf.get_avg_latency()}")
print(f"Average packet loss = {pl_inf.get_avg_loss()}")
print(f"Average packet choke = {pl_inf.get_avg_choke()}")
print(f"Average data flow in bytes/second = {pl_inf.get_avg_data()}")
print(f"Average packets/second = {pl_inf.get_avg_packets()}")
print(f"Total flow in/out in bytes = {pl_inf.get_total_data()}")
print(f"Last sent sequence number = {pl_inf.get_sequence_number()}")
print(f"True if the packet was not lost, dropped, choked or flushed = {pl_inf.is_valid_packet()}")
print(f"Time when the packet was sent = {pl_inf.get_packet_time()}")
print(f"Group size of this packet = {pl_inf.get_packet_bytes()}")
print(f"TCP progress if transmitting = {pl_inf.get_stream_progress()}")
print(f"Time since the last received packet in seconds = {pl_inf.time_since_last_received}")

I know, it's easy but maybe it will be better to do so:

Syntax: Select all

from players.entity import Player

player = Player(1)
print(player.get_latency())
print(player.get_avg_latency())
print(player.get_data_rate())
print(player.connected_time)
...

Also traffic can be outgoing, incoming or both:
http://wiki.sourcepython.com/developing ... el.NetFlow
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:27 pm

9.
If it can be installed on Python 3.8, then there is such a possibility. It happens that some cannot be installed. Like Lupa (Lua 5.3 for Python)
It's a trap!
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:30 pm

InvisibleSoldiers wrote:
Sam wrote:3.

Code: Select all

from engines.server import engine_server
pl_inf = engine_server.get_player_net_info( 1 ) # ARGS: Player Index
print(f"Channel name = {pl_inf.name}")
print(f"Net address of the player = {pl_inf.address}")
print(f"Current net time = {pl_inf.time}")
print(f"Amount of time the player has been connected = {pl_inf.time_connected}")
print(f"Packet history size = {pl_inf.buffer_size}")
print(f"Send data rate in bytes/second = {pl_inf.data_rate}")
print(f"Is loopback = {pl_inf.is_loopback()}")
print(f"Channel is timing out = {pl_inf.is_timing_out()}")
print(f"Is demo playback = {pl_inf.is_playback()}")
print(f"Current latency (RTT) = {pl_inf.get_latency()}")
print(f"Average latency in seconds = {pl_inf.get_avg_latency()}")
print(f"Average packet loss = {pl_inf.get_avg_loss()}")
print(f"Average packet choke = {pl_inf.get_avg_choke()}")
print(f"Average data flow in bytes/second = {pl_inf.get_avg_data()}")
print(f"Average packets/second = {pl_inf.get_avg_packets()}")
print(f"Total flow in/out in bytes = {pl_inf.get_total_data()}")
print(f"Last sent sequence number = {pl_inf.get_sequence_number()}")
print(f"True if the packet was not lost, dropped, choked or flushed = {pl_inf.is_valid_packet()}")
print(f"Time when the packet was sent = {pl_inf.get_packet_time()}")
print(f"Group size of this packet = {pl_inf.get_packet_bytes()}")
print(f"TCP progress if transmitting = {pl_inf.get_stream_progress()}")
print(f"Time since the last received packet in seconds = {pl_inf.time_since_last_received}")

I know, it's easy but maybe it will be better to do so:

Syntax: Select all

from players.entity import Player

player = Player(1)
print(player.get_latency())
print(player.get_avg_latency())
print(player.get_data_rate())
print(player.connected_time)
...

Also traffic can be outgoing, incoming or both:
http://wiki.sourcepython.com/developing ... el.NetFlow


Who's stopping you from rewriting the code?

Code: Select all

player.get_latency = engine_server.get_player_net_info( player.index ).get_latency # If you try, you can write better
It's a trap!
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 4:33 pm

Sam wrote:http://wiki.sourcepython.com/developing ... el.NetFlow

Who's stopping you from rewriting the code?

Code: Select all

player.get_latency = engine_server.get_player_net_info( player.index ).get_latency # If you try, you can write better

This is a little confusing for a scripting language and for beginners. For example, I was not immediately able to find out how to get this net information, the forums helped.
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 4:37 pm

Sam wrote:9.
If it can be installed on Python 3.8, then there is such a possibility. It happens that some cannot be installed. Like Lupa (Lua 5.3 for Python)

it should be possible also in Python 3.8 because why would they lose their customer base, but we are on Python 3.6 if i remember, and i installed it without any problems.
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:39 pm

13.
Without my notes, I cannot help with this. Try to search for a way in API and what do you dislike about `TextMsg("Hell", HudDestination.CONSOLE).send()`?
It's a trap!
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:43 pm

InvisibleSoldiers wrote:
Sam wrote:9.
If it can be installed on Python 3.8, then there is such a possibility. It happens that some cannot be installed. Like Lupa (Lua 5.3 for Python)

it should be possible also in Python 3.8 because why would they lose their customer base, but we are on Python 3.6 if i remember, and i installed it without any problems.


Well... viewtopic.php?f=31&t=1749
It's a trap!
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 4:44 pm

Sam wrote:13.
Without my notes, I cannot help with this. Try to search for a way in API and what do you dislike about `TextMsg("Hell", HudDestination.CONSOLE).send()`?

I didn't know about it, but looking for SourceMod, there is a special function https://sm.alliedmods.net/new-api/conso ... tToConsole , but it's probably wrong to compare Pawn and Python because Python it's all-around language, and Pawn is sort of embedding language like Lua and we're getting closer to native Source SDK usage.
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:49 pm

InvisibleSoldiers wrote:
Sam wrote:http://wiki.sourcepython.com/developing ... el.NetFlow

Who's stopping you from rewriting the code?

Code: Select all

player.get_latency = engine_server.get_player_net_info( player.index ).get_latency # If you try, you can write better

This is a little confusing for a scripting language and for beginners. For example, I was not immediately able to find out how to get this net information, the forums helped.


1. Download Source.Python Source Code
2. Learn Wiki (Can not)
3. Have an IQ over 90
4. Using Visual Studio Code to find API functions (Can another editor)
5. Ask for help on the forum, and within a week you will definitely get an answer, if possible
It's a trap!
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:51 pm

InvisibleSoldiers wrote:
Sam wrote:13.
Without my notes, I cannot help with this. Try to search for a way in API and what do you dislike about `TextMsg("Hell", HudDestination.CONSOLE).send()`?

I didn't know about it, but looking for SourceMod, there is a special function https://sm.alliedmods.net/new-api/conso ... tToConsole , but it's probably wrong to compare Pawn and Python because Python it's all-around language, and Pawn is sort of embedding language like Lua and we're getting closer to native Source SDK usage.


I think it's silly to compare SM with SP xD
It's a trap!
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 4:52 pm

Sam wrote:
InvisibleSoldiers wrote:
Sam wrote:13.
Without my notes, I cannot help with this. Try to search for a way in API and what do you dislike about `TextMsg("Hell", HudDestination.CONSOLE).send()`?

I didn't know about it, but looking for SourceMod, there is a special function https://sm.alliedmods.net/new-api/conso ... tToConsole , but it's probably wrong to compare Pawn and Python because Python it's all-around language, and Pawn is sort of embedding language like Lua and we're getting closer to native Source SDK usage.


I think it's silly to compare SM with SP xD


I wonder when SL (Source Lua) will appear xD
It's a trap!
User avatar
InvisibleSoldiers
Member
Posts: 94
Joined: Fri Mar 15, 2019 6:08 am

Re: My thoughts, questions and wishes

Postby InvisibleSoldiers » Fri Dec 27, 2019 5:00 pm

Sam wrote:
Sam wrote:
InvisibleSoldiers wrote:I didn't know about it, but looking for SourceMod, there is a special function https://sm.alliedmods.net/new-api/conso ... tToConsole , but it's probably wrong to compare Pawn and Python because Python it's all-around language, and Pawn is sort of embedding language like Lua and we're getting closer to native Source SDK usage.


I think it's silly to compare SM with SP xD


I wonder when SL (Source Lua) will appear xD

Yeah, i thought about it too, but there must be reasons for Ayuto in preference of Python instead Lua.
User avatar
Sam
Member
Posts: 73
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: My thoughts, questions and wishes

Postby Sam » Fri Dec 27, 2019 5:22 pm

InvisibleSoldiers wrote:
Sam wrote:
Sam wrote:
I think it's silly to compare SM with SP xD


I wonder when SL (Source Lua) will appear xD

Yeah, i thought about it too, but there must be reasons for Ayuto in preference of Python instead Lua.


Lua is fast but little functional and difficult to learn.
I wanted to use it as a replacement for dll, so
It's a trap!
User avatar
satoon101
Project Leader
Posts: 2609
Joined: Sat Jul 07, 2012 1:59 am

Re: My thoughts, questions and wishes

Postby satoon101 » Fri Dec 27, 2019 6:02 pm

InvisibleSoldiers wrote:Yeah, i thought about it too, but there must be reasons for Ayuto in preference of Python instead Lua.

Source.Python started as EventScripts 3, but since we were abandoning backwards compatibility, we changed the name to Source.Python. At the time, the lead C++ developer was your-name-here, who also had a project called Source-Python-Extensions that allowed for memory hacking in EventScripts v2. So that is where the name for Source.Python originates.
Image

Return to “API Design”

Who is online

Users browsing this forum: No registered users and 13 guests