View Single Post
Author Message
ivenuss
Junior Member
Join Date: Nov 2019
Location: Czech Republic
Old 01-05-2020 , 17:56   [CSGO] Deagle 1 bullet, can someone help me fix bug?
Reply With Quote #1

Hello can someone help me fix bug? Sometimes players gets deagle with 1 bullet (thats right) but sometimes they get deagle with 1/35 ammo. + If someone can help me how to disable deagle when Is noscope round.
Noscope round plugin: https://forums.alliedmods.net/showthread.php?p=2528532
Code:
#include <sourcemod>
#include <sdktools>
 
#pragma semicolon 1
#pragma newdecls required
 
public void OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
}

public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
    
    if(IsPlayerAlive(client) && IsClientInGame(client))
    {
        if(IsClientVIP(client))
        {
            if (GetPlayerWeaponSlot(client, 2) != -1) 
            {
                RemovePlayerItem(client, 2); 
            }
            
            RequestFrame(NextFrameFor_Weapons, GetClientUserId(client));
        }
    }
    
    return Plugin_Continue;
}

void NextFrameFor_Weapons(any data)
{
    int client = GetClientOfUserId(data);
    
    if(IsPlayerAlive(client) && IsClientInGame(client))
    {
        if(GameRules_GetProp("m_bWarmupPeriod") == 0)
        {
            if(IsClientVIP(client))
            {
                int iWep = GivePlayerItem(client, "weapon_deagle");
                SetPlayerAmmo(client, iWep, 1, 0);
            }
        }
    }
}

public bool IsClientVIP(int client)
{
    return CheckCommandAccess(client, "VIP", ADMFLAG_RESERVATION, true);
}

stock void SetPlayerAmmo(int client, int weapon, int clip = -1, int ammo = -1)
{
    if(weapon == INVALID_ENT_REFERENCE)
    {
        return;
    }
    
    if(clip != -1)
    {
        SetEntProp(weapon, Prop_Send, "m_iClip1", clip);
    }

    if(ammo != -1)
    {
        SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", ammo);
        SetEntProp(weapon, Prop_Send, "m_iSecondaryReserveAmmoCount", ammo);
    }
}
ivenuss is offline