Solved Play sound on admin join

Discussion in 'Plugin Requests' started by Macthelost, Jun 19, 2016.

  1. I am a C# programmer myself, but I couldn't find anything in the Oxide API that would allow me to play a sound to everyone on the server. I want to have a custom sound play when a server admin joins. Thank You!
     
    Last edited by a moderator: Jun 19, 2016
  2. You will need to run the Effect prefab using Rust's Effect.Run method.
    You can get all Prefabs using the Pool.
     
  3. What does that mean? I'm sorry, I'm more of an amateur programmer.
     
  4. something like that

    Code:
    Effect.server.Run("assets/prefabs/npc/patrol helicopter/effects/rocket_fire.prefab", player.transform.position);
     
  5. I tried that, but it didn't work. Here is the code I used it in:
    Code:
            void OnPlayerInit(BasePlayer player)
            {
                if (!showConnections)
                    return;            if (player.IsAdmin())
                {
                    rust.BroadcastChat(string.Format(joinFormat, player.displayName, adminColour), null, player.UserIDString);
                    Effect.server.Run("assets/prefabs/weapons/f1 grenade/effects/f1grenade_explosion.prefab", player.transform.position);
                }
                else if (!onlyShowAdmins)
                    rust.BroadcastChat(string.Format(joinFormat, player.displayName, userColour), null, player.UserIDString);
                  
            }
    
     
    Last edited by a moderator: Jun 20, 2016
  6. try it
    Code:
    void OnPlayerInit(BasePlayer player)
    {
        if(player.IsAdmin())
            foreach(var active in BasePlayer.activePlayerList)
                Effect.server.Run("assets/prefabs/weapons/f1 grenade/effects/f1grenade_explosion.prefab", active.transform.position, Vector3.zero, null, false);
    }
     
  7. It worked, but I want it to play a custom sound effect, like when an infamous player joins a heist in PayDay 2.
     
  8. Wulf

    Wulf Community Admin

    You can't use custom sounds, you can only use the effects that in the game.
     
  9. Oh, okay. Thanks anyway!
     
  10. Where must i write this code to Play the Sound?
     
  11. What i must use in plugin?
    Code:
    using System;
    etc
     
  12. Wulf

    Wulf Community Admin

    Use Visual Studio and setup a project with references to the Rust and Oxide DLLs, it will generally tell you.
     
  13. if(player.IsAdmin)
    if you use brackets you get error that non-invocable member cannot be used like a method

    confirmed works
     
  14. At the time that was posted that was correct. What's the point of correcting somebody in a dead thread anyway?
     
  15. When I tried it I got an error. I removed () to fix and figured I'd share.

    By the way I didn't revive this thread. Check the date stamps. Lomarine or future person might find the reply helpful.
     
  16. Wulf

    Wulf Community Admin

    The () in IsAdmin is what the method used to have, the code is from over a year ago where that was valid.
     
  17. Ok, I recall that now. Yeah, I guess I could come across as a dick if it seems like I'm looking at old posts to correct them. I didn't look at the time stamps when I posted so lesson learned. Comment was more for stranger and horst's benefit even though I was replying to serez. Sorry
     
  18. Wulf

    Wulf Community Admin

    No worries. :)