can you share?
Solved External plugin call trouble
Discussion in 'Rust Development' started by Shytoos, Nov 3, 2016.
-
-
??? did you get this to work in info panel to show RP?
-
-
ok so im guessing that this section of code needs to be changed to work with Server rewards callhooks??????
Code:#region Balance private Balance Bala; private Timer BalanceUpdater; public class Balance { public int RefreshRate = 3; public Balance(int RefreshRate) { this.RefreshRate = RefreshRate; } public double GetBalance(string PlayerID) { var player = RustCore.FindPlayerByIdString(PlayerID); if (player == null) return 0; return (double)(Interface.Oxide.CallHook("GetPlayerMoney", player.userID) ?? 0.0); } public void Refresh(StoredData storedData, Dictionary<string, Dictionary<string, IPanel>> panels) { if (!Settings.CheckPanelAvailability("Balance")) return; foreach (var panel in panels) { IPanel iPanel; if (!panel.Value.TryGetValue("BalanceText", out iPanel)) continue; var balance = $"{GetBalance(panel.Key):N}"; var panelText = (IPanelText)iPanel; if (!balance.Equals(panelText.Content)) { panelText.Content = balance; panelText.Refresh(); } } } } #endregion
-
Code:
[PluginReference] Plugin ServerRewards static InfoPanel instance; void OnServerInitialized() { instance =this; }
Code:public int GetBalance(string id) { var player = RustCore.FindPlayerByIdString(id); if (player == null) return 0; return (int)instance.ServerRewards?.Call("CheckPoints", Convert.ToUInt64(id)); }
-
im sorry dont mean to sound dumb but where do each of those codes go at??? -
I dont mean to bring up an old thread but I have the same question as Brohawk. Where do i put these codes? Im guessing they go in InfoPanel.cs , but where? Maybe which line #?
Last edited by a moderator: Jul 9, 2017 -
Line 633 is the OnServerInitialized hook, vanilla should look like this:
Code:void Init() { LoadConfigValues(); LoadData(); } void OnServerInitialized() { Clock = new Watch
Code:void Init() { LoadConfigValues(); LoadData(); } //Add these two [PluginReference] Plugin ServerRewards; static InfoPanel instance; void OnServerInitialized() { Clock = new Watch
Code:void OnServerInitialized() { //Add this instance = this; Clock = new Watch
Code:public int GetBalance(string id) { var player = RustCore.FindPlayerByIdString(id); if (player == null) return 0; return (int)instance.ServerRewards?.Call("CheckPoints", Convert.ToUInt64(id)); }
Last edited by a moderator: Jul 9, 2017 -
Damn! This is the error I'm getting now.
Error while compiling: InfoPanel.cs(635,8): error CS1519: Unexpected symbol `static' in class, struct, or interface member declaration
I feel that I should mention this. I re-installed ServerRewards and got this in the RCON console:
[ServerRewards] All UI elements have been successfully generated!
Calling 'OnServerInitialized' on 'ServerRewards v0.4.55' took 486ms
I have attached the .CS file. -
From this:
Code:[PluginReference] Plugin ServerRewards
Code:[PluginReference] Plugin ServerRewards;
-
thanks Canopy Sheep that work
-
where do i input this ?
[DOUBLEPOST=1501461320][/DOUBLEPOST] -
-
-
where do you locate this ??? Line 633 is the OnServerInitialized hook, vanilla should look like this:. is it hard to just put it in laymans terms...?
-
[DOUBLEPOST=1501603041][/DOUBLEPOST]
[DOUBLEPOST=1501604556][/DOUBLEPOST] -
Open the GatherRewards.json file and turn it to this:
Code:"UseEconomics": false, "UseServerRewards": true