/* * This file is part of CounterStrikeSharp. * CounterStrikeSharp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * CounterStrikeSharp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with CounterStrikeSharp. If not, see . * */ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Utils; namespace CounterStrikeSharp.API.Core; public partial class CCSPlayer_ItemServices { /// /// Drops the active player weapon on the ground. /// /// ItemServices points to null public void DropActivePlayerWeapon(CBasePlayerWeapon activeWeapon) { if(Handle == IntPtr.Zero) throw new InvalidOperationException("ItemServices points to null."); Guard.IsValidEntity(activeWeapon); VirtualFunction.CreateVoid(Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"))(Handle, activeWeapon.Handle); } /// /// Removes every weapon from the player. /// /// ItemServices points to null public void RemoveWeapons() { if (Handle == IntPtr.Zero) throw new InvalidOperationException("ItemServices points to null."); VirtualFunction.CreateVoid(Handle, GameData.GetOffset("CCSPlayer_ItemServices_RemoveWeapons"))(Handle); } public T? GiveNamedItem(string item) where T : CEntityInstance { var pointer = VirtualFunction.Create(Handle, GameData.GetOffset("CCSPlayer_ItemServices_GiveNamedItem"))(Handle, item); if (pointer == IntPtr.Zero) return null; return (T)Activator.CreateInstance(typeof(T), pointer)!; } public AcquireResult CanAcquire(CEconItemView itemView, AcquireMethod method, IntPtr unknown = 0) { return VirtualFunctions.CCSPlayer_ItemServices_CanAcquireFunc.Invoke(this, itemView, method, unknown); } }