View Single Post
Author Message
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 05-04-2019 , 06:57   Setting player ammo?
Reply With Quote #1

Hey,
when I want to set player ammo with this func below and when I use clip or ammo to 0, weapon clip or ammo is set to default ammo or clip value, like when it's deagle it sets to 7/35 using:
PHP Code:
SetPlayerAmmo(clientiWep00); 
Function:
PHP Code:
stock void SetPlayerAmmo(int clientint weaponEntint clip = -1int ammo = -1)
{
    if (
weaponEnt == INVALID_ENT_REFERENCE || !IsValidEntity(weaponEnt))
        return;

    if (
clip != -1)
        
SetEntProp(weaponEntProp_Send"m_iClip1"clip);

    if (
ammo != -1)
    {
        
int iOffset FindDataMapInfo(client"m_iAmmo") + (GetEntProp(weaponEntProp_Data"m_iPrimaryAmmoType") * 4);
        
SetEntData(clientiOffsetammo4true);

        if (
GetEngineVersion() == Engine_CSGO
        {
            
SetEntProp(weaponEntProp_Send"m_iPrimaryReserveAmmoCount"ammo);
        }
    }

btw. no errors in error log
__________________
My Github & Sourcemod work.
If you like my work and if you want to support me, you can through PayPal.

Official SourceMod CZ/SK Discord: https://discord.gg/Qvar55a
Javierko is offline