AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_message (https://forums.alliedmods.net/showthread.php?t=307336)

undead52 05-06-2018 05:14

register_message
 
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);
    }



Relaxing 05-06-2018 05:48

Re: register_message
 
This event doesn't return an id, based here.

fvRate 05-06-2018 07:47

Re: register_message
 
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.

undead52 05-06-2018 14:28

Re: register_message
 
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);
        
        }
        
    }



Bugsy 05-06-2018 15:29

Re: register_message
 
Quote:

Originally Posted by undead52 (Post 2590985)
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?

HamletEagle 05-06-2018 15:38

Re: register_message
 
Quote:

Originally Posted by fvRate (Post 2590919)
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.

undead52 05-07-2018 10:00

Re: register_message
 
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

HamletEagle 05-07-2018 12:26

Re: register_message
 
Quote:

Originally Posted by undead52 (Post 2591093)
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.


All times are GMT -4. The time now is 04:37.

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