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