1. How to get icon of item?
    I can get an icon name, but I don't know how to get image.

    Regards!
     
  2. SpriteResourceLoader.Get(string spriteName)
     
  3. Well, maybe I'm just stupid, but
    Code:
    [Oxide] 16:24 [Error] Failed to call hook 'commandGetPos' on plugin 'xxx v0.1.0' (NullReferenceException: Object reference not set to an instance of an object)
    (Filename: /home/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)[Oxide] 16:24 [Debug]   at SpriteResourceLoader.Get (System.String spriteName) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    And when I'm trying to get Instance by
    Code:
    getInstance: function(variable) {
        return global.Singleton(variable).Instance;
    },
    then

    Code:
    [Oxide] 16:23 [Error] Failed to call hook 'commandGetPos' on plugin 'xxx v0.1.0'
    File: xxx.js Line: 1411 Column: 13 TypeError sprite is null:
      at Jint.Native.Function.ScriptFunctionInstance.Call (JsValue thisArg, Jint.Native.JsValue[] arguments) [0x00000] in <filename unknown>:0
      at Oxide.Ext.JavaScript.Plugins.JavaScriptPlugin.OnCallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hookname, System.Object[] args) [0x00000] in <filename unknown>:0 
    Code:
    commandGetPos: function(session, cmd, arg) {
        if(this.hasPermission(session, 'admintools.all')) {
            var sprite = this.getInstance(global.SpriteResourceLoader);
           
            var pos = this.getPlayerPosition(session);
            this.chat(implode(', ', pos), false, session);
            this.chat(sprite.Get('Items/Bolt Action Rifle'), false, session);
            this.chat(global.SpriteResourceLoader.Get('Items/Bolt Action Rifle'), false, session);
        } else {
            this.chat('Nie masz uprawnieĊ„ do tej komendy!', false, session);
        }
    },
    
    Regards!
     
  4. Wulf

    Wulf Community Admin

    What are you trying to do with the icon exactly? I don't think you can actually put the icon anywhere on the client from the server.
     
  5. Actually I'm trying to get image as base64 or just png/jpg/jpeg. I want to send this to mysql (in case of base64) or to ftp. I need icons to create preview of inventory on website.
     
  6. So.. You can download them from other shop. This way will be easier.
     
  7. I want to do it by myself
     
  8. Ah of course! SpriteResourceLoader doesn't exist on the server. You can still get the sprites though, pretty much by doing exactly the same thing SpriteResourceLoader does to get them.
     
  9. Well, after little break I make Sprite Loader. But how can I convert it to base64 or just send it to FTP in JS?
     
  10. Wulf

    Wulf Community Admin

    You may be able to send it as a POST webrequest using a plugin, but I'm not sure. There wouldn't be a way to FTP it from a plugin as far as I know.
     
  11. At this moment I have Sprite object. I can also get texture object, but it's not PNG. I tried to use txt.EncodeToPNG(); but I got error instand of PNG :D
     
  12. This will be because the PNGs aren't set to read/write enabled, a Unity restriction.
     
  13. So there is any way to get image of an icon?
     
  14. How to get base64 icon via C# plugin?