1. 1. How can I record logs from my plugin to a separate file? For example to logs/logDamage.txt
    2. How can I learn the amount of inflicted damage from HitInfo? How much HP there was and how much it became?
     
  2. Wulf

    Wulf Community Admin

    You'd need to add logging to each plugin.

    Make a test plugin that prints hitInfo out.
     
  3. hit info out:
    Code:
    public class HitInfo
    {
        public bool CanGather;
        public DamageTypeList damageTypes;
        public bool DidGather;
        public bool DidHit;
        public bool DoHitEffects;
        public uint HitBone;
        public BaseEntity HitEntity;
        public uint HitMaterial;
        public Vector3 HitNormalLocal;
        public Vector3 HitNormalWorld;
        public uint HitPart;
        public Vector3 HitPositionLocal;
        public Vector3 HitPositionWorld;
        public Vector3 HitVelocity;
        public BaseEntity Initiator;
        public bool IsPredicting;
        public PhysicMaterial material;
        public Vector3 PointEnd;
        public Vector3 PointStart;
        public Connection Predicted;
        public int ProjectileID;
        public AttackEntity Weapon;
        public BaseEntity WeaponPrefab;    public HitInfo();
        public HitInfo(BaseEntity attacker, DamageType type, float damageAmount, Vector3 vhitPosition);    public Vector3 attackNormal { get; }
        public Translate.Phrase boneName { get; }
        public bool hasDamage { get; }
        public bool isHeadshot { get; }    public void LoadFromAttack(Attack attack, bool serverSide);
    }
    And do you have example logging in plugin ?
     
  4. I haven't tried it but I'm sure you can use the basic .NET file functions to write to a file.. Look at System.IO.File... Might have access issues though I don't know what kind of privileges plugins run as, they might be sandboxed I have no idea.
     
  5. Wulf

    Wulf Community Admin

    System.IO is blacklisted actually. Rust does expose a logging function, but that may not remain. There's a few threads on doing this though.
     
  6. Use: ConVar.Server.Log("Oxide/Logs/logDamage.txt", "LogLine");
     
  7. Thanks a lot! And could you please tell me how to change the log's data format from 12 hour clock to 24 hour clock? And how do I get the info about the amount of damage received from HitInfo?
     
  8. Wulf

    Wulf Community Admin

    Code:
    ConVar.Server.Log("oxide/logs/logdamage_" .. time.GetCurrentTime():ToLocalTime():ToString("d-M-yyyy") .. ".txt", message)
     
  9. var now = DateTime.Now.ToString("yyyyMMdd");
    ConVar.Server.Log("logs/logDamage_" + now + ".txt", msg);

    filename: logDamage_20150702.txt
    [7/2/2015 11:18:29 PM] Raahauge(steamId=76561198151034518, pos=893.3168,30.17666,-241.8587) give damage to Road_To_100_MMR(steamId=76561198135581725, pos=844.0074,34.4678,-267.4487), weapon: weapons/rifle/boltrifle.weapon[5244712], distance:55.7m, to:neck

    this time: [7/2/2015 11:18:29 PM] . Need 23:18:29
     
  10. Wulf

    Wulf Community Admin

    https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx