1. Code:
    object OnXpEarn(BasePlayer player, float amount, string source)
            {
                if (HasPermission(player, "XP2"))
                {                //SendReply(player, source);
                    return null;
                }
                else
    {
    return null;
    }
            }

    Code:
    Object reference not set to an instance of an object
    There is something wrong or I am doing something wrong?
     
  2. Wulf

    Wulf Community Admin

    Sounds like you're trying to use something that doesn't exist. Does your HasPermission take a player or a Steam ID?
     
  3. Code:
    object OnXpEarn(BasePlayer player, float amount, string source)
            {
                    return null; 
            }
    Same.
     
  4. Wulf

    Wulf Community Admin

    There's no way you'd get an NRE from just that.
     
  5. You are right. My bad.

    But this
    Code:
    object OnXpEarn(BasePlayer player, float amount, string source)
            {
                if (player.IsAdmin())
                {
                    SendReply(player, source);
                    return null;
                }
                return null;
            }
    Still NRE.
     
  6. Wulf

    Wulf Community Admin

    Add some null checks, but there's nothing in there that would be null.
     
  7. Sorry Wulf, what do you mean by null checks?
     
  8. Wulf

    Wulf Community Admin

    Checking if a variable is null or not, printing, == checks, etc.
     
  9. It's fine now. But I have another question.
    Since I am making a personal plugin, I also want to boost xp, but for that I need to use the hook just in one plugin, so I have this problem:

    Code:
    object OnXpEarn(BasePlayer player, float amount, string source)
            {
                amount * 10f; //stolen from your plugin :P
    // some other code that works fine
                return null;
            }
    That does not work. I can't find what I am doing wrong.
     
  10. Wulf

    Wulf Community Admin

    You have to return the amount, not null.
     
  11. Code:
    amount = amount * 10f;
    return amount;
    Can't make it work.
    Sorry Wulf, I'm giving you a headache.
     
  12. Wulf

    Wulf Community Admin

    You're likely not on the latest Oxide version then.
     
  13. You're right. Thanks Wulf. You're amazing.