Senior Member
|
10-29-2016
, 18:43
Re: [CS:GO] No weapon fix 3.0 (Player models lay on ground fix)
|
#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
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(cvEnable, OnSettingChanged); cvBlockGrenades = CreateConVar("no_weapon_fix_block_grenades", "0", "Block all grenades from being throwable (1: Enable; 0: Disable)."); g_bBlockGrenades = GetConVarBool(cvBlockGrenades); HookConVarChange(cvBlockGrenades, OnSettingChanged); AutoExecConfig(true, "no_weapon_fix"); m_hMyWeapons = FindSendPropInfo("CBasePlayer", "m_hMyWeapons"); if(m_hMyWeapons == -1) { char Error[128]; FormatEx(Error, sizeof(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 client, int args) { int molotov = GivePlayerItem(client, "weapon_molotov"); if (molotov != INVALID_ENT_REFERENCE) { SetEntPropEnt(client, Prop_Data, "m_hActiveWeapon", molotov); ChangeEdictState(client, FindDataMapInfo(client, "m_hActiveWeapon")); } return Plugin_Continue; }
public void OnClientPutInServer(int client) { SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse); //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[] name, bool dontBroadcast) { int client = GetClientOfUserId(GetEventInt(event, "userid")); PrintToChat(client, "Event_weapon_fire"); g_bAttack[client] = true; } public Action Event_ItemEquip(Handle event, const char[] name, bool 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 = 0, ent = 0; j < 128; j += 4) { ent = GetEntDataEnt2(client, m_hMyWeapons + j); if (ent > 0) {
GetEntityClassname(ent, classname, sizeof(classname)); PrintToChat(client, "InAttack %i", ent); count++; } } } //if (count == 1) { g_hTmr[client] = CreateTimer(0.01, DontEq, client); //} //PrintToChat(client, "InAttack"); }
void Attack(int client) { //PrintToChat(client, "Attack"); }
public Action DontEq(Handle timer, any 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 = 0, ent = 0; j < 128; j += 4) { ent = GetEntDataEnt2(client, m_hMyWeapons + j); if (ent > 0) { GetEntityClassname(ent, classname, sizeof(classname)); PrintToChat(client, "DontEq %i %s", ent, classname); AcceptEntityInput(ent, "Kill"); GivePlayerItem(client, classname); SetEntProp(client, Prop_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 client, int weapon) { int decoy = EntRefToEntIndex(g_iFakeWeaponRef[client]);
char classname[64]; GetEntityClassname(weapon, classname, sizeof(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)", decoy, weapon, classname); 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", decoy, weapon); PrintToChat(client, "%s decoy = %i weapon= %i", classname, decoy, weapon);
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 1); AcceptEntityInput(weapon, "Kill"); g_iFakeWeaponRef[client] = 0; SetEntPropEnt(client, Prop_Data, "m_hActiveWeapon", decoy); ChangeEdictState(client, FindDataMapInfo(client, "m_hActiveWeapon")); } return Plugin_Continue; } public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int 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 = 0, ent = 0; j < 128; j += 4) { ent = GetEntDataEnt2(client, m_hMyWeapons + j); if (ent > 0 && 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", decoy, iWeapon);
SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 1); AcceptEntityInput(decoy, "Kill"); g_iFakeWeaponRef[client] = 0; SetEntPropEnt(client, Prop_Data, "m_hActiveWeapon", iWeapon); ChangeEdictState(client, FindDataMapInfo(client, "m_hActiveWeapon")); } // Create a new fake decoy else if(iWeapon <= 0) { SetEntProp(client, Prop_Data, "m_bDrawViewmodel", 0); iWeapon = GivePlayerItem(client, "weapon_decoy"); PreventThrowable(client, iWeapon); g_iFakeWeaponRef[client] = EntIndexToEntRef(iWeapon);
decoy = EntRefToEntIndex(g_iFakeWeaponRef[client]); PrintToConsole(client, "Create a new fake decoy decoy = %i iWeapon= %i", decoy, iWeapon); }
// Prevent decoy from being throwable if(iWeapon > 0 && (iWeapon == decoy || (g_bGrenade[client] && g_bBlockGrenades))) PreventThrowable(client, iWeapon);
return Plugin_Continue; } void PreventThrowable(int client, int iWeapon) { float fUnlockTime = GetGameTime() + 0.5; SetEntPropFloat(client, Prop_Send, "m_flNextAttack", fUnlockTime); SetEntPropFloat(iWeapon, Prop_Send, "m_flNextPrimaryAttack", fUnlockTime); }
Last edited by SHAREN; 10-29-2016 at 18:44.
|
|