Sourcepython on Linux (seems very unstable)

All other Source.Python topics and issues.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Sourcepython on Linux (seems very unstable)

Postby velocity » Wed Oct 03, 2018 7:39 pm

So I coded all my plugins locally on a windows CS:GO server, but as soon as I operate Linux, everything just starts crashing :(. I have narrowed down some of the issues.

On Linux operating system Ubuntu 18.04 LTS.

Crashes
  • Syntax: Select all

    @OnPlayerRunCommand
    def on_player_run_cmd(player, cmd):
    if player.get_projectile_ammo('flashbang_projectile') <= 0:
    player.give_named_item('weapon_flashbang')
  • Syntax: Select all

    @OnPlayerRunCommand
    def on_player_run_cmd(player, cmd):
    player.origin.get_distance(Vector(0,0,0))
  • Syntax: Select all

    player.teleport(...)
    without delaying it to the next tick (Delay(0, etc...) crashes server.
All the above snippets of code crash the server.

Bugs
When I try to change the color of a player it works, but changing the alpha value doesn't affect the player. This should be somewhat blue but transparent.

Syntax: Select all

player.color = Color(128, 128, 255, 5)


This is what I have discovered so far, there might be more sadly :( Is there any way this can be fixed since it works perfectly on Windows? Notice that the console log doesn't say anything about an error or other.
Last edited by velocity on Fri Oct 05, 2018 12:47 pm, edited 7 times in total.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Sourcepython on Linux (seems very unstable)

Postby satoon101 » Thu Oct 04, 2018 1:02 am

The alpha issue is not a problem with SP itself. It's the nature of that functionality in CS:GO. Valve did add a cvar that enables setting the player alpha, iirc, but I don't remember what it is.

If you are teleporting within a hooked function, you will have to use a 1 tick delay.

I am not sure about the vector issue. We would have to see more code to know why that is happening.
Image
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: Sourcepython on Linux (seems very unstable)

Postby VinciT » Thu Oct 04, 2018 1:36 am

satoon101 wrote:The alpha issue is not a problem with SP itself. It's the nature of that functionality in CS:GO. Valve did add a cvar that enables setting the player alpha, iirc, but I don't remember what it is.

Satoon's right, setting sv_disable_immunity_alpha to 1 will allow you to change the alpha of the player.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: Sourcepython on Linux (seems very unstable)

Postby velocity » Thu Oct 04, 2018 7:41 am

satoon101 wrote:The alpha issue is not a problem with SP itself. It's the nature of that functionality in CS:GO. Valve did add a cvar that enables setting the player alpha, iirc, but I don't remember what it is.

If you are teleporting within a hooked function, you will have to use a 1 tick delay.

I am not sure about the vector issue. We would have to see more code to know why that is happening.


Alright, but why is there a difference on linux compared to windows? In windows I dont need to add an 1 tick delay?
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: Sourcepython on Linux (seems very unstable)

Postby velocity » Thu Oct 04, 2018 8:03 am

These snippets of code also crash the server on Linux, not windows:

Syntax: Select all

@OnPlayerRunCommand
def on_player_run_cmd(player, cmd):
if player.get_projectile_ammo('flashbang_projectile') <= 0:
player.give_named_item('weapon_flashbang')


Syntax: Select all

@OnPlayerRunCommand
def on_player_run_cmd(player, cmd):
player.origin.get_distance(Vector(0,0,0))
Last edited by velocity on Thu Oct 04, 2018 9:33 pm, edited 1 time in total.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Sourcepython on Linux (seems very unstable)

Postby L'In20Cible » Thu Oct 04, 2018 10:13 am

velocity wrote:Alright, but why is there a difference on linux compared to windows? In windows I dont need to add an 1 tick delay?

Because they are different platforms. There is an issue on Linux when you call a function within a hook (mostly a conflict between DynamicHooks and dyncall or something). That issue is well known for a while; multiple issues on the repo referencing it. Until someone figure it out, dynamically calling a function within a hook will always crash on Linux. Which includes any wrappers directly accessible through SP classes. I guess one of the first step would be to compile and try with the latest version of dyncall since the one we use is 7 years old... I will see if I can find some time to try that in the next few days.
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: Sourcepython on Linux (seems very unstable)

Postby velocity » Thu Oct 04, 2018 12:04 pm

@L'In20Cible That would be much appreciated :), @satoon101 I have posted code examples.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Sourcepython on Linux (seems very unstable)

Postby L'In20Cible » Sat Oct 06, 2018 12:45 pm

velocity wrote:@L'In20Cible That would be much appreciated :)
I really don't know when I will get to test that since I'm quite busy lately and my linux environment is far from being up-to-date but, when I do, I really don't plan to dig further than updating the library which honestly, I don't think will fixes it. Delaying your code to the next frame should suffice in most cases. The only time it wouldn't be viable, is if you want to modify the arguments before the original execution or override the returned value. If what you want to achieve doesn't fall into these 2 cases, then you can just do:

Syntax: Select all

@OnPlayerRunCommand
def on_player_run_cmd(player, cmd):
player.delay(0, give_flashbang, (player,))

def give_flashbang(player):
if player.get_projectile_ammo('flashbang_projectile') <= 0:
player.give_named_item('weapon_flashbang')


This is what I did into Parachute v0.03 and it works just fine. Keep in mind that delaying to the next frame is not even noticeable by players since everything you do anyways is not networked to them right away (hint: it is done on the next frame). :wink:
User avatar
velocity
Senior Member
Posts: 220
Joined: Sat May 10, 2014 6:17 pm

Re: Sourcepython on Linux (seems very unstable)

Postby velocity » Sat Oct 06, 2018 7:59 pm

L'In20Cible wrote:
velocity wrote:@L'In20Cible That would be much appreciated :)
I really don't know when I will get to test that since I'm quite busy lately and my linux environment is far from being up-to-date but, when I do, I really don't plan to dig further than updating the library which honestly, I don't think will fixes it. Delaying your code to the next frame should suffice in most cases. The only time it wouldn't be viable, is if you want to modify the arguments before the original execution or override the returned value. If what you want to achieve doesn't fall into these 2 cases, then you can just do:

'
1. What do I do, if I actually need to modify the arguments before the original execution? This could be important because I use a lot of pre-hooks.

Also it .get_distance causes crash and that is weird man. I just went ahead and made the calculations myself.

Now, I don't know much about source-python behind the scenes, but if I were to attempt to fix it myself, could you point me in the right direction? What files is it that control/cause this behavior? Perhaps you don't know at this point then I'll just have to pull a gun to my head :rolleyes:
I get this feeling that burns inside me when I thought I was being cool - you know - using Linux instead of Windows and then this burning feeling, feels like you get mugged on the street.

Anyways I admire your feedback.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Sourcepython on Linux (seems very unstable)

Postby L'In20Cible » Mon Oct 08, 2018 6:08 am

velocity wrote:1. What do I do, if I actually need to modify the arguments before the original execution? This could be important because I use a lot of pre-hooks.
This would need to be dealt with on a case-by-case basis. For example, you could block the original call to reproduce what it is doing yourself in some situations and simply block to re-call in others, etc. Without a full code and full context proposing more adapted alternatives would be hard.

velocity wrote:Also it .get_distance causes crash and that is weird man. I just went ahead and made the calculations myself.
Are you sure it crashes on the call, and not when retrieving the Vector or using it for instance?

velocity wrote:Now, I don't know much about source-python behind the scenes, but if I were to attempt to fix it myself, could you point me in the right direction? What files is it that control/cause this behavior? Perhaps you don't know at this point then I'll just have to pull a gun to my head :rolleyes:
I get this feeling that burns inside me when I thought I was being cool - you know - using Linux instead of Windows and then this burning feeling, feels like you get mugged on the street.

Anyways I admire your feedback.

Pretty much debugging and tracking the data between the libraries we use; DynamicHooks for hooking and dyncall for calling.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 42 guests