Quote:
Originally Posted by Ilusion9
PHP Code:
stock bool HasWeapon(int client, const char[] weapon)
{
int length = GetEntPropArraySize(client, Prop_Send, "m_hMyWeapons");
for (int i= 0; i < length; i++)
{
int item = GetEntPropEnt(client, Prop_Send, "m_hMyWeapons", i);
if (item != -1)
{
char classname[64];
if (GetEntityClassname(item, classname, sizeof(classname)))
{
if (StrEqual(weapon, classname, false))
{
return true;
}
}
}
}
return false;
}
if (HasWeapon(client, "weapon_healthshot"))
{
// do something
}
|
I just tested your code with this plugin and it seems to be working just fine
Also, I used this simple plugin to test your code:
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"
#include <sourcemod>
#include <sdktools>
#pragma newdecls required
public Plugin myinfo =
{
name = "",
author = PLUGIN_AUTHOR,
description = "",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart()
{
RegConsoleCmd("sm_check", check);
}
public Action check(int client, int agrs)
{
if (HasWeapon(client, "weapon_healthshot"))
{
PrintCenterText(client, "Has healthshot");
}
else
{
PrintCenterText(client, "Does not have a healthshot");
}
}
stock bool HasWeapon(int client, const char[] weapon)
{
int length = GetEntPropArraySize(client, Prop_Send, "m_hMyWeapons");
for (int i= 0; i < length; i++)
{
int item = GetEntPropEnt(client, Prop_Send, "m_hMyWeapons", i);
if (item != -1)
{
char classname[64];
if (GetEntityClassname(item, classname, sizeof(classname)))
{
if (StrEqual(weapon, classname, false))
{
return true;
}
}
}
}
return false;
}