• 3 Vote(s) - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Flag plugin for users 1.6
#21
(09-11-2012, 15:20)archit Wrote:
(09-11-2012, 14:53)jari333 Wrote: Okay, the plugin works now. But when i try to make the flags at the positions i want, get i an error:
System.IndexOutOfRangeException: The index is outside the array bounds.

    at teleport.Class1.makeflags ()
System.IndexOutOfRangeException: The index is outside the array bounds.

    at teleport.Class1.makeflags ()
System.IndexOutOfRangeException: The index is outside the array bounds.

    at teleport.Class1.makeflags ()
This is the [TELEPORT] in my sv_config:

[TELEPORTER]
flags=4
flag1=mp_seatown,(1200,500,180),(1500,500,565)
flag2=mp_lambeth,(750,0,-255),(2500,2500,-200)
flag3=mp_exchange,(-500,1500,130),(-1500,0,2020)
flag4=mp_terminal_cls,(650,3880,340),(-1000,6000,320)
Should be
Code:
flags=4
flag1=mp_seatown,(1200_500_180),(1500_500_565)
flag2=mp_lambeth,(750_0_-255),(2500_2500_-200)
flag3=mp_exchange,(-500_1500_130),(-1500_0_2020)
flag4=mp_terminal_cls,(650_3880_340),(-1000_6000_320)
zxz0O0 Wrote:@archit Don't use threads.
What to use in place of it? I have no idea about a replacement of thread

(09-11-2012, 14:20)CJGreenLabel Wrote: This plugin crashed the server after nextmap or map restart. Sad

You used wrong format

PM me the Source code and i will get rid of the threads
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#22
The code is on page one

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

namespace teleport
{
    public class Class1:CPlugin
    {
        public override void OnServerLoad()
        {
            ServerPrint("Teleport 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));
        }
        void monitordist(Vector point, int radius,Vector destination)
        {
            string map = GetDvar("mapname");
            while (GetDvar("mapname") == map)
            {
                if (GetClients() != null)
                {
                    foreach (ServerClient Client in GetClients())
                    {
                        if (Distance(new Vector(Client.OriginX, Client.OriginY, Client.OriginZ), point) <= radius)//same as flag
                        {
                            Client.OriginX = destination.X;
                            Client.OriginY = destination.Y;
                            Client.OriginZ = destination.Z;
                        }
                    }
                }
            }

        }
        void makeflags()
        {
            try
            {
                string flag = GetServerCFG("TELEPORTER", "flags", "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]);
                            Thread distance = new Thread(dist => monitordist(flagsorigin[key], 50, flagsdesti[key]));
                            distance.Start();
                        }
                    }

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


[Image: b_560_95_1.png]

  Reply
#23
(09-11-2012, 21:32)hillbilly Wrote: The code is on page one

LOL Will do it tomorrow, going to sleep nauw
[Image: compiling.png][Image: aLKA8og_460sa.gif]
  Reply
#24
(09-11-2012, 15:20)archit Wrote:
zxz0O0 Wrote:@archit Don't use threads.
What to use in place of it? I have no idea about a replacement of thread

OnAddonFrame is threaded, you can use it instead.
[Image: azuw.jpg]
  Reply
#25
http://www.itsmods.com/forum/Thread-Rele...opers.html

No threads - No crash! Tongue
  Reply
#26
(09-12-2012, 07:46)litgar Wrote: http://www.itsmods.com/forum/Thread-Rele...opers.html

No threads - No crash! Tongue

using System;
using System.Collections.Generic;
using Addon;
using System.Threading;
using System.IO;
using System.Collections;
namespace flags

Doesn't that still crash as your using Threading?
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

  Reply
#27
(09-12-2012, 10:27)hillbilly Wrote:
(09-12-2012, 07:46)litgar Wrote: http://www.itsmods.com/forum/Thread-Rele...opers.html

No threads - No crash! Tongue

using System;
using System.Collections.Generic;
using Addon;
using System.Threading;
using System.IO;
using System.Collections;
namespace flags

Doesn't that still crash as your using Threading?

He just simply forgot to remove "using System.Threading" but he is not creating a single Thread inside his code.
[Image: compiling.png][Image: aLKA8og_460sa.gif]
[-] The following 1 user says Thank You to Ich1994 for this post:
  • hillbilly
  Reply
#28
Here is the Code without Threads:

WARNING::
I did not tested the Code. Nor i checked if it even compiles.
I edit it Notepad++.
But as i look at the Code. It SHOULD work fine

EDIT: Changed access level of Struct to public
EDIT2: Added a missing ;
EDIT3: Removed unused imports
EDIT4: List.Add instead of List.add
EDIT5: Wow '-.- changed OnServerAddon() to OnServerFrame()
EDIT6: List.Clear instead of List.clear
[Image: compiling.png][Image: aLKA8og_460sa.gif]
[-] The following 2 users say Thank You to Ich1994 for this post:
  • Arteq, hillbilly
  Reply
#29
(09-12-2012, 12:22)Ich1994 Wrote: Here is the Code without Threads:

WARNING::
I did not tested the Code. Nor i checked if it even compiles.
I edit it Notepad++.
But as i look at the Code. I SHOULD work fine

code being tested ................

EDIT
Code tested and working.

uploaded by request,
credits .
@archit
@Ich1994
@me.. for testing lol


Attached Files
.rar   flag.rar (Size: 3.19 KB / Downloads: 33)
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

[-] The following 2 users say Thank You to hillbilly for this post:
  • Arteq, jari333
  Reply
#30
Does anyone server use this plugin?
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 1,737 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 2,005 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 18,621 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 2,684 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 1,926 10-19-2013, 06:59
Last Post: iRoNinja
  Make area detect. flag Teleport lewisbibo 4 1,963 10-12-2013, 18:10
Last Post: EnVi Sweden Rocks
  [Release] Yurio Map Plugin Yurio 101 30,219 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 9,647 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 1,158 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 14,812 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks

Forum Jump:


Users browsing this thread: 1 Guest(s)