Hello everybody,
i'm currently trying to change a panel in the plugin InfoPanel for the game Rust I downloaded on uMod - namely i want to replace the RP panel which is displayed below with a counter which is displayed on a web page. Users have requested to count killed zombies. The counter that counts the zombiekills and sends them to the webserver is already working.
The modified InfoPanel plugin can be compiled without problems.
On the website the number 10 is currently displayed in plain text for testing purposes. I have tried to access it using a new method outside of the Points class:
i'm currently trying to change a panel in the plugin InfoPanel for the game Rust I downloaded on uMod - namely i want to replace the RP panel which is displayed below with a counter which is displayed on a web page. Users have requested to count killed zombies. The counter that counts the zombiekills and sends them to the webserver is already working.
The modified InfoPanel plugin can be compiled without problems.
On the website the number 10 is currently displayed in plain text for testing purposes. I have tried to access it using a new method outside of the Points class:
string pointsValue;
public string getZombie() {
webrequest.Enqueue("https://playrust.bojett.com/killcount/getSingle.php", null, (code, response) =>
{
if (code == 200)
{
pointsValue = ($"{response}");
PrintWarning($"{response}");
} else {
// ignore failed webrequests
}
}, this);
return pointsValue;
}
In the second part, where the content is written into the box, my code looks like this; at that point, it doesn't work ingame. The box just stays empty after each refresh.
InfoPanel zombie = new InfoPanel();
string points;
points = zombie.getZombie();
var panelText = (IPanelText)iPanel;
if (!points.Equals(panelText.Content))
{
panelText.Content = points;
panelText.Refresh();
}I hope that there is an experienced C# developer among you who can tell me what I missed. I'm better in other languages than C# :)
Enclosed you will find the whole #region Points block, so I won't withhold anything from you.
#region Points
private Points Poi;
private Timer PointsUpdater;
string pointsValue;
public string getZombie() {
webrequest.Enqueue("https://playrust.bojett.com/killcount/getSingle.php", null, (code, response) =>
{
if (code == 200)
{
pointsValue = ($"{response}");
PrintWarning($"{response}");
} else {
// ignore failed webrequests
}
}, this);
return pointsValue;
}
public class Points
{
public int RefreshRate = 10;
public Points(int RefreshRate)
{
this.RefreshRate = RefreshRate;
}
public int GetPoints(string PlayerID)
{
var player = RustCore.FindPlayerByIdString(PlayerID);
if (player == null) { return 0; }
return (int)(Interface.Oxide.CallHook("CheckPoints", player.userID) ?? 0);
}
public void Refresh(StoredData storedData, Dictionary<string, Dictionary<string, IPanel>> panels)
{
if (!Settings.CheckPanelAvailability("Points"))
return;
foreach (var panel in panels)
{
IPanel iPanel;
if (!panel.Value.TryGetValue("PointsText", out iPanel))
{
continue;
}
InfoPanel zombie = new InfoPanel();
string points;
points = zombie.getZombie();
var panelText = (IPanelText)iPanel;
if (!points.Equals(panelText.Content))
{
panelText.Content = points;
panelText.Refresh();
}
}
}
}
#endregionMany thanks for every hint :)