Raised This Month: $51 Target: $400
 12% 

CurWeapon Event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LeOp4rD
New Member
Join Date: Jul 2022
Location: Algeria
Old 04-05-2024 , 21:30   CurWeapon Event
Reply With Quote #1

Hello, I'm trying to make some actions when a client changes his weapon, but nothing seems to work here :

#include <amxmodx>

public plugin_init(){
register_plugin("knife Buffs" , AMXX_VERSION_STR , "LeOpArD")
register_event("CurWeapon" , "knifeBuff", "a")
}

public knifeBuff(id) {
client_print(0, print_chat, "CurWeapon event triggered for client %d!", id);

return PLUGIN_HANDLED;
}

Last edited by LeOp4rD; 04-05-2024 at 21:31.
LeOp4rD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-06-2024 , 00:34   Re: CurWeapon Event
Reply With Quote #2

Try

register_event("CurWeapon" , "knifeBuff" , "be" , "1=1" );
__________________
Bugsy is offline
LeOp4rD
New Member
Join Date: Jul 2022
Location: Algeria
Old 04-06-2024 , 02:28   Re: CurWeapon Event
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Try

register_event("CurWeapon" , "knifeBuff" , "be" , "1=1" );
THANK YOU SO MUCH !
so 'b' means it will be sent to a single client, and 'e' if hes alive !
IT worked perfectly, but i couldn't understand the condition part

Last edited by LeOp4rD; 04-06-2024 at 02:49.
LeOp4rD is offline
abdelwahab
Member
Join Date: Aug 2019
Old 04-06-2024 , 19:56   Re: CurWeapon Event
Reply With Quote #4

Quote:
Originally Posted by LeOp4rD View Post
i couldn't understand the condition part

https://www.amxmodx.org/api/amxmodx/register_event
abdelwahab is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-07-2024 , 10:13   Re: CurWeapon Event
Reply With Quote #5

These are what you have to work with from a conditions perspective in the CurWeapon event.

https://wiki.alliedmods.net/Half-life_1_game_events
Code:
Name: CurWeapon
byte	IsActive
byte	WeaponID
byte	ClipAmmo
You must reference them in the order as listed.
1=IsActive
2=WeaponID
3=ClipAmmo

So the "1=1" you see above means IsActive must be 1 for the event to trigger in your plugin.

Another example using the 2nd argument of WeaponID. With CSW_AK47=28, you could add a condition to make it only fire on the AK47 by adding:
"2=28"

register_event("CurWeapon" , "AK47Only" , "be" , "1=1" , "2=28" );

Or everything except AK47
register_event("CurWeapon" , "AK47Only" , "be" , "1=1" , "2!28" );
__________________

Last edited by Bugsy; 04-07-2024 at 11:03.
Bugsy is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-07-2024 , 16:55   Re: CurWeapon Event
Reply With Quote #6

sorry to interrupt, I leave this method and withdraw slowly...

PHP Code:
#include <amxmodx>
#include <hamsandwich>

public plugin_precache() 
{
    for(new 
CSW_P228weapon_name[20]; <= CSW_P90i++)
    {
        if(
get_weaponname(iweapon_namecharsmax(weapon_name)))
        {
            
RegisterHam(Ham_Item_Deployweapon_name"Ham_Item_Deploy_Post"true)
        }
    }
}

public 
Ham_Item_Deploy_Post(iWeapon)
{
    const 
OFFSET_WEAPONOWNER 41
    
const OFFSET_LINUX_WEAPONS 4
        
    
new iPlayer get_pdata_cbase(iWeaponOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS)
    
    if( !
is_user_connected(iPlayer) )
        return 
HAM_IGNORED

    client_print
(0print_chat"Ham_Item_Deploy event triggered for client %d!"iPlayer);

    return 
HAM_IGNORED

__________________
mlibre is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-08-2024 , 08:41   Re: CurWeapon Event
Reply With Quote #7

“and withdraw slowly”? What does that mean?
__________________
Bugsy is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 04-08-2024 , 09:08   Re: CurWeapon Event
Reply With Quote #8

it's a...

meme
__________________
mlibre is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 04-08-2024 , 18:24   Re: CurWeapon Event
Reply With Quote #9

@LeOp4rD, register_event_ex is easier to read. Flags are in English instead of letters.
Code:
#include amxmodx #define PLUGIN   "Weapon Switch Snitch" #define VERSION  "1.0.0" #define AUTHOR   "SPiNX" #define URL      "https://github.com/djearthquake" #define charsmin -1 public plugin_init() {     #if AMXX_VERSION_NUM != 182     register_plugin(PLUGIN, VERSION, AUTHOR, URL)     #else     register_plugin(PLUGIN, VERSION, AUTHOR)     #endif } public client_command(id) {        if(is_user_alive(id))     {            static szArgCmd[MAX_NAME_LENGTH]         read_argv(0,szArgCmd, charsmax(szArgCmd))         if(contain(szArgCmd, "weapon_")>charsmin)         {             if(user_has_weapon(id,get_weaponid(szArgCmd))) //extra code due to C4 planting aliases.             {                 replace(szArgCmd, charsmax(szArgCmd), "weapon_", "")                 client_print(0, print_chat, "%n switched to %s.", id, szArgCmd)             }         }     }     return PLUGIN_CONTINUE }

Spoiler
__________________
DJEarthQuake is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-08-2024 , 21:14   Re: CurWeapon Event
Reply With Quote #10

Or just use register_event()…
__________________
Bugsy 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 18:14.


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