All pastes #906429 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-16 18:17 UTC
rendered paste body
#pragma semicolon 1
#include <sourcemod>
#include <cssdm>
new Handle:cssdm_refill_ammo;
new g_ActiveWepOffs = -1;
public OnPluginStart()
{
	cssdm_refill_ammo = CreateConVar("cssdm_refill_ammo", "1", "Sets whether CS:S DM automatically refills ammo");
	HookConVarChange(cssdm_refill_ammo, CvarChange_RefillAmmo);
	HookEvent("weapon_reload", Event_CheckDepleted);
	HookEvent("weapon_fire_on_empty", Event_CheckDepleted);
}

public CvarChange_RefillAmmo(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
		HookEvent("weapon_reload", Event_CheckDepleted);
		HookEvent("weapon_fire_on_empty", Event_CheckDepleted);
}

public Event_CheckDepleted(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if (!client || !IsClientInGame(client))
	{
		return;
	}
	
	new entity = GetEntDataEnt(client, g_ActiveWepOffs);
	if (entity < 1)
	{
		return;
	}
	
	new ammoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
	
	/* Give something reasonable -- the game will chop it off */
	DM_GiveClientAmmo(client, ammoType, 30, false);
}