1. So what im trying to do is that when the F1 explodes it spawns 10 more F1s thrown around it
    I get this error only when it tries to run the timer. the code compiles fine

    Code:
    Failed to run a 3.00 timer in 'test v0.0.1' (NullReferenceException: )
    at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
    at Oxide.Plugins.test+<OnEntityKill>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
    at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00000] in <filename unknown>:0 
    and this is my code :
    Code:
    using System;
    using System.Text;
    using System.Collections.Generic;
    using Newtonsoft.Json.Linq;
    using Oxide.Core;
    using Oxide.Core.Configuration;
    using Oxide.Game.Rust.Cui;
    using Oxide.Core.Plugins;
    using System.Linq;
    using System.Globalization;
    using System.IO;
    using Newtonsoft.Json;
    using UnityEngine;namespace Oxide.Plugins
    {
       [Info("test", "Gary", "0.0.1")]
       internal class test : RustPlugin
       {
            
           public string entit = "assets/prefabs/weapons/f1 grenade/grenade.f1.deployed.prefab";
           public BasePlayer player;       void OnEntityKill(BaseNetworkable entity)
           {
               {
                   string ent = entity.ToString();
                   if (ent.Contains("grenade.f1"))
                   {                   timer.Once(3.9f, () =>
                       {
                           var x = 0;
                           var minis = 10;
                           var pos = entity.transform.position;
                           var rot = entity.transform.rotation;                       while (x < minis) ++x;
                           {
                               System.Random rand = new System.Random();
                               var newnader = GameManager.server.CreateEntity(entit, pos, rot, true);
                               Rigidbody rigidbody = newnader.gameObject.GetComponent<Rigidbody>();
                               rigidbody.useGravity = true;
                               rigidbody.velocity = new Vector3(rand.Next(3), 10, rand.Next(3));
                           }                   });
                   }
               }
           }       void OnExplosiveThrown(BasePlayer player, BaseEntity entity)
           {
               string ent = entity.ToString();
               if(ent.Contains("grenade.f1")) {
                             }
           }
       }
      
       }

    Any advice on fixing the time, or just cleaning up my code in general

    Thanks in advance!
     
  2. @Gary? After the timer delay, de "entity" does for sure not exist anymore.
    And that's why you can't access the non-existing "entity.transform" ;)
     
  3. Yup. ^
    Try storing the position/rotation before the timer.
     
  4. oh lol didnt see that thanks, before i had it to when the explosive was thrown, so i wanted to store the pos when it was about to explode
     
  5. I'm not sure if grenade explosion delay is fixed or randomised but, if it's fixed, you'd need a delay that you know is fractionally shorter than the fuse.
    Would do no harm to null check the entity, though, just in case.

    I did the same to get the smoking position of supply signal grenade because the thrown position could be 20-30 meters out from the call position, depending on terrain etc; Grab the entity position 3 seconds after it's spawned, or whatever.
     
  6. now i have a different problem, spawning the entity, I had it put the pos and rot in chat and that worked, but no entity spawns