AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get user weapon when he switches his weapon (https://forums.alliedmods.net/showthread.php?t=55154)

SchlumPF* 05-15-2007 11:04

Get user weapon when he switches his weapon
 
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

Zenith77 05-15-2007 11:35

Re: Get user weapon when he switches his weapon
 
Quote:

Originally Posted by SchlumPF* (Post 476871)
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

Why does the CurWeapon not work for you? Please post the code you used.

regalis 05-15-2007 12:16

Re: Get user weapon when he switches his weapon
 
1 Attachment(s)
Quote:

Originally Posted by SchlumPF* (Post 476871)
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...


All times are GMT -4. The time now is 10:33.

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