AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Return server_cmd output to string (https://forums.alliedmods.net/showthread.php?t=143622)

Salmus 11-22-2010 02:50

Return server_cmd output to string
 
Hello,

I would like a little help with amxmodx scripting, I'm trying to store output of server_cmd in a string ... I just can't figure it out howto.

I was thinking at:
Code:

new data = server_cmd("echo MATCHSTRING");
new data_match[30]; copy(data_match, 29, data);

if(contain(data_match, "MATCHSTRING)) {
[...]
}

But, data_match returns nothing, I've tried also with log_to_file(file.log, "%s", server_cmd("echo MATCHSTRING"); - but still doesn't work.


So, the main question is: how can I store return of the server_cmd into a variable ?

server_cmd("echo 123"); returns "123" - I want to store this in a variable.


Note: My server_cmd will return dynamic content, that's why I need to store it into a variable.

Exolent[jNr] 11-22-2010 03:20

Re: Return server_cmd output to string
 
server_cmd() returns the length of the string that you sent to the server's console.
It does not return the output of the command that you send.

Quote:

Originally Posted by Salmus (Post 1354263)
server_cmd("echo 123"); returns "123"

I don't know where you got that information, but it is wrong.

Salmus 11-22-2010 04:32

Re: Return server_cmd output to string
 
What I want is to execute a server_cmd and return the output in a string, is it possible ?

Exolent[jNr] 11-22-2010 12:37

Re: Return server_cmd output to string
 
You have to use Orpheu.
Here is an example:
https://forums.alliedmods.net/showpo...&postcount=295


All times are GMT -4. The time now is 11:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.