#define CS_WEAPON 0 //1 = да, 0 = нет
static ammoOffset, your_ammo = 228;
public OnPluginStart()
{
ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
}
ChangeAmmo(client) //перед этим проверь клиента, должен быть valid и тот кому ты меняешь патроны, а если не он, то его до этой функции не пускай
{
new iWeapon = GetPlayerWeaponSlot(client, 0);
if (iWeapon != -1)
{
//тут меняешь кол-во патронов у игрока в зависимости от оружия, потому что оффсеты разные
decl String:sWeaponName[32];
GetEdictClassname(iWeapon, sWeaponName, 32);
if (StrEqual(sWeaponName, "weapon_rifle")) SetEntData(client, ammoOffset + 12, your_ammo);
else if (StrEqual(sWeaponName, "weapon_rifle_ak47")) SetEntData(client, ammoOffset + 12, your_ammo);
else if (StrEqual(sWeaponName, "weapon_rifle_desert")) SetEntData(client, ammoOffset + 12, your_ammo);
else if (StrEqual(sWeaponName, "weapon_rifle_m60")) SetEntData(client, ammoOffset + 12, your_ammo);
else if (StrEqual(sWeaponName, "weapon_smg")) SetEntData(client, ammoOffset + 20, your_ammo);
else if (StrEqual(sWeaponName, "weapon_smg_silenced")) SetEntData(client, ammoOffset + 20, your_ammo);
else if (StrEqual(sWeaponName, "weapon_pumpshotgun")) SetEntData(client, ammoOffset + 28, your_ammo);
else if (StrEqual(sWeaponName, "weapon_shotgun_chrome")) SetEntData(client, ammoOffset + 28, your_ammo);
else if (StrEqual(sWeaponName, "weapon_autoshotgun")) SetEntData(client, ammoOffset + 32, your_ammo);
else if (StrEqual(sWeaponName, "weapon_shotgun_spas")) SetEntData(client, ammoOffset + 32, your_ammo);
else if (StrEqual(sWeaponName, "weapon_hunting_rifle")) SetEntData(client, ammoOffset + 36, your_ammo);
else if (StrEqual(sWeaponName, "weapon_sniper_military")) SetEntData(client, ammoOffset + 40, your_ammo);
else if (StrEqual(sWeaponName, "weapon_grenade_launcher")) SetEntData(client, ammoOffset + 68, your_ammo);
#if CS_WEAPON
else if (StrEqual(sWeaponName, "weapon_rifle_sg552")) SetEntData(client, ammoOffset + 12, your_ammo);
else if (StrEqual(sWeaponName, "weapon_smg_mp5")) SetEntData(client, ammoOffset + 20, your_ammo);
else if (StrEqual(sWeaponName, "weapon_sniper_awp")) SetEntData(client, ammoOffset + 40, your_ammo);
else if (StrEqual(sWeaponName, "weapon_sniper_scout")) SetEntData(client, ammoOffset + 40, your_ammo);
#endif
}
}
возможно подмена патронов сбивает апгрейды оружия или еще что то
так сохраняешь то что было до:
new iClip = GetEntProp(iWeapon, Prop_Send, "m_iClip1");
new iUpgrade = GetEntProp(iWeapon, Prop_Send, "m_upgradeBitVec");
new iUpgradeAmmo = GetEntProp(iWeapon, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded");
и возвращаешь обратно после:
SetEntProp(iWeapon, Prop_Send, "m_iClip1", iClip);
SetEntProp(iWeapon, Prop_Send, "m_upgradeBitVec", iUpgrade);
SetEntProp(iWeapon, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", iUpgradeAmmo);