Raised This Month: $ Target: $400
 0% 

Healing Menu JB MOD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bloodypro05
Junior Member
Join Date: Jul 2020
Location: Palestine
Old 12-15-2020 , 10:46   Healing Menu JB MOD
Reply With Quote #1

Hey,
I have this plugin , to heal t players to 100 health, its fuly working
i need an option also to heal all players , i want it to be at the end of the menu , (not in 2nd page if i have many players)
Code:
#include <amxmodx>
#include <fun>

 public plugin_init()
 {
    	register_clcmd( "say /healmenu","HealMenu" );
 }

 public HealMenu( id )
 {
 	if(get_user_team(id) == 2)
	{
    		new menu = menu_create( "\r[GC JB] \yHealing Menu!", "menu_handler" );

    		new players[32], pnum, tempid;
    		new szName[32], szUserId[32];

    		get_players( players, pnum, "ae", "TERRORIST" ); // flag "a" beca, flag "e" Team
    		for ( new i; i<pnum; i++ )
    		{
        		tempid = players[i];
	
        		get_user_name( tempid, szName, charsmax( szName ) );
        		formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );

       		 	menu_additem( menu, szName, szUserId, 0 );
    		}     
    		menu_display( id, menu, 0 );
    		return PLUGIN_HANDLED
 	}
 	return PLUGIN_HANDLED
}


 public menu_handler( id, menu, item )
 {
    //Do a check to see if they exited because menu_item_getinfo ( see below ) will give an error if the item is MENU_EXIT
    if ( item == MENU_EXIT )
    {
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }

    //now lets create some variables that will give us information about the menu and the item that was pressed/chosen
    new szData[6], szName[64];
    new _access, item_callback;
    //heres the function that will give us that information ( since it doesnt magicaly appear )
    menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );

    //Get the userid of the player that was selected
    new userid = str_to_num( szData );

    //Try to retrieve player index from its userid
    new player = find_player( "k", userid ); // flag "k" : find player from userid

    //If player == 0, this means that the player's userid cannot be found
    //If the player is still alive ( we had retrieved alive players when formating the menu but some players may have died before id could select an item from the menu )
    if ( player && is_user_alive( player ) )
    {
        //Set their health to 100
        set_user_health( player, 100 );
    }

    menu_destroy( menu );
    return PLUGIN_HANDLED;
 }
bloodypro05 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-15-2020 , 11:02   Re: Healing Menu JB MOD
Reply With Quote #2

In the HealMenu(id) function, get the number of items currently added in the menu (native menu_items): if equal to number of items per page - 1, add the "heal all players" option with szUserId set as -1

In menu_handler(id, menu, item), check whether userid variable is -1: if true, iterate through all alive players (get_players to get all alive players; for loops to iterate - click on "7. Looping") and just set_user_health; otherwise, do the same as in your plugin.
__________________








CrazY. is offline
bloodypro05
Junior Member
Join Date: Jul 2020
Location: Palestine
Old 12-15-2020 , 11:15   Re: Healing Menu JB MOD
Reply With Quote #3

Quote:
Originally Posted by CrazY. View Post
In the HealMenu(id) function, get the number of items currently added in the menu (native menu_items): if equal to number of items per page - 1, add the "heal all players" option with szUserId set as -1

In menu_handler(id, menu, item), check whether userid variable is -1: if true, iterate through all alive players (get_players to get all alive players; for loops to iterate - click on "7. Looping") and just set_user_health; otherwise, do the same as in your plugin.
im not that good in scripting , and i dont understand what u just said XD
can u explain more ? and if u can add that with explaining ?
bloodypro05 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:54.


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