Give health through a Menu

Сообщения
35
Реакции
9
Hello, I was looking for a Menu on how to give a specific amount of HP to a specific player or a specific team

I was trying to do it with a for and enum but it doesnt work (I am using ReAPI)

Any help would be appreciated :)
 
Сообщения
35
Реакции
9
Код:
ShowHealMenu( const iId )
{
    new iPlayers[ 32 ];
    new iPlayersNum;
   
    GetPlayers( iPlayers, iPlayersNum, ( FLAG_COUNT_DEAD | FLAG_COUNT_JOINED ) );

    new szIndex[ 16 ];
   
    new iMenu = menu_create( "Heal a player", "HealMenuHandler" );
   
    for ( new i = 0 ; i < iPlayersNum ; i++ )
    {
        if ( ( iId != iPlayers[ i ] ) && HasPermission( iPlayers[ i ], PERMISSION_HEAL ) && !HasPermission( iId, PERMISSION_OVERRIDE ) )
        {
            continue;
        }
       
        formatex( szIndex, charsmax( szIndex ), "%d#%d", iPlayers[ i ], get_user_userid( iPlayers[ i ] ) );
        menu_additem( iMenu, g_ePlayerData[ iPlayers[ i ] ][ Player_Name ], szIndex );
    }
   
    menu_setprop( iMenu, MPROP_NEXTNAME, "Next" );
    menu_setprop( iMenu, MPROP_BACKNAME, "Back" );
    menu_setprop( iMenu, MPROP_EXITNAME, "Exit" );
   
    menu_display( iId, iMenu );
   
    return PLUGIN_HANDLED;
}

public HealMenuHandler( iId, iMenu, iItem )
{
    if ( ( iItem == MENU_EXIT ) || ( g_iRoundStatus != ROUND_NORMAL ) )
    {
        menu_destroy( iMenu );
       
        return PLUGIN_HANDLED;
    }
   
    ClientPlaySound( iId, g_szHealSound );
   
    new szInfo[ 16 ];
   
    new szTarget[ 4 ];
    new szUserId[ 8 ];
   
    new iNum;
    new iTarget;
    new iUserId;
   
    menu_item_getinfo( iMenu, iItem, iNum, szInfo, charsmax( szInfo ), _, _, iNum );
    menu_destroy( iMenu );
   
    strtok( szInfo, szTarget, charsmax( szTarget ), szUserId, charsmax( szUserId ), '#' );
   
    iTarget = str_to_num( szTarget );
    iUserId = str_to_num( szUserId );
   
    // If he is connect and he is alive plus hes a Valid target.
    if ( GetPlayerBit( g_iConnected, iTarget ) && GetPlayerBit( g_iAlive, iTarget ) && ( get_user_userid( iTarget ) == iUserId ) )
    {
        // Heal code
        // ...
    }
   
    return PLUGIN_HANDLED;
}
There is no ENUM because I got no idea how it has to be for a Heal menu, would like some help :)
 
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
To set health you can use:

1) set_user_health(id, 200) - you will set 200 HP (Fun).
2) entity_set_float(id, EV_FL_health, 200.0) - you will set 200 HP (Engine).
3) set_pev(id, pev_health, 200.0) - you will set 200 HP (FakeMeta).
4) set_entvar(id, var_health, 200.0) - you will set 200 HP (ReAPI).
 
Сообщения
35
Реакции
9
Yeah, I know that thing is, what else I need to do (look at the code I already posted here), How can I make a ENUM and make it work through the menu with a set_entvar( iId, var_health, ENUM...) (got no idea)
 
Сообщения
35
Реакции
9
Enum to add a specific amount of health and then through menu -> choose player -> choose amount
 
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
nanaka, open another menu where you select amount of health to give the player.
 
Сообщения
1,420
Реакции
2,511
Помог
58 раз(а)
nanaka, I don’t use new style menus.You just have to save to a global array your target, then open another menu where you will choose the amount of HP and after you’ve chosen, give the chosen amount of HP to the saved target.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу