ItsMods

Full Version: Flag plugin for users 1.6
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8
(01-12-2013, 20:25)archit Wrote: [ -> ]1.4 doesn't show flag but teleport still works?

This is the code that works for both, just tested it, flags show up fine using as flag and as a tp kill zone, attached is flag.dll with radius made a little bigger

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

namespace teleport
{
    public class Class1 : CPlugin
    {
        struct ProcessFlags
        {
            public Vector point;
            public int radius;
            public Vector destination;
            public ProcessFlags(Vector point, int radius, Vector destination)
            {
                this.point = point;
                this.radius = radius;
                this.destination = destination;
            }
        };

        List<ProcessFlags> Flags = new List<ProcessFlags>();

        public override void OnServerLoad()
        {
            ServerPrint("TELEPORTER plugin loaded!");
        }
        public override void OnMapChange()
        {
            Flags.Clear();
            makeflags();
        }
        public override void OnFastRestart()
        {
            OnMapChange();
        }
        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()
        {
            List<ServerClient> clients = GetClients();
            if (clients != null)
            {
                foreach (ProcessFlags it in Flags)
                {
                    foreach (ServerClient Client in clients)
                    {
                        if (Distance(new Vector(Client.OriginX, Client.OriginY, Client.OriginZ), it.point) <= it.radius)//same as flag
                        {
                            Client.OriginX = it.destination.X;
                            Client.OriginY = it.destination.Y;
                            Client.OriginZ = it.destination.Z;
                        }
                    }
                }
            }
        }

        void makeflags()
        {
            try
            {
                string flag = GetServerCFG("TELEPORTER", "flag", "0");
                if (flag != "0")
                {

                    Dictionary<string, Vector> flagsorigin = new Dictionary<string, Vector>();
                    Dictionary<string, Vector> flagsdesti = new Dictionary<string, Vector>();
                    for (int i = 1; i <= int.Parse(flag); i++)
                    {
                        string flaged = GetServerCFG("TELEPORTER", string.Format("flag{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));
                            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));
                            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]);
                            Flags.Add(new ProcessFlags(flagsorigin[key], 50, flagsdesti[key]));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ServerPrint(e.ToString());
            }
        }
    }
}
New update ,whole new format
you didn't/can't add if map, because the version i have works fine as is.
if map=mp_dome
{
flag
{
Origin:
Destination:
}
}
Will work for you?
(01-14-2013, 09:29)archit Wrote: [ -> ]if map=mp_dome
{
flag
{
Origin:
Destination:
}
}
Will work for you?

sorry i meant distance to trigger via if map?
if map=mp_dome
{
flag
{
Origin:
Destination:
Radius:
}
}
??
hmm i cant even get the new one to work, Create a new file name mp_carbon.flag in plugins\teleport and add these?? what a txt file or what?

it just says No flags found
I think
Code:
hmm i cant even get the new one to work, Create a new file name mp_carbon.flag in plugins\teleport and add these?? what a txt file or what?
Code:
Create a new file name mp_carbon.flag in plugins\teleport
Code:
mp_carbon.flag
Code:
.flag
.flag > I think the file must be a .flag
hmm, well i cant get it to work
how to find the cordinates to create new flags?
Pages: 1 2 3 4 5 6 7 8