Commit 4898ebfa authored by Aurora's avatar Aurora
Browse files

Update UserManagement.cs

parent cd906c3e
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Network;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Plugins;
......@@ -27,6 +29,55 @@ namespace Oxide.Plugins
}
}
bool CanBypassQueue(Connection connection) {
String steamid = connection.userid.ToString();
// Compile the headers (for the token).
Dictionary<string, string> headers = new Dictionary<string, string>();
// Add the authorization token.
headers.Add("Authorization", Config["Token"].ToString());
// Send the HTTP GET request.
webrequest.Enqueue(Config["URL"].ToString() + Config["Endpoint"].ToString() + "?steamid=" + steamid, null, (code, response) =>
{
// Check for errors.
if (code != 200 || response == null)
{
return;
}
// Parse request as JSON.
var json = JObject.Parse(response);
int err = (int)json.GetValue("error");
// Check for invalid token.
if (err == 401)
{
Puts($"Invalid token for GET request. ({steamid}). URL - " + Config["URL"].ToString() + ", Endpoint = " + Config["Endpoint"].ToString() + ", Token = " + Config["Token"].ToString() + ", Code = " + code);
return;
}
int groupID = (int)json.GetValue("group");
if ((bool)Config["Debug"])
{
Puts($"PRECHECK: Loaded user ({steamid}) with group ID {groupID}");
}
// Allow a queue skip
if (groupID == 3 && !permission.UserHasGroup(steamid, "vip")) {
permission.AddUserGroup(steamid, "vip");
ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "skipqueue " + steamid);
}
}, this, RequestMethod.GET, headers);
return false;
}
// Reload all users command.
[ConsoleCommand("um.reloadusers")]
private void ReloadusersCommand(ConsoleSystem.Arg arg)
......@@ -175,4 +226,4 @@ namespace Oxide.Plugins
}
}
}
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment