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

register_message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
undead52
Senior Member
Join Date: Dec 2016
Old 05-06-2018 , 05:14   register_message
Reply With Quote #1

i use this code without problem but it changes everybody fovs i need to pu (id,...)but it doesnt work what should i do ?

this works
PHP Code:
register_message(get_user_msgid("SetFOV"), "Message_SetFOV");

public 
Message_SetFOV()
{
    new 
fov get_msg_arg_int(1);
    if( 
fov == 90 )
    {
    
        
set_msg_arg_int(0ARG_BYTEiFov);
    }

doesnt work
PHP Code:

register_message
(get_user_msgid("SetFOV"), "Message_SetFOV");

public 
Message_SetFOV(id)
{
    new 
fov get_msg_arg_int(1);
    if( 
fov == 90 )
    {
    
        
set_msg_arg_int(idARG_BYTEiFov);
    }

undead52 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 05-06-2018 , 05:48   Re: register_message
Reply With Quote #2

This event doesn't return an id, based here.
__________________
Relaxing is offline
fvRate
Junior Member
Join Date: May 2018
Old 05-06-2018 , 07:47   Re: register_message
Reply With Quote #3

Even if it accepts an index parameter, you are not really using it, if you need some specific operation (condition for it to run), for example if player is X then set_msg_arg_int( playerIndex, ARG_BYTE, iFov ); then just use get_players for that.
fvRate is offline
undead52
Senior Member
Join Date: Dec 2016
Old 05-06-2018 , 14:28   Re: register_message
Reply With Quote #4

switched that code but i dont think that is a good code, do you have any good idea ?
PHP Code:
public Message_SetFOV()
{
    new 
fov get_msg_arg_int(1);
    if( 
fov == 90 )
    {
        new 
iVault nvault_open"FoV" );
        new 
players[32], szNumszName[32];
        
get_players(playersszNum)
        for ( new 
0szNumi++)
        {
            new 
id players[i];
            
get_user_name(idszName31);
            
nvault_getiVault szName szDataString charsmaxszDataString ) );  
            
iFov str_to_num(szDataString);
            
set_msg_arg_int(idARG_BYTEiFov);
        
        }
        
    }


Last edited by undead52; 05-06-2018 at 14:28.
undead52 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-06-2018 , 15:29   Re: register_message
Reply With Quote #5

Quote:
Originally Posted by undead52 View Post
switched that code but i dont think that is a good code, do you have any good idea ?
Code:
public Message_SetFOV() {     new fov = get_msg_arg_int(1);     if( fov == 90 )     {         new iVault = nvault_open( "FoV" );         new players[32], szNum, szName[32];         get_players(players, szNum)         for ( new i = 0; i < szNum; i++)         {             new id = players[i];             get_user_name(id, szName, 31);             nvault_get( iVault , szName , szDataString , charsmax( szDataString ) );              iFov = str_to_num(szDataString);
            set_msg_arg_int(id, ARG_BYTE, iFov);
                }             } }
You cannot do this. This message has only 1 argument so you would always specify 1, never the player id.

What FOV angle are you trying to set if it equals 90?
__________________
Bugsy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-06-2018 , 15:38   Re: register_message
Reply With Quote #6

Quote:
Originally Posted by fvRate View Post
Even if it accepts an index parameter, you are not really using it, if you need some specific operation (condition for it to run), for example if player is X then set_msg_arg_int( playerIndex, ARG_BYTE, iFov ); then just use get_players for that.
No.

public Message_SetFOV(MsgId, MsgDest, MsgEntity) { ... }

MsgEntity is the player index. But you don't use player index in set_msg_arg/get_msg_arg natives. The first param is the argument index from the message.

@OP, to add a condition so you can change fov for only one player use the MsgEntity param and do the check before doing set_msg_arg_int.
__________________

Last edited by HamletEagle; 05-06-2018 at 15:43.
HamletEagle is offline
undead52
Senior Member
Join Date: Dec 2016
Old 05-07-2018 , 10:00   Re: register_message
Reply With Quote #7

i made a menu that player could choose their own FoV,i done the menu but have problem there, so i want to set players fov their owv fov value

Last edited by undead52; 05-07-2018 at 10:04.
undead52 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-07-2018 , 12:26   Re: register_message
Reply With Quote #8

Quote:
Originally Posted by undead52 View Post
i made a menu that player could choose their own FoV,i done the menu but have problem there, so i want to set players fov their owv fov value
What? What's the problem? If you have a menu then set a bool to true for that player and in SetFov check if bool[MsgEntity] is true and apply the new fov.
__________________
HamletEagle 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 04:51.


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