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

get_user_msgid() fails to work on server startup?


Post New Thread Reply   
 
Thread Tools Display Modes
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 15:34   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #11

Like this?
PHP Code:
public plugin_precache( )
{
    
register_forwardFM_RegUserMsg"@RegUserMsg" );
}
    
@
RegUserMsgszMsg[ ], iSize )
{
    if( 
equalszMsg"WeaponList" ) )
    
register_messageget_user_msgid"WeaponList" ), "OnMessageWeaponList" ); // hook WeaponList so we can retrieve values for weaponbox
}

public 
OnMessageWeaponList( )
{
    new 
iAmmoIndex get_msg_arg_int); // get ammo index
    
new iAmmoCount get_msg_arg_int); // get ammo count
    
new iWeaponID get_msg_arg_int);  // get weapon id
    
    
g_eAmmoIndexiWeaponID ][ AmmoIndex ] = iAmmoIndex// save ammo index
    
g_eAmmoIndexiWeaponID ][ AmmoCount ] = iAmmoCount// save ammo count
    
    
log_to_file"Weaponlist.txt""%d %d %d"iAmmoIndexiAmmoCountiWeaponID );

__________________
edon1337 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-30-2018 , 16:36   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #12

This way should work enough well:

Code:
#include <amxmodx> #include <fakemeta> new ForwardHandle; public plugin_precache() {     ForwardHandle = register_forward(FM_RegUserMsg, "@OnRegUserMsg", ._post = true); } @OnRegUserMsg(const name[], const size) {     if (equal(name, "WeaponList"))     {         unregister_forward(FM_RegUserMsg, ForwardHandle, .post = true);         register_message(get_orig_retval(), "@OnWeaponList");     } } @OnWeaponList(const messageId, const messageType, const entity) {     // }
__________________

Last edited by Arkshine; 07-30-2018 at 16:38.
Arkshine is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-30-2018 , 17:19   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #13

Quote:
Originally Posted by Arkshine View Post
This way should work enough well:

Code:
#include <amxmodx> #include <fakemeta> new ForwardHandle; public plugin_precache() {     ForwardHandle = register_forward(FM_RegUserMsg, "@OnRegUserMsg", ._post = true); } @OnRegUserMsg(const name[], const size) {     if (equal(name, "WeaponList"))     {         unregister_forward(FM_RegUserMsg, ForwardHandle, .post = true);         register_message(get_orig_retval(), "@OnWeaponList");     } } @OnWeaponList(const messageId, const messageType, const entity) {     // }
Yep, works, thanks!

EDIT: For some reason, sometimes it works, sometimes it doesn't, like WeaponList doesn't even get called
__________________

Last edited by edon1337; 07-30-2018 at 17:51.
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-31-2018 , 06:05   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #14

I tested it for longer and that method makes it work only 1st time, after you change map/restart server it doesn't work
__________________
edon1337 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-31-2018 , 06:41   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #15

Maybe something like

Spoiler
__________________
Arkshine is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-31-2018 , 06:50   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #16

Works as for now, I'll let you know for any further notice
__________________
edon1337 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-05-2018 , 12:24   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #17

Quote:
Originally Posted by PRoSToTeM@ View Post

Possibly we can add register_message_lazy which would get usermsg name instead of id and retrieve msgid when the first message is sent.

I kind of like the idea.
__________________
Arkshine is offline
lagaiphone
New Member
Join Date: Aug 2018
Location: Gφteborg
Old 08-06-2018 , 11:31   Re: get_user_msgid() fails to work on server startup?
Reply With Quote #18

It think it could be the game registers such messages in pfnServerActivate.
lagaiphone 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 19:33.


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