Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help timer/message for flags
#1
can i add, a delay timers to activate the flag, and a message warning to move?

credits @archit


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

namespace Teleport
{
    public class Class1 : CPlugin
    {

        Dictionary<string, Vector> flagsorigin = new Dictionary<string, Vector>();
        Dictionary<string, Vector> flagsdesti = new Dictionary<string, Vector>();
        public override void OnServerLoad()
        {
            ServerPrint("KILLERFLAGS plugin loaded!");
        }
        public override void OnMapChange()
        {
            makeflags();
        }
        public override void OnFastRestart()
        {
            makeflags();
        }
        public static double Distance(Vector vec1, Vector vec2)
        {
            return Math.Sqrt(Math.Pow(vec1.X - vec2.X, 2) + Math.Pow(vec1.Y - vec2.Y, 2) + Math.Pow(vec1.Z - vec2.Z, 2));
        }

        public override void OnAddonFrame()
        {
            foreach (string key in flagsorigin.Keys)
            {
                if (key.Split(',')[0] == GetDvar("mapname"))
                {
                    if (GetClients() != null)
                    {
                        foreach (ServerClient Client in GetClients())
                        {
                            if (Distance(new Vector(Client.OriginX, Client.OriginY, Client.OriginZ), flagsorigin[key]) <= 300f)
                            {
                                Client.OriginX = flagsdesti[key].X;
                                Client.OriginY = flagsdesti[key].Y;
                                Client.OriginZ = flagsdesti[key].Z;
                            }
                        }
                    }
                }
            }
        }
        void makeflags()
        {
            try
            {
                string flag = GetServerCFG("KILLERFLAGS", "die", "0");
                if (flag != "0")
                {

                    for (int i = 1; i <= int.Parse(flag); i++)
                    {
                        string flaged = GetServerCFG("KILLERFLAGS", string.Format("die{0}", i.ToString()), "null");
                        if (flaged != null)
                        {
                            string map = flaged.Split(',')[0];
                            string vector = flaged.Split(',')[1];
                            string vector2 = vector.Split('(')[1];
                            string vector3 = vector2.Split(')')[0];
                            string vec1 = vector3.Split('_')[0];
                            string vec2 = vector3.Split('_')[1];
                            string vec3 = vector3.Split('_')[2];
                            Vector vec = new Vector(Convert.ToSingle(vec1), Convert.ToSingle(vec2), Convert.ToSingle(vec3));
                            if (!flagsorigin.ContainsValue(vec))
                                flagsorigin.Add(string.Format("{0},{1}", map, i.ToString()), vec);
                            vector = flaged.Split(',')[2];
                            vector2 = vector.Split('(')[1];
                            vector3 = vector2.Split(')')[0];
                            vec1 = vector3.Split('_')[0];
                            vec2 = vector3.Split('_')[1];
                            vec3 = vector3.Split('_')[2];
                            vec = new Vector(Convert.ToSingle(vec1), Convert.ToSingle(vec2), Convert.ToSingle(vec3));
                            if (!flagsdesti.ContainsValue(vec))
                                flagsdesti.Add(string.Format("{0},{1}", map, i.ToString()), vec);

                        }

                    }
                    foreach (string key in flagsdesti.Keys)
                    {
                        if (key.Split(',')[0] == GetDvar("mapname"))
                        {
                            Entity en = SpawnModel("script_brushmodel", "prop_flag_neutral", flagsdesti[key]);
                        }
                    }

                    foreach (string key in flagsdesti.Keys)
                    {
                        if (key.Split(',')[0] == GetDvar("mapname"))
                        {
                            Entity en = SpawnModel("script_brushmodel", "prop_flag_neutral", flagsorigin[key]);
                        }
                    }

                }
            }
            catch (Exception e)
            {
                ServerPrint(e.ToString());
            }
        }
    }
}
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#2
(01-07-2013, 22:11)hillbilly Wrote: can i add, a delay timers to activate the flag, and a message warning to move?

yes, you can
Troll
[Image: compiling.png][Image: aLKA8og_460sa.gif]
Reply

#3
ok i will rephrase the question, how can i?
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#4
Is there an AfterDelay in the Server Addon? If so you need to do a delegate after.
Do not take life too seriously. You will never get out of it alive.
[Image: UGPjFJa.jpg]
Reply

#5
Why using script_brushmodel, use script_model
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#6
(01-08-2013, 00:02)DidUknowiPwn Wrote: Is there an AfterDelay in the Server Addon? If so you need to do a delegate after.

No, all timing must be handled manually through OnServerFrame (per frame hook) or OnAddonFrame (250ms frame).

EDIT - Added timing functions to MW3 Server Addon Extensions: http://www.itsmods.com/forum/Thread-Rele...sions.html
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#7
If you still need this I can add it to the plugin
Reply

#8
(01-14-2013, 13:06)archit Wrote: If you still need this I can add it to the plugin

please do
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#9
I couldn't understand what you mean though, if a player stays in a flag area he gets a warning and if he doesn't move he is teleported?
Reply

#10
(01-15-2013, 13:24)archit Wrote: I couldn't understand what you mean though, if a player stays in a flag area he gets a warning and if he doesn't move he is teleported?

yes, as i use 2 versions of the flag, one for tp and one for death trap for glitches.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply



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

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.