Raised This Month: $51 Target: $400
 12% 

[CS:GO] No weapon fix 3.1 (Player models lay on ground fix)


Post New Thread Reply   
 
Thread Tools Display Modes
SHAREN
Senior Member
Join Date: Dec 2011
Old 10-29-2016 , 18:43   Re: [CS:GO] No weapon fix 3.0 (Player models lay on ground fix)
Reply With Quote #41

Im trying to fix another bug.
when you do not have anything other than grenades and underfoot are more grenades (the same) (screenshot1), then after you throw the grenade will bug (screenshot2) then you can not throw grenades

To test bug create new game in client cs.
map de_dust2 (or your other favorite map)
mp_drop_knife_enable 1
sv_cheats 1
Drop all your weapons (knife too)
give weapon_hegrenade
give weapon_hegrenade
give weapon_hegrenade
give weapon_hegrenade
give weapon_hegrenade (or molotov, most importantly make a lot of grenades)
throw grenade

Spoiler


I tried to make a verification whether the pomegranate rushed after each pressing in_attack, if not then there was a bug, and the plugin will upgrade all weapons.
weapon_fire only happens when there is no bug

This draft, but workink
PHP Code:
#pragma semicolon 1
 
#define PLUGIN_VERSION "3.0"
 
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
 
public Plugin myinfo =
{
    
name "No Weapon Fix",
    
author ".#Zipcore",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};
 
ConVar cvEnable;
bool g_bEnable;
 
ConVar cvBlockGrenades;
bool g_bBlockGrenades;
 
int m_hMyWeapons;
int g_iGrens[MAXPLAYERS 1];
 
int g_iFakeWeaponRef[MAXPLAYERS 1];
 
int g_bGrenade[MAXPLAYERS 1];

Handle g_hTmr[MAXPLAYERS 1];
bool g_bAttack[MAXPLAYERS 1];
 
#define LoopIngameClients(%1) for(int %1=1;%1<=MaxClients;++%1)\
if(IsClientInGame(%1))
 
public 
void OnPluginStart()
{
    
CreateConVar("no_weapon_fix_version"PLUGIN_VERSION"No Weapon Fix Version"FCVAR_DONTRECORD|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
    
cvEnable CreateConVar("no_weapon_fix_enable""1""Enables this plugin (1: Enable; 0: Disable).");
    
g_bEnable GetConVarBool(cvEnable);
    
HookConVarChange(cvEnableOnSettingChanged);
    
    
cvBlockGrenades CreateConVar("no_weapon_fix_block_grenades""0""Block all grenades from being throwable (1: Enable; 0: Disable).");
    
g_bBlockGrenades GetConVarBool(cvBlockGrenades);
    
HookConVarChange(cvBlockGrenadesOnSettingChanged);
    
    
AutoExecConfig(true"no_weapon_fix");
    
    
m_hMyWeapons FindSendPropInfo("CBasePlayer""m_hMyWeapons");
    
    if(
m_hMyWeapons == -1)
    {
        
char Error[128];
        
FormatEx(Errorsizeof(Error), "FATAL ERROR m_hMyWeapons [%d]. Please contact the author."m_hMyWeapons);
        
SetFailState(Error);
    }
    
    
HookEvent("item_equip"Event_ItemEquip);
    
HookEvent("weapon_fire"Event_weapon_fire);
    
    
LoopIngameClients(i)
        
OnClientPutInServer(i);

    
RegConsoleCmd("sm_mol"TestMolo);
}

public 
Action TestMolo(int clientint args)
{
    
int molotov GivePlayerItem(client"weapon_molotov");
    if (
molotov != INVALID_ENT_REFERENCE
    {
        
SetEntPropEnt(clientProp_Data"m_hActiveWeapon"molotov);
        
ChangeEdictState(clientFindDataMapInfo(client"m_hActiveWeapon"));
    }
    return 
Plugin_Continue;
}

 
public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
    
//SDKHook(client, SDKHook_EndTouch, OnEndTouch);
}
 
public 
int OnSettingChanged(Handle convar, const char[] oldValue, const char[] newValue)
{
    if(
convar == cvEnable)
        
g_bEnable view_as<bool>(StringToInt(newValue));
}
 
public 
Action Event_weapon_fire(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
PrintToChat(client"Event_weapon_fire");
    
g_bAttack[client] = true;
}
 
public 
Action Event_ItemEquip(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
   
    
g_bGrenade[client] = GetEventInt(event"weptype") == 8;
}

void InAttack(int client)
{
    
int decoy EntRefToEntIndex(g_iFakeWeaponRef[client]);
    
int count;
    
char classname[64];
    if (
decoy <= 0) {
        for (
int j 0ent 0128+= 4) {
            
ent GetEntDataEnt2(clientm_hMyWeapons j);
            if (
ent 0) {

                
GetEntityClassname(entclassnamesizeof(classname));
                
PrintToChat(client"InAttack %i"ent);
                
count++;
            }
        }
    }
    
//if (count == 1) {
        
g_hTmr[client] = CreateTimer(0.01DontEqclient);
    
//}
    //PrintToChat(client, "InAttack");
}

void Attack(int client)
{
    
//PrintToChat(client, "Attack");
}

public 
Action DontEq(Handle timerany client)
{
    
int decoy EntRefToEntIndex(g_iFakeWeaponRef[client]);
    
int count;
    
char classname[64];
    
    if (!
g_bAttack[client] && decoy <= 0) {
        
PrintToChat(client"!g_bAttack[client]");
        for (
int j 0ent 0128+= 4) {
            
ent GetEntDataEnt2(clientm_hMyWeapons j);
            if (
ent 0) {
                
GetEntityClassname(entclassnamesizeof(classname));
                
PrintToChat(client"DontEq %i %s"entclassname);
                
AcceptEntityInput(ent"Kill");
                
GivePlayerItem(clientclassname);
                
SetEntProp(clientProp_Data"m_bDrawViewmodel"1);
                
count++;
            }
        }
    }
    
delete(g_hTmr[client]);
    
g_bAttack[client] = false;
}
 
//public Action OnEndTouch(int client, int weapon)
//{
//    char classname[64];
//    GetEntityClassname(weapon, classname, sizeof(classname));
//    if (StrEqual(classname, "weapon_molotov")) {
//        g_iGrens[client] = 0;
//        PrintToChat(client, "_____g_iGrens[client] = %i", g_iGrens[client]);
//    } else  PrintToChat( client, "weapon = %i", weapon);
//}
 
public Action OnWeaponCanUse(int clientint weapon)
{
    
int decoy EntRefToEntIndex(g_iFakeWeaponRef[client]);

    
char classname[64];
    
GetEntityClassname(weaponclassnamesizeof(classname));
    
// No fake decoy equipped, let him pickup whatever he wants
    
if(decoy <= 0) {
        
//PrintToConsole(client, "decoy <= 0         decoy = %i weapon= %i(%s)", decoy, weapon, classname);
        
g_iGrens[client] = (StrEqual(classname"weapon_molotov")) ? 1:0;
        
//PrintToChat(client, "g_iGrens[client] = %i", g_iGrens[client]);

        
return Plugin_Continue;
    }
    
    
// Picking up fake decoy
    
if(weapon == decoy) {
        
PrintToChat(client"weapon == decoy           decoy = %i weapon= %i(%s)"decoyweaponclassname);
        return 
Plugin_Continue;
    }
    
//PrintToChat(client, "%s           decoy = %i weapon= %i", classname, decoy, weapon);
    
    // Picking up a deocy, lets remove it and use the fake decoy as a real one
    
if(StrEqual(classname"weapon_decoy"))
    {
        
PrintToConsole(client"No fake decoy needed anymore          decoy = %i weapon= %i"decoyweapon);
        
PrintToChat(client"%s           decoy = %i weapon= %i"classnamedecoyweapon);

        
SetEntProp(clientProp_Data"m_bDrawViewmodel"1);
        
AcceptEntityInput(weapon"Kill");        
        
g_iFakeWeaponRef[client] = 0;
        
SetEntPropEnt(clientProp_Data"m_hActiveWeapon"decoy);
        
ChangeEdictState(clientFindDataMapInfo(client"m_hActiveWeapon"));
    }
    
    return 
Plugin_Continue;
}
 
public 
Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    if(!
g_bEnable || !IsPlayerAlive(client))
        return 
Plugin_Continue;

    
// Get the fake decoy
    
int decoy EntRefToEntIndex(g_iFakeWeaponRef[client]);

    
// Check if player has another weapon, thanks to ShaRen
    
int iWeapon decoy;
    for (
int j 0ent 0128+= 4) {
        
ent GetEntDataEnt2(clientm_hMyWeapons j);
        if (
ent && ent != decoy) {        // skip fake decoy
            
iWeapon ent;
            break;
        }
    }

    static 
int g_fLastButtons[MAXPLAYERS+1];
    if(!(
g_fLastButtons[client] & IN_ATTACK) && buttons IN_ATTACK)
        
Attack(client);
    else if (
g_fLastButtons[client] & IN_ATTACK && !(buttons IN_ATTACK))
        
InAttack(client);
    
g_fLastButtons[client] = buttons;
    
    
// No fake decoy needed anymore
    
if(iWeapon != decoy && decoy MaxClients && decoy != INVALID_ENT_REFERENCE)
    {
        
PrintToConsole(client"No fake decoy needed anymore          decoy = %i iWeapon= %i"decoyiWeapon);

        
SetEntProp(clientProp_Data"m_bDrawViewmodel"1);
        
AcceptEntityInput(decoy"Kill");
        
g_iFakeWeaponRef[client] = 0;
        
SetEntPropEnt(clientProp_Data"m_hActiveWeapon"iWeapon);
        
ChangeEdictState(clientFindDataMapInfo(client"m_hActiveWeapon"));
    }
    
// Create a new fake decoy
    
else if(iWeapon <= 0)
    {
        
SetEntProp(clientProp_Data"m_bDrawViewmodel"0);
        
iWeapon GivePlayerItem(client"weapon_decoy");
        
PreventThrowable(clientiWeapon);
        
g_iFakeWeaponRef[client] = EntIndexToEntRef(iWeapon);

        
decoy EntRefToEntIndex(g_iFakeWeaponRef[client]);
        
PrintToConsole(client"Create a new fake decoy          decoy = %i iWeapon= %i"decoyiWeapon);
    }

    
// Prevent decoy from being throwable
    
if(iWeapon && (iWeapon == decoy || (g_bGrenade[client] && g_bBlockGrenades)))
        
PreventThrowable(clientiWeapon);

    return 
Plugin_Continue;
}
 
void PreventThrowable(int clientint iWeapon)
{
    
float fUnlockTime GetGameTime() + 0.5;
       
    
SetEntPropFloat(clientProp_Send"m_flNextAttack"fUnlockTime);
    
SetEntPropFloat(iWeaponProp_Send"m_flNextPrimaryAttack"fUnlockTime);


Last edited by SHAREN; 10-29-2016 at 18:44.
SHAREN is offline
Send a message via Skype™ to SHAREN
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 11-08-2016 , 19:55   Re: [CS:GO] No weapon fix 3.0 (Player models lay on ground fix)
Reply With Quote #42

Added optional heat cooldown. It's useful if another plugin or a weapon strip zone of a map is conflicting with the plugin and causing a spam of fake decoys.

You can adjust the settings to trigger the anti spam instantly or after some time. And you can adjust the cooldown itself.
__________________
zipcore is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode