10-01-2013, 14:50
(This post was last modified: 12-30-2013, 15:03 by [HARD] Tony..)
creators
@xtreme2010 (coding)
@[Z00MBY]Alex (idea)
@[HARD] Tony_M (testing and releasing)
ITS VERSION FIXED ALL BUGS
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Addon;
namespace Marauder
{
public class Main : CPlugin
{
List<Vector> Position = new List<Vector>();
List<int> WeaponID = new List<int>();
List<int> Ammo = new List<int>();
List<int> AmmoClip = new List<int>();
List<Entity> WepModel = new List<Entity>();
//HUD Element
Dictionary<int, int> Client_Marauder = new Dictionary<int, int>();
//Client Data
Dictionary<int, int> Client_Weapon = new Dictionary<int, int>();
Dictionary<int, bool> Client_Premium = new Dictionary<int, bool>();
Dictionary<int, string> Client_WeaponModel = new Dictionary<int, string>();
bool LAST_ALLIES = false;
public bool LastAllies()
{
int ALLIES = 0, AXIS = 0;
ServerClient client = null;
for (int i = 0; i < 18; i++)
{
client = GetClient(i);
if (client != null)
{
if (client.Team == Teams.Allies)
{
ALLIES++;
}
else
{
AXIS++;
}
}
}
//(Axis > 4)
if (ALLIES == 1 && AXIS > 4)
{
return true;
}
return false;
}
public override void OnServerLoad()
{
ServerPrint("***************************************");
ServerPrint("[Marauder] xtreme2010[at]ukr.net**********");
ServerPrint("[Marauder] Created by [MEM]So Close****");
ServerPrint("***************loaded******************");
}
public override int OnPlayerDamaged(ServerClient Attacker, ServerClient Victim, string Weapon, int Damage)
{
if (Victim.Team == Teams.Allies && Client_Premium[Victim.ClientNum] == true && Damage >= Victim.Other.Health && Attacker.Team != Victim.Team)
{
WeaponID.Add(Client_Weapon[Victim.ClientNum]);
Ammo.Add(Victim.Ammo.PrimaryAmmo);
AmmoClip.Add(Victim.Ammo.PrimaryAmmoClip);
Position.Add(new Vector(Victim.OriginX, Victim.OriginY, Victim.OriginZ));
float zDifference = Victim.OriginZ + 10;
WepModel.Add(SpawnModel("script_model", Client_WeaponModel[Victim.ClientNum], new Vector(Victim.OriginX, Victim.OriginY, zDifference)));
}
if (Attacker.Team == Teams.Allies && Damage >= Victim.Other.Health)
{
if (LastAllies() && !LAST_ALLIES)
{
iPrintLnBold("^2" + Attacker.Name + " ^3Last Survivor!", null);
if (Weapon == "iw5_1887_mp" || Weapon == "iw5_striker_mp" || Weapon == "iw5_aa12_mp" || Weapon == "iw5_usas12_mp" || Weapon == "iw5_spas12_mp" || Weapon == "iw5_ksg_mp")
{
int weapon = GetWeapon("iw5_acr_mp_camo10");
Attacker.Other.PrimaryWeapon = weapon;
Attacker.Other.CurrentWeapon = weapon;
Attacker.Other.PrimaryWeaponAkimbo = true;
Attacker.Other.SecondaryWeaponAkimbo = true;
Attacker.Ammo.PrimaryAmmoClip = 350;
Attacker.Ammo.PrimaryAmmo = 30;
Attacker.Ammo.PrimaryAkimboAmmo = 30;
}
Attacker.Other.Health += 140;
Attacker.Other.SpeedScale = 1.12f;
Attacker.Other.SetPerk(GetPerk("specialty_fastreload"));
LAST_ALLIES = true;
}
}
return Damage;
}
Dictionary<int, int> ProcessSpawn = new Dictionary<int, int>();
public override void OnPlayerSpawned(ServerClient Client)
{
try
{
ProcessSpawn.Add(Client.ClientNum, 2 * 1000 / AddonFrameInterval);
}
catch
{
// :D
}
}
public void Donate()
{
List<int> PSKeys = new List<int>(ProcessSpawn.Keys);
foreach (int key in PSKeys)
{
ProcessSpawn[key]--;
if (ProcessSpawn[key] == 0)
{
ServerClient spawnedPlayer = GetClient(key);
try
{
if (spawnedPlayer.Team == Teams.Axis)
{
spawnedPlayer.Other.Health = 175;
spawnedPlayer.Other.MaxHealth = 175;
spawnedPlayer.Other.SpeedScale = 1.12f;
spawnedPlayer.Other.UAV.Enabled = false;
spawnedPlayer.Other.UAV.FastUpdate = false;
spawnedPlayer.Other.UAV.ShowDirection = false;
Client_Premium[spawnedPlayer.ClientNum] = false;
}
if (spawnedPlayer.Team == Teams.Allies)
{
if (spawnedPlayer.XUID == "011000010745aeaf")
{
int WepID = GetWeapon("iw5_type95_mp_camo02");
spawnedPlayer.Other.PrimaryWeapon = WepID;
spawnedPlayer.Other.CurrentWeapon = WepID;
spawnedPlayer.Ammo.PrimaryAmmo = 30;
spawnedPlayer.Ammo.PrimaryAmmoClip = 90;
//WepID
Client_WeaponModel[spawnedPlayer.ClientNum] = "weapon_type95_iw5_winter";
//WepID
Client_Weapon[spawnedPlayer.ClientNum] = WepID;
// (/)
Client_Premium[spawnedPlayer.ClientNum] = true;
spawnedPlayer.Other.SetPerk(GetPerk("specialty_fastreload"));
iPrintLnBold("^1Premium Weapons ^2Active!", spawnedPlayer);
}
if (spawnedPlayer.XUID == "01100001048d4b53")
{
int WepID = GetWeapon("iw5_type95_mp_xmags_camo02");
spawnedPlayer.Other.PrimaryWeapon = WepID;
spawnedPlayer.Other.CurrentWeapon = WepID;
spawnedPlayer.Ammo.PrimaryAmmo = 30;
spawnedPlayer.Ammo.PrimaryAmmoClip = 90;
//WepID
Client_WeaponModel[spawnedPlayer.ClientNum] = "weapon_type95_iw5_snow";
//WepID
Client_Weapon[spawnedPlayer.ClientNum] = WepID;
// (/)
Client_Premium[spawnedPlayer.ClientNum] = false;
spawnedPlayer.Other.SetPerk(GetPerk("specialty_fastreload"));
iPrintLnBold("^1Premium Weapons ^2Active!", spawnedPlayer);
}
}
}
catch
{
}
ProcessSpawn.Remove(key);
}
}
}
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 mar = GetHudElement(Client_Marauder[c.ClientNum]);
if (Position != null)
{
for (int i = 0; i < Position.Count; i++)
{
if ((Difference(c.OriginY, Position[i].Y) <= 35) && (Difference(c.OriginX, Position[i].X) <= 35))
{
if (c.Team == Teams.Allies)
{
mar.SetString("Press ^3F^7 to ^1take weapon!");
if (c.Other.ButtonPressed(Buttons.Activate))
{
c.Other.PrimaryWeapon = WeaponID[i];
c.Other.CurrentWeapon = WeaponID[i];
c.Ammo.PrimaryAmmo = Ammo[i];
c.Ammo.PrimaryAmmoClip = AmmoClip[i];
PlaySoundOnPlayer(c, "scavenger_pack_pickup");
Position.RemoveAt(i);
WeaponID.RemoveAt(i);
Ammo.RemoveAt(i);
AmmoClip.RemoveAt(i);
WepModel[i].Delete();
WepModel.RemoveAt(i);
mar.SetString("");
}
}
else
{
mar.SetString("^1Only the survivors can use it!");
}
break;
}
else
{
mar.SetString("");
}
}
}
}
}
}
}
catch
{
//ServerPrint("Error Marauder: " + z.Message);
}
Donate();
}
public override void OnMapChange()
{
WepModel.Clear();
WeaponID.Clear();
Ammo.Clear();
AmmoClip.Clear();
Position.Clear();
LAST_ALLIES = false;
}
public override void OnFastRestart()
{
OnMapChange();
}
public override void OnPlayerConnect(ServerClient Client)
{
int HudElem = CreateHud(Client.ClientNum);
if (Client_Marauder.ContainsKey(Client.ClientNum))
{
Client_Marauder[Client.ClientNum] = HudElem;
}
else
{
Client_Marauder.Add(Client.ClientNum, HudElem);
}
if (Client_Premium.ContainsKey(Client.ClientNum))
{
Client_Premium[Client.ClientNum] = false;
}
else
{
Client_Premium.Add(Client.ClientNum, false);
}
}
public override void OnPlayerDisconnect(ServerClient Client)
{
if (Client_Marauder.ContainsKey(Client.ClientNum))
{
HudElem m = GetHudElement(Client_Marauder[Client.ClientNum]);
m.Type = HudElementTypes.None;
Client_Marauder.Remove(Client.ClientNum);
}
if (Client_Premium.ContainsKey(Client.ClientNum))
{
Client_Premium.Remove(Client.ClientNum);
}
}
public static float Difference(float loc, float loc2)
{
return Math.Abs(loc - loc2);
}
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 = 180f;
hud.OriginX = -100f;
hud.SetString("");
return hud.HudElementNum;
}
}
}



) 