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;
}