Sending a webrequest on command? (C#)
Discussion in 'Rust Development' started by Secret Santa, Jun 20, 2016.
-
@Secret Santa
Might be useful if you could show the community what your code is and the error thrown by the Oxide debugger. -
I do not know much about c#.
I've looked and read on docs.oxidemod.org but everything is old old code.
If not difficult give an example of how to create when you enter the chat command to send a Post request. -
Wulf Community Admin
It's not old code, but if you can show us, we'll tell you what the issue is. -
Why no normal example? How to send a chat command, etc?
Code:[Command("post")] void PostRequest(IPlayer player, string command, string[] args) { webrequest.EnqueuePost("http://www.google.com/search?q=oxide", "param1=value1¶m2=value2", (code, response) => PostCallback(code, response, player), this); } void PostCallback(int code, string response, IPlayer player) { if (response == null || code != 200) { Puts($"Error: {code} - Couldn't get an answer from Google for {player.Nickname}"); return; } Puts("Google answered for " + player.Nickname + ": " + response); } -
@Secret Santa
I'm not sure I follow what you are trying to ask, but that example seems perfectly normal to me. The command is just /post. -
Wulf Community Admin
That code is for a CovalencePlugin, you'll get errors if your plugin is not that type.
