Hello,
I have an website and the players has to register before play in my server. I have an API in my webserver and I want to check if the players is allowed to log in my server.
My API is working and when the player is allowed to login it responde code 200, but my Oxide Plugin not working. Any help?
Thanks!Code:var Test = { Title : 'Test', Author : 'Me', Version : V(0, 0, 1), Description : 'Plugin', Init : function () { command.AddConsoleCommand('server.CanClientLogin', this.Plugin, 'CanClientLogin'); }, CanClientLogin: function (connection) { webrequests.EnqueueGet('http://myAPI.com/isplayeralowedtologin'+connection.toString().split('/')[1], function(code, response) { if (code === 200) { print('['+connection.toString().split('/')[1]+'] tem passe vip'); } else { return('Sorry, you are not allow to login.'); }; }.bind(this), this.Plugin); } };
Trouble checking my web API
Discussion in 'Rust Development' started by hemk, Apr 16, 2016.
-
Wulf Community Admin
webrequest.EnqueueGet
You should see an error in your server console when you try to use your plugin. -
Thanks for answering Wulf. There is no error and I can see part of the plugin working. It actually gets the response 200 when allowed or 403 when the players is not allowed, but for some reason the players keep connecting anyway, even if hes now allowed. The "return" shouldn't be kicking the player?
Maybe it happens because the "return" is inside a callback. Do you have any idea how to fix it?
Thanks! -
You need to kick the player yourself because your response is called in a callback as webrequest are async.
-
Thanks Hatemail! Do you know a command to kick a player in javascript?
Thanks! -
On mobile so no not off the top of my head. You can look at other whitelist plugins for the Rust methods..
-
I can't find plugins write in javascript or the documentation to kick the player.
-
Wulf Community Admin
You'd need to look in the DLL for how to kick players, else search existing threads. The kicking if handled natively by Rust, not Oxide. There aren't a lot of JavaScript plugins, most are in C#. -
Thanks for the answer guys! I'll rewrite it in C#
By the way, do you know how to get how many players are joining in the server C#? -
Code:
BasePlayer.activePlayerList.Count
-
Thanks Spicy, but this command shows how many players are in the game (after playerInit). What I want is players joining (before playerInit). Do you know how?
-
Wulf Community Admin
BasePlayer.activePlayerList.Count - 1 -
Does it always include an extra player? I made a live player count a few weeks ago to be displayed on my website but even when the count was 0 it still displayed as 1.
-
Wulf Community Admin
Not that I know of. -
If I send a rcon "serverinfo" command I got a json like this:
{ "Hostname": "My server",
"MaxPlayers": 110,
"Players": 49,
"Queued": 0,
"Joining": 5,
"EntityCount": 162741,
"GameTime": "2025-02-10T05:56:49.8197937Z",
"Uptime": 52927,
"Map": "Procedural Map",
"Framerate": 228.0 }
Can I get that same value "Joining" in a Oxide Plugin?
"Joining" = How many players ByPassed the queue and are loading the game, but they dont count in "BasePlayer.activePlayerList.Count" variable because they don't are active yet. -
Thank you very much!
How can I see this tree? -
Wulf Community Admin
Open up the Assembly-CSharp.dll from the game server in a program such as JustDecompile. -
Thanks!

![[IMG]](proxy.php?image=https%3A%2F%2Fi.gyazo.com%2F734dadd07b2ccd4d819061b7d328c7ba.png&hash=11d5123fac26b51715de0d6f30117f32)