Posts: 273
Threads: 14
Joined: Aug 2012
Reputation:
17
You only have to add hud.SetString(""); , it doesn't matter if you use more than one map
Posts: 322
Threads: 43
Joined: Mar 2012
Reputation:
-4
(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;
I was lazy to add HUD
Now plugin with HUD is much better.
I just use Kill Zone without warning
Posts: 836
Threads: 48
Joined: Feb 2012
Reputation:
11
01-20-2013, 00:24
(This post was last modified: 01-20-2013, 00:24 by hillbilly.)
Posts: 285
Threads: 15
Joined: Nov 2011
Reputation:
12
(01-20-2013, 00:24)hillbilly Wrote: CSHARP Code
public override void OnMapChange() { map = GetDvar("mapname"); 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; } }
Code: if(map =="mp_dome")
{
x=10f;
y=65f;
}
Posts: 836
Threads: 48
Joined: Feb 2012
Reputation:
11
01-20-2013, 15:20
(This post was last modified: 01-20-2013, 15:20 by hillbilly.)
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);
}
}
Posts: 273
Threads: 14
Joined: Aug 2012
Reputation:
17
01-20-2013, 15:44
(This post was last modified: 01-20-2013, 15:45 by 8q4s8.)
(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 == "")
Posts: 836
Threads: 48
Joined: Feb 2012
Reputation:
11
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);
}
}
}
Posts: 3,704
Threads: 147
Joined: Jan 2011
Reputation:
119
(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-Cdeveloper. Neko engine wip
Steam: Click
Posts: 273
Threads: 14
Joined: Aug 2012
Reputation:
17
01-20-2013, 16:54
(This post was last modified: 01-20-2013, 16:58 by 8q4s8.)
(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
Posts: 836
Threads: 48
Joined: Feb 2012
Reputation:
11
01-20-2013, 16:58
(This post was last modified: 01-20-2013, 16:59 by hillbilly.)
(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
|