Raised This Month: $51 Target: $400
 12% 

menu_additem extra info


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slycny
Junior Member
Join Date: Mar 2018
Old 03-25-2018 , 15:05   menu_additem extra info
Reply With Quote #1

Hello. How I can add extra info (kill, deaths, or etc.) with name in this player menu? Sorry for my bad english

Quote:
public showPrepareMenu(id)
{
if(!isAdmin(id)) return PLUGIN_HANDLED
new menu = menu_create("\w[\yweb.com\w] \rmeniu", "onPrepareCT")

new players[32], num
get_players(players, num, "ch")
new ui[32]
for(new i; i < num; i++)
{
formatex(ui, 31, "%d", get_user_userid(players[i]))
menu_additem(menu, get_admin_name(players[i]), ui, 0)
}

menu_display(id, menu, 0)

return PLUGIN_HANDLED;
}

public onPrepareCT(id, menu, item)
{
new szData[6], szName[64];
new _access, item_callback;

menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );

new userid = str_to_num( szData );
new player = find_player( "k", userid );

switch(item)
{
case MENU_EXIT:
{
if(PrepareRound) showPrepareMenu(id)
return PLUGIN_HANDLED;
}
default: if(PrepareRound && is_user_connected(player)) cs_set_user_team(player, CS_TEAM_CT)
}
if(PrepareRound)
{
tempCT = player;
client_printcolor(0, "/y[/ctr%s/y] CT leader: /g%s", PREFIX, szName)
client_printcolor(0, "/y[/ctr%s/y] T leader!", PREFIX)
showPrepareMenuT(id)
}
return PLUGIN_HANDLED;
}

Last edited by slycny; 03-25-2018 at 15:12. Reason: sorry
slycny is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-25-2018 , 16:26   Re: menu_additem extra info
Reply With Quote #2

get_user_frags(id)
get_user_deaths(id)
__________________
My English is A0
E1_531G is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-25-2018 , 17:13   Re: menu_additem extra info
Reply With Quote #3

get_admin_name(players[i])

Returning an array is a bad idea
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
slycny
Junior Member
Join Date: Mar 2018
Old 03-26-2018 , 07:16   Re: menu_additem extra info
Reply With Quote #4

Quote:
Originally Posted by E1_531G View Post
get_user_frags(id)
get_user_deaths(id)
Thx, but dont work. I do something wrong? Where is my fault?

Quote:
public showPrepareMenu(id)
{
if(!isAdmin(id)) return PLUGIN_HANDLED
new menu = menu_create("\w[\yweb.comw] \rPlayer meniu", "onPrepareCT")

new players[32], num
get_players(players, num, "ch")
new ui[32]
for(new i; i < num; i++)
{
formatex(ui, 31, "%d \r%d kills", get_user_userid(players[i]), get_user_frags(id))
menu_additem(menu, get_admin_name(players[i]), ui)

}

menu_display(id, menu, 0)

return PLUGIN_HANDLED;
}
Result image: https://imgur.com/wlXvseE

Last edited by slycny; 03-26-2018 at 07:17.
slycny is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 03-26-2018 , 09:42   Re: menu_additem extra info
Reply With Quote #5

Code:
new g_kills[33], g_deaths[33];

public plugin_init() 
{
    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)
}

public fw_PlayerKilled(VTM, KLR)  
{
    if (VTM == KLR || !is_user_alive(KLR) )
        return

    g_kills[KLR]++
    g_deaths[VRM]++
}


formatex(ui, charsmax(ui),  "\y[\rKILLS\y] \y[\g%d\y] \y[\rDEATHS\y] \y[\g%d\y]" : "%s",  g_kills[id], g_deaths[id]);

Last edited by raizo11; 03-26-2018 at 17:17.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
slycny
Junior Member
Join Date: Mar 2018
Old 03-26-2018 , 14:51   Re: menu_additem extra info
Reply With Quote #6

Sorry, but dont work, result is same. P.S. This is from my mix plugin. All points and kills are saved on mysql.
Ant RED color on player name in menu dont work.
Maybe something wrong there "menu_additem(menu, get_admin_name(players[i]), ui)"? I dont know.

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <fakemeta_util>
#include <csx>
#include <newmenus>

#define POINTS_KILL 1

new pKills[33], pPoints[33]

public plugin_init()
{
	register_event("DeathMsg", "DeathEvent", "a");
}

public DeathEvent(victim, attacker, id)
{
	new attacker = read_data(1);
	new victim = read_data(2);
	new hs = read_data(3)
	
	if(WarmUp) 
	{
		set_task(1.0, "RespawnPlayer", victim)
	}
	else if(1 <= victim <= 32 && 1 <= attacker <= 32)
	{
		Kills[attacker]++
		
		if(!WarmUp && !PrepareRound)
		{
			pKills[attacker]++;
			pPoints[attacker] += POINTS_KILL
                }
        }
}

public showPrepareMenu(id)
{
	if(!isAdmin(id)) return PLUGIN_HANDLED
	new menu = menu_create("\w[\yweb.com\w] \rSelect CT leader", "onPrepareCT")

	new players[32], num
	get_players(players, num, "ch")
	new ui[32]
	for(new i; i < num; i++)
	{
		format(ui, 31, "\r%d %d kills %d points", get_user_userid(players[i]), pKills[i], pPoints[i])
		menu_additem(menu, get_admin_name(players[i]), ui)
	}
	
	menu_display(id, menu, 0)
	
	return PLUGIN_HANDLED;
}

public onPrepareCT(id, menu, item)
{
	new szData[6], szName[64];
	new _access, item_callback;

	menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
	
	new userid = str_to_num( szData );
	new player = find_player( "k", userid );

	switch(item)
	{
		case MENU_EXIT: 
		{
			if(PrepareRound) showPrepareMenu(id)
			return PLUGIN_HANDLED;
		}
		default: if(PrepareRound && is_user_connected(player)) cs_set_user_team(player, CS_TEAM_CT)
	}
	if(PrepareRound) 
	{
		tempCT = player;
		client_printcolor(0, "/y[/ctr%s/y] CT leader will by: /g%s", PREFIX, szName)
		client_printcolor(0, "/y[/ctr%s/y] T leader is comming soon", PREFIX)
		showPrepareMenuT(id)
	}
	return PLUGIN_HANDLED;
}

Last edited by slycny; 03-26-2018 at 14:55.
slycny is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-26-2018 , 15:01   Re: menu_additem extra info
Reply With Quote #7

Quote:
formatex(ui, 31, "\r%d kills %d deaths", g_kills(id), g_deaths(id))
raizo11, Go and learn before giving the wrong advice.

slycny:
Quote:
new players[32], num
get_players(players, num, "ch")
new name[32], player
new item[64], info[16]
for(new i; i < num; i++)
{
player = players[i]
get_user_name(player, name, charsmax(name))
formatex( item, charsmax(item), "\y%s \w- \r%d kills", name, get_user_frags(player))
formatex( info, charsmax(info), "%d", get_user_userid(player) )
menu_additem(menu, item, info)
}
This menu will look like:
1. PlayerName - 5 kills
2. UserName - 20 kills
__________________
My English is A0
E1_531G is offline
slycny
Junior Member
Join Date: Mar 2018
Old 03-26-2018 , 15:37   Re: menu_additem extra info
Reply With Quote #8

E1_531G thank you very much. Its work. But now is another small problem
Where is RED line in code, in chat print not only player name, but all this \y%s \w- \r%d kills player name with kills.
Photo:
What I need to change, that it showing only player name?

Code:
public onPrepareCT(id, menu, item)
{
	new szData[6], szName[64];
	new _access, item_callback;

	menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
	
	new userid = str_to_num( szData );
	new player = find_player( "k", userid );

	switch(item)
	{
		case MENU_EXIT: 
		{
			if(PrepareRound) showPrepareMenu(id)
			return PLUGIN_HANDLED;
		}
		default: if(PrepareRound && is_user_connected(player)) cs_set_user_team(player, CS_TEAM_CT)
	}
	if(PrepareRound) 
	{
		tempCT = player;
		client_printcolor(0, "/y[/ctr%s/y] CT leader will by: /g%s", PREFIX, szName)
		client_printcolor(0, "/y[/ctr%s/y] T leader is comming soon", PREFIX)
		showPrepareMenuT(id)
	}
	return PLUGIN_HANDLED;
}

Last edited by slycny; 03-26-2018 at 16:00.
slycny is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 03-26-2018 , 16:21   Re: menu_additem extra info
Reply With Quote #9

I gave an example

So what is the problem? here id my mistake sorry g_kills() to [] I'm in a hurry

client_printcolor(0, "!g[!t%s!g] !tLeader will !gbe !t%s.", PREFIX, szName)

replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!y", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color


free gif hosting

Last edited by raizo11; 03-26-2018 at 17:04.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-27-2018 , 07:57   Re: menu_additem extra info
Reply With Quote #10

Quote:
Originally Posted by slycny View Post
E1_531G thank you very much. Its work. But now is another small problem
Where is RED line in code, in chat print not only player name, but all this \y%s \w- \r%d kills player name with kills.
Photo:
What I need to change, that it showing only player name?
\r \y \d \w are only for the menu.
For the chat you can use: ^4 - green, ^1 - normal (default is yellow), ^3 - team.
In your case:
Quote:
client_printcolor(0, "^4[%s] ^1CT leader will by: ^4%s", PREFIX, szName)
client_printcolor(0, "^4[%s] ^1T leader is comming soon", PREFIX)
__________________
My English is A0

Last edited by E1_531G; 03-27-2018 at 07:58.
E1_531G 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 18:21.


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