AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About an error : "Plugin called message_begin with an invalid message id (0)". (https://forums.alliedmods.net/showthread.php?t=126143)

epic . 05-06-2010 00:32

About an error : "Plugin called message_begin with an invalid message id (0)".
 
When I run a plugin(it can be compiled, and can be loaded), it shows this error:
"Plugin called message_begin with an invalid message id (0)."

What does it mean ? the line of message_begin is correct, so I don`t think the error comes from the line of message_begin .It seems like when the plugin run the message_begin , it lost the "id"

I have searched this thread http://forums.alliedmods.net/showthread.php?t=91134&highlight=error but, I still have no idea.

EDIT : more infomation is in the #5

Thanks for help.

EDIT: when I write it again(as the same as before), it was sloved. It is so weird

Leon M. 05-06-2010 00:49

Re: Plugin called message_begin with an invalid message id (0).
 
Hi, that means you must specify the client who get this messages. (Allowed Numbers 1 - 32)

You could add check is_user_connected(id). If you want to send a message to all clients use message_begin(MSG_BROADCAST, msgid).

Greetz
Leon

epic . 05-06-2010 01:11

Re: Plugin called message_begin with an invalid message id (0).
 
Quote:

Originally Posted by Leon M. (Post 1172203)
Hi, that means you must specify the client who get this messages. (Allowed Numbers 1 - 32)

You could add check is_user_connected(id). If you want to send a message to all clients use message_begin(MSG_BROADCAST, msgid).

Greetz
Leon

Thanks for you quick reply :)
I have specifed the client who get this messages.
For example:
Code:

new g_msgScreenFade
 
public plugin_init()
{
    register_logevent("RoundStart", 2, "1=Round_Start")
    g_msgScreenFade = get_user_msgid("ScreenFade")
}
public RoundStart()
{
    new iPlayers[32], iNum, id, iRandom[32], iRandomNum;
    new origin[3], srco[3];
    new playername[32];
 
    get_players(iPlayers, iNum);
    for ( new i = 0 ; i < iNum ; i++ )
    {
        id = iPlayers[i];
        if ( cs_get_user_team(id) == CS_TEAM_CT )
        {
            iRandom[ iRandomNum++ ] = id;
            g_mark = iRandom[ random( iRandomNum ) ];
        }
    }
    if( !is_user_connected(g_mark) )   
    {
        g_mark = 0
        return
    }
    get_user_origin(g_mark , origin) //the plugin know who is the g_mark here, it can get the origin of the g_mark
    origin[2] -= 26
    srco[0] = origin[0] + 150
    srco[1] = origin[1] + 150
    srco[2] = origin[2] + 800
    lightning_appear(srco, origin)//the plugin know who is the g_mark here, it can run the function of "lightning_appear" to the g_mark
 
    cs_set_user_model(g_mark, "vip"))//the plugin also know who is the g_mark here, it can change the model of the g_mark to "vip"
 
    flash_screen(g_mark) // But, when run the flash_screen which start with "message_begin", the plugin seems like lost the g_mark, it doesn`t run flash_screen to g_mark
    get_user_name(g_mark, playername, 31)
    client_print(0, print_chat, "some word"); //the code under the function "flash_screen", also doesn`t run ,it seem like, the code here still lost the g_mark
    client_print(0, print_chat, "some word", playername);
}
stock flash_screen(id)
{
    if( !is_user_connected(id) ) return
    message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
    write_short(3000)                          // duration
    write_short(1000)                          // hold time
    write_short(0)                              // flags
    write_byte(0)                              // red
    write_byte(255)                            // green
    write_byte(0)                              // blue
    write_byte(100)                            // alpha
    message_end();
}

why ?

Leon M. 05-06-2010 01:30

Re: Plugin called message_begin with an invalid message id (0).
 
Hm, I think that the flash_screen function is correct. Comment out the function and check again.

epic . 05-06-2010 09:03

Re: Plugin called message_begin with an invalid message id (0).
 
2 Attachment(s)
When I used the 1.sma, everything is OK.
But when I use the 2.sma, it shows the error like this :
Code:

05/06/2010 - 20:53:56: Plugin called message_begin with an invalid message id (0).
 [AMXX] Displaying debug trace
[AMXX] Run time error 10: native error (native "message_begin")
[AMXX]    [0]Create_ScreenShake (line 539)
[AMXX]    [1] Missile_damage (line 359)
[AMXX]    [2] vexd_pfntouch (line 332)

Code:

stock Create_ScreenShake(id, amount, duration, frequency)
{
    message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, {0,0,0}, id) //This is the line of 539
    write_short(amount)          // ammount
    write_short(duration)  // lasts this long
    write_short(frequency)  // frequency
    message_end();
}

Code:

public vexd_pfntouch(pToucher, pTouched)
{
    if( !is_valid_ent(pToucher) ) return
    new sz[33]
    entity_get_string(pToucher, EV_SZ_classname, sz, 32)
    if( equal(sz, "savior_missile") )
    {
        new Float:Ori[3], Iori[3]
        entity_get_vector(pToucher, EV_VEC_origin, Ori)
        FVecIVec(Ori, Iori)
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(3)
        write_coord(Iori[0])
        write_coord(Iori[1])
        write_coord(Iori[2])
        write_short(boom)
        write_byte(100)
        write_byte(15)
        write_byte(0)
        message_end();
 
        Missile_damage(pToucher, 200.0, 500.0) //This is the line of 332
        remove_entity(pToucher)
    }
}
 
public Missile_damage(inf, Float:dmg, Float:rad)
{
    new players[32], pnum, Float:rng, Float:cd, Float:ori[3], owner, cdi, killdmg, hurtdmg, takedmg, health, vec[3]
    new sz[33]
    entity_get_string(inf, EV_SZ_classname, sz, 32)
    new team2, team1, ff = get_cvar_num("mp_friendlyfire")
    entity_get_vector(inf, EV_VEC_origin, ori)
    FVecIVec(ori, vec)
    owner = entity_get_edict(inf, EV_ENT_owner)
    team1 = get_user_team(owner)
    get_players(players, pnum, "a")
    for (new i=0; i < pnum; i++)
    {
        team2 = get_user_team(players[i])
        if( team2 == team1 && !ff ) continue
        rng = Float:entity_range(inf, players[i])
        if( rng > rad ) continue
        rng = rad - rng
        cd = dmg / ( rad * rad ) * ( rng * rng )
        cdi = floatround(cd)
        Create_ScreenShake(players[i], (1<<14), (1<<13), (1<<14))// This is the line of 359
    }
}

The difference between 1.sma and 2.sma is : I register_clcmd("+qigong", "cmdUseQigongDown") in the 2.sma, so there is a cmdUseQigongDown(id) and cmdUseQigongUp(id) function in the 2.sma, the rest code is almost the same .

Thanks for any help :crab:

abdul-rehman 05-06-2010 10:47

Re: Plugin called message_begin with an invalid message id (0).
 
What do you really want...?

epic . 05-06-2010 19:09

Re: Plugin called message_begin with an invalid message id (0).
 
Quote:

Originally Posted by abdul-rehman (Post 1172618)
What do you really want...?

The 1.sma is to select a player randomly, and give him a power to launch missiles
The 2.sma is on basis of 1.sma, I want to give the player another power by press +qigong & -qigong with 2.sma


All times are GMT -4. The time now is 03:53.

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