1. Code:
    private void SetXP(BasePlayer player, float amt)
            {
               
           
               
               
                var agent = BasePlayer.FindXpAgent(player.userID);
                float xp = player.xp.SpentXp + player.xp.UnspentXp;
                if (xp < amt && amt < 0 ) return;
                var newxp = xp + amt;
                agent?.Reset();
                agent.Add(Rust.Xp.Definitions.Cheat, newxp);
               
               
               
            }
    This procedure gives or takes XP (not level) from a player, but sometimes it seems to bug out, like its giving out too much XP. Could it be this code? I also have a onexpearn plug in operation, could this be the problem?

    Code:
    object OnXpEarn(ulong steamId, double amount, string source)
            {
                if (string.IsNullOrEmpty(source) ) return null;        
                var bonus = 1f;
                if (ConVar.Server.hostname.Contains("2X")) bonus = 2f;
                if (ConVar.Server.hostname.Contains("3X")) bonus = 3f;
                if (ConVar.Server.hostname.Contains("4X")) bonus = 4f;
                if (ConVar.Server.hostname.Contains("5X")) bonus = 5f;
               
               
           
               
                return (float)(amount * bonus);
            }
    Thanks in advance!
     
  2. You should check to make sure the source isn't "Cheat". XpBooster already does this.
     
  3. What source should i use? Im not interested in 3rd party plugs, i just need this function to work properly 100% of times.
     
  4. Code:
    object OnXpEarn(ulong steamId, double amount, string source)
            {
                if (string.IsNullOrEmpty(source) ) return null;
    if (source.ToLower().Contains("cheat")) return null;       
                var bonus = 1f;
                if (ConVar.Server.hostname.Contains("2X")) bonus = 2f;
                if (ConVar.Server.hostname.Contains("3X")) bonus = 3f;
                if (ConVar.Server.hostname.Contains("4X")) bonus = 4f;
                if (ConVar.Server.hostname.Contains("5X")) bonus = 5f;
               
               
           
               
                return (float)(amount * bonus);
            }
    Just an example. I think the source is just "Cheat" but I used a tolower and contains in case it isn't. Basically, the code won't execute if it's a "cheat" source.
     
  5. Can you answer PM. :)