Raised This Month: $12 Target: $400
 3% 

Return server_cmd output to string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Salmus
Junior Member
Join Date: Dec 2007
Old 11-22-2010 , 02:50   Return server_cmd output to string
Reply With Quote #1

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.

Last edited by Salmus; 11-22-2010 at 02:54. Reason: more infos
Salmus is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-22-2010 , 03:20   Re: Return server_cmd output to string
Reply With Quote #2

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 View Post
server_cmd("echo 123"); returns "123"
I don't know where you got that information, but it is wrong.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Salmus
Junior Member
Join Date: Dec 2007
Old 11-22-2010 , 04:32   Re: Return server_cmd output to string
Reply With Quote #3

What I want is to execute a server_cmd and return the output in a string, is it possible ?
Salmus is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-22-2010 , 12:37   Re: Return server_cmd output to string
Reply With Quote #4

You have to use Orpheu.
Here is an example:
https://forums.alliedmods.net/showpo...&postcount=295
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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