Raised This Month: $ Target: $400
 0% 

Force Weapon Switch: alternate way?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-07-2009 , 22:20   Re: Force Weapon Switch: alternate way?
Reply With Quote #1

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
for method 2, I tryied this to remove it
Code:
server_print("[TEST] Forcing weapon change...")
set_msg_block(35, BLOCK_ONCE)
engclient_cmd(id, "weapon_knife")
__________________
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-08-2009 , 10:52   Re: Force Weapon Switch: alternate way?
Reply With Quote #2

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 #3

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 #4

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 #5

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
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-09-2009 , 13:31   Re: Force Weapon Switch: alternate way?
Reply With Quote #6

I'm back after some testing. There's definitely some kind of glitch with message/event handling in AMXX. It only happens on specific cases though, only with engine-generated messages and emessages.

A. Engine-generated messages
Sent by the game as a result of executing some code, e.g.:
Code:
give_item(id, "weapon_awp")
In this case the engine will automatically send a "WeaponPickup" message.
Code:
engclient_cmd(id, "weapon_knife")
Here, an SVC_WEAPONANIM message is sent when the user has cl_lw set to 0.

B. Emessages
Emessages are pretty much like normal messages, but they are also sent to all other plugins and Metamod plugins.
Code:
emessage_begin(MSG_ONE, get_user_msgid("NVGToggle"), _, id) ewrite_byte(1) emessage_end()

Bug #1
These messages can't be sent during the callback (forward) of a message hooked with register_message. They will cause either:
  • A server crash ("Msg XX has not been sent yet", "Msg: X bytes written, expected Y")
  • A corrupted message ("SVC_BAD", "Illegible Server Message", etc.)

Bug #2
When one of these messages is sent during the callback (forward) of a message hooked with register_event, the message that's sent must have been previously hooked with register_event() too. Failure to do so will cause the callback of the hooked message to either:
  • Get called more than once
  • Get called infinite times, before a "Run time error 3: stack error" shows up


I hope this post helps shed some light on the topic. Sounds like some kind of recursion problem to me.

Here's the detailed test logs for those interested
[IMG]http://img8.**************/img8/4708/testsso9.th.jpg[/IMG]
__________________

Last edited by MeRcyLeZZ; 02-09-2009 at 14:09.
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