Raised This Month: $ Target: $400
 0% 

Force Weapon Switch: alternate way?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-08-2009 , 10:52   Re: Force Weapon Switch: alternate way?
Reply With Quote #1

Quote:
Originally Posted by jim_yang
seems that when cl_lw 0 it will fire another message SVC_WEAPONANIM
so method 1 will get that error because it's still in hooking msg curweapon
Right, thanks for the explanation.

I still don't know what's up with method #2, take a look at this console dump:
Code:
] amx_forceknife 2
] cl_lw 0
] weapon_usp
[TEST] CurWeapon Message - player 1 - weapon weapon_usp
[TEST] CurWeapon Event - player 1 - weapon weapon_usp
[TEST] Forcing weapon change...
[TEST] CurWeapon Event - player 1 - weapon weapon_usp
[TEST] Forcing weapon change...
I attempted to change my weapon only once, still a second CurWeapon Event was called out of nowhere. Is that a bug in AMXX's event system or what? I didn't have any other plugins running besides the test script...

Quote:
Originally Posted by jim_yang
I tryied this to remove it
Code:
server_print("[TEST] Forcing weapon change...")
set_msg_block(35, BLOCK_ONCE)
engclient_cmd(id, "weapon_knife")
Alright, tested that...
For Method #1 I'm now getting kicked out with SVC_BAD when I switch weapons...
For method #2 it's still triggering an additional CurWeapon event out of nowhere.
__________________
MeRcyLeZZ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-08-2009 , 11:37   Re: Force Weapon Switch: alternate way?
Reply With Quote #2

Register your event with arg 1 = 1 ( "1=1 ), means the weapon is active.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-08-2009 , 16:22   Re: Force Weapon Switch: alternate way?
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Register your event with arg 1 = 1 ( "1=1 ), means the weapon is active.
He already checked that:
Code:
if (!is_user_alive(id) || read_data(1) != 1)         return;
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-09-2009 , 01:23   Re: Force Weapon Switch: alternate way?
Reply With Quote #4

My bad, i've just checked the register line

What weird things due to engclient_cmd are you talking about ?
The only bug i've ever had with this was the model (when custom one) not update properly, i had to manyally update it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-10-2009 , 01:00   Re: Force Weapon Switch: alternate way?
Reply With Quote #5

Code:
#include <amxmodx>
#include <fakemeta>
 
#define PLUGIN    "Test"
#define AUTHOR    "Jim"
#define VERSION    "1.0"
 
new g_hook
new g_arg
new g_id
 
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_forward(FM_MessageBegin, "msg_begin")
    register_forward(FM_WriteByte, "writebyte")
    register_forward(FM_MessageEnd, "msg_end_post", 1)
}
 
public msg_begin(const msg_dest, const msg_type, const origin[3], const id)
{
    if(msg_dest == MSG_ONE && msg_type == 66 && is_user_alive(id))
    {
        g_hook = 1
        g_arg = 0
        g_id = id
    }
    return FMRES_IGNORED
}
 
public writebyte(const value)
{
    if(!g_hook)
        return FMRES_IGNORED
 
    ++g_arg
    switch(g_arg)
    {
        case 1:    if(!value)                g_hook = 0
        case 2:    if(value == CSW_KNIFE)    g_hook = 0
    }
    return FMRES_IGNORED
}
 
public msg_end_post()
{
    if(g_hook)
    {
        g_hook = 0
        g_arg = 0
        server_print("curweapon %d", get_user_weapon(g_id))
        engclient_cmd(g_id, "weapon_knife")
        //g_hook = 0
        //g_arg = 0
        g_id = 0
    }
}
I found that when g_hook = 0 is after engclient_cmd, result same as the way register_event(two curweapon msg)
but when g_hook = 0 is before engclient_cmd, only one curweapon msg
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-14-2009 , 17:09   Re: Force Weapon Switch: alternate way?
Reply With Quote #6

Quote:
Originally Posted by jim_yang View Post
I found that when g_hook = 0 is after engclient_cmd, result same as the way register_event(two curweapon msg)
but when g_hook = 0 is before engclient_cmd, only one curweapon msg
Alright, we should see if it's possible to fix it like that in AMXX. I'll take a look at the source in a while... and maybe submit a bug report when I get a clearer picture of what's going on...
__________________
MeRcyLeZZ is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-24-2009 , 21:23   Re: Force Weapon Switch: alternate way?
Reply With Quote #7

Bug reports submitted!

https://bugs.alliedmods.net/show_bug.cgi?id=3664
https://bugs.alliedmods.net/show_bug.cgi?id=3665
__________________
MeRcyLeZZ 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 01:38.


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