Beispiel #1
0
        private static void ApplyKnife(BasePlayer *localPlayer, ref CSkinChangerWeapon configWeapon)
        {
            if (configWeapon.WeaponID == WeaponId.None)
            {
                return;
            }

            WeaponId ActiveIndex = localPlayer->GetActiveWeapon->ItemDefinitionIndex;

            if (ActiveIndex.IsKnife())
            {
                localPlayer->GetViewModel->SetModelIndex(Interface.ModelInfoClient.GetModelIndex(KnifeModel[ActiveIndex]));
            }
        }
Beispiel #2
0
        public static void OnFrameStage(IBaseClientDLL.FrameStage frameStage, BasePlayer *localPlayer)
        {
            if (!localPlayer->IsAlive)
            {
                return;
            }

            Interface.VEngineClient.GetPlayerInfo(Interface.VEngineClient.GetLocalPlayer, out IVEngineClient.PlayerInfo PlayerInfo);

            for (int Index = 0; Index < 8; Index++)
            {
                BaseCombatWeapon *Weapon = localPlayer->GetMyWeapons(Index);

                if (Weapon == null)
                {
                    continue;
                }

                if (Weapon->OriginalOwnerXuidLow != PlayerInfo.m_nXuidLow)
                {
                    continue;
                }

                if (Weapon->OriginalOwnerXuidHigh != PlayerInfo.m_nXuidHigh)
                {
                    continue;
                }

                CSkinChangerWeapon WeaponId = ConfigManager.CSkinChangerWeapons[Weapon->ItemDefinitionIndex.GetWeaponId()];

                ApplyWeapon(localPlayer, Weapon, WeaponId, PlayerInfo);
            }

            ApplyKnife(localPlayer, ref ConfigManager.CSkinChangerWeapons[35]);

            ApplyWearable(localPlayer, ref ConfigManager.CSkinChangerWeapons[36], PlayerInfo);
        }
Beispiel #3
0
        private static void ApplyWearable(BasePlayer *localPlayer, ref CSkinChangerWeapon configWeapon, IVEngineClient.PlayerInfo playerInfo)
        {
            uint *wearables = localPlayer->GetMyWearables;

            if (wearables == null)
            {
                return;
            }

            IBaseClientDLL.ClientClass *Class = Interface.BaseClientDLL.GetAllClasses();

            if (Class == null)
            {
                return;
            }

            int serial = Weapon.Random.Next() % 0x1000;
            int entry  = Interface.ClientEntityList.GetHighestEntityIndex + 1;

            if (entry == 0)
            {
                return;
            }

            if (Interface.ClientEntityList.GetClientEntity((int)(wearables[0] & 0xFFF)) == null)
            {
                while (Class != null)
                {
                    if (Class->ClassId == IBaseClientDLL.ClassId.CEconWearable)
                    {
                        break;
                    }

                    Class = Class->Next;
                }

                Marshal.GetDelegateForFunctionPointer <MakeGloveDelegate>((IntPtr)Class->CreateFunction)(entry, serial);

                wearables[0] = (uint)(entry | (serial << 16));
            }

            BaseCombatWeapon *Glove = (BaseCombatWeapon *)Interface.ClientEntityList.GetClientEntityFromHandle((void *)wearables[0]);

            if (Glove == null)
            {
                return;
            }

            if (Glove->ItemDefinitionIndex != configWeapon.WeaponID)
            {
                Glove->ItemIdHigh = -1;
                Glove->AccountId  = playerInfo.m_nXuidLow;

                Glove->ItemDefinitionIndex = configWeapon.WeaponID;
                ((BaseViewModel *)Glove)->SetModelIndex(Interface.ModelInfoClient.GetModelIndex(GloveModel[Glove->ItemDefinitionIndex]));

                Glove->EntityQuality    = QualityId.Normal;
                Glove->FallBackPaintKit = configWeapon.SkinID;

                ((IClientEntity *)Glove)->GetClientNetworkable->PreDataUpdate(0);
            }
        }
Beispiel #4
0
        private static void ApplyWeapon(BasePlayer *localPlayer, BaseCombatWeapon *weaponPtr, CSkinChangerWeapon configWeapon, IVEngineClient.PlayerInfo playerInfo)
        {
            if (configWeapon.WeaponID == WeaponId.None)
            {
                return;
            }

            weaponPtr->ItemIdHigh = -1;

            weaponPtr->AccountId = playerInfo.m_nXuidLow;

            if (!string.IsNullOrWhiteSpace(configWeapon.WeaponName))
            {
                weaponPtr->CustomName = configWeapon.WeaponName;
            }

            if (configWeapon.StatTrackEnable && configWeapon.StatTrack >= 0)
            {
                weaponPtr->EntityQuality     = QualityId.Strange;
                weaponPtr->FallBackStatTrack = configWeapon.StatTrack;
            }

            weaponPtr->FallBackPaintKit = configWeapon.SkinID;

            WeaponId WeaponIndex = weaponPtr->ItemDefinitionIndex;

            if (WeaponIndex.IsKnife() && WeaponIndex != configWeapon.WeaponID)
            {
                weaponPtr->ItemDefinitionIndex = configWeapon.WeaponID;
                ((BaseViewModel *)weaponPtr)->SetModelIndex(Interface.ModelInfoClient.GetModelIndex(KnifeModel[weaponPtr->ItemDefinitionIndex]));
            }
        }