Raised This Month: $51 Target: $400
 12% 

Problem with skin plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grafi_
Junior Member
Join Date: Apr 2022
Location: Poland
Old 03-28-2023 , 16:07   Problem with skin plugin
Reply With Quote #1

Hi,

I have problem with my plugin - when I get a weapon sometimes I have no arms and the ammunition is always strange for example in the ak-47 I get 253 ammunition for the first magazine and the rest is empty

Code:
public void OnClientPutInServer(int client)
{
    SDKHook(client, SDKHook_WeaponEquip, SDK_WeaponEquip);
}

public Action SDK_WeaponEquip(int client, int weapon)
{
    char weaponClassName[32];
    GetEntityClassname(weapon, weaponClassName, sizeof(weaponClassName));

    if (IsValidEdict(weapon) && weapon != INVALID_ENT_REFERENCE)
    {
        if (g_EarlierEntity[client] != weapon)
        {
            int weaponIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
            RemovePlayerItem(client, weapon);
            AcceptEntityInput(weapon, "Kill");
            RemoveEdict(weapon);*/

            weapon = CreateEntityByName(weaponClassName);
            SetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex", weaponIndex);
            SetEntProp(weapon, Prop_Send, "m_bInitialized", 1);
            DispatchSpawn(weapon);
            g_EarlierEntity[client] = weapon;
            EquipPlayerWeapon(client, weapon);

            if (IsValidEdict(weapon) && weapon != INVALID_ENT_REFERENCE)
            {
                int m_iItemIDLow = GetEntProp(weapon, Prop_Send, "m_iItemIDLow");
                int m_iItemIDHigh = GetEntProp(weapon, Prop_Send, "m_iItemIDHigh");
                
                SetEntProp(weapon, Prop_Send, "m_iItemIDLow", 2048);
                SetEntProp(weapon, Prop_Send, "m_iItemIDHigh", 0);

                SkinsInfo info;

                for (int i = 0; i < g_Skins.Length; i++)
                {
                    g_Skins.GetArray(i, info, sizeof(info));

                    if (g_SkinsEquipped[client].FindValue(info.skinIdentifier) == -1)
                        continue;

                    if (g_SkinsEquipped[client].FindValue(info.skinIdentifier) != -1 && StrEqual(info.weaponIndex, weaponClassName))
                    {
                        SetEntProp(weapon, Prop_Send, "m_nFallbackPaintKit", info.skinPaint);
                        SetEntPropFloat(weapon, Prop_Send, "m_flFallbackWear", info.skinWear);
                        SetEntProp(weapon, Prop_Send, "m_iEntityQuality", 3);
                        SetEntProp(weapon, Prop_Send, "m_nFallbackStatTrak", 072015);
                        SetEntProp(weapon, Prop_Send, "m_iAccountID", GetSteamAccountID(client));
		                SetEntProp(weapon, Prop_Send, "m_hOwnerEntity", client);
                        SetEntDataString(weapon, FindSendPropInfo("CBaseAttributableItem", "m_szCustomName"), "★ Custom TAG ★", 128);
                    }
                }
                DataPack pack;
                CreateDataTimer(0.2, RestoreItemID, pack);
                pack.WriteCell(EntIndexToEntRef(weapon));
                pack.WriteCell(m_iItemIDHigh);
                pack.WriteCell(m_iItemIDLow);
            }
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
Grafi_ is offline
Grafi_
Junior Member
Join Date: Apr 2022
Location: Poland
Old 03-30-2023 , 09:18   Re: Problem with skin plugin
Reply With Quote #2

I fixed the problem, but now there is another one. When I have a skin set for the ak-47, and I start shooting the crosshair behaves strangely and this is fixed when I buy another weapon that does not get the skin from the plugin and change the weapon back to the ak47 then the crosshair behaves normally. What can I do about it?
https://youtu.be/hF3mQbJX4l4
Code:
void Ptah_GiveNamedItemPost(int client, const char[] weaponClassName, const CEconItemView item, int weapon, bool OriginIsNULL, const float origin[3])
{
    if (IsValidEntity(weapon) && !IsFakeClient(client))
        SetWeaponProps(client, weapon, weaponClassName);
}

void SetWeaponProps(int client, int weapon, const char[] weaponClassName)
{
    SkinsInfo info;

    for (int i = 0; i < g_Skins.Length; i++)
    {
        g_Skins.GetArray(i, info, sizeof(info));

        if (!StrEqual(weaponClassName, info.weaponIndex) || g_SkinsEquipped[client].FindValue(info.skinIdentifier) == -1)
            continue;

        static int iIdHigh = 16384;
 		SetEntProp(weapon, Prop_Send, "m_iItemIDLow", -1);
 		SetEntProp(weapon, Prop_Send, "m_iItemIDHigh", iIdHigh++);    
        SetEntProp(weapon, Prop_Send, "m_nFallbackPaintKit", info.skinPaint);
        SetEntPropFloat(weapon, Prop_Send, "m_flFallbackWear", info.skinWear);
        SetEntProp(weapon, Prop_Send, "m_iEntityQuality", 3);
        SetEntProp(weapon, Prop_Send, "m_nFallbackStatTrak", 1337);
        SetEntProp(weapon, Prop_Send, "m_iAccountID", GetSteamAccountID(client));
 		SetEntProp(weapon, Prop_Send, "m_hOwnerEntity", client);
 		SetEntProp(weapon, Prop_Send, "m_hPrevOwner", -1);
        SetEntDataString(weapon, FindSendPropInfo("CBaseAttributableItem", "m_szCustomName"), "★ Custom TAG ★", 128);
    }
}

Last edited by Grafi_; 03-30-2023 at 09:26.
Grafi_ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode