AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with menu "CS 1.6" (https://forums.alliedmods.net/showthread.php?t=153711)

DaemonGen 03-28-2011 00:13

Problem with menu "CS 1.6"
 
I am making a menu to show other players who do not have a team selected then do an action with them.

The problem I have is that after 10 or more players have been selected it then acts weird and selects a different player and applies the action.

Code:

public menu_pTeam( id )
{
    new MSG[ 2 ];
    new menu = menu_create( "\rChoose A Player:", "menu_handler" );

    for ( new i = 1; i <= g_iMaxPlayers; i++ )
    {
        // Ignore player ID if not connected
        if ( !is_user_connected( i ) || g_pTeam[ i ] > 0 || pid == i )
            continue;

        formatex( MSG, 1, "%i", i )
        menu_additem( menu, P_NAME[ i ], MSG );
    }
   
    menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER );

    menu_id[ id ] = 2;
   
    menu_display( id, menu, 0 );
}

The action is used on a player using "data" to get the chosen player ID
Code:

    new data[ 6 ], pName[ 64 ];
    new access, callback;

    menu_item_getinfo( menu, item, access, data, 5, pName, 63, callback );

    new key = str_to_num( data );

Any suggestions for a different way to make the player menu or an error in code?
P_NAME[ id ] is the players name when they connect to the server.

Thanks

fysiks 03-28-2011 00:27

Re: Problem with menu "CS 1.6"
 
You need to make the string MSG longer. Use:

Code:

    new MSG[3]
    // ...
        num_to_str(i, MSG, charsmax(MSG))
        menu_additem( menu, P_NAME[ i ], MSG );
        // ...



All times are GMT -4. The time now is 14:32.

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