Solved External plugin call trouble
Discussion in 'Rust Development' started by Shytoos, Nov 3, 2016.
-
Posted in between your old post and his new post.
-
??? did you get this to work in info panel to show RP?
-
Look at the older posts, it still works.
-
ok so im guessing that this section of code needs to be changed to work with Server rewards callhooks??????
[DOUBLEPOST=1488258759][/DOUBLEPOST]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(); } } } } #endregionwhat older posts im confused???? -
Code:
[PluginReference] Plugin ServerRewards static InfoPanel instance; void OnServerInitialized() { instance =this; }[DOUBLEPOST=1488258917][/DOUBLEPOST]I believe that's all, if I'm missing something it's on page one in this post.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 -
For the latest version (0.9.5), see below:
Line 633 is the OnServerInitialized hook, vanilla should look like this:
You can add these values above OnServerInitialized (make sure your indentation is correct):Code:void Init() { LoadConfigValues(); LoadData(); } void OnServerInitialized() { Clock = new Watch
INSIDE OnServerInitialized, add this:Code:void Init() { LoadConfigValues(); LoadData(); } //Add these two [PluginReference] Plugin ServerRewards; static InfoPanel instance; void OnServerInitialized() { Clock = new Watch
Then replace lines 1316-1321 with this:Code:void OnServerInitialized() { //Add this instance = this; Clock = new Watch
Edit: Fixed typoCode: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. -
Typo, my bad. Add a semi-colon after [PluginReference] Plugin ServerRewards
From this:
To this:Code:[PluginReference] Plugin ServerRewards
Code:[PluginReference] Plugin ServerRewards;
-
thanks Canopy Sheep that work
-
where do i input this ?
[DOUBLEPOST=1501461320][/DOUBLEPOST]could you please help as i'm trying to convert to rp , thank you -
See my post above (#29)
-
sorry but i have a file for info panel in config and data , don't see what your talking about . sorry for my stupidity on this , but the plugin it self could have updated to accommodate a function like this.
-
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...?
-
i can't seem to find this info ??? could you help please
[DOUBLEPOST=1501603041][/DOUBLEPOST]never mind found it .lol
[DOUBLEPOST=1501604556][/DOUBLEPOST]thank thank thank !!! got it working , however i have both coins and rp collecting , how do i stop economics from collecting or do i just remove it now . -
Open the GatherRewards.json file and turn it to this:
Code:"UseEconomics": false, "UseServerRewards": true
