1. ok. overlay, works. overlay from URL, works. effects buildin the prefabs, works.

    but the sound would be hard / not possible . would have to think to get that on a diff. way...

    is it possible to "open" the container where the effects etc are in , adding something and pack that all together again ? or... adding my own audio clips to the game// clients somehow else ? maybe someone has some idea :p
     
  2. Wulf

    Wulf Community Admin

    Not possible to add your own audio clips; all you can do is play the effects (these trigger sounds) that the client/server already has. If the file is loaded by both the server and the client, you can call it, but you'd have to did into Unity to see if this is even possible after the game is already built. You'll likely need bundle the files as an .asset though.
     
  3. Got today another thought...

    i already did it , with Virtual audio cable + Ingame voice chat to play sounds/music that others can hear.

    i kinda recall that in legacy there was methods for voice sent etc , dont know if it was accessible or not.

    Is there maybe something like that to be able to play something on that way?
     
  4. Wulf

    Wulf Community Admin

    Sure you can play something over your mic, but that's something else entirely. That will have the limitations that voice has.
     
  5. can i somehow access the method with that the player receives the sent voice , as server with BasePlayer `?
     
  6. Wulf

    Wulf Community Admin

    Voice isn't handled by the server, you won't be able to do much with it. Voice is sent between clients.
     
  7. Wouldnt be able at all as a server to get to somewhere near that Method to change for example the Radius of a specific player?


    Code:
    public void P2PBroadcast(float radius, P2PMessages.Type type, byte[] data, bool includeSelf = true)
    {
        if ((data != null) && (data.Length > 0))
        {
            Vector3 position = base.transform.position;
            using (MemoryStream stream = new MemoryStream(data.Length + 1))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte) type);
                    writer.Write(data);
                    foreach (BasePlayer player in visiblePlayerList)
                    {
                        if (((((player != this) && (player != null)) && ((Vector3.Distance(position, player.transform.position) <= radius) && (player.userID != 0))) && player.isConnected) && !SteamNetworking.SendP2PPacket(new CSteamID(player.userID), stream.GetBuffer(), (uint) (data.Length + 1), EP2PSend.k_EP2PSendUnreliableNoDelay, 0))
                        {
                        }
                    }
                    if (includeSelf)
                    {
                        stream.Position = 0L;
                        SingletonComponent<SteamClient>.Instance.ProcessSteamNetworkingPacket(stream, new CSteamID(this.userID));
                    }
                }
            }
        }
    }0 0x0public void P2PBroadcast(float radius, P2PMessages.Type type, byte[] data, bool includeSelf = true)
    {
        if ((data != null) && (data.Length > 0))
        {
            Vector3 position = base.transform.position;
            using (MemoryStream stream = new MemoryStream(data.Length + 1))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte) type);
                    writer.Write(data);
                    foreach (BasePlayer player in visiblePlayerList)
                    {
                        if (((((player != this) && (player != null)) && ((Vector3.Distance(position, player.transform.position) <= radius) && (player.userID != 0))) && player.isConnected) && !SteamNetworking.SendP2PPacket(new CSteamID(player.userID), stream.GetBuffer(), (uint) (data.Length + 1), EP2PSend.k_EP2PSendUnreliableNoDelay, 0))
                        {
                        }
                    }
                    if (includeSelf)
                    {
                        stream.Position = 0L;
                        SingletonComponent<SteamClient>.Instance.ProcessSteamNetworkingPacket(stream, new CSteamID(this.userID));
                    }
                }
            }
        }
    }
     
  8. Wulf

    Wulf Community Admin

    P2P = client to client, the server has no involvement in that.
     
  9. argh shit xd ... sry that im still debating that . just thought i found something .
    Little question besides that - some fields or methods are marked as public, but it seems that i cannot do anything with them.
    Like a bit time ago that question if i can get the Current bullet position ....
    Dunno why then they public.
     
  10. Sry to catch up on this again, but got a little thought.

    As far as i know, the HumanNPC's that can be created with the Plugin from Nogrod, can be counted as Players that also
    have an actual ID.

    Wouldnt it be possible to use the Npc to "Speak" ( or play a sound with Virtual audio cable) ?
     
  11. Also not possible. Player "Voice" is handled by P2P.
     
  12. how would you send effect to all players online?
     
  13. Wulf

    Wulf Community Admin

    Loop through all players and run the same thing on each.
     
  14. i tried

    Code:
                                foreach (var player in BasePlayer.activePlayerList)
                                Effect.server.Run("assets/bundled/prefabs/fx/survey_explosion.prefab", player.transform.position, Vector3.zero, null, false);
    
    and i get
    error CS0103: The name `player' does not exist in the current context
     
    Last edited by a moderator: Jan 22, 2017
  15. Wulf

    Wulf Community Admin

    Yup, but you'd want to target a position by the player.
     
  16. How would i do that i tried
    Code:
    Effect.server.Run("assets/bundled/prefabs/fx/survey_explosion.prefab", player.transform.position, Vector3.zero, null, false);
    
    but i get error CS0103: The name `player' does not exist in the current context
    [DOUBLEPOST=1485061610][/DOUBLEPOST]This line is giving that error foreach (BasePlayer player in BasePlayer.activePlayerList)
    [DOUBLEPOST=1485062200][/DOUBLEPOST]
    Code:
            private void StartRadTimers()
            {
                int ontime = configData.Timers.Static_On;
                int offtime = configData.Timers.Static_Off;
                if (configData.Options.Use_RandomTimers)
                {
                    ontime = GetRandom(configData.Timers.Random_OnMin, configData.Timers.Random_OnMax);
                    offtime = GetRandom(configData.Timers.Random_OffMin, configData.Timers.Random_OffMax);
                }
                OnTimer = ontime * 60;
                timer.Repeat(1, OnTimer, () =>
                {
                    OnTimer--;
                    if (OnTimer == 0)
                    {                  
                        foreach (var zone in RadiationZones)
                            zone.Deactivate();
                        if (configData.Options.Using_InfoPanel) timer.Once(5, ()=> ConVar.Server.radiation = false);                    if (configData.Options.Broadcast_Timers)
                            rust.RunServerCommand($"weather.rain 1");
                            timer.In(20, () => rust.RunServerCommand($"weather.rain 0"));                      
                            MessageAllPlayers(lang.GetMessage("RadsOffMsg", this), offtime);
                      
                        OffTimer = offtime * 60;
                        timer.Repeat(1, OffTimer, () =>
                        {
                            OffTimer--;
                            if (OffTimer == 0)
                            {
                                foreach (var zone in RadiationZones)
                                    zone.Reactivate();
                                if (configData.Options.Using_InfoPanel) ConVar.Server.radiation = true;
                                if (configData.Options.Broadcast_Timers)
                                    MessageAllPlayers(lang.GetMessage("RadsOnMsg", this), ontime);
                              
                                StartRadTimers();
                                foreach (var player in BasePlayer.activePlayerList)
                                Effect.server.Run("assets/bundled/prefabs/fx/survey_explosion.prefab", player.transform.position, Vector3.zero, null, false);              {                ForcePlayerPosition(player, "-590.5, 2.3, 51.6".ToVector3());
                  player.Respawn();
              }
                            }
                        });
                    }
                });
            }
    tried this way also receive CS0103: The name `player' does not exist in the current context not sure what im missing
     
    Last edited by a moderator: Jan 22, 2017
  17. Added in
    public BasePlayer player;
     
  18. Wulf

    Wulf Community Admin

    That won't help you.... all you've done is made an empty variable.
     
  19. Idn then i been looking at examples all day cant seem to get rid of CS0103: The name `player' does not exist in the current context not sure what im missing for line foreach (BasePlayer player in BasePlayer.activePlayerList)
     
  20. Wulf

    Wulf Community Admin

    That means you are trying to call a variable that doesn't exist where you are trying to call it.