Not work PluginReference for CSPlugin
Discussion in 'Rust Development' started by Sanlerus, Jan 24, 2016.
-
Code:
[PluginReference] Plugin AspectRatio;
-
int ratio = (int)(Interface.Oxide.CallHook("GetAspectRatio", player.userID) ?? 0); // work
int ratio = (int)(PluginAspectRatio?.Call("GetAspectRatio", player.userID) ?? 0); // not work
[DOUBLEPOST=1453625562][/DOUBLEPOST]Not work, AspectRatio is null.
[DOUBLEPOST=1453635699,1453624462][/DOUBLEPOST]This code is work.
Code:var plugins = Interface.Oxide.GetLibrary<Plugins>(); PluginAspectRatio = plugins.Find("AspectRatio"); -
The PluginReference field is not available in the CSPlugin class, only in CSharpPlugin and its derived classes (the specific game plugin classes).
And when you are using PluginReference in a CSharpPlugin (or RustPlugin,......) then you should be able to use them like so:
or if the plugin contains invalid characters that you cannot use as the name of a variableCode:[PluginReference] Plugin ThePluginsFileName;
Code:[PluginReference("0-FriendsApi")] Plugin FriendsApi;
