ItsMods

Full Version: [Code] Akimbo weapon fix (new)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey,

I just found my old code, i tested it. Works fine.

Known bug:
If you switch from akimbo weapon to ump45 game will crash ( not server ), but you can fix it by adding some code.

How it works?
Simple. Just disables akimbo/enables on weapon switch.

Video:
I'll upload soon.

Note: replace ak47 by another weapon or just add more.

Give me credits if you're using it.

Credits:
@sailormoon - coded


Source:
Code:
using System.Collections.Generic;
using System.IO;
using Addon;

namespace AkimboFix
{
    public class CMain : CPlugin
    {

        public override void OnAddonFrame()
        {
            List<ServerClient> clients;
             clients = GetClients();

             if (clients != null)
             {
                 foreach (ServerClient c in clients)
                 {
                     if (c.ConnectionState != ConnectionStates.MapLoading &&
                         c.ConnectionState != ConnectionStates.Connecting &&
                         c.ConnectionState != ConnectionStates.Zombie)
                     {
                         ServerClient Client = c;

                         if (c.Other.isAlive)
                         {
                                 if (Client.Other.CurrentWeapon == GetWeapon("iw5_ak47_mp"))
                                 {
                                     Client.Other.PrimaryWeaponAkimbo = true;
                                     Client.Other.SecondaryWeaponAkimbo = true;
                                 }
                                 else
                                 {
                                     Client.Other.PrimaryWeaponAkimbo = false;
                                     Client.Other.SecondaryWeaponAkimbo = false;
                                 }
                         }
                         else
                         {
                             Client.Other.PrimaryWeaponAkimbo = false;
                             Client.Other.SecondaryWeaponAkimbo = false;
                         }
                     }

                 }
             }
        }

        public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
        {
            if (Message == "!s")
            {
                // give ak 47 as test
                Client.Other.PrimaryWeapon = GetWeapon("iw5_ak47_mp");
               // Client.Other.CurrentWeapon = GetWeapon("iw5_ak47_mp_camo02");
            }
            return base.OnSay(Message, Client, Teamchat);
        }

        public override void OnPlayerChangeWeapon(ServerClient Client, int WeaponID)
        {
            if (Client.Other.CurrentWeapon != GetWeapon("iw5_ak47_mp"))
            {
                Client.Other.CurrentWeaponAkimbo = false;
                Client.Other.PrimaryWeaponAkimbo = false;
                Client.Other.SecondaryWeaponAkimbo = false;
                Client.Other.WeaponSlot3Akimbo = false;
                Client.Other.WeaponSlot4Akimbo = false;
                Client.Other.WeaponSlot5Akimbo = false;
                Client.Other.WeaponSlot6Akimbo = false;
            }

            base.OnPlayerChangeWeapon(Client, WeaponID);
        }
    }
}
If you switch from akimbo weapon to ump45 game will crash ( not server ), but you can fix it by adding some code.

Also pp90m1 crash the client.
Anyway thanks so much Smile
It works! Big, huge thanks for this fix!
super

Rolleyes
Idea
Tongue
@master131 , maybe you'll add this to addon extensions?

You can remove
Code:
ServerClient Client = c;
I was lazy to replace 'Client' variable Meow
Oooom sry! when i copied your source code to visual studio (with addon reference) it gives me many errors!
c.ConnectionState
ConnectionStates
c.Other
Client.Other.CurrentWeapon == GetWeapon
Client.Other
how to solve it!?
(02-24-2013, 23:47)mn_acer1 Wrote: [ -> ]Oooom sry! when i copied your source code to visual studio (with addon reference) it gives me many errors!
c.ConnectionState
ConnectionStates
c.Other
Client.Other.CurrentWeapon == GetWeapon
Client.Other
how to solve it!?


Can you copy the errors and paste them here, so we can help you to fix it Smile
(02-24-2013, 23:58)99IRock Wrote: [ -> ]
(02-24-2013, 23:47)mn_acer1 Wrote: [ -> ]Oooom sry! when i copied your source code to visual studio (with addon reference) it gives me many errors!
c.ConnectionState
ConnectionStates
c.Other
Client.Other.CurrentWeapon == GetWeapon
Client.Other
how to solve it!?


Can you copy the errors and paste them here, so we can help you to fix it Smile
thanks it's solved by this addon http://www.itsmods.com/forum/attachment.php?aid=2159
the problems gone now! Smile
it seems i had older addon version!
i gotta take a look at this addon and see what it can does! Tongue
@tubwux request for this plugin. here u go Smile
(02-27-2013, 16:35)EnVi Sweden Rocks Wrote: [ -> ]@tubwux request for this plugin. here u go Smile

Thaaakkkk yoooouuuuu
Pages: 1 2