1. Hello!

    How do I get the BasePlayer from BaseNetworkable to send a message to the player spawning the entity?

    Code:
            private void OnEntitySpawned(BaseNetworkable entity)
            {
                if (entity.ShortPrefabName != "?")
                    return;            BaseEntity baseEnt = entity.GetComponent<BaseEntity>();
                BasePlayer player = BasePlayer.FindByID((entity as BaseEntity).OwnerID);            if (!baseEnt)
                    return;            if (player == null)
                    return;            Player.Message(player, "Message", 0);
              }
    player is always null here.
     
  2. OnEntitySpawned - Called after any networked entity has spawned (including trees).
    Why would you need to get the BasePlayer class from this?
     
  3. What I showed in this thread is just an example, I just need to get the player dropping the entity so I can send them a message.

    I've tried different ways but the player is always null.
     
  4. Code:
    void OnItemDropped(Item item, BaseEntity entity)
    {
       Puts("OnItemDropped works!");
    }
    
     
  5. No, I am talking about OnEntitySpawned, SupplySignals for example. I want to get the BasePlayer from a spawned grenade.smoke.deployed.

    I'm using OnEntitySpawned so I can kill the deployed signal instantly after a throw and before it calls an airdrop.
     
    Last edited by a moderator: Mar 21, 2018
  6. Have a look here - uMod - Supply Signal Alerts
     
  7. I have, but that's OnExplosiveDropped and OnExplosiveThrown.

    The only thing I want to know is how to get BasePlayer from OnEntitySpawned.
     
  8. I think that OnEntitySpawned is not related to Baseplayer at all. Items can be spawned in barrels or loot crates. if you drop the signal then it's OnExplosiveThrown. That's exactly what you want if you want to kill the signal and prevent from airdrop.
     
  9. Code:
            private void OnExplosiveDropped(BasePlayer player, BaseEntity entity) => OnExplosiveThrown(player, entity);        private void OnExplosiveThrown(BasePlayer player, BaseEntity entity)
            {
                if (!(entity is SupplySignal))
                    return;
                entity.Kill();
                SendReply(player, "<color=orange>Supply Signals are disabled.</color>")
            }
    
     
  10. @Sonny-Boi I did that yesterday, but it kills the signal after it calls an airdrop.

    OnEntitySpawned kills the entity instantly after they throw it.
    [DOUBLEPOST=1521712598][/DOUBLEPOST]Managed to get it working with just 'OnExplosiveThrown' and using 'grenade.smoke.deployed'
     
  11. If you're just going to kill the entity immediately after spawned, why not utilize OnItemUse and prevent the spawn in the first place?