none
Problem RRS feed

  • Question

  • How can i add  hudElem0 in public void someMethod1

    it says not found in someMethod1 the hudElem0

    i need a command there

            private void CreateServerAd2()
            {



                _delayTimer = new System.Timers.Timer();
                    _delayTimer.Interval = 50000;
                    _delayTimer.AutoReset = true; //so that it only calls the method once
                    _delayTimer.Elapsed += (s, args) => someMethod();
                
                _delayTimer.Start();


                __delayTimer = new System.Timers.Timer();
                __delayTimer.Interval = 100000;
                __delayTimer.AutoReset = true; //so that it only calls the method once
                __delayTimer.Elapsed += (s, args) => someMethod1();
              
                __delayTimer.Start();

            }

            public void someMethod()
            {


                

                HudElem hudElem0 = base.CreateNewHudElem();
              
                hudElem0.Type = HudElementTypes.Text;
                hudElem0.ShowToEnt = base.Entity_World;
                hudElem0.HideInMenu = true;
                hudElem0.Font = HudElementFonts.Default;
                hudElem0.FontScale = 1.1f;
                hudElem0.PointType = 82;
                hudElem0.OriginY = 200f;
                hudElem0.OriginX = 410f;
                hudElem0.Color.GlowA = 50;
                hudElem0.Color.GlowR = 155;
                hudElem0.Color.GlowG = 0;
                hudElem0.Color.GlowB = 0;
                hudElem0.SetString("Top of Plane is not allowed");
                _delayTimer.Stop();
                hudElem0.Type = HudElementTypes.None;
                





            }

            public void someMethod1()
            {

                
                HudElem hudElem1 = base.CreateNewHudElem();
                hudElem1.Type = HudElementTypes.Text;
                hudElem1.ShowToEnt = Entity_World;
                hudElem1.HideInMenu = true;
                hudElem1.Font = HudElementFonts.Default;
                hudElem1.FontScale = 1.1f;
                hudElem1.PointType = 82;
                hudElem1.OriginY = 200f;
                hudElem1.OriginX = 410f;
                hudElem1.Color.GlowA = 50;
                hudElem1.Color.GlowR = 155;
                hudElem1.Color.GlowG = 0;
                hudElem1.Color.GlowB = 0;
                hudElem1.SetString("test");
                __delayTimer.Stop();
                hudElem1.Type = HudElementTypes.None;
                

                



            }

    Saturday, April 1, 2017 2:45 PM

All replies

  • What is hudElem?

    Success
    Cor

    Saturday, April 1, 2017 3:56 PM
  • Hud Element is a text for call of duty

    i trie to make a slider

    text + wait + text

    and i need help

    Saturday, April 1, 2017 4:00 PM
  • i need hudElem0 in someMethod1 and hudElem0 in someMethod

    Saturday, April 1, 2017 4:02 PM
  • Hi xxhitmanxx,

    I would suggest that you could create a method to create hudElem0 and return hudElem0. like this:

    public HudElem gethudElem0()
             {
                 HudElem hudElem0 = base.CreateNewHudElem();           
                 hudElem0.Type = HudElementTypes.Text;
                 hudElem0.ShowToEnt = base.Entity_World;
                 hudElem0.HideInMenu = true;
                 hudElem0.Font = HudElementFonts.Default;
                 hudElem0.FontScale = 1.1f;
                 hudElem0.PointType = 82;
                 hudElem0.OriginY = 200f;
                 hudElem0.OriginX = 410f;
                 hudElem0.Color.GlowA = 50;
                 hudElem0.Color.GlowR = 155;
                 hudElem0.Color.GlowG = 0;
                 hudElem0.Color.GlowB = 0;
                 hudElem0.SetString("Top of Plane is not allowed");
                 _delayTimer.Stop();
                 hudElem0.Type = HudElementTypes.None;
                 retrun hudElem0;
             }

    #Usage:

    public void someMethod() {

    HudElem hudElem0 = gethudElem0(); }

    public void someMethod1()
    {
    
      HudElem hudElem0 = gethudElem0();
    
      HudElem hudElem1 = base.CreateNewHudElem();
                 hudElem1.Type = HudElementTypes.Text;
                 hudElem1.ShowToEnt = Entity_World;
                 hudElem1.HideInMenu = true;
                 hudElem1.Font = HudElementFonts.Default;
                 hudElem1.FontScale = 1.1f;
                 hudElem1.PointType = 82;
                 hudElem1.OriginY = 200f;
                 hudElem1.OriginX = 410f;
                 hudElem1.Color.GlowA = 50;
                 hudElem1.Color.GlowR = 155;
                 hudElem1.Color.GlowG = 0;
                 hudElem1.Color.GlowB = 0;
                 hudElem1.SetString("test");
                 __delayTimer.Stop();
                 hudElem1.Type = HudElementTypes.None;
                 
    }
    

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 4, 2017 2:43 AM
    Moderator
  • Server is crashing

            private void CreateServerAd2()
            {



                _delayTimer = new System.Timers.Timer();
                    _delayTimer.Interval = 50000;
                    _delayTimer.AutoReset = true; //so that it only calls the method once
                    _delayTimer.Elapsed += (s, args) => someMethod();
                
                _delayTimer.Start();


                __delayTimer = new System.Timers.Timer();
                __delayTimer.Interval = 100000;
                __delayTimer.AutoReset = true; //so that it only calls the method once
                __delayTimer.Elapsed += (s, args) => someMethod1();

                __delayTimer.Start();

            }

            public void someMethod()
            {
                HudElem hudElem0 = gethudElem0();
            }

            public void someMethod1()
            {

                HudElem hudElem0 = gethudElem0();

                HudElem hudElem1 = base.CreateNewHudElem();
                hudElem1.Type = HudElementTypes.Text;
                hudElem1.ShowToEnt = Entity_World;
                hudElem1.HideInMenu = true;
                hudElem1.Font = HudElementFonts.Default;
                hudElem1.FontScale = 1.1f;
                hudElem1.PointType = 82;
                hudElem1.OriginY = 200f;
                hudElem1.OriginX = 410f;
                hudElem1.Color.GlowA = 50;
                hudElem1.Color.GlowR = 155;
                hudElem1.Color.GlowG = 0;
                hudElem1.Color.GlowB = 0;
                hudElem1.SetString("test");
                _delayTimer.Stop();
                hudElem1.Type = HudElementTypes.None;

            }


            public HudElem gethudElem0()
            {
                
                HudElem hudElem0 = base.CreateNewHudElem();
                hudElem0.Type = HudElementTypes.Text;
                hudElem0.ShowToEnt = base.Entity_World;
                hudElem0.HideInMenu = true;
                hudElem0.Font = HudElementFonts.Default;
                hudElem0.FontScale = 1.1f;
                hudElem0.PointType = 82;
                hudElem0.OriginY = 200f;
                hudElem0.OriginX = 410f;
                hudElem0.Color.GlowA = 50;
                hudElem0.Color.GlowR = 155;
                hudElem0.Color.GlowG = 0;
                hudElem0.Color.GlowB = 0;
                hudElem0.SetString("Top of Plane is not allowed");
                _delayTimer.Stop();
                hudElem0.Type = HudElementTypes.None;
                return gethudElem0();
                
            }

    Thursday, April 6, 2017 12:18 PM
  • return gethudElem0; not works
    Thursday, April 6, 2017 12:19 PM
  • You've got some issues.

    __delayTimer.AutoReset = true; //so that it only calls the method once
    is backwards. This will call the timer every time the interval is reached. 

    "true if the Timer should raise the Elapsed event each time the interval elapses; false if it should raise the Elapsed event only once, after the first time the interval elapses. The default is true." -Retrieved from MSDN



    In response to: "return gethudElem0; not works". The return statement should be "return hudElem0;"



    Try this:

     private void CreateServerAd2()
    {
      _delayTimer = new System.Timers.Timer();
      _delayTimer.Interval = 50000;
      _delayTimer.AutoReset = false; //so that it only calls the method once
      _delayTimer.Elapsed += (s, args) => someMethod();
      _delayTimer.Start();
    
    
      __delayTimer = new System.Timers.Timer();
      __delayTimer.Interval = 100000;
      __delayTimer.AutoReset = false; //so that it only calls the method once
      __delayTimer.Elapsed += (s, args) => someMethod1();
    
      __delayTimer.Start();
    }
    
    
    public HudElem createHudElem() {
                HudElem _hudElem = base.CreateNewHudElem();
                _hudElem.Type = HudElementTypes.Text;
                _hudElem.ShowToEnt = base.Entity_World;
                _hudElem.HideInMenu = true;
                _hudElem.Font = HudElementFonts.Default;
                _hudElem.FontScale = 1.1f;
                _hudElem.PointType = 82;
                _hudElem.OriginY = 200f;
                _hudElem.OriginX = 410f;
                _hudElem.Color.GlowA = 50;
                _hudElem.Color.GlowR = 155;
                _hudElem.Color.GlowG = 0;
                _hudElem.Color.GlowB = 0;
                _hudElem.SetString("Top of Plane is not allowed");
     //        _delayTimer.Stop(); // Why is this here? This is what was stopping your timer..
                hudElem.Type = HudElementTypes.None;
                return _hudElem
    }
    
    
    public void someMethod() {
    
        HudElem _hudElem = createHudElem();
    
    }
    
    public void someOtherMethod() {
    
        HudElem _hudElem = createHudElem();
    
    }







    If you need to access the instance of the same HudElem between multiple methods, create the HudElem before starting the timers.





    Example:

     private HudElem myHudElem = null;
    
    
    private void CreateServerAd2()
    {
        myHudElem = createHudElem();
    
    
      _delayTimer = new System.Timers.Timer();
      _delayTimer.Interval = 50000;
      _delayTimer.AutoReset = false; //so that it only calls the method once
      _delayTimer.Elapsed += (s, args) => someMethod();
      _delayTimer.Start();
    
    
      __delayTimer = new System.Timers.Timer();
      __delayTimer.Interval = 100000;
      __delayTimer.AutoReset = false; //so that it only calls the method once
      __delayTimer.Elapsed += (s, args) => someMethod1();
    
      __delayTimer.Start();
    }
    
    
    public HudElem createHudElem() {
                HudElem _hudElem = base.CreateNewHudElem();
                _hudElem.Type = HudElementTypes.Text;
                _hudElem.ShowToEnt = base.Entity_World;
                _hudElem.HideInMenu = true;
                _hudElem.Font = HudElementFonts.Default;
                _hudElem.FontScale = 1.1f;
                _hudElem.PointType = 82;
                _hudElem.OriginY = 200f;
                _hudElem.OriginX = 410f;
                _hudElem.Color.GlowA = 50;
                _hudElem.Color.GlowR = 155;
                _hudElem.Color.GlowG = 0;
                _hudElem.Color.GlowB = 0;
                _hudElem.SetString("Top of Plane is not allowed");
     //        _delayTimer.Stop(); // Why is this here? This is what was stopping your timer..
                hudElem.Type = HudElementTypes.None;
                return _hudElem
    }
    
    
    public void someMethod() {
    
        //Do something with myHudElem
    
    }
    
    public void someOtherMethod() {
    
        //Do something with myHudElem
    
    }




    Thursday, April 6, 2017 12:33 PM