Page 1 of 1

Sourcepython on Linux (seems very unstable)

Posted: Wed Oct 03, 2018 7:39 pm
by velocity
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.

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 1:02 am
by satoon101
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.

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 1:36 am
by VinciT
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.

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 7:41 am
by velocity
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?

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 8:03 am
by velocity
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))

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 10:13 am
by L'In20Cible
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.

Re: Sourcepython on Linux (seems very unstable)

Posted: Thu Oct 04, 2018 12:04 pm
by velocity
@L'In20Cible That would be much appreciated :), @satoon101 I have posted code examples.

Re: Sourcepython on Linux (seems very unstable)

Posted: Sat Oct 06, 2018 12:45 pm
by L'In20Cible
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:

Re: Sourcepython on Linux (seems very unstable)

Posted: Sat Oct 06, 2018 7:59 pm
by velocity
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.

Re: Sourcepython on Linux (seems very unstable)

Posted: Mon Oct 08, 2018 6:08 am
by L'In20Cible
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.