I made example to your first post, because you would get healtshots in spawn every round start.
This check first, does player have healt shot or how many (follow cvar ammo_item_limit_healthshot value)
PHP Code:
#include <sdktools>
ConVar ammo_item_limit_healthshot;
public void OnPluginStart()
{
ammo_item_limit_healthshot = FindConVar("ammo_item_limit_healthshot");
if(ammo_item_limit_healthshot == INVALID_HANDLE) SetFailState("No Cvar ammo_item_limit_healthshot found");
HookEvent("player_spawn", player_spawn);
}
public void player_spawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(GetClientTeam(client) <= 1) return; // player need to be in right team
char classname[35];
int m_hMyWeapons_size = GetEntPropArraySize(client, Prop_Send, "m_hMyWeapons"); // array size
int item;
bool m_bHasHealthShot;
for(int index = 0; index < m_hMyWeapons_size; index++) // look player items
{
item = GetEntPropEnt(client, Prop_Send, "m_hMyWeapons", index);
if(item == -1) continue; // skip invalid
GetEntityClassname(item, classname, sizeof(classname));
// Health Shot
if(StrEqual(classname, "weapon_healthshot", false))
{
m_bHasHealthShot = true;
int ammotype = GetEntProp(item, Prop_Send, "m_iPrimaryAmmoType");
if(ammotype == -1) continue; // skip if ammo type offset invalid
int ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, ammotype);
if(ammo < ammo_item_limit_healthshot.IntValue)
{
SetEntProp(client, Prop_Send, "m_iAmmo", ammo + 1, _, ammotype);
//GivePlayerItem(client, "weapon_healthshot");
}
}
}
if(!m_bHasHealthShot && ammo_item_limit_healthshot.IntValue > 0) GivePlayerItem(client, "weapon_healthshot");
}
There is
https://sm.alliedmods.net/new-api/cs...OnCSWeaponDrop
I look another time, I go sleep
__________________