AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Execute Menu Action on target (https://forums.alliedmods.net/showthread.php?t=19981)

Zenith77 10-29-2005 19:32

Execute Menu Action on target
 
Ok, i want to know how to do soemthing to a selcted player...


For example I have a menu

Code:


Bla Bla

1. Bob
2. Joe
3. etc

9. Next
0. Exit

If i select Bob, I want to know how do i find out his index?

This is the code i have...

Code:
public ShowtryoutSelMenu(id) {         new szPlayer[200]     new szMenu[200]     new num[33]     new i         add(szMenu, 199, "Tryout\Accept Menu ( Press 8 To change Action ) ")         for( i = 0; i <get_maxplayers(); i++) {                 if( !is_user_connected(i) ) continue                 if( indexDislpayed[i] ) continue             //  if( is_user_admin(i) ) continue             //  if( i == id ) continue                 num[id]++                 if( num[id] == 8 ) {                         num[id] = 0                         break         }                     if( num[id] < 8 ) {                     new name[32]                         get_user_name(i, name, 31)                         szPlayer = ("%d. %s^n", num[id], name)                         add(szMenu, 199, szPlayer)                         indexDislpayed[i] = true                 }     }         switch(Action[id]) {                 case 1: add(szMenu, 199, "8. Tryout^n" )         case 2: add(szMenu, 199, "8. Accept^n" )     }         add(szMenu, 199, "9. Next^n")     add(szMenu, 199, "0. Exit")         show_menu(id,KeystryoutSelMenu, szMenu, -1, "tryoutSelMenu") // Display menu     } public PressedtryoutSelMenu(id, key) {     /* Menu:     * TryOut\Accept Menu     * $players(1,7,%n. %v)         * 8. Tryout\Accept         * 9.Next     * 0. Exit     */     switch (key) {         case 9: {                         new i                         for( i = 1; i < get_maxplayers(); i++ ) {                                 indexDislpayed[i] = false             }         }                     case 8: {                         ShowtryoutSelMenu(id)                     }                 case 7: {                         switch(Action[id]) {                                 case 1: Action[id] = ACTION_ACCEPT                 case 2: Action[id] = ACTION_TRYOUT             }                         ShowtryoutSelMenu(id)         }                 case 6: {                         // Do something to target         }     } }


I tried looking at AMXX's default menu plugin to find out how they did it but
I couldnt understand it :/

If you need any more info regarding this code, please tell me.

I thank you for all your help
--Zenith77

Kensai 10-29-2005 19:46

What do you mean? Show the menu only to "Bob"?

Make a command that shows the menu for the target player.

i.e.

Code:
public blah(id,level,cid)     {     if (!cmd_access(id,level,cid,3))         return PLUGIN_HANDLED             new arg[32], arg2[32]     read_argv(1,arg,31)     read_argv(2,arg2,31)         new target=cmd_target(id,arg,4)     if(!target)         {         client_print(id,print_console,"Invalid Target!")         return PLUGIN_HANDLED     }         ShowMenu(target)         return PLUGIN_HANDLED }

I think. :D

Zenith77 10-29-2005 19:51

lol kensai... thats not what i mean :P

I want to execute a function on the player he selects through a menu... not a command :P.

Kensai 10-29-2005 20:04

OOOO. So like if the menu is like.

Want 200hp?
1. Yes
2. No

And he picks yes you want his hp to be set to 200?
[/small]

Sodium 10-29-2005 20:07

http://forums.alliedmods.net/showthr...p?t=11192+menu

Zenith77 10-29-2005 20:34

@ kensai: nope thats still wrong...


nm everybody, i think i find a way, i'll post back to see if it works..

Kensai 10-29-2005 20:41

Lol, well nevermind then. You lost me.

Charr 10-29-2005 21:19

I think he means when you select bob, it executes a function on him.


All times are GMT -4. The time now is 23:39.

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