dordnung / System2

System2 Extension for Sourcemod
59 stars 16 forks source link

System2_RunThreadCommand Issue #2

Closed sgtaziz closed 7 years ago

sgtaziz commented 9 years ago

Hello! Let me start by saying this is a very nice project, extremely helpful for me as I need to run node multiple times throughout my code.

Now here is my issue: Running System2_RunThreadCommand does not pass the variable. When passing "client," I always receive the value 0 (which is the same thing as undefined.) I've tried this with ints, datapacks, and other types with the same problem. I recommend double checking everything. Also, when stress testing System2_RunThreadCommand, server freezes for a few seconds. I do this by simply calling 'ls' every second. However, this issue might be simply server-specific

Lastly, I recommend adding this stock:

stock String_EscapeSSH(String:str[], strlen)
{
    ReplaceString(str, strlen, "\\", "\\\\");
    ReplaceString(str, strlen, "'", "\\'");
    ReplaceString(str, strlen, ";", "\\;");
    ReplaceString(str, strlen, "`", "\\`");
    ReplaceString(str, strlen, ":", "\\:");
    ReplaceString(str, strlen, "!", "\\!");
    ReplaceString(str, strlen, "#", "\\#");
    ReplaceString(str, strlen, "%", "\\%");
    ReplaceString(str, strlen, "^", "\\^");
    ReplaceString(str, strlen, "&", "\\&");
    ReplaceString(str, strlen, "(", "\\(");
    ReplaceString(str, strlen, ")", "\\)");
    ReplaceString(str, strlen, "{", "\\{");
    ReplaceString(str, strlen, "}", "\\}");
    ReplaceString(str, strlen, ">", "\\>");
    ReplaceString(str, strlen, "<", "\\<");
    ReplaceString(str, strlen, "\"", "\\\"");
}

It is very helpful in case you need to make sure a string is safe to be passed as a variable in SSH. Thanks!

ghost commented 9 years ago

Hey,

I will take a look why it does not pass the variable. I can't change when your server lags at stress testing. When your server is to busy because of the testing than you need and faster server. You can try to use Nice to reduce it.

sgtaziz commented 9 years ago

Don't worry about the lag thing, it was in fact due to a bug with MySQL using 100% cpu usage. I've reconfigured and it works perfectly fine now. It seems as the whole variable passing is the only issue I'm having at the moment.

Thank you for your time and help :)

ghost commented 9 years ago

Good to here. Currently there is no possibility to add additional data to pass to the native.

So i added a new native System2_RunThreadCommandWithData(CmdCallback:callback, any:data = INVALID_HANDLE, const String:command[], any:...)

You need a new build of the extension from here: http://vs.gugyclan.eu:8000/job/System2/lastSuccessfulBuild/artifact/Release/system2.ext.so And the include from here: http://vs.gugyclan.eu:8000/job/System2/lastSuccessfulBuild/artifact/system2.inc

sgtaziz commented 9 years ago

I'm not sure if you're misunderstanding the issue or if I'm misunderstanding your statement, but I'm not trying to pass variables to the command string. I can simply format it before calling. The issue is that any:data is not getting passed along to the CmdCallback for me. It simply receives a 0 no matter what I try.

ghost commented 9 years ago

Yes, because the default System2_RunThreadCommand command does not have a any:data parameter. It only has a any:.. Parameter to format the command string.

So I added:

System2_RunThreadCommandWithData(CmdCallback:callback, any:data = INVALID_HANDLE, const String:command[], any:...).

As you can see, the second parameter is now a any:data parameter :)

sgtaziz commented 9 years ago

Ah! Thank you very much! I appreciate that a lot. Cheers!