Hello guys i tried to make it so one player onthe allies team can get juggernaut it worked kinda but everyone could get it. here is code. And on map change it resets
How i fixed it:
First make a global variable at the top
Then i made a function called JuggerFunc having the first juggernaut code inside it
Once i have done that i move on to OnChatSay (not sure exact name) then i do the if message:
and i also made it so only survivors can use it
Then i made it restart on map change:
Thanks KungFu (not registerd user) for alot of help
Code:
int firstjugg = 0;
if (Message == "!juggernaut")
{
if (Client.Team == Teams.Allies)
{
if (firstjugg == 15)
{
TellClient(Client.ClientNum, "^1Juggernaut already taken", true);
}
else if (firstjugg == 0)
{
firstjugg = 15;
TellClient(Client.ClientNum, "You got jugger", true);
int fjugg = GetWeapon("riotshield_mp");
Client.Other.MaxHealth = 150;
Client.Other.Health = 1;
int fjugg1 = GetWeapon("iw5_p99_mp");
Client.Other.PrimaryWeapon = fjugg;
Client.Other.CurrentWeapon = fjugg;
Client.Other.SecondaryWeapon = fjugg1;
}
}
else if (Client.Team == Teams.Axis)
{
TellClient(Client.ClientNum, "^1You cannot have juggernaut", true);
}
}
How i fixed it:
First make a global variable at the top
Code:
public class plugin_test : CPlugin
{
int firstjugg = 0;
Code:
public void JuggerFunc(ServerClient Client)
{
iPrintLnBold("^1|." + Client.Name + " Got juggernaut.|", null);
int fjugg = GetWeapon("riotshield_mp");
Client.Other.MaxHealth = 180;
Client.Other.Health = 180;
int fjugg1 = GetWeapon("iw5_p99_mp_silencer");
Client.Ammo.SecondaryAmmoClip = 35;
Client.Ammo.SecondaryAmmo = 10;
Client.Other.PrimaryWeapon = fjugg;
Client.Other.CurrentWeapon = fjugg;
Client.Other.CurrentWeapon = fjugg1;
Client.Other.SecondaryWeapon = fjugg1;
firstjugg = 15;
}
Once i have done that i move on to OnChatSay (not sure exact name) then i do the if message:
Code:
{
if (Message == "!juggernaut")
{
if (firstjugg == 0)
{
JuggerFunc(Client);
}
else if (firstjugg == 15)
{
TellClient(Client.ClientNum, "^1Jugger already taken!", true);
}
}
Code:
if (Client.Team == Teams.Allies)
{
if (Message == "!juggernaut")
{
if (firstjugg == 0)
{
JuggerFunc(Client);
}
else if (firstjugg == 15)
{
TellClient(Client.ClientNum, "^1Jugger already taken!", true);
}
}
}
else if (Client.Team == Teams.Axis)
{
if (Message == "!juggernaut")
{
TellClient(Client.ClientNum, "^1You cant have jugger!", true);
}
}
Then i made it restart on map change:
Code:
public override void OnMapChange()
{
ServerPrint("Map changed!");
firstjugg = 0;
}
Thanks KungFu (not registerd user) for alot of help