AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Harbu/Menu Help (https://forums.alliedmods.net/showthread.php?t=48004)

geertjan88 12-02-2006 04:17

Harbu/Menu Help
 
In harbu there is an menu called atm_menu.
Code:

///////////////////////////////
//
// ATM CODE
//
///////////////////////////////



// ATM Menu 1. Deposit, 2. Withdraw
public actionMenuatm(id,key)
{
 switch(key){
 case 0:{
 showMenudep(id)
 }
 case 1:{
 showMenuwit(id)
 }
 }

 return PLUGIN_HANDLED
}

public Menu_Atm(id)
{
  if(get_item_amount(id,get_cvar_num("rp_itemid_atmcard"),"money") == 0)
  {
      client_print(id,print_chat,"[Bank] You need an ATM Card to use this^n")
      return PLUGIN_HANDLED
  }
  if(cuffed[id] == 1)
  {
      client_print(id,print_chat,"[Bank] Can't deposit or withdraw money when cuffed^n")
      return PLUGIN_HANDLED
  }
  new menuBodyp[512]
  new len = format(menuBodyp,511,"ATM Menu^n^n")
  len += format(menuBodyp[len],511-len,"1. Deposit^n2. Withdraw^n^n0. Exit")
  show_menu(id,((1<<0)|(1<<1)|(1<<9)),menuBodyp)
  return PLUGIN_HANDLED
}

Now this is probably a really stupid question, but well also donkey's can learn things. When you use an atm it shows up Menu_atm wich is shown above. But how does amx knows when you press 1 or 2 it should excecute what is written in ActionMenuAtm how are those two things connected i mean how do you connect them. I tried to search all over the code but i can't find the piece of code where it is coded that when someone presses a key in menu_atm that after that it should excecute the action in actionMenuatm.

geertjan88 12-02-2006 06:42

Re: Harbu/Menu Help
 
never mind i already found out it is in this little sentence:
Code:

new len = format(menuBodyp,511,"Phone Menu^n^n")
Please lock this

stupok 12-02-2006 17:10

Re: Harbu/Menu Help
 
Not quite...

Code:
show_menu(id,((1<<0)|(1<<1)|(1<<9)),menuBodyp)

show_menu

The (1<<0) means, in lay-man's terms, to check when the 1 key is pressed, which corresponds with the first, #0, option in the menu.
The key 2 corresponds with the second, #1, option in the menu.
The key 0 corresponds with the ninth, #9, option in the menu.

Option 1 = 0
Option 2 = 1
Option 3 = 2
etc...

In your above post, you did not include the function that reads what key was pressed.

Lord_Destros 12-03-2006 19:16

Re: Harbu/Menu Help
 
Quote:

Originally Posted by geertjan88 (Post 409759)
never mind i already found out it is in this little sentence:
Code:

new len = format(menuBodyp,511,"Phone Menu^n^n")
Please lock this

Yeah the fact that the line you showed refers to a phone menu should have given it away :lol:


All times are GMT -4. The time now is 06:48.

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