Raised This Month: $ Target: $400
 0% 

Get user weapon when he switches his weapon


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-15-2007 , 12:16   Re: Get user weapon when he switches his weapon
Reply With Quote #3

Quote:
Originally Posted by SchlumPF* View Post
hi
i just want to know how i could get the current weapon of a player and save it as a variable. i hearded of the curweapon event but it doesnt work for me :S i need this for a kreedzplugin... i want to edit the top10 so just ppl who used a knife or usp can get a entry in top10
pls help me
use this:
Code:
#define MAXPLAYERS 32

// Array that holds number of the players last weapon 
// (for changing the speed related to the current weapon)
new g_WeaponUsed[MAXPLAYERS+1]

public plugin_init()
{
    register_event("CurWeapon", "Change_Wpn", "be")//Weapon changed....maybe adding "1=1"
}


// Called on player switches his weapon
public Change_Wpn(id)
{
    new WeaponNum = read_data(2)  // read and store the weaponID
    new WeaponActive = read_data(1)  // read the flag if weapon is active (user holds in his hand)
    
    if ((WeaponNum != g_WeaponUsed[id]) && WeaponActive)  // if weapon has changed and its the active weapon continue
    {
        g_WeaponUsed[id] = WeaponNum
        // do something...
    }
    return PLUGIN_HANDLED
}
Btw.: you have to save the last weapon to avoid action on other CurWeapon events than changeweapon.

And here is a file with the weapon data...
Attached Files
File Type: txt Weapon index.txt (17.2 KB, 168 views)
__________________
regalis is offline
 



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 10:33.


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