Ok, there's no problem with GiveAmmo - my fault, it's just not fired at all for automatic reloads.
This is a better patch obeying the maxammo of that ammotype again.
PHP Code:
new bool:g_bHasNoAmmoInClip1[MAXPLAYERS+1] = {false,...};
public OnClientPutInServer(client)
{
g_DeathTimes[client] = 0.0;
CreateTimer(10.0, Timer_Welcome, GetClientUserId(client));
g_bHasNoAmmoInClip1[client] = false;
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if(!g_AmmoHooks)
return Plugin_Continue;
new entity = GetEntDataEnt2(client, g_ActiveWepOffs);
if (entity < 1)
{
g_bHasNoAmmoInClip1[client] = false;
return Plugin_Continue;
}
// He's out of ammo -> reloading
new iClip1 = GetEntProp(entity, Prop_Send, "m_iClip1");
if(iClip1 == 0)
{
g_bHasNoAmmoInClip1[client] = true;
}
// He got ammo in clip1 again but hadn't before -> reloaded.
else if(g_bHasNoAmmoInClip1[client])
{
g_bHasNoAmmoInClip1[client] = false;
new ammoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
if(ammoType < 0)
{
return Plugin_Continue;
}
// Give some ammo.
DM_GiveClientAmmo(client, ammoType, 30, false);
}
return Plugin_Continue;
}