Error:Code:using Oxide.Core.Libraries.Covalence; using System; using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Plugins;namespace Oxide.Plugins { [Info("test", "by ", 1.0)] [Description("test plugin")] class test : RustPlugin { [ChatCommand("test")] 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"); return; } Puts("Google answered for : " + response); } } }
Code:[Oxide] 15:14 [Debug] at Oxide.Plugins.test.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
Solved WebRequest geterror
Discussion in 'Rust Development' started by Sauron 2, Jun 19, 2016.
-
Wulf Community Admin
The error is above the part your posted. Also, your class should start with a capital letter.
-
Here i replace on test
Last edited by a moderator: Jun 19, 2016 -
Wulf Community Admin
The actual error is in your log, above the DEBUG portion you posted. -
-
Wulf Community Admin
-
Code:using Oxide.Core.Libraries.Covalence; using System; using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Plugins;namespace Oxide.Plugins { [Info("Test", "by ", 1.0)] [Description("Test plugin")] class test : RustPlugin { [ChatCommand("Test")] 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"); return; } Puts("Google answered for : " + response); } } }
-
Wulf Community Admin
I just need he error, not the code. The error is in he log part hat you didn't show me. Also, you can't use IPlayer in a normal plugin's chat command.
-
Here you use IPlayer Oxide API for Rust
İ test on the lua:
Code:PLUGIN.HasConfig = false PLUGIN.Title = "EpicPlugin" PLUGIN.Author = "Unknown" PLUGIN.Version = V(0, 1, 0) PLUGIN.Description = "Makes epic stuff happen"function PLUGIN:Init() command.AddConsoleCommand("global.test", self.Plugin, "TestCommand") endfunction PLUGIN:OnPlayerChat(arg) if not arg then return end if not arg.connection then return end if not arg.connection.player then return end local player = arg.connection.player local chat = arg:GetString(0, "text") if (chat=="") then return end webrequests.EnqueuePost("http://localhost/test.php?key=test","test=1&arg=2", function(code, content) if(code == 200) then print(content) end end,self.object) end
Last edited by a moderator: Jun 20, 2016 -
Wulf Community Admin
-
-
Wulf Community Admin
The example is for CovalencePlugin, you'd need to adjust accordingly if you want to make a RustPlugin. -
Use [ChatCommand("post")] get error Method Hook...Last edited by a moderator: Jun 21, 2016 -
Wulf Community Admin
The [ChatCommand] Attribute is only for RustPlugin and other game-specific ones.
BasePlayer needs to be used for commands in RustPlugin, IPlayer is for use with CovalencePlugin, you're mixing them up. -
-
Wulf Community Admin
Code:using Oxide.Core; using Oxide.Core.Libraries;namespace Oxide.Plugins { [Info("EpicPlugin", "Unknown", 1.0)] [Description("This example illustrates how to use a POST Webrequest")] class EpicPlugin : RustPlugin { [ChatCommand("postrequest")] void PostRequest(BasePlayer 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, BasePlayer player) { if (response == null || code != 200) { Puts($"Error: {code} - Couldn't get an answer from Google for {player.displayName}"); return; } Puts("Google answered for " + player.displayName + ": " + response); } } }
-
Thanks.Please put more examples in docs.oxidemod.org .And that is very little information...
player.displayName changed player.Name ?Last edited by a moderator: Jun 22, 2016 -
Wulf Community Admin
player.displayName is from Rust, player.Name is from the Covalence API. -
And also where you can read all the commands like player.displayName and others...?
-
You need to add references. Check this out -> Setting up a C# workspace in Visual Studio 2015 | Oxide