1. I saw the Metabolism plugin and saw that it uses OnRunPlayerMetabolism, is there a way to edit the rates through a Player object rather than this OnRun event?
     
  2. Yes, here's an example of adding 500 calories:

    Code:
    player.metabolism.calories.Add(500);
    
     
  3. Actually, I think I misunderstood what OnRunPlayerMetabolism does... Does it run once on connection or is it an override method that allows me to define my own metabolism method?

    Basically, what I'm wanting to do is pause the effects of the metabolism under a certain condition... would simply returning from this hook accomplish that? If so, how would I resume default behavior when such a condition is false?
     
  4. Wulf

    Wulf Community Admin

    OnRunPlayerMetabolism is a hook that is called whenever the metabolism changes on a player, usually when running. If you want to "pause" or cancel it, just return a non-null value (usually true or false).
     
  5. Not sure what I'm doing wrong, according to the docs, returning true will cancel the update... so I'd assume returning false would let it behave normally. However, the follow code seems to cancel the update no matter the returned value.

    Code:
    void OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
    {
        var player = entity.ToPlayer();
        if (player == null) return false;    SendReply(player, metabolism.calories.value.ToString());    if (condition) {
            // Lock thirst/hunger, don't change it.
            return true;
        } else {
            // Proceed normally with default metabolism.
            return false;
        }
    }
     
    Last edited by a moderator: Sep 29, 2016
  6. To my understanding:
    Code:
    object OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity entity)
    {
        var player = entity.ToPlayer();
        if (player == null) return null;    SendReply(player, metabolism.calories.value.ToString());    if (condition) {
            // Lock thirst/hunger, don't change it.
            return true; //(or false)
        } else {
            // Proceed normally with default metabolism.
            return null;
        }
    }
    Correct me if im wrong
     
  7. Ahh, that works... Perhaps the docs should be a bit more clear on that.

    Thanks everyone for the help! :)
     
  8. Well they are accurate for calling the function, but if you require to return something you need to assign it correctly.
    Just a question, how much experience have you had with C#?