This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[SOLVED][L4D2] Get primary weapon before item_pickup event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cigs
Senior Member
Join Date: Jul 2006
Old 05-08-2010 , 06:34   [SOLVED][L4D2] Get primary weapon before item_pickup event
Reply With Quote #1

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"evtPreItemPickUpEventHookMode_Pre)    
}

public 
Action:evtPreItemPickUp(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"))
    if(
client)
    {
        if(
GetClientTeam(client)==&& !IsFakeClient(client))
        {
            
PrintToChatAll("Before Player Picks Up and Item:")
            
            
// get data before item_pickup event?
            
new entprimary GetPlayerWeaponSlot(client0)
            if(
IsValidEdict(entprimary))
            {
                
decl String:sCurrentPrimary[128]
                
GetEdictClassname(entprimarysCurrentPrimarysizeof(sCurrentPrimary))
                
PrintToChatAll("-> Player's Current Primary: %s"sCurrentPrimary)
            }
            else
            {
                
PrintToChatAll("-> Player does not have a Primary")
            }
        }
    }
    return 
Plugin_Continue

__________________

Last edited by cigs; 05-08-2010 at 21:50. Reason: add [SOLVED] to title
cigs is offline
cigs
Senior Member
Join Date: Jul 2006
Old 05-08-2010 , 12:56   Re: [L4D2] Get primary weapon before item_pickup event
Reply With Quote #2

Nevermind. I used the weapon_drop event afterall and got the data I needed from the dropped weapon, instead of the weapon (in slot1) before it's dropped.
__________________
cigs is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode