• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help timer/message for flags
#21
You only have to add hud.SetString(""); , it doesn't matter if you use more than one map
[-] The following 1 user says Thank You to 8q4s8 for this post:
  • hillbilly
  Reply
#22
(01-17-2013, 20:30)hillbilly Wrote: Thanks Alex but i see that contains the dreaded Threading? is this ok now, or does it still cause server crashes?

No Threading, I forgot to remove: using System.Threading; Tongue

I was lazy to add HUD Big Grin

Now plugin with HUD is much better.

I just use Kill Zone without warning
[-] The following 1 user says Thank You to [Z00MBY] Alex for this post:
  • hillbilly
  Reply
#23
How to add extra maps to this, tried but cant get the bugger to work?

CSHARP Code
  1. using System;
  2. using Addon;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace killzone
  7. {
  8. public class killzone : CPlugin
  9. {
  10. Dictionary<int, int> HudElem = new Dictionary<int, int>();
  11.  
  12. public static float Difference(float loc, float loc2)
  13. {
  14. return Math.Abs(loc - loc2);
  15. }
  16.  
  17. float x;
  18. float y;
  19.  
  20. int distW;
  21. int distKill;
  22.  
  23. String map = "";
  24.  
  25. public override void OnMapChange()
  26. {
  27. map = GetDvar("mapname");
  28. if (map == "mp_mogadishu")
  29. {
  30. ////Zone of Death
  31. x = 1000f; //coord X
  32. y = 2100f; // coord Y
  33. distKill = 200; // Zone of Death
  34.  
  35. //// Warning Message
  36. distW = distKill + 100;
  37. }
  38.  
  39.  
  40. }
  41.  
  42.  
  43. public override void OnServerFrame()
  44. {
  45.  
  46. List<ServerClient> clients;
  47. try
  48. {
  49. clients = GetClients();
  50. if (clients != null)
  51. {
  52. foreach (ServerClient client in GetClients())
  53. {
  54. HudElem hud = GetHudElement(HudElem[client.ClientNum]);
  55. if (client.Other.isAlive == true &&
  56. client.ConnectionState != ConnectionStates.MapLoading &&
  57. client.ConnectionState != ConnectionStates.Connecting &&
  58. client.ConnectionState != ConnectionStates.Zombie)
  59. {
  60.  
  61. if (map == "mp_mogadishu")
  62. {
  63. if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
  64. {
  65. KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);
  66.  
  67. }
  68.  
  69. if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
  70. {
  71. hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
  72. }
  73. else
  74. {
  75. hud.SetString("");
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }
  82. catch (Exception e)
  83. {
  84. ServerPrint("Error in killzone plugin: \n" +
  85. e.Message + "\n" +
  86. e.StackTrace + "\n" +
  87. e.Source + "\n" +
  88. e.InnerException + "\n" +
  89. e.HelpLink);
  90. }
  91.  
  92. }
  93. private int CreateHud(int ClientNum)
  94. {
  95. HudElem hud = CreateNewHudElem();
  96. hud.Type = HudElementTypes.Text;
  97. hud.ShowToEnt = ClientNum;
  98. hud.HideInMenu = true;
  99. hud.Font = HudElementFonts.Default;
  100. hud.FontScale = 1.5f;
  101. hud.PointType = 120;
  102. hud.OriginY = 300f;
  103. hud.OriginX = -100f;
  104. hud.SetString("");
  105. return hud.HudElementNum;
  106. }
  107. public override void OnPlayerDisconnect(ServerClient Client)
  108. {
  109. if (HudElem.ContainsKey(Client.ClientNum))
  110. {
  111. HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]);
  112. hud2.Type = HudElementTypes.None;
  113. HudElem.Remove(Client.ClientNum);
  114. }
  115. }
  116. public override void OnPlayerConnect(ServerClient Client)
  117. {
  118. int Hud1 = CreateHud(Client.ClientNum);
  119. if (HudElem.ContainsKey(Client.ClientNum))
  120. HudElem[Client.ClientNum] = Hud1;
  121. else
  122. HudElem.Add(Client.ClientNum, Hud1);
  123. }
  124.  
  125. }
  126. }
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

  Reply
#24
(01-20-2013, 00:24)hillbilly Wrote:
CSHARP Code
  1. public override void OnMapChange()
  2. {
  3. map = GetDvar("mapname");
  4. if (map == "mp_mogadishu")
  5. {
  6. ////Zone of Death
  7. x = 1000f; //coord X
  8. y = 2100f; // coord Y
  9. distKill = 200; // Zone of Death
  10.  
  11. //// Warning Message
  12. distW = distKill + 100;
  13. }
  14. }
Code:
if(map =="mp_dome")
{
x=10f;
y=65f;
}
  Reply
#25
yeah tried that but still wont work.

Code:
using System;
using Addon;
using System.Collections.Generic;
using System.Text;

namespace killzone
{
    public class killzone : CPlugin
    {
        Dictionary<int, int> HudElem = new Dictionary<int, int>();

        public static float Difference(float loc, float loc2)
        {
            return Math.Abs(loc - loc2);
        }

        float x;
        float y;

        int distW;
        int distKill;

        String map = "";

        public override void OnMapChange()
        {
            map = GetDvar("mapname");
            if (map == "mp_underground")
            {
                x = 1649f;
                y = -15f;
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }
            
            if (map == "mp_mogadishu")
            {
                ////Zone of Death
                x = 1000f; //coord X
                y = 2100f; // coord Y
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }


        }


        public override void OnServerFrame()
        {

            List<ServerClient> clients;
            try
            {
                clients = GetClients();
                if (clients != null)
                {
                    foreach (ServerClient client in GetClients())
                    {
                        HudElem hud = GetHudElement(HudElem[client.ClientNum]);
                        if (client.Other.isAlive == true &&
       client.ConnectionState != ConnectionStates.MapLoading &&
       client.ConnectionState != ConnectionStates.Connecting &&
       client.ConnectionState != ConnectionStates.Zombie)
                        {

                            if (map == "mp_mogadishu")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint("Error in killzone plugin: \n" +
                             e.Message + "\n" +
                             e.StackTrace + "\n" +
                             e.Source + "\n" +
                             e.InnerException + "\n" +
                             e.HelpLink);
            }

        }
        private int CreateHud(int ClientNum)
        {
            HudElem hud = CreateNewHudElem();
            hud.Type = HudElementTypes.Text;
            hud.ShowToEnt = ClientNum;
            hud.HideInMenu = true;
            hud.Font = HudElementFonts.Default;
            hud.FontScale = 1.5f;
            hud.PointType = 120;
            hud.OriginY = 300f;
            hud.OriginX = -100f;
            hud.SetString("");
            return hud.HudElementNum;
        }
        public override void OnPlayerDisconnect(ServerClient Client)
        {
            if (HudElem.ContainsKey(Client.ClientNum))
            {
                HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]);
                hud2.Type = HudElementTypes.None;
                HudElem.Remove(Client.ClientNum);
            }
        }
        public override void OnPlayerConnect(ServerClient Client)
        {
            int Hud1 = CreateHud(Client.ClientNum);
            if (HudElem.ContainsKey(Client.ClientNum))
                HudElem[Client.ClientNum] = Hud1;
            else
                HudElem.Add(Client.ClientNum, Hud1);
        }

    }
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

  Reply
#26
(01-20-2013, 15:20)hillbilly Wrote: yeah tried that but still wont work.

Code:
using System;
using Addon;
using System.Collections.Generic;
using System.Text;

namespace killzone
{
    public class killzone : CPlugin
    {
        Dictionary<int, int> HudElem = new Dictionary<int, int>();

        public static float Difference(float loc, float loc2)
        {
            return Math.Abs(loc - loc2);
        }

        float x;
        float y;

        int distW;
        int distKill;

        String map = "";

        public override void OnMapChange()
        {
            map = GetDvar("mapname");
            if (map == "mp_underground")
            {
                x = 1649f;
                y = -15f;
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }
            
            if (map == "mp_mogadishu")
            {
                ////Zone of Death
                x = 1000f; //coord X
                y = 2100f; // coord Y
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }


        }


        public override void OnServerFrame()
        {

            List<ServerClient> clients;
            try
            {
                clients = GetClients();
                if (clients != null)
                {
                    foreach (ServerClient client in GetClients())
                    {
                        HudElem hud = GetHudElement(HudElem[client.ClientNum]);
                        if (client.Other.isAlive == true &&
       client.ConnectionState != ConnectionStates.MapLoading &&
       client.ConnectionState != ConnectionStates.Connecting &&
       client.ConnectionState != ConnectionStates.Zombie)
                        {

                            if (map == "mp_mogadishu")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint("Error in killzone plugin: \n" +
                             e.Message + "\n" +
                             e.StackTrace + "\n" +
                             e.Source + "\n" +
                             e.InnerException + "\n" +
                             e.HelpLink);
            }

        }
        private int CreateHud(int ClientNum)
        {
            HudElem hud = CreateNewHudElem();
            hud.Type = HudElementTypes.Text;
            hud.ShowToEnt = ClientNum;
            hud.HideInMenu = true;
            hud.Font = HudElementFonts.Default;
            hud.FontScale = 1.5f;
            hud.PointType = 120;
            hud.OriginY = 300f;
            hud.OriginX = -100f;
            hud.SetString("");
            return hud.HudElementNum;
        }
        public override void OnPlayerDisconnect(ServerClient Client)
        {
            if (HudElem.ContainsKey(Client.ClientNum))
            {
                HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]);
                hud2.Type = HudElementTypes.None;
                HudElem.Remove(Client.ClientNum);
            }
        }
        public override void OnPlayerConnect(ServerClient Client)
        {
            int Hud1 = CreateHud(Client.ClientNum);
            if (HudElem.ContainsKey(Client.ClientNum))
                HudElem[Client.ClientNum] = Hud1;
            else
                HudElem.Add(Client.ClientNum, Hud1);
        }

    }

You forgot to add this for mp_underground
Code:
if (map == "mp_underground")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                          }

I think you could also remove the if(map == "")
  Reply
#27
where's my nooby mistake?


Code:
using System;
using Addon;
using System.Collections.Generic;
using System.Text;

namespace killzone
{
    public class killzone : CPlugin
    {
        Dictionary<int, int> HudElem = new Dictionary<int, int>();

        public static float Difference(float loc, float loc2)
        {
            return Math.Abs(loc - loc2);
        }

        float x;
        float y;

        int distW;
        int distKill;

        String map = "";

        public override void OnMapChange()
        {
            map = GetDvar("mapname");
            if (map == "mp_underground")
            {
                x = 1649f;
                y = -15f;
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }
            
            if (map == "mp_mogadishu")
            {
                ////Zone of Death
                x = 1000f; //coord X
                y = 2100f; // coord Y
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }


        }


        public override void OnServerFrame()
        {

            List<ServerClient> clients;
            try
            {
                clients = GetClients();
                if (clients != null)
                {
                    foreach (ServerClient client in GetClients())
                    {
                        HudElem hud = GetHudElement(HudElem[client.ClientNum]);
                        if (client.Other.isAlive == true &&
       client.ConnectionState != ConnectionStates.MapLoading &&
       client.ConnectionState != ConnectionStates.Connecting &&
       client.ConnectionState != ConnectionStates.Zombie)
                        {

                            if (map == "mp_underground")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }

                            if (map == "mp_mogadishu")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint("Error in killzone plugin: \n" +
                             e.Message + "\n" +
                             e.StackTrace + "\n" +
                             e.Source + "\n" +
                             e.InnerException + "\n" +
                             e.HelpLink);
            }

        }
        private int CreateHud(int ClientNum)
        {
            HudElem hud = CreateNewHudElem();
            hud.Type = HudElementTypes.Text;
            hud.ShowToEnt = ClientNum;
            hud.HideInMenu = true;
            hud.Font = HudElementFonts.Default;
            hud.FontScale = 1.5f;
            hud.PointType = 120;
            hud.OriginY = 300f;
            hud.OriginX = -100f;
            hud.SetString("");
            return hud.HudElementNum;
        }
        public override void OnPlayerDisconnect(ServerClient Client)
        {
            if (HudElem.ContainsKey(Client.ClientNum))
            {
                HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]);
                hud2.Type = HudElementTypes.None;
                HudElem.Remove(Client.ClientNum);
            }
        }
        public override void OnPlayerConnect(ServerClient Client)
        {
            int Hud1 = CreateHud(Client.ClientNum);
            if (HudElem.ContainsKey(Client.ClientNum))
                HudElem[Client.ClientNum] = Hud1;
            else
                HudElem.Add(Client.ClientNum, Hud1);
        }

    }
}
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

  Reply
#28
(01-20-2013, 16:13)hillbilly Wrote: where's my nooby mistake?


Code:
using System;
using Addon;
using System.Collections.Generic;
using System.Text;

namespace killzone
{
    public class killzone : CPlugin
    {
        Dictionary<int, int> HudElem = new Dictionary<int, int>();

        public static float Difference(float loc, float loc2)
        {
            return Math.Abs(loc - loc2);
        }

        float x;
        float y;

        int distW;
        int distKill;

        String map = "";

        public override void OnMapChange()
        {
            map = GetDvar("mapname");
            if (map == "mp_underground")
            {
                x = 1649f;
                y = -15f;
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }
            
            if (map == "mp_mogadishu")
            {
                ////Zone of Death
                x = 1000f; //coord X
                y = 2100f; // coord Y
                distKill = 200; // Zone of Death

                //// Warning Message
                distW = distKill + 100;
            }


        }


        public override void OnServerFrame()
        {

            List<ServerClient> clients;
            try
            {
                clients = GetClients();
                if (clients != null)
                {
                    foreach (ServerClient client in GetClients())
                    {
                        HudElem hud = GetHudElement(HudElem[client.ClientNum]);
                        if (client.Other.isAlive == true &&
       client.ConnectionState != ConnectionStates.MapLoading &&
       client.ConnectionState != ConnectionStates.Connecting &&
       client.ConnectionState != ConnectionStates.Zombie)
                        {

                            if (map == "mp_underground")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }

                            if (map == "mp_mogadishu")
                            {
                                if ((Difference(client.OriginX, x) <= distKill) && (Difference(client.OriginY, y) <= distKill))
                                {
                                    KillPlayer(client.ClientNum, client.ClientNum, GetWeapon("iw5_m60jugg"), string.Empty);

                                }

                                if ((Difference(client.OriginX, x) <= distW) && (Difference(client.OriginY, y) <= distW))
                                {
                                    hud.SetString("^1ATTENTION! You are near to the Zone of Death!!");
                                }
                                else
                                {
                                    hud.SetString("");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint("Error in killzone plugin: \n" +
                             e.Message + "\n" +
                             e.StackTrace + "\n" +
                             e.Source + "\n" +
                             e.InnerException + "\n" +
                             e.HelpLink);
            }

        }
        private int CreateHud(int ClientNum)
        {
            HudElem hud = CreateNewHudElem();
            hud.Type = HudElementTypes.Text;
            hud.ShowToEnt = ClientNum;
            hud.HideInMenu = true;
            hud.Font = HudElementFonts.Default;
            hud.FontScale = 1.5f;
            hud.PointType = 120;
            hud.OriginY = 300f;
            hud.OriginX = -100f;
            hud.SetString("");
            return hud.HudElementNum;
        }
        public override void OnPlayerDisconnect(ServerClient Client)
        {
            if (HudElem.ContainsKey(Client.ClientNum))
            {
                HudElem hud2 = GetHudElement(HudElem[Client.ClientNum]);
                hud2.Type = HudElementTypes.None;
                HudElem.Remove(Client.ClientNum);
            }
        }
        public override void OnPlayerConnect(ServerClient Client)
        {
            int Hud1 = CreateHud(Client.ClientNum);
            if (HudElem.ContainsKey(Client.ClientNum))
                HudElem[Client.ClientNum] = Hud1;
            else
                HudElem.Add(Client.ClientNum, Hud1);
        }

    }
}

The whole code is "nooby" mistake.
C++/Obj-C developer. Neko engine wip
Steam: Click
  Reply
#29
(01-20-2013, 16:13)hillbilly Wrote: where's my nooby mistake?

Your code is working fine for me, maybe you added the wrong location.

@SailorMoon Your post won't help and the code from @[Z00MBY] Alex isn't that bad, I would like to see your code though
[-] The following 1 user says Thank You to 8q4s8 for this post:
  • hillbilly
  Reply
#30
(01-20-2013, 16:54)8q4s8 Wrote:
(01-20-2013, 16:13)hillbilly Wrote: where's my nooby mistake?

Your code is working fine for me, maybe you added the wrong location.

Ok thanks i'll try again.

@Sailormoon

try finishing off what you started, or is it yet again another failure.
http://www.itsmods.com/forum/Thread-Prev...ml?page=11
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

[-] The following 2 users say Thank You to hillbilly for this post:
  • 99IRock, Nekochan
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Help remove timer Dynasty 15 3,009 08-25-2013, 13:56
Last Post: hillbilly
  Help Spawn Message Playing on Respawn? Killjoy 7 1,837 07-11-2013, 14:53
Last Post: Killjoy
  [News] Message from Gabe to Steam Community d0h! 8 2,123 04-05-2013, 18:16
Last Post: SuperNovaAO
  Countdown timer pflaurie 2 765 03-14-2013, 11:30
Last Post: pflaurie
  Help bunkers,tex, glusses and Flags teleport ᵧₒᵤ funny 4 1,263 01-28-2013, 21:57
Last Post: 99IRock
  [Request] Different message per map hillbilly 6 1,315 12-22-2012, 20:55
Last Post: hillbilly
  [HELP] pm's message korsika 1 842 12-15-2012, 13:13
Last Post: Ich1994
  Chat Message The Tronuo 8 1,535 11-12-2012, 18:05
Last Post: Nekochan
  Health,regenerate, and message changes help mbakerinnv 4 1,294 11-02-2012, 18:12
Last Post: mbakerinnv
  S&D Welcome message only once (no repeating) islamsaab 2 893 10-11-2012, 18:40
Last Post: islamsaab

Forum Jump:


Users browsing this thread: 1 Guest(s)