RandomSpawner

Randomly spawn a specific amount of an entity on the map

Total Downloads: 1,856 - First Release: Nov 14, 2015 - Last Update: Apr 14, 2017

5/5, 4 likes
  1. Wulf

    Wulf Community Admin

    Wulf updated Random Spawner with a new update entry:

    1.2.1

     
  2. rspawn 50 horse

    Failed to call hook 'ccmdSpawnRandom' on plugin 'RandomSpawner v1.2.1' (NullReferenceException: Object reference not set to an instance of an object)

    rspawn 50 assets/bundled/prefabs/autospawn/animals/stag.prefab

    Failed to call hook 'ccmdSpawnRandom' on plugin 'RandomSpawner v1.2.1' (NullReferenceException: Object reference not set to an instance of an object)
     
  3. Failed to call hook 'ccmdSpawnRandom' on plugin 'RandomSpawner v1.2.1' (NullReferenceException: Object reference not set to an instance of an object)---or... Ingame chat Couldn't find prefab "bear.prefab" , Couldn't find prefab "bear"
     
  4. can't launch from console. seems to work with chat.. i think...

    (15:03:37) | Failed to call hook 'ccmdSpawnRandom' on plugin 'RandomSpawner v1.2.1' (NullReferenceException: Object reference not set to an instance of an object)
    (15:03:37) | at Oxide.Plugins.RandomSpawner.RunAsChatCommand (.Arg arg, System.Action`3 command) [0x00000] in <filename unknown>:0
    at Oxide.Plugins.RandomSpawner.ccmdSpawnRandom (.Arg arg) [0x00000] in <filename unknown>:0
    at Oxide.Plugins.RandomSpawner.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
    at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
    at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
     
  5. Hello, i liked use: /rspawn 10 "scientist" ('spawn scientist' in console)
     
  6. console commands not work:(
    i plan to use this with Timed Execute, spawn scientist but
    Timed Execute use console commands
     
  7. I have granted myself the permission and that worked.

    But when i type "getprefabs" in console it pushes nothing to console, any ideas why?
     
  8. getting this errors
    Code:
    Failed to call hook 'ccmdGetPrefabs' on plugin 'RandomSpawner v1.2.1' (DirectoryNotFoundException: Could not find a part of the path "C:\TCAFiles\Users\SeulGiJ\20789\server\Streamline\oxide\logs\Prefabs.txt".)
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0 at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare) at System.IO.StreamWriter..ctor (System.String path, Boolean append, System.Text.Encoding encoding, Int32 bufferSize) [0x00000] in :0 at System.IO.StreamWriter..ctor (System.String path, Boolean append) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.IO.StreamWriter:.ctor (string,bool) at System.IO.File.AppendAllText (System.String path, System.String contents) [0x00000] in :0 at ConVar.Server.Log (System.String strFilename, System.String strMessage) [0x00000] in :0 at Oxide.Plugins.RandomSpawner.ccmdGetPrefabs (.Arg arg) [0x00000] in :0 at Oxide.Plugins.RandomSpawner.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in :0 at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in :0 at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in :0 at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in :0
     
    Last edited by a moderator: Sep 17, 2017
  9. This is happening because Oxide was moved to another directory awhile ago and it seems the path given is relative to my_server_identity. You can fix this by either creating the directory /server/my_server_identity/oxide/logs on your server or by changing this line
    ConVar.Server.Log("oxide/logs/Prefabs.txt", ListToString(prefabs, 0, Environment.NewLine));
    to point to a valid directory on your server. for instance..
    ConVar.Server.Log("Prefabs.txt", ListToString(prefabs, 0, Environment.NewLine));
    should work

    Ok so rspawn console command has been broken for a long time. I am not a programmer and don't quite get the errors so I decided to not use his "run as a chat command" thing and instead just plunked the spawn code within the consolecommand for simplicity. I also added some extra code so it'll actually tell you what its doing in the console... no more wondering if it actually worked
    upload_2017-9-11_10-42-38.png

    If you use N-Teleportation, you can use command teleport.topos <yourname> x y z to go check out the spawn yourself.

    Find the line [ConsoleCommand("rspawn")] and replace the entire thing with this:
    Code:
            [ConsoleCommand("rspawn")]
            void ccmdSpawnRandom(ConsoleSystem.Arg arg)
            {
                //Bandaid fix.
                if (arg.Connection != null && arg.Connection.authLevel < 2)
                    return;
                if (!arg.HasArgs())
                {
                    Puts("Usage: rspawn <amount> <entity prefab>");
                    return;
                }
                string prefab = arg.Args[1];
                int amount = 0;
                try
                {
                    amount = Convert.ToInt32(arg.Args[0]);
                }
                catch (FormatException ex)
                {
                    Puts("Amount must be a number value!");
                    return;
                }
                Vector3 rlocation = Vector3.zero;
                for (int i = 1; i <= amount; i++)
                {
                    rlocation = GetRandomVector();
                    SpawnEntity(prefab, rlocation);
                    Puts($"[{i}/{amount}] Spawned {prefab} at {rlocation}.");
                }
            }
    As the overview says.. this thing will spawn entities anywhere so you can have floating animals and stuff like that.
    [DOUBLEPOST=1505142634][/DOUBLEPOST]also here's a list of common prefabs:
    assets/rust.ai/agents/bear/bear.prefab
    assets/rust.ai/agents/boar/boar.prefab
    assets/rust.ai/agents/chicken/chicken.prefab
    assets/rust.ai/agents/horse/horse.prefab
    assets/prefabs/player/player.prefab
    assets/prefabs/player/player_corpse.prefab
    assets/prefabs/npc/scientist/scientist.prefab
    assets/rust.ai/agents/stag/stag.prefab
    assets/rust.ai/agents/wolf/wolf.prefab
    assets/rust.ai/agents/zombie/zombie.prefab
    assets/prefabs/tools/c4/explosive.timed.deployed.prefab (lol)

    If you want to see if the prefab spawned, you could comment out this line
    //rlocation = GetRandomVector();
    which forces the spawn location to 0, 0, 0
    and then teleport.topos <yourname> 0 0 0 with noclip on or hard code in some coords.
     
    Last edited by a moderator: Sep 12, 2017
  10. Thank you somuch!!
     
  11. this plugin no longer compiles!

    (09:53:31) | Error while compiling: RandomSpawner.cs(49,27): error CS0117: `ConVar.Server' does not contain a definition for `Log'

    due to line

    ConVar.Server.Log("oxide/logs/Prefabs.txt", ListToString(prefabs, 0, Environment.NewLine));
     
  12. Have the same problem
     
  13. anyway i can add a command to the guishop menu so people can do /shop and then use the command?
     
  14. I believe this was supposed to be in another thread?
     
  15. its part of both plugins so i was unsure where to post i want people to beable to use random spawner via the guishop menu /shop plugin but im unsure of the command i need to add



    oh wait maybe your right lol
     
  16. As creator of the plugin, you may know problem why there is error compiling, which is seen some posts above?
     
  17. Yes, I will probably do a small rework of the plugin.
     
  18. Many thanks if you do find the time. It would be very useful to have an option to create a spawn point where your targeting, ala the Murderers.cs plugin. Regardless, base functionality back would rock, anything else is gravy. Also, check for a PM pls.
     
  19. Hello. ef1caf838da837a0669c45cf0436fdd4_large - Copie.jpg I have this error on the screen