Here is one version.
- Holding
weapon_amerknife or
weapon_spade you not loose stamina while sprinting.
PHP Code:
#include <sdktools>
public void OnPluginStart()
{
HookEventEx("player_spawn", player_spawn);
}
public void player_spawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
//send fake callback, update "weapon"
OnPlayerRunCmdPre(client, 0, 0, {0.0,0.0,0.0}, {0.0,0.0,0.0}, -1, 0, 0, 0, 0, {0,0});
}
public void OnPlayerRunCmdPre(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2])
{
static bool correctweapon[MAXPLAYERS+1];
static float oldstamina[MAXPLAYERS+1];
float stamina = GetEntPropFloat(client, Prop_Send, "m_flStamina");
//PrintToServer(" stamina %0.2f weapon %i", stamina, weapon);
if(weapon > MaxClients)
{
correctweapon[client] = false;
char clsname[60];
GetEntityClassname(weapon, clsname, sizeof(clsname));
if(StrEqual(clsname, "weapon_amerknife", false) || StrEqual(clsname, "weapon_spade", false))
correctweapon[client] = true;
}
else if(weapon == -1)
{
correctweapon[client] = false;
}
if(correctweapon[client])
{
if(oldstamina[client] - stamina > 0.0)
{
stamina = stamina + (oldstamina[client] - stamina);
SetEntPropFloat(client, Prop_Send, "m_flStamina", stamina);
}
}
oldstamina[client] = stamina;
}
I also got plugin work with DHooks and get in more advance, but it works 32bit SRCDS and crash 64bit SRCDS... so I decided push it a side for now.
__________________