ItsMods

Full Version: one person juggernaut FIXED WITH CODE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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;
Then i made a function called JuggerFunc having the first juggernaut code inside it
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);
                    }
                }
and i also made it so only survivors can use it
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 Smile
Noone can help me?
It doesn't work because it is setting the value only to the person who's typing the command. That means everyone else still got the value 0 and can use the command.
Any way i can fix this? and i want it to reset on map change. Thanks.
i kinda get what you mean but kinda not
E: i didnt fully get it anyone can help with abit of code i dont wanna just get code but i dont really understand