Raised This Month: $ Target: $400
 0% 

Force Weapon Switch: alternate way?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-06-2009 , 18:16   Re: Force Weapon Switch: alternate way?
Reply With Quote #1

I tried to set m_pActiveItem (373) before :

Code:
set_pdata_cbase ( id, 373, ActiveWpn ); ExecuteHam ( Ham_Item_Deploy, ActiveWpn );
It works fine for me now. I'm not sure if m_pClientActiveItem (374) is needed, though.
Arkshine is offline
Old 02-07-2009, 15:03
MeRcyLeZZ
This message has been deleted by MeRcyLeZZ. Reason: damn
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-07-2009 , 15:05   Re: Force Weapon Switch: alternate way?
Reply With Quote #3

Oh, and for those wondering what problems I had with the engclient_cmd code, test the following script with amx_forceknife set to 1 and 2. Then set your client-side cl_lw cvar to 0 and test again.

Method #1 makes the server crash with "New message started when msg 35 has not been sent yet".
Method #2 results in an additional CurWeapon Event call, but no matching CurWeapon Message pair for it (weird, huh?).

Code:
#include <amxmodx> #include <fakemeta> new cvar_method, g_msgCurWeapon enum {     CVAR_DISABLE = 0, // 0 - disable knife forcing     CVAR_PRE_HOOK, // 1 - force change at pre-hook     CVAR_POST_HOOK // 2 - force change at post-hook } public plugin_init() {     register_plugin("Force Knife", "0.1", "Test")         cvar_method = register_cvar("amx_forceknife", "0")         g_msgCurWeapon = get_user_msgid("CurWeapon")         // CurWeapon Message (pre-hook)     register_message(g_msgCurWeapon, "message_cur_weapon")         // CurWeapon Event (post-hook)     register_event("CurWeapon", "event_cur_weapon", "b") } public message_cur_weapon(msg_id, msg_dest, msg_entity) {     // Player not alive or not an active weapon     if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)         return;         // Get current weapon's id and name     static weapon, wname[32]     weapon = get_msg_arg_int(2)     get_weaponname(weapon, wname, sizeof wname - 1)         // Print some debug info     server_print("[TEST] CurWeapon Message - player %d - weapon %s", msg_entity, wname)         // Check method setting     if (get_pcvar_num(cvar_method) != CVAR_PRE_HOOK)         return;         // Check if holding a knife     if (weapon == CSW_KNIFE)         return;         // If not, force a change     server_print("[TEST] Forcing weapon change...")     engclient_cmd(msg_entity, "weapon_knife") } public event_cur_weapon(id) {     // Player not alive or not an active weapon     if (!is_user_alive(id) || read_data(1) != 1)         return;         // Get current weapon's id and name     static weapon, wname[32]     weapon = read_data(2)     get_weaponname(weapon, wname, sizeof wname - 1)         // Print some debug info     server_print("[TEST] CurWeapon Event - player %d - weapon %s", id, wname)         // Check method setting     if (get_pcvar_num(cvar_method) != CVAR_POST_HOOK)         return;         // Check if holding a knife     if (weapon == CSW_KNIFE)         return;         // If not, force a change     server_print("[TEST] Forcing weapon change...")     engclient_cmd(id, "weapon_knife") }
__________________
MeRcyLeZZ is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 02-07-2009 , 16:33   Re: Force Weapon Switch: alternate way?
Reply With Quote #4

Quote:
set_pdata_cbase ( id, 373, ActiveWpn );
ExecuteHam ( Ham_Item_Deploy, ActiveWpn );
EDIT:
Hold on, this one is also crashing the server when setting cl_lw to 0. Damn it.
__________________
MeRcyLeZZ is offline
Old 02-07-2009, 17:46
Dores
This message has been deleted by Dores. Reason: Oh nvm...
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