05-29-2013, 17:44
Code:
using System;
using System.Collections.Generic;
using Addon;
using System.Threading;
using System.IO;
using System.Collections;
namespace flags
{
public class flags : CPlugin
{
Dictionary<int, int> Client_HudElem_lm = new Dictionary<int, int>();
public override void OnServerLoad()
{
ServerPrint("Flags plugin by Litgar loaded!");
}
public override void OnMapChange()
{
string map = GetDvar("mapname");
if (map == "mp_paris")
{
Entity w = SpawnModel("script_model", "prop_flag_neutral", new Vector(-2179.646f, -205.2038f, 185.125f));
Entity w1 = SpawnModel("script_model", "prop_flag_neutral", new Vector(-585.984f, 875.5912f, 1293.608f));
}
}
public override void OnAddonFrame()
{
List<ServerClient> clients;
try
{
clients = GetClients();
if (clients != null && clients.Count > 0)
{
foreach (ServerClient c in GetClients())
{
if (c.Other.isAlive == true)
{
HudElem hl = GetHudElement(Client_HudElem_lm[c.ClientNum]);
string map = GetDvar("mapname");
/////////
if (map == "mp_paris")
{
if ((Difference(c.OriginY, -205.2038f) <= 100) && (Difference(c.OriginX, -2179.646f) <= 100) && c.OriginZ >= 185.125f)
{
hl.SetString("Press ^3F^7 to ^1Teleport");
if (c.Other.ButtonPressed(Buttons.Activate))
{if (c.Stats.Kills >= 5 && c.Team == Teams.Allies)
{
iPrintLnBold("^2Teleportation!", c);
c.OriginX = -882.2723f;
c.OriginY = 5308.667f;
c.OriginZ = 460.125f;
}
else if (c.Stats.Kills == 4 && c.Team == Teams.Allies)
{
iPrintLnBold("^2You need^1 1 ^2Kills Zombie for teleportation!", c);
}
else { iPrintLnBold("^2Teleportation!", c);
c.OriginX = -882.2723f;
c.OriginY = 5308.667f;
c.OriginZ = 460.125f;}
}
}
else
{
hl.SetString("");
}
}
}
}
}
}
catch (Exception z)
{
ServerPrint("Error flag: " + z.Message);
}
}
public static float Difference(float loc, float loc2)
{
return Math.Abs(loc - loc2);
}
public override void OnPlayerDisconnect(ServerClient client)
{
if (Client_HudElem_lm.ContainsKey(client.ClientNum))
{
HudElem info2 = GetHudElement(Client_HudElem_lm[client.ClientNum]);
info2.Type = HudElementTypes.None;
Client_HudElem_lm.Remove(client.ClientNum);
}
}
public override void OnPlayerConnect(ServerClient client)
{
int HudElemNum1 = CreateHud_lm(client.ClientNum);
if (Client_HudElem_lm.ContainsKey(client.ClientNum))
Client_HudElem_lm[client.ClientNum] = HudElemNum1;
else
Client_HudElem_lm.Add(client.ClientNum, HudElemNum1);
}
private int CreateHud_lm(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 = 180f;
hud.OriginX = -100f;
hud.SetString("");
return hud.HudElementNum;
}
}
}
position of the attached file