Hello.
I am running a DoD:S map where there are several
game_player_equip entities where each has the
Use input linked with the
OnTrigger output of a
trigger_multiple entity.
I am trying to access
m_weaponNames and
m_weaponCount props of the
game_player_equip with the following code in the stable SourceMod 1.7.2:
PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
if (StrEqual(classname, "game_player_equip", false))
{
if (SDKHookEx(entity, SDKHook_Use, ManageGPEEntUseHook))
{
PrintToServer("game_player_equip entity %d's Use hooking succeeded", entity);
}
else
{
PrintToServer("game_player_equip entity %d's Use hooking failed", entity);
}
}
}
public Action ManageGPEEntUseHook(int entity, int activator, int caller, UseType type, float value)
{
char message[128];
if (Entity_IsPlayer(activator))
{
char arrayWeaponNames[MAX_EQUIP][128];
int arrayWeaponCount[MAX_EQUIP];
int numberWeaponNamesCurrElems = GetEntPropArraySize(entity, Prop_Data, "m_weaponNames");
strcopy(message, sizeof(message), "numberWeaponNamesCurrElems: %d")
PrintToServer(message, numberWeaponNamesCurrElems);
PrintToChatAll(message, numberWeaponNamesCurrElems);
for(int i = 0; i < numberWeaponNamesCurrElems; i++)
{
GetEntPropString(entity, Prop_Data, "m_weaponNames", arrayWeaponNames[i], 128, i);
arrayWeaponCount[i] = GetEntProp(entity, Prop_Data, "m_weaponCount", 4, i);
strcopy(message, sizeof(message), "arrayWeaponNames[%d]: '%s'")
PrintToServer(message, i, arrayWeaponNames[i]);
PrintToChatAll(message, i, arrayWeaponNames[i]);
strcopy(message, sizeof(message), "arrayWeaponCount[%d]: %d")
PrintToServer(message, i, arrayWeaponCount[i]);
PrintToChatAll(message, i, arrayWeaponCount[i]);
}
}
return Plugin_Continue;
}
getting the following lines of text in console when the player touch one of the
trigger_multiple:
Code:
numberIWeaponNamesCurrElems: 32
arrayIWeaponNames[0]: 'weapon_riflegren_us'
arrayIWeaponCount[0]: 3
L 08/29/2015 - 20:31:47: [SM] Native "GetEntPropString" reported: Prop m_weaponNames is not an array. Element 1 is invalid.
etc.
As we can see, the runtime error tells that the
m_weaponNames is not an array but, when i use the GetEntPropArraySize to store its size in my
numberWeaponNamesCurrElems variable, i get the number 32. So why does the GetEntPropString give me that error? Is it bugged?
__________________