#pragma semicolon 1
#define PLUGIN_VERSION "1.3.1"
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#pragma newdecls required
public Plugin myinfo =
{
name = "No Weapon Fix",
author = ".#Zipcore",
description = "",
version = PLUGIN_VERSION,
url = ""
};
#define LoopIngamePlayers(%1) for(int %1=1;%1<=MaxClients;++%1)\
if(IsClientInGame(%1) && !IsFakeClient(%1))
int g_iFakeWeaponRef[MAXPLAYERS + 1];
bool g_bEnable;
public void OnPluginStart()
{
CreateConVar("no_weapon_fix_version", PLUGIN_VERSION, "No Weapon Fix Version", FCVAR_DONTRECORD|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
ConVar cvEnable = CreateConVar("no_weapon_fix_enable", "1", "Set to 0 to disable this plugin.", _, true, 0.0, true, 1.0);
g_bEnable = cvEnable.BoolValue;
HookConVarChange(cvEnable, OnSettingChanged);
LoopIngamePlayers(client)
OnClientPostAdminCheck(client);
}
public void OnSettingChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
g_bEnable = convar.BoolValue;
}
public void OnClientPostAdminCheck(int client)
{
g_iFakeWeaponRef[client] = -1;
SDKHook(client, SDKHook_WeaponEquip, WeaponSwitch);
SDKHook(client, SDKHook_WeaponDrop, WeaponDrop);
}
public Action WeaponSwitch(int client, int weapon)
{
if(weapon != (weapon = EntRefToEntIndex(g_iFakeWeaponRef[client])))
{
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 1);
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
}
return Plugin_Continue;
}
public Action WeaponDrop(int client, int weapon)
{
if(weapon == EntRefToEntIndex(g_iFakeWeaponRef[client]) && weapon != -1)
{
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 1);
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
}
return Plugin_Continue;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if(!g_bEnable || !IsPlayerAlive(client))
return Plugin_Continue;
static int iEntity;
if((iEntity = EntRefToEntIndex(g_iFakeWeaponRef[client])) != -1)
{
float fUnlockTime = GetGameTime() + 0.5;
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 0);
SetEntPropFloat(client, Prop_Send, "m_flNextAttack", fUnlockTime);
SetEntPropFloat(iEntity, Prop_Send, "m_flNextPrimaryAttack", fUnlockTime);
}
else if(weapon == -1 || GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon") == -1)
{
float fUnlockTime = GetGameTime() + 0.5;
SetEntPropFloat(client, Prop_Send, "m_flNextAttack", fUnlockTime);
SetEntPropFloat(weapon = GivePlayerItem(client, "weapon_decoy"), Prop_Send, "m_flNextPrimaryAttack", fUnlockTime);
g_iFakeWeaponRef[client] = EntIndexToEntRef(weapon);
return Plugin_Changed;
}
return Plugin_Continue;
}