scripting/dm_basics.sp
changeset 80 2cbda5738ddd
parent 79 a5a49887015f
     1.1 --- a/scripting/dm_basics.sp	Sat Jun 23 18:14:24 2012 -0400
     1.2 +++ b/scripting/dm_basics.sp	Sat Jun 23 19:04:45 2012 -0400
     1.3 @@ -23,6 +23,7 @@
     1.4  
     1.5  #pragma semicolon 1
     1.6  #include <sourcemod>
     1.7 +#include <sdktools>
     1.8  #include <cssdm>
     1.9  
    1.10  /* Plugin stuff */
    1.11 @@ -37,6 +38,7 @@
    1.12  
    1.13  /* Player stuff */
    1.14  new Float:g_DeathTimes[MAXPLAYERS+1];
    1.15 +new bool:g_bHasNoAmmoInClip1[MAXPLAYERS+1] = {false,...};
    1.16  
    1.17  /** PUBLIC INFO */
    1.18  public Plugin:myinfo = 
    1.19 @@ -129,7 +131,7 @@
    1.20  	new ammoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
    1.21  	
    1.22  	/* Give something reasonable -- the game will chop it off */
    1.23 -	DM_GiveClientAmmo(client, ammoType, 30, false);
    1.24 +	DM_GiveClientAmmo(client, ammoType, 200, false);
    1.25  }
    1.26  
    1.27  public CvarChange_RestartMapTimer(Handle:cvar, const String:oldvalue[], const String:newvalue[])
    1.28 @@ -231,6 +233,8 @@
    1.29  {
    1.30  	g_DeathTimes[client] = 0.0;
    1.31  	CreateTimer(10.0, Timer_Welcome, GetClientUserId(client));
    1.32 +	
    1.33 +	g_bHasNoAmmoInClip1[client] = false;
    1.34  }
    1.35  
    1.36  public Action:DM_OnClientDeath(client)
    1.37 @@ -287,3 +291,39 @@
    1.38  	return Plugin_Continue;
    1.39  }
    1.40  
    1.41 +public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
    1.42 +{
    1.43 +    if(!g_AmmoHooks)
    1.44 +        return Plugin_Continue;
    1.45 +    
    1.46 +    new entity = GetEntDataEnt2(client, g_ActiveWepOffs);
    1.47 +    if (entity < 1)
    1.48 +    {
    1.49 +        g_bHasNoAmmoInClip1[client] = false;
    1.50 +        return Plugin_Continue;
    1.51 +    }
    1.52 +    
    1.53 +    // He's out of ammo -> reloading
    1.54 +    new iClip1 = GetEntProp(entity, Prop_Send, "m_iClip1");
    1.55 +    if(iClip1 == 0)
    1.56 +    {
    1.57 +        g_bHasNoAmmoInClip1[client] = true;
    1.58 +    }
    1.59 +    // He got ammo in clip1 again but hadn't before -> reloaded.
    1.60 +    else if(g_bHasNoAmmoInClip1[client])
    1.61 +    {
    1.62 +        g_bHasNoAmmoInClip1[client] = false;
    1.63 +        
    1.64 +        new ammoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
    1.65 +        
    1.66 +        if(ammoType <= 0)
    1.67 +        {
    1.68 +            return Plugin_Continue;
    1.69 +        }
    1.70 +        
    1.71 +        // Give some ammo.
    1.72 +        DM_GiveClientAmmo(client, ammoType, 200, false);
    1.73 +    }
    1.74 +    
    1.75 +    return Plugin_Continue;
    1.76 +}
    1.77 \ No newline at end of file