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

open chat after clicking menu item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 11:25   open chat after clicking menu item
Reply With Quote #1

Hello, I wanted to ask how I can open player's chat when he clicks menu item. Hope your answers help.
LemoNSK is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 11:35   Re: open chat after clicking menu item
Reply With Quote #2

Try
PHP Code:
engclient_cmdid"say" ); 
Not sure if it will work.
edon1337 is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 11:37   Re: open chat after clicking menu item
Reply With Quote #3

PHP Code:
client_cmd(id"say"
but I assume (looking at your other threads) that's not what you are looking for.

in plugin_init:
PHP Code:
register_clcmd("PM""PMText"); 
PMTEXT Function:
PHP Code:
public PMText(id) {
    new 
szText[128];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);
       
       
//szTextis string which holds what user has written, assign it to global string, let's say g_sPM[33][128]
       
g_sPM[id] = szText;
    return 
PLUGIN_HANDLED;

To make user type PM:
PHP Code:
client_cmd(id"messagemode PM"

Last edited by Airkish; 07-19-2018 at 12:45.
Airkish is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-19-2018 , 12:00   Re: open chat after clicking menu item
Reply With Quote #4

Quote:
Originally Posted by edon1337 View Post
Try
PHP Code:
engclient_cmdid"say" ); 
Not sure if it will work.
Yeah it wont work Tobi,
#1 say is command that called after done writing text in chat
#2 chat is opening with messagemode command, which is client-side
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 07-19-2018 at 12:01.
Ghosted is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 13:17   Re: open chat after clicking menu item
Reply With Quote #5

Quote:
Originally Posted by Airkish View Post
PHP Code:
client_cmd(id"say"
but I assume (looking at your other threads) that's not what you are looking for.

in plugin_init:
PHP Code:
register_clcmd("PM""PMText"); 
PMTEXT Function:
PHP Code:
public PMText(id) {
    new 
szText[128];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);
       
       
//szTextis string which holds what user has written, assign it to global string, let's say g_sPM[33][128]
       
g_sPM[id] = szText;
    return 
PLUGIN_HANDLED;

To make user type PM:
PHP Code:
client_cmd(id"messagemode PM"
And how to store what he wrote in the string when client_cmd is done and he has written what he wanted?
LemoNSK is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 14:18   Re: open chat after clicking menu item
Reply With Quote #6

Quote:
Originally Posted by LemoNSK View Post
And how to store what he wrote in the string when client_cmd is done and he has written what he wanted?
It's stored in g_sPM variable
Airkish is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 14:28   Re: open chat after clicking menu item
Reply With Quote #7

Quote:
Originally Posted by Airkish View Post
It's stored in g_sPM variable

Dunno why player return's zero. Can you find mistake?

PHP Code:
    new szData[6], szName[64];
    new 
_accessitem_callback;
    
menu_item_getinfo(menuitem_accessszDatacharsmax(szData), szNamecharsmax(szName), item_callback);
    
    new 
userid str_to_numszData );
    new 
player find_player"a"userid ); 

Last edited by LemoNSK; 07-19-2018 at 14:28.
LemoNSK is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 15:01   Re: open chat after clicking menu item
Reply With Quote #8

Quote:
Originally Posted by LemoNSK View Post
Dunno why player return's zero. Can you find mistake?

PHP Code:
    new szData[6], szName[64];
    new 
_accessitem_callback;
    
menu_item_getinfo(menuitem_accessszDatacharsmax(szData), szNamecharsmax(szName), item_callback);
    
    new 
userid str_to_numszData );
    new 
player find_player"a"userid ); 
Show menu code
Airkish is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 15:43   Re: open chat after clicking menu item
Reply With Quote #9

Quote:
Originally Posted by Airkish View Post
Show menu code
PHP Code:
new menu;

new 
string:g_sPM[33][128];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /pm""SendMessage");
    
register_clcmd("PM""PMText");  
}

public 
SendMessageid )
{
    new 
playerOnline ConnectedPeople();
    
menu menu_create("\ySelect a person to send message to""sendmessage_handler");
    
    new 
players[32], tempid;
    
    for(new 
1playerOnline 1x++)
    {    
        
tempid players[x];
        new 
name[70]; new msg[255];
        
format(msgsizeof(msg), "%d"get_user_userid(tempid));
        
        
get_user_name(xnamesizeof(name));    
        
menu_additem(menunamemsg0);
    }
    
menu_display(idmenu0);
    return 
PLUGIN_HANDLED;
}

public 
PMText(id) {
    new 
szText[128];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);
       
     
    
g_sPM[id] = szText;
    return 
PLUGIN_HANDLED;
}  

public 
sendmessage_handler(idmenuitem)
{
    new 
playerOnline ConnectedPeople();
    if ( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
      
    new 
szData[6], szName[64];
    new 
_accessitem_callback;
    
menu_item_getinfo(menuitem_accessszDatacharsmax(szData), szNamecharsmax(szName), item_callback);
    
    new 
userid str_to_numszData );
    new 
player find_player"a"userid );
    
    if(!
player
    {
        
CC_SendMessage(id"&x07[&x04LamdaProCS&x07] &x03Player is no longer available!");
        return 
PLUGIN_CONTINUE;
    }
    
    
client_cmd(id"messagemode PM")  
    
    return 
1;
}

ConnectedPeople()
{
    new 
connectedPeople;
    for(new 
133x++)
    {
        if(
is_user_connected(x))
        {
            
connectedPeople++;
        }
    }
    return 
connectedPeople;


Last edited by LemoNSK; 07-19-2018 at 15:43.
LemoNSK is offline
Old 07-19-2018, 16:07
kristi
This message has been deleted by kristi.
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 07-19-2018 , 16:30   Re: open chat after clicking menu item
Reply With Quote #10

Try
PHP Code:
public SendMessage(id)
{
    new 
szText[128], String[32];
    new 
menu menu_create("\ySelect a person to send message to""sendmessage_handler");

    new 
players[32], pnumtempidcount;

    
get_playersplayerspnum"ch" ); 

    for ( new 
ipnumi++ )
    {
        
tempid players[i];
        if(
tempid == id)
            continue;
        
count++;
        
formatex(String31"%d"tempid);
        
formatex(szTextsizeof(szText), "%s"user_name(tempid));
        
menu_additemmenuszTextString0);
    }
    
menu_displayidmenu);
    
}

public 
sendmessage_handler(idmenuitem)
{
    if(
item == MENU_EXIT) {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
data[9], name[64], userid;
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), namecharsmax(name), callback);

    
userid str_to_num(data);

    new 
szName[32];
    
get_user_name(useridszNamecharsmax(szName))

    
client_print(idprint_center"Selected Player: %s"szName//To see if name from menu matches
    
client_cmd(id"messagemode PM");
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;

Airkish 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 19:13.


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