Raised This Month: $ Target: $400
 0% 

Using chat to fill in the blanks in a command?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 06-24-2006 , 15:37   Using chat to fill in the blanks in a command?
Reply With Quote #1

I'm trying to make a menu plugin for a group of servers I play on. I know how to make basic menus and sub-menus, but I'm having trouble with one type of thing in particular...

I want to be able to select from a list of a couple options on one menu, which would read like this (minus the _'s):
__________
Menu Title

1. Psay
2. Execclient
3. Slay and send message

0. Exit
__________


Selecting option 0 would close the menu, but selecting options 1, 2, and 3 would bring up a new menu consisiting of the players on the server which would look something like this (minus the _'s) if there were 14 people on the server:
__________
Players 1/2

1. Bobby
2. Timmy
3. Jimmy
4. Tommy
5. Beepy
6. Tweety
7. Zippy
8. Mister Egg

9. More
0. Exit
__________


The hard part is that I'd like to be able to select one of those names and have it bring up a chat prompt (like when you use say or team say) so you don't have to open the console or add the players name before the message or command you want run on them. I need to be able to input something into that box which then would be added to the end of an amx_psay command or an execclient command as the message/command to be executed on the player of choice.

An example of what I'd like to be able to do:
_____________
1) Admin Bob presses 1

2) Admin Bob presses 5

3) Admin Bob types into message prompt (without the <>): <Hello, how are you doing?> and presses return

4) Admin Bob's client acts as though he has typed into his console (without the <>): <amx_psay Beepy "Hello, how are you doing?">

5) Beepy gets a private message from Admin Bob which reads (without the <>): <Hello, how are you doing?>
_____________

So basically what it comes down to is that I'd like to know how to make something like this:

First Menu choice equals variable x
Second Menu Choice equals variable y
What gets typed into the command prompt equals variable z

all of this should end up being the same as though you'd typed into the console (minus the <>): <"x" "y" "z">.


Thank you for reading the lengthly post.
~Fin~
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 06-24-2006 , 16:08   Re: Using chat to fill in the blanks in a command?
Reply With Quote #2

You could print a message telling them to type the rest of the command into chat, hook chat (set a variable in the menu cmd and then unset it after they finish the command) and then run the command with that.
__________________
twistedeuphoria is offline
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 06-24-2006 , 16:10   Re: Using chat to fill in the blanks in a command?
Reply With Quote #3

How would I do that? Could you show me an example?
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 06-24-2006 , 16:16   Re: Using chat to fill in the blanks in a command?
Reply With Quote #4

Code:
  new sayspecial[33] = 0 ... public plugin_init() {     ...     register_clcmd("say","say_hook")     ... } public menu_cmd(id,key) {     switch(key)     {         case 1:         {             sayspecial[id] = 1             client_print(id,print_chat,"Enter your other params in chat:")         }         ...             }     return PLUGIN_HANDLED } public say_hook(id) {     new said[191]     read_args(said,190)     remove_quotes(said)     if(sayspecial[id])     {         switch(sayspecial[id])         {             case 1: client_cmd(id,"command1 %s",said)             case 2: client_cmd(id,"command2 %s",said)             case 3: client_cmd(id,"command3 %s",said)         }         sayspecial[id] = 0         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE }
__________________
twistedeuphoria is offline
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 06-24-2006 , 18:20   Re: Using chat to fill in the blanks in a command?
Reply With Quote #5

I have a question about the code you made, where would I put the player selection? Thanks for the start.

Last edited by Stealth Penguin; 06-24-2006 at 20:58. Reason: isolating the question
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 06-24-2006 , 21:31   Re: Using chat to fill in the blanks in a command?
Reply With Quote #6

If I understood you correctly, you put the player selection inside the switch statement in the menu cmd function.
__________________
twistedeuphoria is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-25-2006 , 09:01   Re: Using chat to fill in the blanks in a command?
Reply With Quote #7

You could simply register a new menu with it's own command, then put this inside the switch statement's case for the submenu key:
Code:
client_cmd(id , "amx_menu_command");
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.

Last edited by v3x; 06-25-2006 at 09:03. Reason: gaben
v3x is offline
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 06-25-2006 , 09:44   Re: Using chat to fill in the blanks in a command?
Reply With Quote #8

Woohoo, its partially functional!

Its not working entirely yet but I did manage to get psay to work at least the first time, but all of my normal chat is blocked (that should be easy to fix though).
Code:
public PlayerListCommand(id,key) {     switch (key)     {         case 7: ShowPlayerListMenu(id,++g_nPlayerListMenuPosition[id])         case 8: ShowPlayerListMenu(id,--g_nPlayerListMenuPosition[id])         case 9: ShowMiscMenu(id, 0)         default:         {             new player = g_menuPlayers2[id][g_nPlayerListMenuPosition[id] * 6 + key]             target[id] = player             new name2[32]             get_user_name(player,name2,31)             if ( PlayerOption2[id] == 1 )             {                 sayspecial[id] = 1                             }             else if( PlayerOption[id] == 2 )             {                 sayspecial[id] = 2             }             new authid[32],authid2[32], name[32]             get_user_authid(id,authid,31)             get_user_authid(player,authid2,31)             get_user_name(id,name,31)             get_user_name(player,name2,31)             ShowPlayerListMenu(id,g_nPlayerListMenuPosition[id])         }     } } public DoShowPlayerListMenu(id,level,cid) {     if (!cmd_access(id,level,cid,1))     {         return PLUGIN_HANDLED     }     ShowPlayerListMenu(id,g_nPlayerListMenuPosition[id] = 0)     return PLUGIN_HANDLED } ///////////////////////////////////////////////////////////////////////////// public say_hook(id) {     new said[191]     new name[64]     read_args(said,190)     remove_quotes(said)     get_user_name(target[id],name,63)     if( sayspecial[id] != 0 )     {         switch(sayspecial[id])         {             case 1:             {                 client_cmd(id,"amx_psay %s %s",name,said)                 sayspecial[id] = 0             }             case 2:             {                 client_cmd(id,"amx_execclient %s %s",name,said)                 sayspecial[id] = 0             }         }         sayspecial[id] = 0     }     return PLUGIN_HANDLED }

target stores the index of the player chosen from the PlayerListMenu (I think). Now to fix the chat. Thanks for all the help with this.

Last edited by Stealth Penguin; 06-25-2006 at 12:11.
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
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 08:07.


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