I've been trying to get the primary weaponname just before a player picks up an item/weapon in L4D2, but it always returns the pickup up item/weapon, not the previous item/weapon in player's first slot.
If I'd only need the weapon, I could use the weapon_drop event or the m_hLastWeapon netprop, but I need more data than that. So I need to be able to get it before item_pickup.
I'm new to SDKHooks, and I've been told I could possible prehook it with SDKHooks, but I wouldn't know how...
PHP Code:
public OnPluginStart()
{
HookEvent("item_pickup", evtPreItemPickUp, EventHookMode_Pre)
}
public Action:evtPreItemPickUp(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"))
if(client)
{
if(GetClientTeam(client)==2 && !IsFakeClient(client))
{
PrintToChatAll("Before Player Picks Up and Item:")
// get data before item_pickup event?
new entprimary = GetPlayerWeaponSlot(client, 0)
if(IsValidEdict(entprimary))
{
decl String:sCurrentPrimary[128]
GetEdictClassname(entprimary, sCurrentPrimary, sizeof(sCurrentPrimary))
PrintToChatAll("-> Player's Current Primary: %s", sCurrentPrimary)
}
else
{
PrintToChatAll("-> Player does not have a Primary")
}
}
}
return Plugin_Continue
}
__________________