1. Hi it's a noob question but im using callhook
    Code:
    CopyPaste.CallHook("TryPasteFromSteamID", "null", "zone_militarytunnel", "height 0");
    The void is: TryPasteFromSteamID(ulong userID, string filename, string[] args)

    How can I send a args (height 0) into the callhook?
    Or is there another way to paste something using automated script? not triggered by a player (like on server init, /paste "filename" "height 0")?
     
    Last edited by a moderator: May 25, 2018
  2. Wulf

    Wulf Community Admin

    That is a chat command, so if the method expects a user ID then you'd need to provide that. If height and 0 are separate arguments, then you'd just send them separately, else you can do as you already are, but you still need to provide ALL of the arguments if they aren't optional (in this case, likely aren't.)
     
  3. I modified the script it and it doesnt need player id if the first strings begins with "_zone" it takes the pos from a loc on map instead of player.

    The last string in the void is a " str[] args ". how do i place a "height 0" imside a string[]? :/

    I put a Puts("test"); in iront line line inside the void see if the callhook reaches it but i never see "test" appearing in console with whatever i try to enter in the callhook :s i dont know why it cant reach it. There si no error at all
     
  4. Wulf

    Wulf Community Admin

    https://www.dotnetperls.com/array
     
  5. ty.
    I try this: CopyPaste.CallHook("TryPasteFromSteamID", null, "zone_militarytunnel", new string [] {"height", "0"});
    so its supposed to do same action as if someone used the command: /paste zone_militarytunnel height 0
    I think?

    but whatever i enter in it, it nevers show the puts "test" msg in the console when i placed it at the beginning of the void. it then means the callhook does even reach the void. how so? it should at least return an error if something is wrong but it just do nothing in console :( the callhook looks broken somehow
     
  6. Wulf

    Wulf Community Admin

    Then it's likely failing due to not being able to find a matching "hook", probably because of the ulong being expected there rather than the null you are sending.
     
  7. I managed to make it work until last line. I am having one last issue regarding another callhook at the last step

    Calling hook on same plugin works just fine without error: Interface.CallHook("Test", name, entity);
    I get an error as soon as I try to use another plugin: BotSpawn.CallHook("UpdateBotSpawn", name, entity);

    Inside the voids, I simply have a Puts or just empty void. I get the following error:
    Code:
    Failed to call hook 'TryPasteFromSteamID' on plugin 'CopyPaste v3.6.4' (NullReferenceException: Object reference not set to an instance of an object)
      at Oxide.Plugins.CopyPaste.Paste (System.Collections.Generic.List`1 entities, Vector3 startPos, .BasePlayer player, Boolean stability, System.String filename) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CopyPaste.TryPaste (Vector3 startPos, System.String filename, .BasePlayer player, Single RotationCorrection, System.String[] args, Boolean autoHeight) [0x00000] in <filename unknown>:0 etc etc etc
    When this type of error happens its a null element not returning properly but how come I can return the name and entity to the interface void, but not on the other plugin? they have both String name, BaseEntity entity. This is driving me nuts lol
     
  8. Wulf

    Wulf Community Admin

    You have something in that TryPasteFromSteamID method that is null when it shouldn't be, as in it expects it to not be null. I'd suggest adding some null checks in the method to see what is.
     
  9. Ok ill have a look. Strange that it passed through all other callhooks until last one before telling me there is a null not liked. thanks
     
  10. there were lots of return vars and it seems that I got a workaround for that null error by adding a timer.Once (0sec). It allowed the returns to finish loading values and use the timer after that to call what I needed. I guess some values weren't returned before I call the hook. Well thanks again
     
  11. Wulf

    Wulf Community Admin

    Hard to tell without seeing your code, but that sounds unnecessary and pretty weird.