1. Is there a way to tell if the player chose to respawn randomly, or chose to respawn on one of his sleeping bags/beds?

    I have all respawns forced to use Spawns Database data, but would like to override that if the player chose to respawn on his sleeping bag.
     
  2. Bump - Have a similar question. How can I differentiate a bed spawn vs a random spawn?
     
  3. Calytic

    Calytic Community Admin Community Mod

    I don't think there is a way to differentiate them using the oxide hook alone.

    What you could do is a Vis check for a sleeping bag or bed within ~2 meter of the newly spawned player. Then check the ownership of said sleeping bag to confirm it is actually a bag they own. Given the (relatively) new cooldown on nearby bags there isn't much incentive to place a ton of bags right next to eachother, therein making this method more reliable.

    Below is some untested psuedo-code but should put you on that track.. The code below assumes that the player position has already updated to the spawn position by the time this hook is called. I cannot confirm that is the case right now but I think it is reasonable to assume it is.

    Code:
    void OnPlayerRespawned(BasePlayer player)
    {
        List<SleepingBag> bags = new List<SleepingBag>();
        Vis.Entities<SleepingBag>(player.transform.position, 2f, bags);    if(bags.Count > 0) {
            foreach(SleepingBag bag in bags) {
                if(bag.deployerUserID == player.userID) {
                    // RESPAWNED AT SLEEPING BAG
                    return;
                }
            }
        }
    }
     
    Last edited: Feb 16, 2016