| ShLuMieL |
01-17-2014 11:18 |
[HELP] with messagemode.
Hey to all I want to make a menu that will open the players names menu and I can give point with this menu.
I create a CMD that you can give a player point's 'a_givepoints [Name] [Num]'
and I want to do messagemode to this name and then I just need to write number and it will give to this player points.
Look at this code.
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Admin Menu"
#define VERSION "1.0"
#define AUTHOR "AUTHOR"
// Points.
new gPoints[33];
// Plugin Start.
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
// Clcmds.
register_clcmd("say /a", "Menu");
// Manager Cmds.
register_concmd("a_givepoints", "GivePoints", ADMIN_RCON, "Add points to a player")
register_concmd("a_takepoints", "TakePoints" ,ADMIN_RCON, "Remove points from a player")
}
public Menu(id)
{
new szItem[256]
formatex(szItem, charsmax(szItem), "Main Menu:")
new menu = menu_create(szItem, "Menu_Handler")
menu_additem(menu, "Admin Cmds.", "", 0);
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}
public Menu_Handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
switch(item)
{
case 0: AdminCmdsMenu(id)
}
return PLUGIN_HANDLED;
}
// Admins Cmds Menu.
public AdminCmdsMenu(id)
{
new some[256], menu;
static players[32],szTemp[10],pnum;
get_players(players,pnum,"ch");
formatex(some,255,"Player's Control:");
menu = menu_create(some,"AdminCmdsMenu_Handler");
for (new i; i < pnum; i++)
{
formatex(some,256,"%s", get_player_name(players[i]));
num_to_str(players[i],szTemp,charsmax(szTemp));
menu_additem(menu, some, szTemp);
}
menu_setprop(menu, MPROP_EXITNAME, "Back")
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
menu_display(id, menu);
return PLUGIN_HANDLED;
}
public AdminCmdsMenu_Handler(id,menu, item){
if (item == MENU_EXIT)
{
Menu(id);
return PLUGIN_HANDLED;
}
new data[6];
new player = str_to_num(data);
client_cmd(id, "messagemode a_givepoints ^"%s^"", get_player_name(player))
return PLUGIN_HANDLED;
}
// Manager Cmds.
public GivePoints(id) {
if(get_user_flags(id) & ADMIN_RCON) {
new PlayerToGive[32], POINTS[32]
read_argv(1,PlayerToGive,31)
read_argv(2,POINTS, 31)
new Player = cmd_target(id,PlayerToGive,9)
if(!Player) {
return PLUGIN_HANDLED
}
new POINTStoGive = str_to_num(POINTS)
new MaxPoints = 1000;
if(POINTStoGive <= 0) {
ColorChat(id,"You canno't give^3 0 ^1or ^3less ^4Points^1.");
return PLUGIN_HANDLED;
}
else if(POINTStoGive > MaxPoints) {
ColorChat(id,"You canno't give more than ^3%i ^4Points^1.", MaxPoints);
return PLUGIN_HANDLED;
}
new name[32],owner[32]
get_user_name(id,owner,31)
get_user_name(Player,name,31)
ColorChat(0,"^4ADMIN^3 %s^1 give to^4 %s^3 %s ^4Points^1.", owner,name,POINTS);
gPoints[Player] += POINTStoGive
}
else {
client_print(id,print_console,"You have no acces to that command")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
public TakePoints(id) {
if(get_user_flags(id) & ADMIN_RCON) {
new PlayerToTake[32], POINTS[32]
read_argv(1,PlayerToTake,31 )
read_argv(2,POINTS,31 )
new Player = cmd_target(id,PlayerToTake,9)
if(!Player) {
return PLUGIN_HANDLED
}
new POINTStoTake = str_to_num(POINTS)
if(POINTStoTake > gPoints[Player]) {
ColorChat(id,"You canno't take more ^4Points ^1that he have.");
return PLUGIN_HANDLED;
}
else {
new name[32],owner[32]
get_user_name(id,owner,31)
get_user_name(Player,name,31)
ColorChat(0,"^4ADMIN^3 %s^1 take to^4 %s^3 %s^1 Points.", owner,name,POINTS);
gPoints[Player] -= POINTStoTake
}
}
else {
client_print(id,print_console,"You have no acces to that command.")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
stock get_player_name(id){
static szName[32];
get_user_name(id,szName,31);
return szName;
}
stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...)
{
new msg[191], players[32], count = 1;
static len; len = formatex(msg, charsmax(msg), "^x04[^x01 %s^x04 ]^x01 ", PLUGIN);
vformat(msg[len], charsmax(msg) - len, string, 3);
if(id) players[0] = id;
else get_players(players,count,"ch");
for (new i = 0; i < count; i++)
{
if(is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
Thanks for helping.
|