Veteran Member
Join Date: Jan 2010
Location: mom's basement
|
01-14-2019
, 02:57
Re: [CSGO] How to prevent reloading if you have too much ammo
|
#13
|
PHP Code:
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(buttons & IN_RELOAD)
{
buttons &= ~IN_RELOAD;
}
return Plugin_Continue;
}
test
PHP Code:
#include <sdkhooks>
#include <cstrike>
StringMap store;
public void OnPluginStart()
{
store = new StringMap();
RegConsoleCmd("sm_test", test);
}
public Action test(int client, int args)
{
int entity = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
SetEntProp(entity, Prop_Send, "m_iClip1", 150);
//return Plugin_Handled;
char key[30];
int value;
StringMapSnapshot snap = store.Snapshot();
for(int a = 0; a < snap.Length; a++)
{
snap.GetKey(a, key, sizeof(key));
if(store.GetValue(key, value))
{
CSWeaponID weaponid = CS_ItemDefIndexToID(StringToInt(key));
CS_WeaponIDToAlias(weaponid, key, sizeof(key));
Format(key, sizeof(key), "weapon_%s", key);
PrintToServer("%s Value %i", key, value);
}
}
delete snap;
return Plugin_Handled;
}
public void OnEntityCreated(int entity, const char[] classname)
{
if(!IsValidEntity(entity) || StrContains(classname, "weapon_", false) == -1) return;
RequestFrame(nextframe, EntIndexToEntRef(entity));
}
public void nextframe(int ref)
{
int entity = EntRefToEntIndex(ref);
if(entity == -1) return;
if(GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType") == -1) return; // projectile
int m_iClip1 = GetEntProp(entity, Prop_Send, "m_iClip1");
if(m_iClip1 == 255) return; // projectile
char key[10];
Format(key, sizeof(key), "%i", GetEntProp(entity, Prop_Send, "m_iItemDefinitionIndex"));
if(store.SetValue(key, m_iClip1, false))
{
PrintToServer("New weapon '%s' clip size saved %i", key, m_iClip1);
}
}
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(buttons & IN_RELOAD)
{
int entity = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
if(entity == -1) return Plugin_Continue;
char key[10];
int value;
Format(key, sizeof(key), "%i", GetEntProp(entity, Prop_Send, "m_iItemDefinitionIndex"));
if(!store.GetValue(key, value)) return Plugin_Continue;
if(GetEntProp(entity, Prop_Send, "m_iClip1") <= value) return Plugin_Continue;
buttons &= ~IN_RELOAD;
}
return Plugin_Continue;
}
Last edited by Bacardi; 01-14-2019 at 04:35.
|
|